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

📄 gdata_condensed.js

📁 google的gdata api包
💻 JS
📖 第 1 页 / 共 5 页
字号:
      return this.Run(this.IE() && Array.prototype.pop)!==false;    } catch(e) {return false;}  };    //IE 5, Macintosh  this.IE_5_Mac = function(){    try {      return(true === undefined);    } catch(e) {      return(            document.all &&             document.getElementById &&             !document.mimeType &&             !window.opera)!==false;    }  };  //Opera 7+  this.OPERA = function(){    try {      return this.Run(document.all && document.contains)!==false;    } catch(e) {return false;}  };  //Gecko, actually Mozilla 1.2+  this.MOZILLA = function() {    try {      return this.Run(                     document.implementation &&                      document.implementation.createDocument &&                      document.evaluate &&                      !document.contains )!==false;    } catch(e) {return false;}  };  //Safari  this.SAFARI = function(){    try {      return this.Run(                     document.implementation &&                      document.implementation.createDocument &&                      document.contains)!==false;    } catch(e) {return false;}  };  //Any browser which supports the W3C DOM  this.DOM = function() {    return(document.getElementById);  };  this.Run = function(test) {    if (test===undefined) {      return false;    } else {      return test;    }  };  this.XPathSupport = function() {    return this.IE_5_5_newer() || document.implementation.hasFeature('XPath','3.0');   };}var DOM = (document.getElementById);var Detect;if (DOM) {  Detect = new BrowserDetector();}// 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.*///------------------------------------------------------------------------------function DumpError(msg) {}function DumpException(msg) {}//------------------------------------------------------------------------------// Logging//------------------------------------------------------------------------------function LOG_LEVEL() {}LOG_LEVEL.NONE  = 0;LOG_LEVEL.ERROR = 1;LOG_LEVEL.DEBUG = 2;LOG_LEVEL.TRACE = 3;LOG_LEVEL.ALL   = 4;function DEBUG_ENABLE_CROSSSITE() {} function DEBUG_CROSSSITE() { return false;}//------------------------------------------------------------------------------// Inline log functions//------------------------------------------------------------------------------function LOG_CLASS(classDef, name) {}function LOG(msg, opt_level) {}function LOG_DEBUG(msg, opt_show) {}function LOG_ERROR(msg) {}function LOG_EVENT(msg) {}function LOG_TRACE(obj, fn, args) {}function LOG_SEPARATOR(opt_text) {}function LOG_TIMER_START(name) {}function LOG_TIMER_STOP(name) {}function LOG_XML_PRINT(doc, opt_level) {}function LOG_DUMP_FEED(feed) {}function VARJ_INC(name) {}//------------------------------------------------------------------------------// Inline debug functions//------------------------------------------------------------------------------function DBG_ALERT(msg, opt_prefix) {}function DBG_ASSERT(cond, opt_msg) {}function DBG_ABSTRACT(obj, fn, args) {}function DBG_NOT_IMPLEMENTED(str) {}// 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.*//** @filecomment* transport.js provides the basic server related operations:* get a feed, create an item, update & delete an item* we abstract this out, so that a unit test framework based on FILE transport* can be developed later*//** returns the appropriate transportobject based on * the passed in type*/function GD_getTransport(transportType) {  switch (transportType) {    case GD_Transport.TRANSPORT_FILE:      // File Transport object      DBG_ALERT("File transport NYI");      return null;    case GD_Transport.TRANSPORT_HTTP:      return new GD_HttpTransport();    case GD_Transport.TRANSPORT_GOOGLECALENDAR:      return new GD_GaiaTransport("cl");     default:      return new GD_GaiaTransport("cl");   }}/** * base transport, for the common things in life*/ function GD_Transport() {   this.userName_ = null;  this.pwd_ = null;} GD_Transport.TRANSPORT_FILE = 1;GD_Transport.TRANSPORT_HTTP = 2;GD_Transport.TRANSPORT_GOOGLECALENDAR = 3; GD_Transport.AUTH_HANDLER = "https://www.google.com/accounts/ClientLogin"; GD_Transport.AUTH_HEADER  = "Authorization"; GD_Transport.AUTH_HEADERVALUE = "GoogleLogin auth="; GD_Transport.AUTH_TOKEN = "Auth";GD_Transport.AUTH_SERVICE = "service=";GD_Transport.AUTH_SOURCE = "source=desktop_Feed_reader";GD_Transport.AUTH_USER  = "Email=";GD_Transport.AUTH_PWD = "Passwd="; GD_Transport.METHOD_OVERRIDE = "X-HTTP-Method-Override"; GD_Transport.NOREDIRECT_HEADER = "X-If-No-Redirect";GD_Transport.SETCOOKIE_HEADER = "Set-Cookie"; GD_Transport.COOKIE_HEADER = "Cookie"; /*** set method GD_Transport.userName_*/GD_Transport.prototype.setUserName = function(stringValue) {   this.userName_ = stringValue; }; /** * get method GD_Transport.userName_*/GD_Transport.prototype.getUserName = function() {   return this.userName_; };/** * set method GD_Transport.pwd_*/ GD_Transport.prototype.setPassword = function(stringValue) {   this.pwd_ = stringValue; };/** * get method GD_Transport.pwd_*/ GD_Transport.prototype.getPassword = function() {   return this.pwd_; };/**  * prototype for the GetDocument method * @param docUri {string} the URI of the XML document to load * @param opt_callback {function} takes one argument, *     the loaded XMLDocument for the documentUri */GD_Transport.prototype.GetDomDocument = function(docUri, opt_callback) {};/** * prototype for the InsertEntry method*/ GD_Transport.prototype.InsertEntry = function(feed, entry) {};/** * prototype for the UpdateEntry method*/ GD_Transport.prototype.UpdateEntry = function(entry) {};/** * prototype for the DeleteEntry method*/ GD_Transport.prototype.DeleteEntry = function(entry) {};/** * file transport section, prototype only*/ function GD_FileTransport() {  GD_Transport.call(this);}UTIL_inherits(GD_FileTransport, GD_Transport);GD_FileTransport.prototype.toString = function(opt_verbose) {  return "GD_FileTransport()";};/** * http transport */function GD_HttpTransport() {  GD_Transport.call(this);  this.shardingCookie_ = null;}UTIL_inherits(GD_HttpTransport, GD_Transport);GD_HttpTransport.prototype.toString = function(opt_verbose) {  return "GD_HttpTransport()";};/*** set method GD_HttpTransport.shardingCookie_*/GD_HttpTransport.prototype.setCookie = function(str) {   this.shardingCookie_ = str;};/*** get method GD_HttpTransport.shardingCookie_*/GD_HttpTransport.prototype.getCookie = function() {   return this.shardingCookie_; };/** * gets the DomDocument for the HTTP transport * @param docUri {string} the URI of the XML document to load * @param opt_callback {function} takes one argument, *     the loaded XMLDocument for the documentUri */GD_HttpTransport.prototype.GetDomDocument = function(docUri, opt_callback) {  LOG_TRACE(docUri, "GD_HttpTransport => GetDomDocument", null);  var callback = (opt_callback)    ? function(request) { opt_callback.call(null, request.responseXML); }    : undefined;  var params = new XmlHttpParameters("GET", docUri, 200, null, callback);  this.CallXmlHttp(params);};/*** DeleteEntry for the HTTP transport,* gets the target URI from the passed in entry*/GD_HttpTransport.prototype.DeleteEntry = function(gdEntry, opt_callBack) {  var deleteUri = gdEntry.getEditUri();  LOG_TRACE(deleteUri, "GD_HttpTransport => DeleteEntry", null);  var params = new XmlHttpParameters("DELETE", deleteUri, 204,      null, opt_callBack);  this.CallXmlHttp(params);};/*** UpdateEntry for the HTTP transport,* gets the target URI from the passed in entry*/GD_HttpTransport.prototype.UpdateEntry = function(gdEntry, opt_callBack) {  var updateUri = gdEntry.getEditUri();  LOG_TRACE(updateUri, "GD_HttpTransport => UpdateEntry", null);  var params = new XmlHttpParameters("PUT", updateUri, -1,      gdEntry.save(), opt_callBack);  this.CallXmlHttp(params);};/** * InsertEntry for the HTTP transport, * sets the target URI from the passed in feed */GD_HttpTransport.prototype.InsertEntry = function(ofFeed, gdEntry,                                                   opt_callBack) {  var insertUri = ofFeed.getPostUri();  if (insertUri != null) {    LOG_TRACE(insertUri, "GD_HttpTransport => InsertEntry", null);    var params = new XmlHttpParameters("POST", insertUri, -1,        gdEntry.save(), opt_callBack);    this.CallXmlHttp(params);  }  else {    throw "this is a read only feed";    }};/** * SetHeaders for the HTTP transport, * just sets the accept content type here */GD_HttpTransport.prototype.SetHeaders = function(xmlHttpRequestObject) {  LOG_TRACE("Entering...", "HTTP.SetHeaders", null);  xmlHttpRequestObject.setRequestHeader("Accept", "text/xml");   xmlHttpRequestObject.setRequestHeader("content-type", "application/atom+xml");   xmlHttpRequestObject.setRequestHeader("Cache-Control", "no-cache"); };/** * @param params {XmlHttpParameters}  */GD_HttpTransport.prototype.PrepareAuthentication = function(params) {  this.DoRequest(params);};/** * Bundle a collection of parameters that are used when making an * XMLHttpRequest. The state of a transaction should be stored in  * the XmlHttpParameters rather than the GD_HttpTransport, as the * GD_HttpTransport is likely a singleton, so requests it facilitates * should not share state. * * @param verb {string} must be "GET" or "DELETE" or "PUT" or "POST" * @param uri {string} * @param allowedStatus {int} * @param payload {string?} * @param opt_callback {function} will receive one argument, *     the loaded XMLHttpRequest, and its return value will be ignored * @param opt_retrying {boolean} indicates whether this is a retry attempt; *     defaults to false */function XmlHttpParameters(verb, uri, allowedStatus, payload,                           opt_callback, opt_retrying) {  this.verb = verb;  this.uri = uri;  this.allowedStatus = allowedStatus;  this.payload = payload;  this.callback = opt_callback;  this.retrying = !!opt_retrying;}/** * method do create the actual request. This one just calls PrepareAuth *   which will continue calling DoRequest after auth is done * @param params {XmlHttpParameters} */GD_HttpTransport.prototype.CallXmlHttp = function(params) {  try {    LOG_TRACE("Entering...", "CallXmlHttp", null);    this.PrepareAuthentication(params);  } catch (e) {    DBG_ALERT(e.toString());    DBG_ALERT('The exception happened in CallXmlHttp for  ' + params.verb +             ' at URI: ' + params.uri);        throw e;   }  LOG_TRACE("Exiting...", "CallXmlHttp", null);  };/** * @param params {XmlHttpParameters}  */GD_HttpTransport.prototype.DoRequest = function(params) {  try {    LOG_TRACE("Entering...", "CallXmlHttp", null);        var xmlRequest = XMLX_getHttpRequest();    var fAsync = false;     if (params.callback) {      xmlRequest.onreadystatechange =        function() { GD_HandleAsyncData(xmlRequest, params); };      fAsync = true;     }    if (DEBUG_CROSSSITE()) {      netscape.security.PrivilegeManager.          enablePrivilege("UniversalBrowserRead");      netscape.security.PrivilegeManager.          enablePrivilege("UniversalBrowserWrite");    }           LOG_TRACE("Using default XlmRequest open", "CallXmlHttp", null);     xmlRequest.open(params.verb, params.uri, fAsync);     // thwart the cache    if (params.verb == "GET") {      xmlRequest.setRequestHeader("If-Modified-Since",                                  "Sat, 1 Jan 2000 00:00:00 GMT");    }    this.SetHeaders(xmlRequest);

⌨️ 快捷键说明

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