Sorry ... det er bl.a. Ekspertens BB-kode parsing, der phucker koden op :o|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript">
resizeTo(510, 708);
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>List & Search Folders</title>
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta http-equiv="MSThemeCompatible" content="yes">
<style type="text/css">
html, body {
overflow: hidden;
}
body {
margin: 0;
padding: 0;
font: 0.75em verdana, arial, sans-serif;
background: threedface;
}
input {
font: 0.9em verdana, arial, sans-serif;
padding: 2px;
}
#controls {
width: 455px;
margin: 15px auto 0;
}
#controls fieldset {
margin-bottom: 10px;
}
#controls legend {
padding: 0 5px 5px;
}
#controls label {
position: relative;
width: 420px;
height: 30px;
margin: 0 10px;
display: block;
}
#controls label .right {
position: absolute;
width: 300px;
right: 0;
}
.narrow {
width: 85px;
margin: 0 2px;
}
#controls button {
width: 70px;
}
.buttons {
padding: 0 0 8px;
text-align: center;
}
.center {
text-align: center;
}
#display {
width: 434px;
height: 400px;
padding: 5px 10px;
margin: 30px auto 0;
overflow-x: hidden;
overflow-y: auto;
background: #fff;
border: 1px solid threedshadow;
}
#display a {
display: block;
width: 430px;
margin: 3px 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div id="controls">
<fieldset>
<legend>List Folders</legend>
<label>Start folder: <input class="right" id="rootFolder" type="text" value="C:/sti/til/mappe"></label>
<div class="buttons"><button onclick="init()">Initiate</button></div>
</fieldset>
<fieldset id="searchSet" disabled="disabled">
<legend>Search For Folders</legend>
<label class="center"><input id="f_A" class="narrow" type="text">
<input id="f_B" class="narrow" type="text">
<input id="f_C" class="narrow" type="text">
<input id="f_D" class="narrow" type="text"></label>
<div class="buttons"><button onclick="searchFolders()">Search</button></div>
</fieldset>
</div>
<div id="display"></div>
<script type="text/javascript">
var aFolders = null;
function init() {
document.getElementById("searchSet").setAttribute("disabled", "disabled");
aFolders = getFolders(document.getElementById("rootFolder").value, []);
document.getElementById("searchSet").removeAttribute("disabled");
}
function getFolders(sFolder, aFldrs) {
var aTmp, sName, sPath, sReplPath,
oFso = new ActiveXObject("Scripting.FileSystemObject"),
oFolder = oFso.getFolder(sFolder),
oEnum = new Enumerator(oFolder.subFolders);
for (; !oEnum.atEnd(); oEnum.moveNext()) {
sPath = oEnum.item().path;
sReplPath = sPath.replace(/\\/g, "/");
sName = oEnum.item().name;
aTmp = sName.split(" ");
aFldrs.push([aTmp[0], aTmp[1], aTmp[2], aTmp[3], sReplPath]);
arguments.callee(sPath, aFldrs);
}
return aFldrs;
}
function searchFolders() {
var sValFA = document.getElementById("f_A").value,
sValFB = document.getElementById("f_B").value,
sValFC = document.getElementById("f_C").value,
sValFD = document.getElementById("f_D").value,
aRes = [], nFilled, nMatches;
for (var i=aFolders.length-1; i>=0; i--) {
nFilled = 0;
nMatches = 0;
if (sValFA!="") {
nFilled++;
if (aFolders[ i][0]==sValFA) nMatches++;
}
if (sValFB!="") {
nFilled++;
if (aFolders[ i][1]==sValFB) nMatches++;
}
if (sValFC!="") {
nFilled++;
if (aFolders[ i][2]!=sValFC) nMatches++;
}
if (sValFD!="") {
nFilled++;
if (aFolders[ i][3]!=sValFD) nMatches++;
}
if (nFilled>0 && nFilled==nMatches) aRes.push(aFolders[ i][4]);
}
aRes.sort(mySort);
showResult(aRes);
function mySort(a, b) {
return a<b ? 1 : a>b ? -1 : 0;
}
}
function showResult(aRes) {
var elmA, elmDispl = document.getElementById("display");
while (elmDispl.firstChild) elmDispl.removeChild(elmDispl.firstChild);
for (var i=aRes.length-1; i>=0; i--) {
elmA = document.createElement("a");
elmA.setAttribute("href", "
file:///"+aRes[ i]);
elmA.setAttribute("title", aRes[ i]);
elmA.appendChild(document.createTextNode(aRes[ i]));
elmDispl.appendChild(elmA);
}
}
</script>
</body>
</html>