📄 n2corelibs-utilities-54559.js
字号:
//! ################################################################//! This file contains both original and merged/adapted code.//! Except where indicated, all code is//! Copyright (c) 2004-2007 Amazon.com, Inc., and its Affiliates.//! All Rights Reserved.//! Not to be reused without permission//! $DateTime: 2007/07/13 11:44:01 $if ((typeof gbN2Loaded != 'undefined') && !goN2Initializer.isReady()) {window.oTheDoc = document;window.oTheBody = oTheDoc.body;window.oTheHead = document.getElementsByTagName('head').item(0);window.gaTD = {};var goN2Dbg = window.goN2Debug;goN2Initializer.runThisWhen = function (sWhen, fFn, sComment) {if (goN2Dbg) {;;}if ( (typeof fFn != 'function') || fFn == null) return false;sWhen = sWhen.toLowerCase();if ( (sWhen =='inbody' && document.body) || this.aEventsRun[sWhen] ){fFn();} else {this.aHandlers[this.aHandlers.length] = { sWhen: sWhen, fFn: fFn, sComment: sComment };}return true};goN2Initializer.initializeThis = goN2Initializer.runThisWhen;goN2Initializer.run = function (sWhen) {sWhen = (typeof sWhen == 'undefined') ? null : sWhen;sWhen = sWhen.toLowerCase();this.aEventsRun[sWhen] = true;if (goN2Dbg) {;//goN2Debug.info("N2Initializer called with " + (sWhen ? "'"+sWhen+"'" : "null"));}var aH = this.aHandlers;var len = aH.length;for (var i=0;i<len;i++) {var oTmp = aH[i];if ((oTmp.bCalled != true) &&(oTmp.fFn) &&( (sWhen == null) || (oTmp.sWhen && (oTmp.sWhen == sWhen)))) {if (goN2Dbg) {;}if (oTmp.fFn) {oTmp.fFn();}oTmp.bCalled = true;}}}function n2RunEvent(sWhen) {goN2Initializer.run(sWhen);}goN2LibMon.bJSLoaded = false;goN2LibMon.bCSSLoaded = false;goN2LibMon.nREQUESTLOAD = -2;goN2LibMon.nBEGINLOAD = -3;goN2LibMon.requestLoad = function (sLibID, sFeatureID) {var oTmp = this.aLibs[sLibID];if (oTmp) { oTmp.nDuration= this.nREQUESTLOAD; }};goN2LibMon.beginLoad = function (sLibID, sFeatureID) {var oTmp = this.aLibs[sLibID];if (oTmp) {oTmp.sFeature = sFeatureID;oTmp.nBegin = new Date().getTime();oTmp.nDuration= this.nBEGINLOAD;}};goN2LibMon.endLoad = function (sLibID, nStatus) {var oTmp = this.aLibs[sLibID];if (oTmp) {oTmp.nDuration = new Date().getTime() - oTmp.nBegin;oTmp.bLoaded=true;}var bALL=this.allLibsLoaded();goN2Initializer.run(sLibID+'loaded');if (bALL) {gbN2Loaded = this.bJSLoaded = true;goN2Initializer.run('lastlibraryloaded');}};goN2LibMon.allLibsLoaded = function () {var bAllLoaded=true;for (var key in this.aLibs) {if (this.aLibs[key] && this.aLibs[key].nDuration <0) { bAllLoaded=false; }}return bAllLoaded;};goN2LibMon.confirmJSLoaded = goN2LibMon.isJSLoaded = function() { return this.bJSLoaded; };goN2LibMon.confirmCSSLoaded = goN2LibMon.isCSSLoaded = function() { return true; };function n2LibraryIsLoaded (sLibID) {var oTmp = goN2LibMon.aLibs[sLibID];if (oTmp)return oTmp.bLoaded;return false;}goN2Initializer.isReady = function() {return true;}n2RunEvent('n2Loader:safetyNet:loaded')}if (window.goN2LibMon) goN2LibMon.beginLoad('utilities', 'n2CoreLibs');function N2Utilities() {this.className = 'N2Utilities';this.version = '1.0.1';this.revision= '$Revision: #35 $';this.initialized = false;this.bIsCSS;this.bIsW3C;this.bIsIE4;this.bIsNN4;this.bIsIE6CSS;this.bIsIE;this.bIsSafari;this.browser_version;//! * **********************************************************************//! The following section of this file code was mainly adapted from://! "Dynamic HTML:The Definitive Reference"//! 2nd Edition//! by Danny Goodman//! Published by O'Reilly & Associates ISBN 1-56592-494-0//! http://www.oreilly.com//! http://www.amazon.com/exec/obidos/tg/detail/-/0596003161/qid=1049505315//! Copyright 2002 Danny Goodman. All Rights Reserved.//! Some minor changes and additions have been made to suit the//! current application requirements and to enhance functionality.//! ************************************************************************this.initDHTMLAPI = function () {if (document.images) {this.bIsCSS = (document.body && document.body.style) ? true : false;this.bIsW3C = (this.bIsCSS && document.getElementById) ? true : false;this.bIsIE4 = (this.bIsCSS && document.all) ? true : false;this.bIsNN4 = (document.layers) ? true : false;this.bIsIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;this.bIsSafari = (navigator.userAgent.indexOf("AppleWebKit") > -1) ? true : false;}}this.seekLayer = function (oDoc, sName) {var elem;for (var i = 0; i < oDoc.layers.length; i++) {if (oDoc.layers[i].name == sName) {elem = oDoc.layers[i];break;}if (oDoc.layers[i].document.layers.length > 0) {elem = this.seekLayer(document.layers[i].document, sName);}}return elem;}this.getRawObject = function (obj) {;}this._getRawObject = function (obj, bFailureOK) {var elem;;if (!obj) {return null;}if (typeof obj == "string") {if (this.bIsW3C) {elem = document.getElementById(obj);} else if (this.bIsIE4) {elem = document.all(obj);} else if (this.bIsNN4) {elem = this.seekLayer(document, obj);}if ( this.isUndefOrNull(elem) && !bFailureOK ) {;}} else {elem = obj;}return elem;}this.getObject = function (obj) {var elem = this.getElement(obj);if (elem && this.bIsCSS) {elem = elem.style;}return elem;}this.shiftTo = function (obj, x, y) {var oStyle = this.getElementStyle(obj);if (oStyle) {if (this.bIsCSS) {var units = (typeof oStyle.left == "string") ? "px" : 0;oStyle.left = x + units;oStyle.top = y + units;} else if (this.bIsNN4) {oStyle.moveTo(x,y)}}}this.shiftBy = function (obj, deltaX, deltaY) {var oStyle = this.getElementStyle(obj);if (oStyle) {if (this.bIsCSS) {var units = (typeof oStyle.left == "string") ? "px" : 0;oStyle.left = this.getElementLeft(obj) + deltaX + units;oStyle.top = this.getElementTop(obj) + deltaY + units;} else if (this.bIsNN4) {oStyle.moveBy(deltaX, deltaY);}}}this.setZIndex = function (obj, zOrder) {var oStyle = this.getElementStyle(obj);if (oStyle) { oStyle.zIndex = zOrder; }}this.setBGColor = function (obj, color) {var oStyle = this.getElementStyle(obj);if (oStyle) {if (this.bIsNN4) {oStyle.bgColor = color;} else if (this.bIsCSS) {oStyle.backgroundColor = color;}}}this.show = function (obj) {var oStyle = this.getElementStyle(obj);if (oStyle) { oStyle.visibility = "visible"; }}this.hide = function (obj) {var oStyle = this.getElementStyle(obj);if (oStyle) { oStyle.visibility = "hidden"; }}this.MOZALPHAMAX = 255./256.;this.getAlphaLevel = function (elem) {var oElem = this.getElement(elem);var ret;if (oElem) {var style = oElem.style;if (oElem.filters && oElem.filters.alpha) {ret = oElem.filters.alpha.opacity;} else if (style) {if (this.isDefined(style.MozOpacity)) {var strOpacity = style.MozOpacity;if (strOpacity.length > 0) {ret = parseFloat(style.MozOpacity);if (ret >= this.MOZALPHAMAX && this.isDefined(style.azdMozOpacity)) {var saved = parseFloat(style.azdMozOpacity);if (saved >= this.MOZALPHAMAX) {ret = saved;}}ret = ret * 100;}} else if (this.isDefined(style.opacity)) {ret = (style.opacity.length==0 ? 1 : parseFloat(style.opacity)) * 100;} else if (this.isDefined(style.KhtmlOpacity)) {ret = (style.KhtmlOpacity.length==0 ? 1 : parseFloat(style.KhtmlOpacity)) * 100;}}}if (this.isUndefined(ret)) {ret = 100; // presume that no set opacity means opaque;}return ret;}this.setAlphaLevel = function (elem, level) {level = (level <= 0 ? 0 : (level >= 100 ? 100 : level));var oElem = this.getElement(elem);;if (oElem) {var style = oElem.styleif (oElem.filters) {var filters = oElem.filters;if (!filters.alpha) {;this.addClass(oElem, "n2Fadable");filters = oElem.filters; // object changed by adding a filter;}if (filters.alpha) {filters.alpha.opacity = level;} else {;}} else if (style && this.isDefined(style.MozOpacity)) {var reqLevel = level * 0.01;var mozLevel = (reqLevel > this.MOZALPHAMAX ? this.MOZALPHAMAX : reqLevel);if (mozLevel != reqLevel) {;}style.MozOpacity = mozLevel;style.azdMozOpacity = "" + reqLevel; // store as string (just as MozOpacity is) to get same rounding} else if (style && this.isDefined(style.opacity)) {var reqLevel = "" + (level * 0.01);style.opacity = reqLevel;} else if (style && this.isDefined(style.KhtmlOpacity)) {var reqLevel = "" + (level * 0.01);ret = (style.KhtmlOpacity.length==0 ? 1 : parseFloat(style.KhtmlOpacity)) * 100;} else {;}}}this.getElementLeft = function (obj) {var oElem = this.getElement(obj);var result = 0;if (oElem) {var cssDecl, defaultView = document.defaultView;if ( defaultView &&(typeof defaultView.getComputedStyle == 'function') &&(cssDecl=defaultView.getComputedStyle(oElem, null))) {result = cssDecl.getPropertyValue("left");} else if (oElem.currentStyle) {result = oElem.currentStyle.left;} else if (oElem.style) {result = oElem.style.left;} else if (this.bIsNN4) {result = oElem.left;}result = parseInt(result);if (isNaN(result)) {result = this.getPageElementLeft(oElem);}}return result;}this.getElementTop = function (obj) {var oElem = this.getElement(obj);var result = 0;if (oElem) {var cssDecl, defaultView = document.defaultView;if (defaultView &&(typeof defaultView.getComputedStyle == 'function') &&(cssDecl=defaultView.getComputedStyle(oElem, null))) {result = cssDecl.getPropertyValue("top");} else if (oElem.currentStyle) {result = oElem.currentStyle.top;} else if (oElem.style) {result = oElem.style.top;} else if (this.bIsNN4) {result = oElem.top;}}result = parseInt(result);if (isNaN(result)) {result = this.getPageElementTop(oElem);}return result;}this.getElementWidth = function (obj) {var oElem = this.getElement(obj);var result = 0;if (oElem) {var width = oElem.width;if (width && this.isMozilla5() && (typeof width != 'string' || width.match(/^[0-9]+$/) !== null)) {result = width;} else if (oElem.offsetWidth) {result = oElem.offsetWidth;} else if (oElem.clip && oElem.clip.width) {result = oElem.clip.width;} else if (oElem.style && oElem.style.pixelWidth) {result = oElem.style.pixelWidth;}}return parseInt(result);}this.getElementHeight = function (obj) {var oElem = this.getElement(obj);var result = 0;if (oElem) {var height = oElem.height;if (height && this.isMozilla5() && (typeof height != 'string' || height.match(/^[0-9]+$/) !== null)) {result = height;} else if (oElem.offsetHeight) {result = oElem.offsetHeight;} else if (oElem.clip && oElem.clip.height) {result = oElem.clip.height;} else if (oElem.style && oElem.style.pixelHeight) {result = oElem.style.pixelHeight;}}return parseInt(result);}this.getInsideWindowWidth = function () {if (window.innerWidth) {return window.innerWidth;} else if (document.body && document.body.clientWidth) {return document.body.clientWidth;};return 0;}this.getInsideWindowHeight = function () {if (window.innerHeight) {return window.innerHeight;} else if (document.body && document.body.clientHeight) {return document.body.clientHeight;};return 0;}//! ************************************************************//! END CODE derived from "Dynamic HTML:The Definitive Reference"//! 2nd Edition//! by Danny Goodman//! Published by O'Reilly & Associates ISBN 1-56592-494-0//! http://www.oreilly.com//! Copyright 2002 Danny Goodman. All Rights Reserved.//! ################################################################//! All the code that follows is Copyright 2003 Amazon.com.//! All Rights Reserved.//! ************************************************************//! Copyright (c) Amazon.com 2003, 2004. All Rights Reserved.//! Not to be reused without permission//! ################################################################this.initialize = function () {this.initDHTMLAPI();var agid = navigator.userAgent.toLowerCase();this.bIsIE = (agid.indexOf("msie") != -1);this.bIsGecko = (agid.indexOf("gecko") != -1);this.bIsFirefox = (agid.indexOf("firefox") != -1);this.browser_version = parseInt(navigator.appVersion);this.getRawObject = this._getRawObject; // rest to use the correct fn.this.getElement = this._getRawObject;this.getElementStyle = this.getObject;this.getObjectWidth = this.getElementWidth;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -