Kod Örnekleri & Teknik Rehberler
Python, C#, PHP ve modern web teknolojileri üzerine profesyonel örnekler.
Python & Veri Bilimi
PopülerÖğrenmesi kolay ve son derece güçlü. Yapay Zeka, Veri Analizi ve Otomasyon dünyasının lider dili Python ile ilgili en güncel snippetları keşfedin.
Dış dünyaya açık bir API kullanarak, girilen şehrin anlık hava durumunu ve sıcaklık bilgilerini çeken Python uygulaması.
import requests
api_key = "YOUR_API_KEY"
sehir = "Ankara"
url = f"http://api.openweathermap.org/data/2.5/weather?q={sehir}&appid={api_key}&units=metric"
response = requests.get(url).json()
sicaklik = response['main']['temp']
durum = response['weather'][0]['description']
print(f"{sehir} için hava: {sicaklik} derece ve {durum}")
api_key = "YOUR_API_KEY"
sehir = "Ankara"
url = f"http://api.openweathermap.org/data/2.5/weather?q={sehir}&appid={api_key}&units=metric"
response = requests.get(url).json()
sicaklik = response['main']['temp']
durum = response['weather'][0]['description']
print(f"{sehir} için hava: {sicaklik} derece ve {durum}")
Büyük veri setleri içerisinde belirli kriterlere göre filtreleme yapmayı ve istatistiksel özet almayı sağlayan profesyonel veri analizi örneği.
import pandas as pd
# Veri setini yükle
df = pd.read_csv('satislar.csv')
# Filtreleme: Satışı 5000'den büyük olan ve Ankara şubesi verileri
filtre = df[(df['Satis'] > 5000) & (df['Sehir'] == 'Ankara')]
# Genel istatistiksel özet
print(filtre.describe())
# Gruplandırarak toplam alma
print(df.groupby('Kategori')['Satis'].sum())
# Veri setini yükle
df = pd.read_csv('satislar.csv')
# Filtreleme: Satışı 5000'den büyük olan ve Ankara şubesi verileri
filtre = df[(df['Satis'] > 5000) & (df['Sehir'] == 'Ankara')]
# Genel istatistiksel özet
print(filtre.describe())
# Gruplandırarak toplam alma
print(df.groupby('Kategori')['Satis'].sum())
C# (CSharp) & .NET Core
KurumsalModern, nesne yönelimli ve yüksek performanslı. ASP.NET Core ve Entity Framework ile profesyonel web ve masaüstü projeleri geliştirin.
Kullanıcının MessageBox kusutunda seçmiş olduğu karara göre işlem yapmak için DialogResult kullanılmaktadır.
if (DialogResult.Yes == MessageBox.Show("Kararınız nedir?", "Important Question", MessageBoxButtons.YesNo))
{
MessageBox.Show("EVET seçildi");
}
else
{
MessageBox.Show("İptal edildi");
}
{
MessageBox.Show("EVET seçildi");
}
else
{
MessageBox.Show("İptal edildi");
}
Faktöriyel Hesabı
CSHARPTextboxt'tan girilen sayının faktöriyelini hesaplayıp sonucu gösteren bir kod örneği
int toplam = 1;
int girilenSayi = int.Parse(textBox1.Text);
for (int i = 1; i < girilenSayi ; i++)
{
toplam += toplam*i;
}
MessageBox.Show(toplam.ToString());
int girilenSayi = int.Parse(textBox1.Text);
for (int i = 1; i < girilenSayi ; i++)
{
toplam += toplam*i;
}
MessageBox.Show(toplam.ToString());
PHP & Web Programlama
DinamikWeb dünyasının emektar ve güçlü dili. PDO veritabanı yönetimi, API işlemleri ve modern PHP 8.x tekniklerini inceleyin.
While döngüsü döngüye girilmeden önce şartın sağlanıp sağlanmadığını kontrol ettikten sonra işlemleri yapmaktadır. İşlemler ilk kez yapıldıktan sonra şartın sağlanıp sağlanmaması isteniyorsa bu durumda do..while döngüsü kullanılır.
<?
$sayac=1;
Do
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
sayac++;
}
while ($sayac <= 7) ;
?>
$sayac=1;
Do
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
sayac++;
}
while ($sayac <= 7) ;
?>
Veritabanından çekilen verileri comboboxta yazdıran güzel bir kod. Herhangi bir formun içerisinde <SELECT></SELECT> blokları arasına yerleştirilmesi gerekiyor.
<SELECT NAME='kategori_id'>
<?
$dbh=mysql_connect ("localhost", "", "") or die (' Veritabanına bağlantı sağlanamıyor. Nedeni: ' . mysql_error());
mysql_select_db ("veritabanı_adı");
$sql = "SELECT * FROM tablo";
$sonuc = mysql_query($sql);
while ($satir = mysql_fetch_row($sonuc))
{
?>
<OPTION Value="<?=$satir[0]?>"><?=$satir[1]?></OPTION>
<?
}
?>
</select>
<?
$dbh=mysql_connect ("localhost", "", "") or die (' Veritabanına bağlantı sağlanamıyor. Nedeni: ' . mysql_error());
mysql_select_db ("veritabanı_adı");
$sql = "SELECT * FROM tablo";
$sonuc = mysql_query($sql);
while ($satir = mysql_fetch_row($sonuc))
{
?>
<OPTION Value="<?=$satir[0]?>"><?=$satir[1]?></OPTION>
<?
}
?>
</select>
JavaScript (ES6+)
Frontendİnteraktif web sayfalarının kalbi. Modern JS, Async/Await ve DOM manipülasyonu üzerine en pratik kod parçacıkları burada.
Sayfalarınızda kullanıcıların mouse (fare)'un sol tuş fonksiyonlarına ulaşmasını istemiyorsanız bu scripti rahatlıkla kullanabilirsiniz.
<style type="text/css">
.menuFront {
position: absolute;
visibility: hidden;
top: 0px;
left: 0px;
background-color: #C0C0C0;
border-left: 1px solid #FFFFFF;
border-right: 1px solid #000000;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #000000;
margin: 1px;
cursor: default;
z-index: 11;
}
.menuBack {
position: absolute;
visibility: hidden;
top: 0px;
left: 0px;
background-color: #C0C0C0;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
z-index: 10;
}
.item {
position: absolute;
visibility: inherit;
color: #000000;
font-size: 9pt;
font-family: Arial, sans-serif;
font-weight: bold;
left: 1px;
height: 15px;
padding-left : 5px;
z-index: 11;
}
.itemSep {
position: absolute;
visibility: inherit;
left: 1px;
height: 7px;
padding-left: 5px;
padding-right: 5px;
z-index: 11;
}
.sep {
position: absolute;
color: #FFFFFF;
width: 100%;
height: 1px;
z-index: 11;
}
.arrow {
position: absolute;
font-size: 9pt;
font-family: Marlett, sans-serif;
font-weight: normal;
margin-top: 2px;
z-index: 11;
}
</style>
<script language="JavaScript1.2">
var widthMax;
var heightMax;
var xCoor;
var yCoor;
var sWidth;
var sHeight;
var xScroll;
var widthScroll;
var menu = new Array;
var divId = new Array;
function rightClick()
{
document.oncontextmenu = show;
document.onclick = hideMenus;
}
function menuItem()
{
this.item = arguments[0];
this.hasSubMenu = arguments[1];
this.level = arguments[2];
this.subMenuFront = arguments[3];
this.subMenuBack = arguments[4];
this.subMenuOffset = arguments[5];
this.link = arguments[6];
}
function findMenuLevel(parentId)
{
for (i = 0; i < divId.length; i = i + 2)
{
if (divId[i] == (parentId + "Front"))
{
return divId[i + 1];
break;
}
}
}
function createMenu(menuId, menuWidth, level)
{
var frontLayer = document.createElement("DIV");
with (frontLayer)
{
id = menuId + "Front";
className = "menuFront";
with (style)
{
posWidth = menuWidth;
posHeight = 3;
backgroundColor = outBgCr;
visibility = "hidden";
}
}
document.body.appendChild(frontLayer);
var backLayer = document.createElement("DIV");
with (backLayer)
{
id = menuId + "Back";
className = "menuBack";
with (style)
{
posWidth = menuWidth + 2;
posHeight = 5;
backgroundColor = outBgCr;
visibility = "hidden";
}
}
document.body.appendChild(backLayer);
divId[divId.length] = menuId + "Front";
divId[divId.length] = level;
divId[divId.length] = menuId + "Back";
divId[divId.length] = level;
}
function createItem(itemId, displayText, parentId, pageSrc, hasSubMenu)
{
var menuFront = document.getElementById(parentId + "Front");
var menuBack = document.getElementById(parentId + "Back");
var level = findMenuLevel(parentId);
var subMenuFront = "";
var subMenuBack = "";
var subMenuOffset = -1;
var itemLayer = document.createElement("DIV");
with (itemLayer)
{
onmouseover = over;
onmouseout = out;
onclick = goToLink;
id = itemId;
className = "item";
if (displayText != "-")
{
if (hasSubMenu)
{
link = "";
innerText = displayText;
var sepLayer = document.createElement("DIV");
with (sepLayer)
{
className = "arrow";
innerText = "4";
with (style)
{
left = menuFront.style.posWidth - 20;
}
itemLayer.appendChild(sepLayer);
}
}
else
{
innerText = displayText;
}
with (style)
{
posTop = menuFront.style.posHeight - 3;
posWidth = menuFront.style.posWidth - 4;
fontFamily = itemFont;
color = outCr;
if (hasSubMenu)
{
subMenuOffset = menuFront.style.posHeight - 3;
}
}
menuFront.style.posHeight += 15;
menuBack.style.posHeight += 15;
}
}
menuFront.appendChild(itemLayer);
menu[menu.length] = new menuItem(itemId, hasSubMenu, level, subMenuFront, subMenuBack, subMenuOffset, pageSrc);
}
function createSep(parentId)
{
var menuFront = document.getElementById(parentId + "Front");
var menuBack = document.getElementById(parentId + "Back");
var sepLayer = document.createElement("DIV");
with (sepLayer)
{
className = "itemSep";
innerHTML = "<hr size=\"1\" class=\"sep\" align=\"center\">";
with (style)
{
posTop = menuFront.style.posHeight;
posWidth = menuFront.style.posWidth - 4;
}
menuFront.style.posHeight += 7;
menuBack.style.posHeight += 7;
}
menuFront.appendChild(sepLayer);
}
function linkSubMenu(itemId, subMenuId)
{
for (i = 0; i < menu.length; i++)
{
if (menu[i].item == itemId)
{
menu[i].subMenuFront = subMenuId + "Front";
menu[i].subMenuBack = subMenuId + "Back";
break;
}
}
}
function hideMenus()
{
for (i = 0; i < divId.length; i = i + 2)
{
var menuLayer = document.getElementById(divId[i]);
menuLayer.style.visibility = "hidden";
}
}
function popUpPos()
{
var menuFront = document.getElementById(divId[0]);
var menuBack = document.getElementById(divId[2]);
widthMax = document.body.clientWidth;
heightMax = document.body.clientHeight;
xCoor = window.event.x;
yCoor = window.event.y;
sWidth = menuFront.style.posWidth;
sHeight = menuFront.style.posHeight;
xScroll = document.body.scrollTop;
widthScroll = document.body.offsetWidth - widthMax;
xWidth = xCoor + sWidth;
yHeight = yCoor + sHeight;
if (menuFront.style.visibility == "hidden")
{
if (yHeight < (heightMax - 1))
{
menuFront.style.posTop = yCoor + xScroll;
menuBack.style.posTop = yCoor + xScroll;
}
else
{
if (yCoor < sHeight)
{
menuFront.style.posTop = xScroll;
menuBack.style.posTop = xScroll;
}
else
{
menuFront.style.posTop = yCoor - sHeight + xScroll - 2;
menuBack.style.posTop = yCoor - sHeight + xScroll - 2;
if ((menuFront.style.posTop + menuFront.style.posHeight - xScroll + 2) > heightMax)
{
menuFront.style.posTop = heightMax - menuFront.style.posHeight + xScroll - 2;
menuBack.style.posTop = heightMax - menuFront.style.posHeight + xScroll - 2;
}
}
}
if (xWidth < widthMax - 1)
{
menuFront.style.posLeft = xCoor;
menuBack.style.posLeft = xCoor;
}
else
{
if (xCoor == (widthMax + 1))
{
menuFront.style.posLeft = xCoor - sWidth - 3;
menuBack.style.posLeft = xCoor - sWidth - 3;
}
else
{
if (widthMax < xCoor)
{
menuFront.style.posLeft = xCoor - sWidth - widthScroll - 1;
menuBack.style.posLeft = xCoor - sWidth - widthScroll - 1;
}
else
{
menuFront.style.posLeft = xCoor - sWidth - 2;
menuBack.style.posLeft = xCoor - sWidth - 2;
}
}
}
}
}
function findOffset(itemId)
{
offset = 0;
for (i = 0; i < menu.length; i++)
{
if (itemId == document.getElementById(menu[i].item))
{
offset = menu[i].level;
break;
}
}
for (i = 0; i < divId.length; i = i + 2)
{
if (offset == divId[i + 1])
{
return i;
}
}
}
function popUpSubPos(xCoor, yCoor, subMenuFront, subMenuBack, offset)
{
var menuFront = document.getElementById(divId[offset]);
var menuBack = document.getElementById(divId[offset + 2]);
widthMax = document.body.clientWidth;
heightMax = document.body.clientHeight;
sWidth = subMenuFront.style.posWidth;
sHeight = subMenuFront.style.posHeight;
xScroll = document.body.scrollTop;
widthScroll = document.body.offsetWidth - document.body.clientWidth;
xWidth = xCoor + sWidth;
yHeight = yCoor + sHeight;
if (subMenuFront.style.visibility == "hidden")
{
if ((yHeight - xScroll) < (heightMax - 1))
{
subMenuFront.style.posTop = yCoor;
subMenuBack.style.posTop = yCoor;
}
else
{
subMenuFront.style.posTop = yCoor - sHeight + 15;
subMenuBack.style.posTop = yCoor - sHeight + 15;
}
if (xWidth < widthMax - 1)
{
subMenuFront.style.posLeft = xCoor;
subMenuBack.style.posLeft = xCoor;
}
else
{
subMenuFront.style.posLeft = xCoor - menuFront.style.posWidth - subMenuFront.style.posWidth + 5;
subMenuBack.style.posLeft = xCoor - menuFront.style.posWidth - subMenuFront.style.posWidth + 5;
}
}
}
function show()
{
var source = window.event.srcElement.tagName;
var menuFront = document.getElementById(divId[0]);
var menuBack = document.getElementById(divId[2]);
if (menuFront.style.visibility == "hidden")
{
if (source != "A" && source != "IMG" && source != "INPUT" && source != "SELECT" && source != "TEXTAREA")
{
popUpPos();
menuFront.style.visibility = "visible";
menuBack.style.visibility = "visible";
return false;
}
}
else
{
hideMenus();
}
}
function checkElement(itemId)
{
if (itemId.className == "arrow")
{
return itemId.parentElement;
}
else
{
return itemId;
}
}
function over()
{
var itemId = event.srcElement;
itemId = checkElement(itemId);
offset = findOffset(itemId);
var menuFront = document.getElementById(divId[offset]);
var xCoor = menuFront.style.posLeft + itemId.style.posWidth;
var yCoor = menuFront.style.posTop;
var divSubId = divId.slice(4);
itemId.style.backgroundColor = overBgCr;
itemId.style.color = overCr;
for (i = 0; i < menu.length; i++)
{
if (itemId == document.getElementById(menu[i].item))
{
for (j = 0; j < divSubId.length; j = j + 2)
{
if ((menu[i].level) < divSubId[j + 1])
{
var subMenu = document.getElementById(divSubId[j]);
subMenu.style.visibility = "hidden";
}
}
if (menu[i].hasSubMenu)
{
var subMenuFront = document.getElementById(menu[i].subMenuFront);
var subMenuBack = document.getElementById(menu[i].subMenuBack);
subMenuFront.style.zIndex = menu[i].level + 12;
subMenuBack.style.zIndex = menu[i].level + 11;
popUpSubPos(xCoor, yCoor + menu[i].subMenuOffset, subMenuFront, subMenuBack, offset);
subMenuFront.style.visibility = "visible";
subMenuBack.style.visibility = "visible";
}
break;
}
}
}
function out()
{
var itemId = event.srcElement;
itemId = checkElement(itemId);
itemId.style.backgroundColor = outBgCr;
itemId.style.color = outCr;
}
function goToLink()
{
var itemId = event.srcElement;
for (i = 0; i < menu.length; i++)
{
if ((itemId == document.getElementById(menu[i].item)) && (menu[i].link != ""))
{
window.location.href = menu[i].link;
break;
}
}
}
function isIE()
{
return (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion >= 5))
}
if (isIE)
{
document.onload = hideMenus;
document.onclick = show;
}
</script>
<script language="JavaScript1.2">
var overBgCr = "#3333CC";
var overCr = "#FFFFFF";
var outBgCr = "#C0C0C0";
var outCr = "#000000";
var itemFont = "Arial";
function createPopUpMenu()
{
createMenu("menu1", 150, 0); // Ana menüyü olusturmak için.
createItem("item1", "Link 1", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createItem("item2", "Link 2", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createItem("item3", "Link 3", "menu1", "", true); // alt menüsü olan bir item ekleniyor.
createItem("item4", "Link 4", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createItem("item5", "Link 5", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createMenu("menu2", 200, 1); //Alt menüyü olusturmak için. menü 2
createItem("item6", "Link 6", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
createItem("item7", "Link 7", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
createItem("item8", "Link 8", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
createItem("item9", "Link 9", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
linkSubMenu("item3", "menu2"); // menu2 deki 3ncü item ile 2nci menüyü iliskilendiriliyor..
}
</script>
.menuFront {
position: absolute;
visibility: hidden;
top: 0px;
left: 0px;
background-color: #C0C0C0;
border-left: 1px solid #FFFFFF;
border-right: 1px solid #000000;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #000000;
margin: 1px;
cursor: default;
z-index: 11;
}
.menuBack {
position: absolute;
visibility: hidden;
top: 0px;
left: 0px;
background-color: #C0C0C0;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
z-index: 10;
}
.item {
position: absolute;
visibility: inherit;
color: #000000;
font-size: 9pt;
font-family: Arial, sans-serif;
font-weight: bold;
left: 1px;
height: 15px;
padding-left : 5px;
z-index: 11;
}
.itemSep {
position: absolute;
visibility: inherit;
left: 1px;
height: 7px;
padding-left: 5px;
padding-right: 5px;
z-index: 11;
}
.sep {
position: absolute;
color: #FFFFFF;
width: 100%;
height: 1px;
z-index: 11;
}
.arrow {
position: absolute;
font-size: 9pt;
font-family: Marlett, sans-serif;
font-weight: normal;
margin-top: 2px;
z-index: 11;
}
</style>
<script language="JavaScript1.2">
var widthMax;
var heightMax;
var xCoor;
var yCoor;
var sWidth;
var sHeight;
var xScroll;
var widthScroll;
var menu = new Array;
var divId = new Array;
function rightClick()
{
document.oncontextmenu = show;
document.onclick = hideMenus;
}
function menuItem()
{
this.item = arguments[0];
this.hasSubMenu = arguments[1];
this.level = arguments[2];
this.subMenuFront = arguments[3];
this.subMenuBack = arguments[4];
this.subMenuOffset = arguments[5];
this.link = arguments[6];
}
function findMenuLevel(parentId)
{
for (i = 0; i < divId.length; i = i + 2)
{
if (divId[i] == (parentId + "Front"))
{
return divId[i + 1];
break;
}
}
}
function createMenu(menuId, menuWidth, level)
{
var frontLayer = document.createElement("DIV");
with (frontLayer)
{
id = menuId + "Front";
className = "menuFront";
with (style)
{
posWidth = menuWidth;
posHeight = 3;
backgroundColor = outBgCr;
visibility = "hidden";
}
}
document.body.appendChild(frontLayer);
var backLayer = document.createElement("DIV");
with (backLayer)
{
id = menuId + "Back";
className = "menuBack";
with (style)
{
posWidth = menuWidth + 2;
posHeight = 5;
backgroundColor = outBgCr;
visibility = "hidden";
}
}
document.body.appendChild(backLayer);
divId[divId.length] = menuId + "Front";
divId[divId.length] = level;
divId[divId.length] = menuId + "Back";
divId[divId.length] = level;
}
function createItem(itemId, displayText, parentId, pageSrc, hasSubMenu)
{
var menuFront = document.getElementById(parentId + "Front");
var menuBack = document.getElementById(parentId + "Back");
var level = findMenuLevel(parentId);
var subMenuFront = "";
var subMenuBack = "";
var subMenuOffset = -1;
var itemLayer = document.createElement("DIV");
with (itemLayer)
{
onmouseover = over;
onmouseout = out;
onclick = goToLink;
id = itemId;
className = "item";
if (displayText != "-")
{
if (hasSubMenu)
{
link = "";
innerText = displayText;
var sepLayer = document.createElement("DIV");
with (sepLayer)
{
className = "arrow";
innerText = "4";
with (style)
{
left = menuFront.style.posWidth - 20;
}
itemLayer.appendChild(sepLayer);
}
}
else
{
innerText = displayText;
}
with (style)
{
posTop = menuFront.style.posHeight - 3;
posWidth = menuFront.style.posWidth - 4;
fontFamily = itemFont;
color = outCr;
if (hasSubMenu)
{
subMenuOffset = menuFront.style.posHeight - 3;
}
}
menuFront.style.posHeight += 15;
menuBack.style.posHeight += 15;
}
}
menuFront.appendChild(itemLayer);
menu[menu.length] = new menuItem(itemId, hasSubMenu, level, subMenuFront, subMenuBack, subMenuOffset, pageSrc);
}
function createSep(parentId)
{
var menuFront = document.getElementById(parentId + "Front");
var menuBack = document.getElementById(parentId + "Back");
var sepLayer = document.createElement("DIV");
with (sepLayer)
{
className = "itemSep";
innerHTML = "<hr size=\"1\" class=\"sep\" align=\"center\">";
with (style)
{
posTop = menuFront.style.posHeight;
posWidth = menuFront.style.posWidth - 4;
}
menuFront.style.posHeight += 7;
menuBack.style.posHeight += 7;
}
menuFront.appendChild(sepLayer);
}
function linkSubMenu(itemId, subMenuId)
{
for (i = 0; i < menu.length; i++)
{
if (menu[i].item == itemId)
{
menu[i].subMenuFront = subMenuId + "Front";
menu[i].subMenuBack = subMenuId + "Back";
break;
}
}
}
function hideMenus()
{
for (i = 0; i < divId.length; i = i + 2)
{
var menuLayer = document.getElementById(divId[i]);
menuLayer.style.visibility = "hidden";
}
}
function popUpPos()
{
var menuFront = document.getElementById(divId[0]);
var menuBack = document.getElementById(divId[2]);
widthMax = document.body.clientWidth;
heightMax = document.body.clientHeight;
xCoor = window.event.x;
yCoor = window.event.y;
sWidth = menuFront.style.posWidth;
sHeight = menuFront.style.posHeight;
xScroll = document.body.scrollTop;
widthScroll = document.body.offsetWidth - widthMax;
xWidth = xCoor + sWidth;
yHeight = yCoor + sHeight;
if (menuFront.style.visibility == "hidden")
{
if (yHeight < (heightMax - 1))
{
menuFront.style.posTop = yCoor + xScroll;
menuBack.style.posTop = yCoor + xScroll;
}
else
{
if (yCoor < sHeight)
{
menuFront.style.posTop = xScroll;
menuBack.style.posTop = xScroll;
}
else
{
menuFront.style.posTop = yCoor - sHeight + xScroll - 2;
menuBack.style.posTop = yCoor - sHeight + xScroll - 2;
if ((menuFront.style.posTop + menuFront.style.posHeight - xScroll + 2) > heightMax)
{
menuFront.style.posTop = heightMax - menuFront.style.posHeight + xScroll - 2;
menuBack.style.posTop = heightMax - menuFront.style.posHeight + xScroll - 2;
}
}
}
if (xWidth < widthMax - 1)
{
menuFront.style.posLeft = xCoor;
menuBack.style.posLeft = xCoor;
}
else
{
if (xCoor == (widthMax + 1))
{
menuFront.style.posLeft = xCoor - sWidth - 3;
menuBack.style.posLeft = xCoor - sWidth - 3;
}
else
{
if (widthMax < xCoor)
{
menuFront.style.posLeft = xCoor - sWidth - widthScroll - 1;
menuBack.style.posLeft = xCoor - sWidth - widthScroll - 1;
}
else
{
menuFront.style.posLeft = xCoor - sWidth - 2;
menuBack.style.posLeft = xCoor - sWidth - 2;
}
}
}
}
}
function findOffset(itemId)
{
offset = 0;
for (i = 0; i < menu.length; i++)
{
if (itemId == document.getElementById(menu[i].item))
{
offset = menu[i].level;
break;
}
}
for (i = 0; i < divId.length; i = i + 2)
{
if (offset == divId[i + 1])
{
return i;
}
}
}
function popUpSubPos(xCoor, yCoor, subMenuFront, subMenuBack, offset)
{
var menuFront = document.getElementById(divId[offset]);
var menuBack = document.getElementById(divId[offset + 2]);
widthMax = document.body.clientWidth;
heightMax = document.body.clientHeight;
sWidth = subMenuFront.style.posWidth;
sHeight = subMenuFront.style.posHeight;
xScroll = document.body.scrollTop;
widthScroll = document.body.offsetWidth - document.body.clientWidth;
xWidth = xCoor + sWidth;
yHeight = yCoor + sHeight;
if (subMenuFront.style.visibility == "hidden")
{
if ((yHeight - xScroll) < (heightMax - 1))
{
subMenuFront.style.posTop = yCoor;
subMenuBack.style.posTop = yCoor;
}
else
{
subMenuFront.style.posTop = yCoor - sHeight + 15;
subMenuBack.style.posTop = yCoor - sHeight + 15;
}
if (xWidth < widthMax - 1)
{
subMenuFront.style.posLeft = xCoor;
subMenuBack.style.posLeft = xCoor;
}
else
{
subMenuFront.style.posLeft = xCoor - menuFront.style.posWidth - subMenuFront.style.posWidth + 5;
subMenuBack.style.posLeft = xCoor - menuFront.style.posWidth - subMenuFront.style.posWidth + 5;
}
}
}
function show()
{
var source = window.event.srcElement.tagName;
var menuFront = document.getElementById(divId[0]);
var menuBack = document.getElementById(divId[2]);
if (menuFront.style.visibility == "hidden")
{
if (source != "A" && source != "IMG" && source != "INPUT" && source != "SELECT" && source != "TEXTAREA")
{
popUpPos();
menuFront.style.visibility = "visible";
menuBack.style.visibility = "visible";
return false;
}
}
else
{
hideMenus();
}
}
function checkElement(itemId)
{
if (itemId.className == "arrow")
{
return itemId.parentElement;
}
else
{
return itemId;
}
}
function over()
{
var itemId = event.srcElement;
itemId = checkElement(itemId);
offset = findOffset(itemId);
var menuFront = document.getElementById(divId[offset]);
var xCoor = menuFront.style.posLeft + itemId.style.posWidth;
var yCoor = menuFront.style.posTop;
var divSubId = divId.slice(4);
itemId.style.backgroundColor = overBgCr;
itemId.style.color = overCr;
for (i = 0; i < menu.length; i++)
{
if (itemId == document.getElementById(menu[i].item))
{
for (j = 0; j < divSubId.length; j = j + 2)
{
if ((menu[i].level) < divSubId[j + 1])
{
var subMenu = document.getElementById(divSubId[j]);
subMenu.style.visibility = "hidden";
}
}
if (menu[i].hasSubMenu)
{
var subMenuFront = document.getElementById(menu[i].subMenuFront);
var subMenuBack = document.getElementById(menu[i].subMenuBack);
subMenuFront.style.zIndex = menu[i].level + 12;
subMenuBack.style.zIndex = menu[i].level + 11;
popUpSubPos(xCoor, yCoor + menu[i].subMenuOffset, subMenuFront, subMenuBack, offset);
subMenuFront.style.visibility = "visible";
subMenuBack.style.visibility = "visible";
}
break;
}
}
}
function out()
{
var itemId = event.srcElement;
itemId = checkElement(itemId);
itemId.style.backgroundColor = outBgCr;
itemId.style.color = outCr;
}
function goToLink()
{
var itemId = event.srcElement;
for (i = 0; i < menu.length; i++)
{
if ((itemId == document.getElementById(menu[i].item)) && (menu[i].link != ""))
{
window.location.href = menu[i].link;
break;
}
}
}
function isIE()
{
return (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion >= 5))
}
if (isIE)
{
document.onload = hideMenus;
document.onclick = show;
}
</script>
<script language="JavaScript1.2">
var overBgCr = "#3333CC";
var overCr = "#FFFFFF";
var outBgCr = "#C0C0C0";
var outCr = "#000000";
var itemFont = "Arial";
function createPopUpMenu()
{
createMenu("menu1", 150, 0); // Ana menüyü olusturmak için.
createItem("item1", "Link 1", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createItem("item2", "Link 2", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createItem("item3", "Link 3", "menu1", "", true); // alt menüsü olan bir item ekleniyor.
createItem("item4", "Link 4", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createItem("item5", "Link 5", "menu1", "http://www.ipucu.web.tr", false); // menü1'e link ekleniyor.
createMenu("menu2", 200, 1); //Alt menüyü olusturmak için. menü 2
createItem("item6", "Link 6", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
createItem("item7", "Link 7", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
createItem("item8", "Link 8", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
createItem("item9", "Link 9", "menu2", "http://www.ipucu.web.tr", false); // menü2'ye link ekleniyor.
linkSubMenu("item3", "menu2"); // menu2 deki 3ncü item ile 2nci menüyü iliskilendiriliyor..
}
</script>
Sayfayı ziyaret eden kişilerin burçlarını öğrenmelerini sağlamak için hazırlanmış güzel bir script.
<TABLE cellSpacing=0 cellPadding=0 width=600 align=center border=0>
<TBODY bgColor=#FF66FF>
<TR>
<TD vAlign=bottom align=left width=600 height=30>
<SCRIPT>
function astro()
{
var month,day;
var b = false;
var i=0;
var j=0;
while (b == false)
{
document.formsign.month[i].checked?b=true:i++
}
month = i+1;
while (b == true)
{
document.formsign.month[j].checked?b=false:j++
}
day = j+1;
if (month < 01 || month > 12)
{document.write("<h1>Invalid Month : " + month + "</h1><br>");}
if (day < 01 || day > 31)
{document.write("<h1>Invalid Day : " + day + "</h1><br>");}
if ((month == 01 && day < 19) || (month == 12 && day >= 23))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz OĞLAK Burcundansınız.</h1></center>");
}
if ((month == 02 && day < 19) || (month == 1 && day >= 20))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz KOVA burcundansınız.</h1></center>");
}
if ((month == 03 && day < 21) || (month == 2 && day >= 20))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz BALIK burcundansınız.</h1></center>");
}
if ((month == 04 && day < 21) || (month == 3 && day >= 22))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz KOÇ burcundansınız.</h1></center>");
}
if ((month == 05 && day < 21) || (month == 4 && day >= 21))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz BOĞA burcundansınız.</h1></center>");
}
if ((month == 06 && day < 22) || (month == 5 && day >= 22))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz İKİZLER burcundansınız.</h1></center>");
}
if ((month == 07 && day < 23) || (month == 6 && day >= 23))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz YENGEÇ burcundansınız.</h1></center>");
}
if ((month == 08 && day < 23) || (month == 7 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz ASLAN burcundansınız.</h1></center>");
}
if ((month == 09 && day < 23) || (month == 8 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz BAŞAK burcundansınız.</h1></center>");
}
if ((month == 10 && day < 23) || (month == 9 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz TERAZİ burcundansınız.</h1></center>");
}
if ((month == 11 && day < 22) || (month == 10 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz AKREP burcundansınız.</h1></center>");
}
if ((month == 12 && day < 22) || (month == 11 && day >= 23))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz YAY burcundansınız.</h1></center>");}
}
</SCRIPT>
<CENTER>
<FORM name=formsign>
<H3>Doğduğunuz ayı seçiniz.</H3><INPUT type=radio value=01
name=month>Ocak <INPUT type=radio value=02 name=month>Şubat <INPUT
type=radio value=03 name=month>Mart <INPUT type=radio value=04
name=month>Nisan <INPUT type=radio value=05 name=month>Mayıs <INPUT
type=radio value=06 name=month>Haziran <INPUT type=radio value=07
name=month>Temmuz <INPUT type=radio value=08 name=month>Ağustos <INPUT
type=radio value=09 name=month>Eylül <INPUT type=radio value=10
name=month>Ekim <INPUT type=radio value=11 name=month>Kasım <INPUT
type=radio value=12 name=month>Aralık </SELECT><BR>
<H3>Doğduğunuz günü seçiniz.</H3><INPUT type=radio value=01
name=day>01 <INPUT type=radio value=02 name=day>02 <INPUT type=radio
value=03 name=day>03 <INPUT type=radio value=04 name=day>04 <INPUT
type=radio value=05 name=day>05 <INPUT type=radio value=06 name=day>06
<INPUT type=radio value=07 name=day>07 <INPUT type=radio value=08
name=day>08 <INPUT type=radio value=09 name=day>09 <INPUT type=radio
value=10 name=day>10 <INPUT type=radio value=11 name=day>11 <INPUT
type=radio value=12 name=day>12 <INPUT type=radio value=13 name=day>13
<INPUT type=radio value=14 name=day>14 <INPUT type=radio value=15
name=day>15 <INPUT type=radio value=16 name=day>16 <INPUT type=radio
value=17 name=day>17 <INPUT type=radio value=18 name=day>18 <INPUT
type=radio value=19 name=day>19 <INPUT type=radio value=20 name=day>20
<INPUT type=radio value=21 name=day>21 <INPUT type=radio value=22
name=day>22 <INPUT type=radio value=23 name=day>23 <INPUT type=radio
value=24 name=day>24 <INPUT type=radio value=25 name=day>25 <INPUT
type=radio value=26 name=day>26 <INPUT type=radio value=27 name=day>27
<INPUT type=radio value=28 name=day>28 <INPUT type=radio value=29
name=day>29 <INPUT type=radio value=30 name=day>30 <INPUT type=radio
value=31 name=day>31
<HR>
<BR><INPUT onclick=astro() type=button value="Burcumu göster">
</FORM></CENTER>
<P></P></TD></TR></TBODY></TABLE>
<TBODY bgColor=#FF66FF>
<TR>
<TD vAlign=bottom align=left width=600 height=30>
<SCRIPT>
function astro()
{
var month,day;
var b = false;
var i=0;
var j=0;
while (b == false)
{
document.formsign.month[i].checked?b=true:i++
}
month = i+1;
while (b == true)
{
document.formsign.month[j].checked?b=false:j++
}
day = j+1;
if (month < 01 || month > 12)
{document.write("<h1>Invalid Month : " + month + "</h1><br>");}
if (day < 01 || day > 31)
{document.write("<h1>Invalid Day : " + day + "</h1><br>");}
if ((month == 01 && day < 19) || (month == 12 && day >= 23))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz OĞLAK Burcundansınız.</h1></center>");
}
if ((month == 02 && day < 19) || (month == 1 && day >= 20))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz KOVA burcundansınız.</h1></center>");
}
if ((month == 03 && day < 21) || (month == 2 && day >= 20))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz BALIK burcundansınız.</h1></center>");
}
if ((month == 04 && day < 21) || (month == 3 && day >= 22))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz KOÇ burcundansınız.</h1></center>");
}
if ((month == 05 && day < 21) || (month == 4 && day >= 21))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz BOĞA burcundansınız.</h1></center>");
}
if ((month == 06 && day < 22) || (month == 5 && day >= 22))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz İKİZLER burcundansınız.</h1></center>");
}
if ((month == 07 && day < 23) || (month == 6 && day >= 23))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz YENGEÇ burcundansınız.</h1></center>");
}
if ((month == 08 && day < 23) || (month == 7 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz ASLAN burcundansınız.</h1></center>");
}
if ((month == 09 && day < 23) || (month == 8 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz BAŞAK burcundansınız.</h1></center>");
}
if ((month == 10 && day < 23) || (month == 9 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz TERAZİ burcundansınız.</h1></center>");
}
if ((month == 11 && day < 22) || (month == 10 && day >= 24))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz AKREP burcundansınız.</h1></center>");
}
if ((month == 12 && day < 22) || (month == 11 && day >= 23))
{ document.write("<br><br><br><br><br><br><br><br><center><h1>Siz YAY burcundansınız.</h1></center>");}
}
</SCRIPT>
<CENTER>
<FORM name=formsign>
<H3>Doğduğunuz ayı seçiniz.</H3><INPUT type=radio value=01
name=month>Ocak <INPUT type=radio value=02 name=month>Şubat <INPUT
type=radio value=03 name=month>Mart <INPUT type=radio value=04
name=month>Nisan <INPUT type=radio value=05 name=month>Mayıs <INPUT
type=radio value=06 name=month>Haziran <INPUT type=radio value=07
name=month>Temmuz <INPUT type=radio value=08 name=month>Ağustos <INPUT
type=radio value=09 name=month>Eylül <INPUT type=radio value=10
name=month>Ekim <INPUT type=radio value=11 name=month>Kasım <INPUT
type=radio value=12 name=month>Aralık </SELECT><BR>
<H3>Doğduğunuz günü seçiniz.</H3><INPUT type=radio value=01
name=day>01 <INPUT type=radio value=02 name=day>02 <INPUT type=radio
value=03 name=day>03 <INPUT type=radio value=04 name=day>04 <INPUT
type=radio value=05 name=day>05 <INPUT type=radio value=06 name=day>06
<INPUT type=radio value=07 name=day>07 <INPUT type=radio value=08
name=day>08 <INPUT type=radio value=09 name=day>09 <INPUT type=radio
value=10 name=day>10 <INPUT type=radio value=11 name=day>11 <INPUT
type=radio value=12 name=day>12 <INPUT type=radio value=13 name=day>13
<INPUT type=radio value=14 name=day>14 <INPUT type=radio value=15
name=day>15 <INPUT type=radio value=16 name=day>16 <INPUT type=radio
value=17 name=day>17 <INPUT type=radio value=18 name=day>18 <INPUT
type=radio value=19 name=day>19 <INPUT type=radio value=20 name=day>20
<INPUT type=radio value=21 name=day>21 <INPUT type=radio value=22
name=day>22 <INPUT type=radio value=23 name=day>23 <INPUT type=radio
value=24 name=day>24 <INPUT type=radio value=25 name=day>25 <INPUT
type=radio value=26 name=day>26 <INPUT type=radio value=27 name=day>27
<INPUT type=radio value=28 name=day>28 <INPUT type=radio value=29
name=day>29 <INPUT type=radio value=30 name=day>30 <INPUT type=radio
value=31 name=day>31
<HR>
<BR><INPUT onclick=astro() type=button value="Burcumu göster">
</FORM></CENTER>
<P></P></TD></TR></TBODY></TABLE>