home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2006 October / wn148cd2.iso / Windows / S'informer / Maxthon / Plugin / SearchBar / DynOutline.js next >
Text File  |  2004-11-13  |  3KB  |  110 lines

  1. <!--
  2. function fInitOutline(vType) {
  3.   // Initializing function fo collapse, expand, or selectively expand outline
  4.   // Arguments:
  5.   //   vType : allowed values are "expand", "collapse", or "initexpand"
  6.   //   "initexpand" collapses the entire outline EXCEPT for UL, OL, and
  7.   //   table elements that have an attribute of "initexpanded"
  8.  
  9.   var vListTags = ["UL", "OL", "TABLE"];
  10.   for(j=0;j<vListTags.length;j++) {
  11.     var vTagName=vListTags[j];
  12.     vCollapseTag = document.all.tags(vTagName);
  13.     for(i=0; i<vCollapseTag.length; i++) {
  14.       if (fDynOutlineEnabled(vCollapseTag[i].parentElement)) {
  15.         switch (vType) {
  16.           case "expand" :
  17.             vCollapseTag[i].style.display="block";
  18.             break;
  19.           case "collapse" :
  20.             vCollapseTag[i].style.display="none";
  21.             break;
  22.           case "initexpand" :
  23.             if (vCollapseTag[i].getAttribute("initexpanded", false) != null) {
  24.               vCollapseTag[i].style.display="block";
  25.             } else {
  26.               vCollapseTag[i].style.display="none";
  27.             }
  28.             break;
  29.         }
  30.       }
  31.     }
  32.   }
  33. }
  34.  
  35. function fDynOutline() {
  36.   var vSource = event.srcElement;
  37.   vSource = fGetControlTag(vSource);
  38.   if (null == vSource) {
  39.     return;
  40.   }
  41.   if (!fDynOutlineEnabled(vSource)) {
  42.     return;
  43.   }
  44.   var vIndex = vSource.sourceIndex+1;
  45.   while (vIndex < document.all.length && fContainedIn(document.all[vIndex], vSource)) {
  46.     var SourceTemp = document.all[vIndex];
  47.     vTag = SourceTemp.tagName;
  48.     if (vTag == "UL" || vTag == "OL" || vTag == "TABLE") {
  49.       SourceTemp.style.display = (SourceTemp.style.display == "none" ? "block" : "none");
  50.     }
  51.     vIndex++;
  52.   }
  53. }
  54.  
  55. function fDynOutlineEnabled(argSource) {
  56.   // looks for flag in HTML code;
  57.   // permissible values are "noMyDynamicOutline" and "MyDynamicOutline"
  58.   while (argSource.tagName != "BODY") {
  59.     vTable = (argSource.tagName == "TABLE");
  60.     if (vTable && argSource.getAttribute("border", false) != "0") {
  61.       return false;
  62.     }
  63.     if (argSource.tagName == "OL" || argSource.tagName == "UL" || vTable) {
  64.       if (argSource.getAttribute("noMyDynamicOutline", false) != null) {
  65.         return false;
  66.       }
  67.       if (argSource.getAttribute("MyDynamicOutline", false) != null) {
  68.         return true;
  69.       }
  70.     }
  71.     argSource = argSource.parentElement;
  72.   }
  73.   return false
  74. }
  75.  
  76. function fGetControlTag(argSource) {
  77.   vTRok = false;
  78.   while (argSource.tagName != "HTML") {
  79.     if (argSource.tagName == "IMG" || argSource.tagName == "FONT" ||
  80.         argSource.tagName == "A"   || argSource.tagName == "TD") {
  81.       vTRok = true;
  82.     }
  83.     if (argSource.tagName == "LI") {
  84.       return argSource;
  85.     }
  86.     if (argSource.tagName == "TR") {
  87.       if (vTRok) {
  88.         return argSource;
  89.       } else {
  90.         return null;
  91.       }
  92.     }
  93.     argSource = argSource.parentElement;
  94.   }
  95.   return null;
  96. }
  97.  
  98. function fContainedIn(argSource, argDestination) {
  99.   if (argSource.tagName == "!") {
  100.     return true;
  101.   }
  102.   argSource = fGetControlTag(argSource);
  103.   if (argSource == argDestination) {
  104.       return true;
  105.   } else {
  106.    return false;
  107.   }
  108. }
  109. //-->
  110.