⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 script.js

📁 实现了基本的oa功能:个人日志。。。
💻 JS
📖 第 1 页 / 共 5 页
字号:
                           for(var i=0;i<collection.length;i++){
                                 collection[i].checked=checked;
                             }
                             var item =oWorkItem;
                                            while(item.parentNode!=null){
                                                            if(oWorkItem.parentNode.tagName=="TABLE"&&oWorkItem.parentNode.id=="treeViewTableRoot")break;
                                                                    if(item.parentNode.tagName=="DIV"){
                                                                       root=item.parentNode;
                                                                       checked=true;
                                                                       collection=root.getElementsByTagName("INPUT");
                                                                            for(var i=0;i<collection.length;i++){
                                                                              if(!collection[i].checked)checked = false;
                                                                             }
                                                                        document.getElementById(root.id+"checkbox").checked=checked;
                                                                       }
                                                                      item=item.parentNode;
                                                                     }

                     }catch(exception){     }

       }
       }//end if
       else if(oWorkItem.tagName == "IMG"&&new String(oWorkItem.id).indexOf("ImageEx")!=-1){
                           var re = new RegExp("ImageEx","gim");
                           var str = oWorkItem.id.replace(re,"");
                           document.getElementById(str+"checkbox").checked=true;
                           collection=document.getElementById(str).getElementsByTagName("INPUT");
                           for(var i=0;i<collection.length;i++){
                                 collection[i].checked=true;
                           }
                           if(document.getElementById(str).style.display=="none"){
                                 document.getElementById(str+"_img").click();
                            }
                           collection=document.getElementById(str).getElementsByTagName("DIV");
                           for(var i=0;i<collection.length;i++){
                               if(document.getElementById(collection[i].id).style.display=="none"){
                                   document.getElementById(collection[i].id+"_img").click();
                                }
                           }
                     while(oWorkItem.parentNode!=null){
                        if(oWorkItem.parentNode.tagName=="TABLE"&&oWorkItem.parentNode.id=="treeViewTableRoot")break;
                        if(oWorkItem.parentNode.tagName=="DIV"){
                               root=oWorkItem.parentNode;
                              try{document.getElementById(root.id+"checkbox").checked=true; }catch(exception){}
                          }//end if div
                         oWorkItem=oWorkItem.parentNode;
                    } //end while
           } //end else if

}

  /**
  *  This function is used in Collection tag
  *   @author : liuheyuan
  */
// Drag function start
// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
 function displayBox(id){
     document.getElementById(id).style.display= '';
      }
 function closeBox(id){
     document.getElementById(id).style.display= 'none';
     }
// Drag function end

  /**
  * To check if the user input an number element
  * @author  liuheyuan
  * @date  2003.3.1
  */
 function pageByPageCheckFunction(currentPage,pageSize){
        var str=document.getElementById(pageSize).value;
        for(var i=0;i<str.length;i++){
           if(!(str.charAt(i)>=0&&str.charAt(i)<=9)){
                 alert("error number");
                 return false;
                     }//end  if
              }//end for
         str=document.getElementById(currentPage).value;
         for(var i=0;i<str.length;i++){
             if(!(str.charAt(i)>=0&&str.charAt(i)<=9)){
                 alert("error number");
                 return false;
                 }  //end if
            } //end for
         return true;
       }
 /**
  * To contain the property of each cell in the table
  * @property content the innerHTML of the td
  * @property width the width of the td
  * @property bgColor bgColor of the td
  * @author  liuheyuan
  * @date  2003.3.1
  */
  function Item(){
         this.content = new String();
         this.width= new String();
         this.bgColor= new String();
           }
  /**
  * To dynamically create the Table use the property of content varible
  * @param content the content used to create the table element
  * @param pageSize the size of row in the table
  * @param tdlength the size of column in the row
  * @param tBodyId  the id to insert the role ,this maybe a table, tBody ,or tHeader
  * @author  liuheyuan
  * @date  2003.3.1
  */

  function DOMCreatTable(content,pageSize,tdlength,tBodyId){
     try{
       var tBody=document.getElementById(tBodyId);
       var oRow ,oCell, i,j, item;
       var length=tBody.rows.length;
       for(i=0;i<length;i++){
            tBody.deleteRow();
              }
       for(i=0;i<pageSize;i++){
            oRow = tBody.insertRow();
            if(i%2==0){
                oRow.className="alternateA"; }
                else{
                oRow.className="alternateB"; }
             for(j=0;j<tdlength;j++){
                   item = content[i+","+j];
                   oCell = oRow.insertCell();
                   oCell.innerHTML=item.content;
                   oCell.width=item.width;
                   oCell.bgColor= item.bgColor;
                  }//end for
                }  //end for
        }catch(exception){
              alert("exception: "+exception);    }
          return false;
   }
  /**
  * To set the checked property of the checkbox  by the value of the checked property of the child checkbox
  * @param length the length of the children checkbox
  * @param parentId the id of the parent checkbox
  * @author  liuheyuan
  * @date  2003.3.1
  */
  function checkParent(length,parentId){
         try{
           var i,item;
           var parent = document.getElementById(parentId);
           var checked = true;
           for(i=0;i<length;i++){
              item = document.getElementById(parentId+i);
              if(item.checked==false) checked=false;
               } //end for
              parent.checked=checked;
                }catch(exception){
                    alert("exception" +exception);       }      }
  /**
  * To set the checked property of the checkbox in the collection by the value of the parent checked property
  * @param collectionId the id of the collection
  * @param parentId the id of the parent checkbox
  * @author  liuheyuan
  * @date  2003.3.1
  */
  function checkChild(collectionId,parentId){
           try{
              var i,item;
              var checked = document.getElementById(parentId).checked;
              var collection = document.getElementById(collectionId).getElementsByTagName("INPUT");
              for(i=0;i<collection.length;i++){
                   item = collection[i];
                   if(item.type=="checkbox") item.checked=checked;
                  } //end for
                    }catch(exception){
             alert("exception" +exception);  }
     }
  /**
  * To swap the selectedNode of the select list with the  option before it
  * @param selectId the id of the select element
  * @author  liuheyuan
  * @date  2003.3.4
  */

    function up(selectId){
        var select= document.getElementById(selectId);
         for(var i=0;i<select.options.length;i++){
         if(select.options[i].selected){
            if(i>0){
               select.options[i].swapNode(select.options[i-1]);
              }
           }
         }
    }
  /**
  * To swap the selectedNode of the select list with the  option after it
  * @param selectId the id of the select element
  * @author  liuheyuan
  * @date  2003.3.4
  */
    function down(selectId){
               var select= document.getElementById(selectId);
                for(var i=select.options.length-1;i>=0;i--){
                if(select.options[i].selected){
                    if(i<select.options.length-1){
                       select.options[i].swapNode(select.options[i+1]);
                      }
                  }
          }
   }
  /**
  * To remove the selected option from the select list
  * @param selectId the id of the select element
  * @author  liuheyuan
  * @date  2003.3.4
  */
     function removeSelectedOption(selectId){
      var select= document.getElementById(selectId);
      var bunch = select.options;
        for(i=0;i<bunch.length;)
                {
                        if(bunch[i].selected) bunch[i].removeNode();
                                else
                                        i++;
                        }
   }
  /**
  * To dynamically add the  options to the select element
  * @param selectId the id of the select element
  * @param str the content of the options collection ,the synatax is optiontext1.optionvalue1,optiontext2.optionvalue2
  * @param remove  boolean value to indicate whether to  remove the options from the select element first or not
  * @author  liuheyuan
  * @date  2003.3.5
  */
    function DOMCreateOption(selectId,str,remove){
          var selectItem = document.getElementById(selectId);
          if(remove){
             //to remove the options from the select
              while(selectItem.options.length!=0){
                    selectItem.remove(0);
              }
           }
              var options= str.split(",");
              for(var i=0;i<options.length;i++){
                  var option = new String(options[i]).split(".");
                  selectItem.add(createOption(option[0],option[1]));
             } //end for
    }
  /**
  * Create an option
  * @param strText the text of the option
  * @param strValue the value of the option
  * @author liuhey
  * @date 2003.3.6
  */
  function createOption(strText, strValue)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -