📄 1019856700-common.js
字号:
} Debug("Scrolling to " + scrollto_y); win.scrollTo(0, scrollto_y); }}function IsElementVisible(win, id) { var el = MaybeGetElement(win, id); if (el == null) { return false; } var el_top = GetPageOffsetTop(el); var el_bottom = el_top + el.offsetHeight; var win_top = GetScrollTop(win); var win_bottom = win_top + GetWindowHeight(win); if (el_top >= win_top && el_bottom <= win_bottom) { return true; } return false;}function GetWindowWidth(win) { // all except Explorer if ("innerWidth" in win) { return win.innerWidth; } // Explorer 6 Strict Mode else if ("documentElement" in win.document && "clientWidth" in win.document.documentElement) { return win.document.documentElement.clientWidth; } // other Explorers else if ("clientWidth" in win.document.body) { return win.document.body.clientWidth; } return 0;}function GetWindowHeight(win) { // all except Explorer if ("innerHeight" in win) { return win.innerHeight; } // Explorer 6 Strict Mode else if ("documentElement" in win.document && "clientHeight" in win.document.documentElement) { return win.document.documentElement.clientHeight; } // other Explorers else if ("clientHeight" in win.document.body) { return win.document.body.clientHeight; } return 0;}function GetAvailScreenWidth(win) { return win.screen.availWidth;}function GetAvailScreenHeight(win) { return win.screen.availHeight;}// Returns a "nice" window height.// Use the screen height. (Or should we use the height of the current window?)function GetNiceWindowHeight(win) { return Math.floor(0.8 * GetAvailScreenHeight(win));}// Used for horizontally centering a new window of the given width in the// available screen. Set the new window's distance from the left of the screen// equal to this function's return value.// Params: width: the width of the new window// Returns: the distance from the left edge of the screen for the new window to// be horizontally centeredfunction GetCenteringLeft(win, width) { return (win.screen.availWidth - width) >> 1;}// Used for vertically centering a new window of the given height in the// available screen. Set the new window's distance from the top of the screen// equal to this function's return value.// Params: height: the height of the new window// Returns: the distance from the top edge of the screen for the new window to// be vertically aligned.function GetCenteringTop(win, height) { return (win.screen.availHeight - height) >> 1;}/* * Opens a child popup window that has no browser toolbar/decorations. * (Copied from caribou's common.js library with small modifications.) * * @param url the URL for the new window (Note: this will be unique-ified) * @param opt_name the name of the new window * @param opt_width the width of the new window * @param opt_height the height of the new window * @param opt_center if true, the new window is centered in the available screen * @param opt_hide_scrollbars if true, the window hides the scrollbars * @param opt_noresize if true, makes window unresizable * @param opt_blocked_msg message warning that the popup has been blocked * @return a reference to the new child window */function Popup(url, opt_name, opt_width, opt_height, opt_center, opt_hide_scrollbars, opt_noresize, opt_blocked_msg) { if (!opt_height) { opt_height = Math.floor(GetWindowHeight(window.top) * 0.8); } if (!opt_width) { opt_width = Math.min(GetAvailScreenWidth(window), opt_height); } var features = "resizable=" + (opt_noresize ? "no" : "yes") + "," + "scrollbars=" + (opt_hide_scrollbars ? "no" : "yes") + "," + "width=" + opt_width + ",height=" + opt_height; if (opt_center) { features += ",left=" + GetCenteringLeft(window, opt_width) + "," + "top=" + GetCenteringTop(window, opt_height); } return OpenWindow(window, url, opt_name, features, opt_blocked_msg);}/* * Opens a new window. Returns the new window handle. Tries to open the new * window using top.open() first. If that doesn't work, then tries win.open(). * If that still doesn't work, prints an alert. * (Copied from caribou's common.js library with small modifications.) * * @param win the parent window from which to open the new child window * @param url the URL for the new window (Note: this will be unique-ified) * @param opt_name the name of the new window * @param opt_features the properties of the new window * @param opt_blocked_msg message warning that the popup has been blocked * @return a reference to the new child window */function OpenWindow(win, url, opt_name, opt_features, opt_blocked_msg) { var newwin = OpenWindowHelper(top, url, opt_name, opt_features); if (!newwin || newwin.closed || !newwin.focus) { newwin = OpenWindowHelper(win, url, opt_name, opt_features); } if (!newwin || newwin.closed || !newwin.focus) { if (opt_blocked_msg) alert(opt_blocked_msg); } else { // Make sure that the window has the focus newwin.focus(); } return newwin;}/* * Helper for OpenWindow(). * (Copied from caribou's common.js library with small modifications.) */function OpenWindowHelper(win, url, name, features) { var newwin; if (features) { newwin = win.open(url, name, features); } else if (name) { newwin = win.open(url, name); } else { newwin = win.open(url); } return newwin;}//------------------------------------------------------------------------// DOM walking utilities//------------------------------------------------------------------------function MaybeEscape(str, escape) { return escape ? HtmlEscape(str) : str;}//------------------------------------------------------------------------// Window data//------------------------------------------------------------------------// Gets an array, which can store data for the window. This data// is deleted when the window is unloaded.var windata = [];function GetWindowData(win) { var data = windata[win.name]; if (!data) { windata[win.name] = data = []; } return data;}// Clear js data for a window.function ClearWindowData(win_name) { if (windata[win_name]) { windata[win_name] = null; }}//------------------------------------------------------------------------// String utilities//------------------------------------------------------------------------// Do html escapingvar amp_re_ = /&/g;var lt_re_ = /</g;var gt_re_ = />/g;// Convert text to HTML format. For efficiency, we just convert '&', '<', '>'// characters.// Note: Javascript >= 1.3 supports lambda expression in the replacement// argument. But it's slower on IE.// Note: we can also implement HtmlEscape by setting the value// of a textnode and then reading the 'innerHTML' value, but that// that turns out to be slower.// Params: str: String to be escaped.// Returns: The escaped string.function HtmlEscape(str) { if (!str) return ""; return str.replace(amp_re_, "&").replace(lt_re_, "<"). replace(gt_re_, ">").replace(quote_re_, """);}/** converts html entities to plain text. It covers the most common named * entities and numeric entities. * It does not cover all named entities -- it covers &{lt,gt,amp,quot,nbsp}; but * does not handle some of the more obscure ones like &{ndash,eacute};. */function HtmlUnescape(str) { if (!str) return ""; return str. replace(/&#(\d+);/g, function (_, n) { return String.fromCharCode(parseInt(n, 10)); }). replace(/&#x([a-f0-9]+);/gi, function (_, n) { return String.fromCharCode(parseInt(n, 16)); }). replace(/&(\w+);/g, function (_, entity) { entity = entity.toLowerCase(); return entity in HtmlUnescape.unesc ? HtmlUnescape.unesc[entity] : '?'; });}HtmlUnescape.unesc = { lt: '<', gt: '>', quot: '"', nbsp: ' ', amp: '&' };// Replace multiple spaces with to retain whitespace formatting// in addition to escaping '&', '<', and '>'.var dbsp_re_ = / /g;var ret_re_ = /\r/g;var nl_re_ = /\n/g;function HtmlWhitespaceEscape(str) { str = HtmlEscape(str); str = str.replace(dbsp_re_, " "); str = str.replace(ret_re_, ""); str = str.replace(nl_re_, "<br>"); return str;}// Escape double quote '"' characters in addition to '&', '<', '>' so that a// string can be included in an HTML tag attribute value within double quotes.// Params: str: String to be escaped.// Returns: The escaped string.var quote_re_ = /\"/g;function QuoteEscape(str) { return HtmlEscape(str).replace(quote_re_, """);}var JS_SPECIAL_RE_ = /[\'\\\r\n\b\"<>&]/g;function JSEscOne_(s) { if (!JSEscOne_.js_escs_) { var escapes = {}; escapes['\\'] = '\\\\'; escapes['\''] = '\\047'; escapes['\n'] = '\\n'; escapes['\r'] = '\\r'; escapes['\b'] = '\\b'; escapes['\"'] = '\\042'; escapes['<'] = '\\074'; escapes['>'] = '\\076'; escapes['&'] = '\\046'; JSEscOne_.js_escs_ = escapes; } return JSEscOne_.js_escs_[s];}/** convert a string to a javascript string literal. This function has the * property that the return value is also already html escaped, so the output * can be embedded in an html handler attribute. */function ToJSString(s) { return "'" + s.toString().replace(JS_SPECIAL_RE_, JSEscOne_) + "'";}// converts multiple ws chars to a single space, and strips// leading and trailing wsvar spc_re_ = /\s+/g;var beg_spc_re_ = /^ /;var end_spc_re_ = / $/;function CollapseWhitespace(str) { if (!str) return ""; return str.replace(spc_re_, " ").replace(beg_spc_re_, ""). replace(end_spc_re_, "");}var newline_re_ = /\r?\n/g;var spctab_re_ = /[ \t]+/g;var nbsp_re_ = /\xa0/g;function StripNewlines(str) { if (!str) return ""; return str.replace(newline_re_, " ");}function CanonicalizeNewlines(str) { if (!str) return ""; return str.replace(newline_re_, '\n');}function HtmlifyNewlines(str) { if (!str) return ""; return str.replace(newline_re_, "<br>");}function NormalizeSpaces(str) { if (!str) return ""; return str.replace(spctab_re_, " ").replace(nbsp_re_, " ");}// URL encodes the string.function UrlEncode(str) { return encodeURIComponent(str);}function Trim(str) { if (!str) return ""; return str.replace(/^\s+/, "").replace(/\s+$/, "");}function EndsWith(str, suffix) { if (!str) return !suffix; return (str.lastIndexOf(suffix) == (str.length - suffix.length));}// Check if a string is emptyfunction IsEmpty(str) { return CollapseWhitespace(str) == "";}// Check if a character is a letterfunction IsLetterOrDigit(ch) { return ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") || (ch >= '0' && ch <= '9'));}// Check if a character is a space characterfunction IsSpace(ch) { return (" \t\r\n".indexOf(ch) >= 0);}// Converts any instances of "\r" or "\r\n" style EOLs into "\n" (Line Feed),// and also trim the extra newlines and whitespaces at the end.var eol_re_ = /\r\n?/g;var trailingspc_re_ = /[\n\t ]+$/;function NormalizeText(str) { return str.replace(eol_re_, "\n").replace(trailingspc_re_, "");}// Inserts <wbr>s (word break tag) after every n non-space chars and/or// after or before certain special chars. The input string should be plain// text that has not yet been HTML-escaped.// Params:// str: The string to insert <wbr>s into.// n: The maximum number of consecutive non-space characters to allow before// adding a <wbr>. To turn off this rule (i.e. if you only want to add// breaks based on special characters), pass in the value -1.// chars_to_break_after: The list of special characters (concatenated into a// string) after which a <wbr> should be added, if there is no natural// break at that point. To turn off this rule, pass in the empty string.// chars_to_break_before: The list of special characters (concatenated into a// string) before which a <wbr> should be added, if there is no natural// break at that point. To turn off this rule, pass in the empty string.// Returns: The string str htmlescaped, and with <wbr>s inserted according to// the rules specified by the other arguments.function HtmlEscapeInsertWbrs(str, n, chars_to_break_after, chars_to_break_before) { AssertNumArgs(4); var out = ''; var strpos = 0; var spc = 0; for (var i = 1; i < str.length; ++i) { var prev_char = str.charAt(i - 1); var next_char = str.charAt(i); if (IsSpace(next_char)) { spc = i; } else if (i - spc == n || chars_to_break_after.indexOf(prev_char) != -1 || chars_to_break_before.indexOf(next_char) != -1) { out += HtmlEscape(str.substring(strpos, i)) + '<wbr>'; strpos = i; spc = i; } } out += HtmlEscape(str.substr(strpos)); return out;}// Converts a string to its canonicalized label form.var illegal_chars_re_ = /[ \/(){}&|\\\"\000]/g;function CanonicalizeLabel(str, lowercase) { var uppercase = str.replace(illegal_chars_re_, '-');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -