fixman
19/05/2003, 15:25
Canım sıkıldıkça değişik JavaScript'ler yazmaya çalışıyorum...
İlk Script, aslında JScript ve ActiveX kullanarak yerel dizinleri ve dosyaları nasıl kontrol edebileceğinizi gösteriyor... Üzerinde biraz çalışarak geliştirebilir ve işe yarar bir hale getirebilirsiniz :
<script language="JScript">
<!--
var fso, allDrives, thisDriveLetter, thisDriveType, thisDriveInfo, thisDriveStatus;
var thisIndex, allFiles, thisFile, allFolders, thisFolder;
var textContent, driveList, fileList;
fso = new ActiveXObject("Scripting.FileSystemObject");
function listDrives(){
driveList = document.all("Drives");
fileList = document.all("Files");
allDrives = new Enumerator(fso.Drives);
textContent = "<table border=1 cellpadding=4 cellspacing=4>";
for(; !allDrives.atEnd(); allDrives.moveNext()){
thisDrive = allDrives.item();
thisDriveLetter = thisDrive.DriveLetter;
thisDriveType = thisDrive.DriveType;
switch(thisDriveType){
case 1 : thisDriveInfo = "Taşınabilir Aygıt"; break;
case 2 : thisDriveInfo = "Sabit Aygıt"; break;
case 3 : thisDriveInfo = "Ağ Aygıtı"; break;
case 4 : thisDriveInfo = "CD-ROM"; break;
case 5 : thisDriveInfo = "RAM Disk"; break;
default : thisDriveInfo = "Bilinmeyen Aygıt"; break;
}
if(thisDriveType == 3)
thisDriveStatus = thisDrive.ShareName;
else if(thisDrive.IsReady)
thisDriveStatus = thisDrive.VolumeName;
else
thisDriveStatus = "Sürücü hazır değil.";
textContent += "<tr onClick=showList('" + thisDriveLetter + ":/');> \
<td align=center style=cursor:pointer>" + thisDriveLetter + ": </td> \
<td style=cursor:pointer>" + thisDriveInfo + "</td> \
<td>" + thisDriveStatus + "</td> \
</tr>";
}
textContent += "</table>";
driveList.innerHTML = textContent;
showList("C:\\");
}
function showList(thisPath){
if(fso.FolderExists(thisPath)){
thisIndex = fso.GetFolder(thisPath);
allFolders = new Enumerator(thisIndex.SubFolders);
allFiles = new Enumerator(thisIndex.Files);
textContent = "<table border=1 cellpadding=4 cellspacing=4>";
if(!thisIndex.IsRootFolder)
textContent += "<tr style=color:red;cursor:pointer \
onClick=showList('" + thisPath + "/..');> \
<td colspan=3 align=right>Yukarı</td> \
</tr>";
for(; !allFolders.atEnd(); allFolders.moveNext()){
thisFolder = allFolders.item();
thisFolderPath = thisFolder.ShortPath.replace(/\\/g,"/");
textContent += "<tr style=color:blue;cursor:pointer \
onClick=showList('" + thisFolderPath + "');> \
<td>" + thisFolder.Name + "</td> \
<td colspan=2>" + thisFolder.Type + "</td> \
</tr>";
}
for(; !allFiles.atEnd(); allFiles.moveNext()){
thisFile = allFiles.item();
thisFileByteSize = Math.round(thisFile.Size / 1024);
textContent += "<tr> \
<td>" + thisFile.Name + "</td> \
<td>" + thisFile.Type + "</td> \
<td align=right>" + thisFileByteSize + " KB</td> \
</tr>";
}
textContent += "</table>";
fileList.innerHTML = textContent;
}
}
-->
</script>
<body onLoad=listDrives();>
<table cellpadding=4 cellspacing=4>
<tr>
<td id=Drives valign=top></td>
<td id=Files valign=top></td>
</tr>
</table>
</body>
Not : cursor:pointer kısımlarını cursor:zointer olarak değiştireceksiniz... (z, p olacak...) Dikkatinize!
İkinci scriptimiz ise Netscape'de de hata vermemesine rağmen çok hızlı olduğu için Netscape'i peşinde süründürüyor... Garip bir pencere oyunu... Bu script de ham halde olduğu için geliştirip kullanmak yine size kalmış :
http://free.7host02.com/xcrypt/other/z_window_hunter.htm
Yani budur...
Umarım ortalığı fazla karıştırmıyorum...
Sevgiler...
İlk Script, aslında JScript ve ActiveX kullanarak yerel dizinleri ve dosyaları nasıl kontrol edebileceğinizi gösteriyor... Üzerinde biraz çalışarak geliştirebilir ve işe yarar bir hale getirebilirsiniz :
<script language="JScript">
<!--
var fso, allDrives, thisDriveLetter, thisDriveType, thisDriveInfo, thisDriveStatus;
var thisIndex, allFiles, thisFile, allFolders, thisFolder;
var textContent, driveList, fileList;
fso = new ActiveXObject("Scripting.FileSystemObject");
function listDrives(){
driveList = document.all("Drives");
fileList = document.all("Files");
allDrives = new Enumerator(fso.Drives);
textContent = "<table border=1 cellpadding=4 cellspacing=4>";
for(; !allDrives.atEnd(); allDrives.moveNext()){
thisDrive = allDrives.item();
thisDriveLetter = thisDrive.DriveLetter;
thisDriveType = thisDrive.DriveType;
switch(thisDriveType){
case 1 : thisDriveInfo = "Taşınabilir Aygıt"; break;
case 2 : thisDriveInfo = "Sabit Aygıt"; break;
case 3 : thisDriveInfo = "Ağ Aygıtı"; break;
case 4 : thisDriveInfo = "CD-ROM"; break;
case 5 : thisDriveInfo = "RAM Disk"; break;
default : thisDriveInfo = "Bilinmeyen Aygıt"; break;
}
if(thisDriveType == 3)
thisDriveStatus = thisDrive.ShareName;
else if(thisDrive.IsReady)
thisDriveStatus = thisDrive.VolumeName;
else
thisDriveStatus = "Sürücü hazır değil.";
textContent += "<tr onClick=showList('" + thisDriveLetter + ":/');> \
<td align=center style=cursor:pointer>" + thisDriveLetter + ": </td> \
<td style=cursor:pointer>" + thisDriveInfo + "</td> \
<td>" + thisDriveStatus + "</td> \
</tr>";
}
textContent += "</table>";
driveList.innerHTML = textContent;
showList("C:\\");
}
function showList(thisPath){
if(fso.FolderExists(thisPath)){
thisIndex = fso.GetFolder(thisPath);
allFolders = new Enumerator(thisIndex.SubFolders);
allFiles = new Enumerator(thisIndex.Files);
textContent = "<table border=1 cellpadding=4 cellspacing=4>";
if(!thisIndex.IsRootFolder)
textContent += "<tr style=color:red;cursor:pointer \
onClick=showList('" + thisPath + "/..');> \
<td colspan=3 align=right>Yukarı</td> \
</tr>";
for(; !allFolders.atEnd(); allFolders.moveNext()){
thisFolder = allFolders.item();
thisFolderPath = thisFolder.ShortPath.replace(/\\/g,"/");
textContent += "<tr style=color:blue;cursor:pointer \
onClick=showList('" + thisFolderPath + "');> \
<td>" + thisFolder.Name + "</td> \
<td colspan=2>" + thisFolder.Type + "</td> \
</tr>";
}
for(; !allFiles.atEnd(); allFiles.moveNext()){
thisFile = allFiles.item();
thisFileByteSize = Math.round(thisFile.Size / 1024);
textContent += "<tr> \
<td>" + thisFile.Name + "</td> \
<td>" + thisFile.Type + "</td> \
<td align=right>" + thisFileByteSize + " KB</td> \
</tr>";
}
textContent += "</table>";
fileList.innerHTML = textContent;
}
}
-->
</script>
<body onLoad=listDrives();>
<table cellpadding=4 cellspacing=4>
<tr>
<td id=Drives valign=top></td>
<td id=Files valign=top></td>
</tr>
</table>
</body>
Not : cursor:pointer kısımlarını cursor:zointer olarak değiştireceksiniz... (z, p olacak...) Dikkatinize!
İkinci scriptimiz ise Netscape'de de hata vermemesine rağmen çok hızlı olduğu için Netscape'i peşinde süründürüyor... Garip bir pencere oyunu... Bu script de ham halde olduğu için geliştirip kullanmak yine size kalmış :
http://free.7host02.com/xcrypt/other/z_window_hunter.htm
Yani budur...
Umarım ortalığı fazla karıştırmıyorum...
Sevgiler...