📄 gdata_condensed.js
字号:
/* Copyright (c) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.*//*** @fileoverview* This file contains some common helper functions*/// Based on <http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/// core.html#ID-1950641247>var DOM_ELEMENT_NODE = 1;var DOM_ATTRIBUTE_NODE = 2;var DOM_TEXT_NODE = 3;var DOM_CDATA_SECTION_NODE = 4;var DOM_ENTITY_REFERENCE_NODE = 5;var DOM_ENTITY_NODE = 6;var DOM_PROCESSING_INSTRUCTION_NODE = 7;var DOM_COMMENT_NODE = 8;var DOM_DOCUMENT_NODE = 9;var DOM_DOCUMENT_TYPE_NODE = 10;var DOM_DOCUMENT_FRAGMENT_NODE = 11;var DOM_NOTATION_NODE = 12; // // regular expression for xsd date-time //var UTIL_PARSE_XMLDATE = /(\d{4})-(\d{2})-(\d{2})/;var UTIL_PARSE_XMLDATETIME = /(\d{4})-?(\d{2})-?(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))(Z)?(([+-])(\d{2}):(\d{2}))?/;function UTIL_inherits(subClass, superClass) { subClass.prototype = new superClass(); subClass.prototype.Base = superClass.prototype; subClass.prototype.constructor = superClass.constructor;}/*** helper to detect if a variable is persistable* @param toTest the value to test* @return true if peristable*/function UTIL_isPersistable(toTest) { if (typeof(toTest) == 'string') { if (toTest !== null && toTest.length > 0 ) { return true; } } return false; }/*** helper to convert a date to RFC3339 string presentation* @param date {Date} the date to convert* @return {string} date formatted according to RFC3339*/function UTIL_dateToRFC3339(dateToConvert) { var strReturn = null; strReturn = dateToConvert.getUTCFullYear() + "-" + UTIL_pad((dateToConvert.getUTCMonth()+1).toString(), 2, "0") + "-" + UTIL_pad((dateToConvert.getUTCDate()).toString(), 2, "0"); if (dateToConvert.getTime() > 0) { strReturn += "T" + UTIL_pad(dateToConvert.getUTCHours().toString(), 2, "0") + ":" + UTIL_pad(dateToConvert.getUTCMinutes().toString(), 2, "0") + ":" + UTIL_pad(dateToConvert.getUTCSeconds().toString(), 2, "0"); // convert to hours var timediff = dateToConvert.getTimezoneOffset(); timediff /= 60; strReturn += timediff > 0 ? "+" : "-"; strReturn += UTIL_pad(Math.abs(timediff).toFixed(0), 2, "0") + ":00"; } return strReturn;}/*** helper to convert a string in RFC3339 presentation to a date* @param dateString the string date value to convert* @return the date*/ function UTIL_parseXmlDateTime(dateString) { var d = null; var dateParts = dateString.match(UTIL_PARSE_XMLDATETIME); if (dateParts == null) { // // if dateTime didn't parse, try date // return UTIL_parseXmlDate(dateString); } else { d = new Date(); var year = parseInt(dateParts[1],10); var month = parseInt(dateParts[2],10); var day = parseInt(dateParts[3],10); var hour = parseInt(dateParts[4],10); var min = parseInt(dateParts[5],10); var sec = parseInt(dateParts[6],10); if ((dateParts[8] || dateParts[9]) && !(hour==0 && min==0 && sec==0)) { // utc mode d.setUTCFullYear(year); d.setUTCMonth(month-1); d.setUTCDate(day); d.setUTCHours(hour); d.setUTCMinutes(min); d.setUTCSeconds(sec); d.setUTCMilliseconds(0); if (dateParts[8] === 'Z') { // so the time is in UTC LOG_TRACE(dateParts[8], "UTIL_parseXmlDateTime", dateString); } else { // should be an offset now var timeOffset = 0; if (dateParts[10]) { timeOffset = Number(dateParts[11]) * 60; timeOffset += Number(dateParts[12]); timeOffset *= ((dateParts[10] === '-') ? 1 : -1); } timeOffset *= 60 * 1000; d = new Date(Number(d) + timeOffset); } // // BUGBUG - apply +/- bias from part 8 // } else { d.setFullYear(year); d.setMonth(month-1); d.setDate(day); d.setHours(hour); d.setMinutes(min); d.setSeconds(sec); d.setMilliseconds(0); } } LOG_TRACE(dateString + "----" + d, "UTIL_parseXmlDateTime", dateString); return d; } /*** helper to convert a string in RFC3339 presentation to a date* @param dateString the string date value to convert, no timezone* @return the date*/ function UTIL_parseXmlDate(dateString) { var d; var dateParts = dateString.match(UTIL_PARSE_XMLDATE); if (dateParts != null) { d = new Date(); d.setHours(0); d.setMinutes(0); d.setSeconds(0); d.setMilliseconds(0); var year = parseInt(dateParts[1],10); var month = parseInt(dateParts[2],10); var day = parseInt(dateParts[3],10); d.setFullYear(year); d.setMonth(month-1); d.setDate(day); } return d; }/*** helper to pad a string with a given char* @param str the string to pad* @param length the length to pad to* @param chr the char to use for padding* @return the padded string*/function UTIL_pad(str, length, chr) { while (length > str.length) { str = chr + str; } return str;}/*** helper to encode a string that is passed in to URL encoding* this is used for requests to a webserver, so do not use * encodeUriComponent here* @param sStr the stirng to encode* @return the encoded string*/function UTIL_urlEncodeString(sStr) { return escape(sStr). replace(/\+/g, '%2B'). replace(/\"/g,'%22'). replace(/\'/g, '%27'). replace(/\//g,'%2F');}/*** helper to attach an event to a target object* @param target the object to attach the event to* @param type the event type* @param callback the event callback*/function UTIL_domEventHandler(target, type, callback) { if (target.addEventListener) { target.addEventListener(type, callback, false); } else { target.attachEvent("on" + type, callback); }}/*** helper to create a DIV element, currently used for debugging* @param opt_text the text in the div* @param opt_className the css class to use*/function UTIL_domCreateDiv(opt_text, opt_className) { var el = document.createElement("div"); if (opt_text) { UTIL_domAppendChild(el, document.createTextNode(opt_text)); } if (opt_className) { el.className = opt_className; } return el;}/*** helper to append a child in the dom* @param parent the node to append to* @param child the node to append*/function UTIL_domAppendChild(parent, child) { try { parent.appendChild(child); } catch (e) { LOG_ERROR("UTIL_domAppendChild: " + e); } return child;}/*** Applies the given function to each element of the array, preserving* this, and passing the index.*/function UTIL_mapExec(array, func) { for (var i = 0; i < array.length; ++i) { func.call(this, array[i], i); }}/*** Returns an array that contains the return value of the given* function applied to every element of the input array.*/function UTIL_mapExpr(array, func) { var ret = []; for (var i = 0; i < array.length; ++i) { ret.push(func(array[i])); } return ret;}/*** Reverses the given array in place.*/function UTIL_reverseInplace(array) { for (var i = 0; i < array.length / 2; ++i) { var h = array[i]; var ii = array.length - i - 1; array[i] = array[ii]; array[ii] = h; }}/*** Shallow-copies an array.*/function UTIL_copyArray(dst, src) { for (var i = 0; i < src.length; ++i) { dst.push(src[i]); }}/*** Returns the text value of a node; for nodes without children this* is the nodeValue, for nodes with children this is the concatenation* of the value of all children.*/function UTIL_xmlValue(node) { if (!node) { return ''; } var ret = ''; if (node.nodeType == DOM_TEXT_NODE || node.nodeType == DOM_CDATA_SECTION_NODE || node.nodeType == DOM_ATTRIBUTE_NODE) { ret += node.nodeValue; } else if (node.nodeType == DOM_ELEMENT_NODE || node.nodeType == DOM_DOCUMENT_NODE || node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) { for (var i = 0; i < node.childNodes.length; ++i) { ret += arguments.callee(node.childNodes[i]); } } return ret;}/*** Returns the representation of a node as XML text.*/function UTIL_xmlText(node, opt_cdata) { var buf = []; xmlTextR(node, buf, opt_cdata); return buf.join('');}/*** worker function for UTIL_xmlText()*/function xmlTextR(node, buf, cdata) { if (node.nodeType == DOM_TEXT_NODE) { buf.push(xmlEscapeText(node.nodeValue)); } else if (node.nodeType == DOM_CDATA_SECTION_NODE) { if (cdata) { buf.push(node.nodeValue); } else { buf.push('<![CDATA[' + node.nodeValue + ']]>'); } } else if (node.nodeType == DOM_COMMENT_NODE) { buf.push('<!--' + node.nodeValue + '-->'); } else if (node.nodeType == DOM_ELEMENT_NODE) { buf.push('<' + xmlFullNodeName(node)); for (var i = 0; i < node.attributes.length; ++i) { var a = node.attributes[i]; if (a && a.nodeName && a.nodeValue) { buf.push(' ' + xmlFullNodeName(a) + '="' + xmlEscapeAttr(a.nodeValue) + '"'); } } if (node.childNodes.length === 0) { buf.push('/>'); } else { buf.push('>'); for (i = 0; i < node.childNodes.length; ++i) { arguments.callee(node.childNodes[i], buf, cdata); } buf.push('</' + xmlFullNodeName(node) + '>'); } } else if (node.nodeType == DOM_DOCUMENT_NODE || node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) { for (i = 0; i < node.childNodes.length; ++i) { arguments.callee(node.childNodes[i], buf, cdata); } }}/*** helper for xmlTextR*/function xmlFullNodeName(n) { if (n.prefix && n.nodeName.indexOf(n.prefix + ':') !== 0) { return n.prefix + ':' + n.nodeName; } else { return n.nodeName; }}/*** Escape XML special markup chracters: tag delimiter < > and entity* reference start delimiter &. The escaped string can be used in XML* text portions (i.e. between tags).*/function xmlEscapeText(s) { return ('' + s).replace(/&/g, '&').replace(/</, '<'). replace(/>/, '>');}/*** Escape XML special markup characters: tag delimiter < > entity* reference start delimiter & and quotes ". The escaped string can be* used in double quoted XML attribute value portions (i.e. in* attributes within start tags).*/function xmlEscapeAttr(s) { return xmlEscapeText(s).replace(/\"/g, '"');}/*** Escape markup in XML text, but don't touch entity references. The* escaped string can be used as XML text (i.e. between tags).*/function xmlEscapeTags(s) { return s.replace(/</, '<').replace(/>/g, '>');}// remove this if you merge if (window.GD_Loader) { // continue loading window.GD_Loader();}// end/* Copyright (c) 2006 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.*//*** @fileoverview* BrowserDetector (object)** A class for detecting version 5 browsers by the Javascript objects * they support and not their user agent strings (which can be * spoofed).** Warning: Though slow to develop, browsers may begin to add * DOM support in later versions which might require changes to this * file.** Typical usage:* Detect = new BrowserDetector();* if (Detect.IE()) //IE-only code...*//*** @constructor*/function BrowserDetector() { //IE 4+ this.IE = function() { try { return this.Run(document.all && window.ActiveXObject) !==false; } catch(e) { /* IE 5.01 doesn't support the 'contains' object and fails the first test */ if (document.all) { return true; } return false; } }; //IE 5.5+ this.IE_5_5_newer = function(){ try {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -