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

📄 1019856700-common.js

📁 springioc部分最新的分析
💻 JS
📖 第 1 页 / 共 4 页
字号:
  return "";}//------------------------------------------------------------------------// Time//------------------------------------------------------------------------function Now() {  return (new Date()).getTime();}//------------------------------------------------------------------------// Dynamic HTML/DOM utilities//------------------------------------------------------------------------// Gets a element by its id, may return nullfunction MaybeGetElement(win, id) {  return win.document.getElementById(id);}// Same as MaybeGetElement except that it throws an exception if it's nullfunction GetElement(win, id) {  var el = win.document.getElementById(id);  if (!el) {    DumpError("Element " + id + " not found.");  }  return el;}// Gets elements by its id/name// IE treats getElementsByName as searching over ids, while Moz use names.// so tags must have both id and name as the same stringfunction GetElements(win, id) {  return win.document.getElementsByName(id);}// Gets the parent of a html element.function GetParentNode(n) {  try {    return n.parentNode;  } catch (e) {    // n.parentNode may throw a permission-denied exception on mozilla    // (e.g. on text element), ignore this exception.    return n;  }}function IsDescendant(parent, child) {  do {    if (parent === child) return true;    child = GetParentNode(child);  } while (child && child !== document.body);  return false;}// Get attribute value of a DOM nodefunction GetAttribute(node, attribute) {  if (!node.getAttribute) {    return null;  }  var attr = node.getAttribute(attribute);  if (is_ie && attribute == "style") {    return attr.value;  } else {    return attr;  }}// Sets inner html of a html elementfunction SetInnerHTML(win, id, html) {  try {    GetElement(win, id).innerHTML = html;  } catch (ex) {    DumpException(ex);  }}// Gets inner-html of a html elementfunction GetInnerHTML(win, id) {  try {    return GetElement(win, id).innerHTML;  } catch (ex) {    DumpException(ex);    return "";  }}// Clears inner html of a html elementfunction ClearInnerHTML(win, id) {  try {    GetElement(win, id).innerHTML = "";  } catch (ex) {    DumpException(ex);  }}// Sets a CSS style of an elementfunction SetCssStyle(win, id, name, value) {  try {    var elem = GetElement(win, id);    elem.style[name] = value;  } catch (ex) {    DumpException(ex);  }}// Get CSS property from a style attribute stringfunction GetStyleProperty(style, name) {  var i = style.indexOf(name);  if (i != -1) {    var j = style.indexOf(";", i);    if (j == -1) {      j = style.length;    }    // the +1 below is for the colon following the attribute name    return CollapseWhitespace(style.substring(i + name.length + 1, j));  }  return null;}// Show/hide an element.function ShowElement(el, show) {  el.style.display = show ? "" : "none";}// Show/hide a block element.// ShowElement() doesn't work if object has an initial class with display:nonefunction ShowBlockElement(el, show) {  el.style.display = show ? "block" : "none";}// Show/hide an inline element.// ShowElement() doesn't work when an element starts off display:none.function ShowInlineElement(el, show) {  el.style.display = show ? "inline" : "none";}// Set the text of a button. This is to get around a bug in mozilla,// where we can't set the text of a button by setting innerHTML.function SetButtonText(button, text) {  button.childNodes[0].nodeValue = text;}// Append a new HTML element to a HTML node.function AppendNewElement(win, parent, tag) {  var e = win.document.createElement(tag);  parent.appendChild(e);  return e;}// Finds the child with the given ID, or null if there is node.// This does not search the children's children.function FindChildWithID(parent, id) {  var el;  for (el = parent.firstChild; el && el.id != id; el = el.nextSibling) {    // skip  }  return el;}// Adds a disabled option to the given menufunction AddMenuDisabledOption(win, menu, html) {  var op = AppendNewElement(win, menu, 'OPTION');  op.disabled = true;  op.innerHTML = html;  return op;}// Adds a option to the given menufunction AddMenuOption(win, menu, value, html) {  var op = AppendNewElement(win, menu, 'OPTION');  op.value = value;  op.innerHTML = html;  return op;}// Create a new DIV (append it to the end of the document)function CreateDIV(win, id) {  var div = MaybeGetElement(win, id);  if (!div) {    div = AppendNewElement(win, win.document.body, "div");    div.id = id;  }  return div;}// Create a new IFRAME (append it to the end of the document)function CreateIFRAME(win, id, url) {  var iframe = MaybeGetElement(win, id);  if (!iframe) {    // We cannot create an IFRAME directly (IE doesn't allow it), so we    // create a DIV and then insert an IFRAME.    // We also give the IFRAME a name (same as id)    var div = AppendNewElement(win, win.document.body, "div");    div.innerHTML = "<iframe id=" + id + " name=" + id +             " src=" + url + "></iframe>";    iframe = GetElement(win, id);  }  return iframe;}// Create a new TR containing the given td'sfunction Tr(win, tds) {  var tr = win.document.createElement("TR");  for (var i = 0; i < tds.length; i++) {    tr.appendChild(tds[i]);  }  return tr;}// Create a new TD, with an optional colspanfunction Td(win, opt_colspan) {  var td = win.document.createElement("TD");  if (opt_colspan) {    td.colSpan = opt_colspan;  }  return td;}// Check if an element has a given classfunction HasClass(el, cl) {  if (el == null || el.className == null) return false;  var classes = el.className.split(" ");  for (var i = 0; i < classes.length; i++) {    if (classes[i] == cl) {      return true;    }  }  return false;}// Add a class to elementfunction AddClass(el, cl) {  if (HasClass(el, cl)) return;  el.className += " " + cl;}// Remove a class from an elementfunction RemoveClass(el, cl) {  if (el.className == null) return;  var classes = el.className.split(" ");  var result = [];  var changed = false;  for (var i = 0; i < classes.length; i++) {    if (classes[i] != cl) {      if (classes[i]) { result.push(classes[i]); }    } else {      changed = true;    }  }  if (changed) { el.className = result.join(" "); }}// Performs an in-order traversal of the tree rooted at the given node// (excluding the root node) and returns an array of nodes that match the// given selector. The selector must implement the method://// boolean select(node);//// This method is a generalization of the DOM method "getElementsByTagName"//function GetElementsBySelector(root, selector) {  var nodes = [];  for (var child = root.firstChild; child; child = child.nextSibling) {    AddElementBySelector_(child, selector, nodes);  }  return nodes;}// Recursive helper for GetElemnetsBySelector()function AddElementBySelector_(root, selector, nodes) {  // First test the parent  if (selector.select(root)) {    nodes.push(root);  }  // Then recurse through the children  for (var child = root.firstChild; child; child = child.nextSibling) {    AddElementBySelector_(child, selector, nodes);  }}//------------------------------------------------------------------------// Window/screen utilities// TODO: these should be renamed (e.g. GetWindowWidth to GetWindowInnerWidth// and moved to geom.js)//------------------------------------------------------------------------// Get page offset of an elementfunction GetPageOffsetLeft(el) {  var x = el.offsetLeft;  if (el.offsetParent != null)    x += GetPageOffsetLeft(el.offsetParent);  return x;}// Get page offset of an elementfunction GetPageOffsetTop(el) {  var y = el.offsetTop;  if (el.offsetParent != null)    y += GetPageOffsetTop(el.offsetParent);  return y;}// Get page offset of an elementfunction GetPageOffset(el) {  var x = el.offsetLeft;  var y = el.offsetTop;  if (el.offsetParent != null) {    var pos = GetPageOffset(el.offsetParent);    x += pos.x;    y += pos.y;  }  return {x: x, y: y};}function GetPageOffsetRight(el) {  return GetPageOffsetLeft(el) + el.offsetWidth;}function GetPageOffsetBottom(el) {  return GetPageOffsetTop(el) + el.offsetHeight;}// Get the y position scroll offset.function GetScrollTop(win) {  // all except Explorer  if ("pageYOffset" in win) {    return win.pageYOffset;  }  // Explorer 6 Strict Mode  else if ("documentElement" in win.document &&           "scrollTop" in win.document.documentElement) {    return win.document.documentElement.scrollTop;  }  // other Explorers  else if ("scrollTop" in win.document.body) {    return win.document.body.scrollTop;  }  return 0;}// Get the x position scroll offset.function GetScrollLeft(win) {  // all except Explorer  if ("pageXOffset" in win) {    return win.pageXOffset;  }  // Explorer 6 Strict Mode  else if ("documentElement" in win.document &&           "scrollLeft" in win.document.documentElement) {    return win.document.documentElement.scrollLeft;  }  // other Explorers  else if ("scrollLeft" in win.document.body) {    return win.document.body.scrollLeft;  }  return 0;}/** * Checks if window scrollbar has reached its maximum offset * * @param win a window object * @param opt_isHoriz true if horizontal bar, false if vertical */function IsScrollAtEnd(win, opt_isHoriz) {  var total =    (opt_isHoriz) ? document.body.offsetWidth : document.body.offsetHeight;  var inner =    (opt_isHoriz) ? GetWindowWidth(win) : GetWindowHeight(win);  var offset =    (opt_isHoriz) ? GetScrollLeft(win) : GetScrollTop(win);  return (inner + offset >= total || total < inner);}// Scroll window to pos// position: 0 = top, 0.5 = middle, 1 = bottomfunction ScrollTo(win, el, position) {  var y = GetPageOffsetTop(el);  y -= GetWindowHeight(win) * position;  win.scrollTo(0, y);}// Scroll so that as far as possible the entire element is in view.var ALIGN_BOTTOM = 'b';var ALIGN_MIDDLE = 'm';var ALIGN_TOP = 't';function ScrollIntoView(win, el, alignment) {  var el_top = GetPageOffsetTop(el);  var el_bottom = el_top + el.offsetHeight;  var win_top = GetScrollTop(win);  var win_height = GetWindowHeight(win);  var win_bottom = win_top + win_height;  // Out of view?  if (el_top < win_top ||      el_bottom > win_bottom) {    var scrollto_y;    if (alignment == ALIGN_BOTTOM) {      scrollto_y = el_bottom - win_height + 5;    } else if (alignment == ALIGN_MIDDLE) {      scrollto_y = (el_top + el_bottom) / 2 - win_height/2;    } else {      scrollto_y = el_top - 5;        // ALIGN_TOP

⌨️ 快捷键说明

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