| (function() { var goog = goog || {}; |
| goog.global = this; |
| goog.DEBUG = true; |
| goog.LOCALE = "en"; |
| goog.evalWorksForGlobals_ = null; |
| goog.provide = function(name) { |
| goog.exportPath_(name) |
| }; |
| goog.setTestOnly = function(opt_message) { |
| if(!goog.DEBUG) { |
| opt_message = opt_message || ""; |
| throw Error("Importing test-only code into non-debug environment" + opt_message ? ": " + opt_message : "."); |
| } |
| }; |
| goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) { |
| var parts = name.split("."), cur = opt_objectToExportTo || goog.global; |
| !(parts[0] in cur) && cur.execScript && cur.execScript("var " + parts[0]); |
| for(var part;parts.length && (part = parts.shift());) { |
| if(!parts.length && goog.isDef(opt_object)) { |
| cur[part] = opt_object |
| }else { |
| cur = cur[part] ? cur[part] : cur[part] = {} |
| } |
| } |
| }; |
| goog.getObjectByName = function(name, opt_obj) { |
| for(var parts = name.split("."), cur = opt_obj || goog.global, part;part = parts.shift();) { |
| if(goog.isDefAndNotNull(cur[part])) { |
| cur = cur[part] |
| }else { |
| return null |
| } |
| } |
| return cur |
| }; |
| goog.globalize = function(obj, opt_global) { |
| var global = opt_global || goog.global, x; |
| for(x in obj) { |
| global[x] = obj[x] |
| } |
| }; |
| goog.addDependency = function() { |
| }; |
| goog.useStrictRequires = false; |
| goog.require = function() { |
| }; |
| goog.basePath = ""; |
| goog.nullFunction = function() { |
| }; |
| goog.identityFunction = function(var_args) { |
| return var_args |
| }; |
| goog.abstractMethod = function() { |
| throw Error("unimplemented abstract method"); |
| }; |
| goog.addSingletonGetter = function(ctor) { |
| ctor.getInstance = function() { |
| return ctor.instance_ || (ctor.instance_ = new ctor) |
| } |
| }; |
| goog.typeOf = function(value) { |
| var s = typeof value; |
| if(s == "object") { |
| if(value) { |
| if(value instanceof Array) { |
| return"array" |
| }else { |
| if(value instanceof Object) { |
| return s |
| } |
| } |
| var className = Object.prototype.toString.call(value); |
| if(className == "[object Window]") { |
| return"object" |
| } |
| if(className == "[object Array]" || typeof value.length == "number" && typeof value.splice != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("splice")) { |
| return"array" |
| } |
| if(className == "[object Function]" || typeof value.call != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("call")) { |
| return"function" |
| } |
| }else { |
| return"null" |
| } |
| }else { |
| if(s == "function" && typeof value.call == "undefined") { |
| return"object" |
| } |
| } |
| return s |
| }; |
| goog.propertyIsEnumerableCustom_ = function(object, propName) { |
| if(propName in object) { |
| for(var key in object) { |
| if(key == propName && Object.prototype.hasOwnProperty.call(object, propName)) { |
| return true |
| } |
| } |
| } |
| return false |
| }; |
| goog.propertyIsEnumerable_ = function(object, propName) { |
| return object instanceof Object ? Object.prototype.propertyIsEnumerable.call(object, propName) : goog.propertyIsEnumerableCustom_(object, propName) |
| }; |
| goog.isDef = function(val) { |
| return val !== undefined |
| }; |
| goog.isNull = function(val) { |
| return val === null |
| }; |
| goog.isDefAndNotNull = function(val) { |
| return val != null |
| }; |
| goog.isArray = function(val) { |
| return goog.typeOf(val) == "array" |
| }; |
| goog.isArrayLike = function(val) { |
| var type = goog.typeOf(val); |
| return type == "array" || type == "object" && typeof val.length == "number" |
| }; |
| goog.isDateLike = function(val) { |
| return goog.isObject(val) && typeof val.getFullYear == "function" |
| }; |
| goog.isString = function(val) { |
| return typeof val == "string" |
| }; |
| goog.isBoolean = function(val) { |
| return typeof val == "boolean" |
| }; |
| goog.isNumber = function(val) { |
| return typeof val == "number" |
| }; |
| goog.isFunction = function(val) { |
| return goog.typeOf(val) == "function" |
| }; |
| goog.isObject = function(val) { |
| var type = goog.typeOf(val); |
| return type == "object" || type == "array" || type == "function" |
| }; |
| goog.getUid = function(obj) { |
| return obj[goog.UID_PROPERTY_] || (obj[goog.UID_PROPERTY_] = ++goog.uidCounter_) |
| }; |
| goog.removeUid = function(obj) { |
| "removeAttribute" in obj && obj.removeAttribute(goog.UID_PROPERTY_); |
| try { |
| delete obj[goog.UID_PROPERTY_] |
| }catch(ex) { |
| } |
| }; |
| goog.UID_PROPERTY_ = "closure_uid_" + Math.floor(Math.random() * 2147483648).toString(36); |
| goog.uidCounter_ = 0; |
| goog.getHashCode = goog.getUid; |
| goog.removeHashCode = goog.removeUid; |
| goog.cloneObject = function(obj) { |
| var type = goog.typeOf(obj); |
| if(type == "object" || type == "array") { |
| if(obj.clone) { |
| return obj.clone() |
| } |
| var clone = type == "array" ? [] : {}, key; |
| for(key in obj) { |
| clone[key] = goog.cloneObject(obj[key]) |
| } |
| return clone |
| } |
| return obj |
| }; |
| goog.bindNative_ = function(fn) { |
| return fn.call.apply(fn.bind, arguments) |
| }; |
| goog.bindJs_ = function(fn, selfObj) { |
| var context = selfObj || goog.global; |
| if(arguments.length > 2) { |
| var boundArgs = Array.prototype.slice.call(arguments, 2); |
| return function() { |
| var newArgs = Array.prototype.slice.call(arguments); |
| Array.prototype.unshift.apply(newArgs, boundArgs); |
| return fn.apply(context, newArgs) |
| } |
| }else { |
| return function() { |
| return fn.apply(context, arguments) |
| } |
| } |
| }; |
| goog.bind = function() { |
| goog.bind = Function.prototype.bind && Function.prototype.bind.toString().indexOf("native code") != -1 ? goog.bindNative_ : goog.bindJs_; |
| return goog.bind.apply(null, arguments) |
| }; |
| goog.partial = function(fn) { |
| var args = Array.prototype.slice.call(arguments, 1); |
| return function() { |
| var newArgs = Array.prototype.slice.call(arguments); |
| newArgs.unshift.apply(newArgs, args); |
| return fn.apply(this, newArgs) |
| } |
| }; |
| goog.mixin = function(target, source) { |
| for(var x in source) { |
| target[x] = source[x] |
| } |
| }; |
| goog.now = Date.now || function() { |
| return+new Date |
| }; |
| goog.globalEval = function(script) { |
| if(goog.global.execScript) { |
| goog.global.execScript(script, "JavaScript") |
| }else { |
| if(goog.global.eval) { |
| if(goog.evalWorksForGlobals_ == null) { |
| goog.global.eval("var _et_ = 1;"); |
| if(typeof goog.global._et_ != "undefined") { |
| delete goog.global._et_; |
| goog.evalWorksForGlobals_ = true |
| }else { |
| goog.evalWorksForGlobals_ = false |
| } |
| } |
| if(goog.evalWorksForGlobals_) { |
| goog.global.eval(script) |
| }else { |
| var doc = goog.global.document, scriptElt = doc.createElement("script"); |
| scriptElt.type = "text/javascript"; |
| scriptElt.defer = false; |
| scriptElt.appendChild(doc.createTextNode(script)); |
| doc.body.appendChild(scriptElt); |
| doc.body.removeChild(scriptElt) |
| } |
| }else { |
| throw Error("goog.globalEval not available"); |
| } |
| } |
| }; |
| goog.typedef = true; |
| goog.getCssName = function(className, opt_modifier) { |
| var getMapping = function(cssName) { |
| return goog.cssNameMapping_[cssName] || cssName |
| }, renameByParts = function(cssName) { |
| for(var parts = cssName.split("-"), mapped = [], i = 0;i < parts.length;i++) { |
| mapped.push(getMapping(parts[i])) |
| } |
| return mapped.join("-") |
| }, rename; |
| rename = goog.cssNameMapping_ ? goog.cssNameMappingStyle_ == "BY_WHOLE" ? getMapping : renameByParts : function(a) { |
| return a |
| }; |
| return opt_modifier ? className + "-" + rename(opt_modifier) : rename(className) |
| }; |
| goog.setCssNameMapping = function(mapping, style) { |
| goog.cssNameMapping_ = mapping; |
| goog.cssNameMappingStyle_ = style |
| }; |
| goog.getMsg = function(str, opt_values) { |
| var values = opt_values || {}, key; |
| for(key in values) { |
| var value = ("" + values[key]).replace(/\$/g, "$$$$"); |
| str = str.replace(RegExp("\\{\\$" + key + "\\}", "gi"), value) |
| } |
| return str |
| }; |
| goog.exportSymbol = function(publicPath, object, opt_objectToExportTo) { |
| goog.exportPath_(publicPath, object, opt_objectToExportTo) |
| }; |
| goog.exportProperty = function(object, publicName, symbol) { |
| object[publicName] = symbol |
| }; |
| goog.inherits = function(childCtor, parentCtor) { |
| function tempCtor() { |
| } |
| tempCtor.prototype = parentCtor.prototype; |
| childCtor.superClass_ = parentCtor.prototype; |
| childCtor.prototype = new tempCtor; |
| childCtor.prototype.constructor = childCtor |
| }; |
| goog.base = function(me, opt_methodName) { |
| var caller = arguments.callee.caller; |
| if(caller.superClass_) { |
| return caller.superClass_.constructor.apply(me, Array.prototype.slice.call(arguments, 1)) |
| } |
| for(var args = Array.prototype.slice.call(arguments, 2), foundCaller = false, ctor = me.constructor;ctor;ctor = ctor.superClass_ && ctor.superClass_.constructor) { |
| if(ctor.prototype[opt_methodName] === caller) { |
| foundCaller = true |
| }else { |
| if(foundCaller) { |
| return ctor.prototype[opt_methodName].apply(me, args) |
| } |
| } |
| } |
| if(me[opt_methodName] === caller) { |
| return me.constructor.prototype[opt_methodName].apply(me, args) |
| }else { |
| throw Error("goog.base called from a method of one name to a method of a different name"); |
| } |
| }; |
| goog.scope = function(fn) { |
| fn.call(goog.global) |
| }; |
| goog.MODIFY_FUNCTION_PROTOTYPES = true; |
| if(goog.MODIFY_FUNCTION_PROTOTYPES) { |
| Function.prototype.bind = Function.prototype.bind || function(selfObj) { |
| if(arguments.length > 1) { |
| var args = Array.prototype.slice.call(arguments, 1); |
| args.unshift(this, selfObj); |
| return goog.bind.apply(null, args) |
| }else { |
| return goog.bind(this, selfObj) |
| } |
| }; |
| Function.prototype.partial = function() { |
| var args = Array.prototype.slice.call(arguments); |
| args.unshift(this, null); |
| return goog.bind.apply(null, args) |
| }; |
| Function.prototype.inherits = function(parentCtor) { |
| goog.inherits(this, parentCtor) |
| }; |
| Function.prototype.mixin = function(source) { |
| goog.mixin(this.prototype, source) |
| } |
| } |
| ;goog.debug = {}; |
| goog.debug.Error = function(opt_msg) { |
| this.stack = Error().stack || ""; |
| if(opt_msg) { |
| this.message = String(opt_msg) |
| } |
| }; |
| goog.inherits(goog.debug.Error, Error); |
| goog.debug.Error.prototype.name = "CustomError"; |
| goog.string = {}; |
| goog.string.Unicode = {NBSP:"\u00a0"}; |
| goog.string.startsWith = function(str, prefix) { |
| return str.lastIndexOf(prefix, 0) == 0 |
| }; |
| goog.string.endsWith = function(str, suffix) { |
| var l = str.length - suffix.length; |
| return l >= 0 && str.indexOf(suffix, l) == l |
| }; |
| goog.string.caseInsensitiveStartsWith = function(str, prefix) { |
| return goog.string.caseInsensitiveCompare(prefix, str.substr(0, prefix.length)) == 0 |
| }; |
| goog.string.caseInsensitiveEndsWith = function(str, suffix) { |
| return goog.string.caseInsensitiveCompare(suffix, str.substr(str.length - suffix.length, suffix.length)) == 0 |
| }; |
| goog.string.subs = function(str) { |
| for(var i = 1;i < arguments.length;i++) { |
| var replacement = String(arguments[i]).replace(/\$/g, "$$$$"); |
| str = str.replace(/\%s/, replacement) |
| } |
| return str |
| }; |
| goog.string.collapseWhitespace = function(str) { |
| return str.replace(/[\s\xa0]+/g, " ").replace(/^\s+|\s+$/g, "") |
| }; |
| goog.string.isEmpty = function(str) { |
| return/^[\s\xa0]*$/.test(str) |
| }; |
| goog.string.isEmptySafe = function(str) { |
| return goog.string.isEmpty(goog.string.makeSafe(str)) |
| }; |
| goog.string.isBreakingWhitespace = function(str) { |
| return!/[^\t\n\r ]/.test(str) |
| }; |
| goog.string.isAlpha = function(str) { |
| return!/[^a-zA-Z]/.test(str) |
| }; |
| goog.string.isNumeric = function(str) { |
| return!/[^0-9]/.test(str) |
| }; |
| goog.string.isAlphaNumeric = function(str) { |
| return!/[^a-zA-Z0-9]/.test(str) |
| }; |
| goog.string.isSpace = function(ch) { |
| return ch == " " |
| }; |
| goog.string.isUnicodeChar = function(ch) { |
| return ch.length == 1 && ch >= " " && ch <= "~" || ch >= "\u0080" && ch <= "\ufffd" |
| }; |
| goog.string.stripNewlines = function(str) { |
| return str.replace(/(\r\n|\r|\n)+/g, " ") |
| }; |
| goog.string.canonicalizeNewlines = function(str) { |
| return str.replace(/(\r\n|\r|\n)/g, "\n") |
| }; |
| goog.string.normalizeWhitespace = function(str) { |
| return str.replace(/\xa0|\s/g, " ") |
| }; |
| goog.string.normalizeSpaces = function(str) { |
| return str.replace(/\xa0|[ \t]+/g, " ") |
| }; |
| goog.string.trim = function(str) { |
| return str.replace(/^[\s\xa0]+|[\s\xa0]+$/g, "") |
| }; |
| goog.string.trimLeft = function(str) { |
| return str.replace(/^[\s\xa0]+/, "") |
| }; |
| goog.string.trimRight = function(str) { |
| return str.replace(/[\s\xa0]+$/, "") |
| }; |
| goog.string.caseInsensitiveCompare = function(str1, str2) { |
| var test1 = String(str1).toLowerCase(), test2 = String(str2).toLowerCase(); |
| return test1 < test2 ? -1 : test1 == test2 ? 0 : 1 |
| }; |
| goog.string.numerateCompareRegExp_ = /(\.\d+)|(\d+)|(\D+)/g; |
| goog.string.numerateCompare = function(str1, str2) { |
| if(str1 == str2) { |
| return 0 |
| } |
| if(!str1) { |
| return-1 |
| } |
| if(!str2) { |
| return 1 |
| } |
| for(var tokens1 = str1.toLowerCase().match(goog.string.numerateCompareRegExp_), tokens2 = str2.toLowerCase().match(goog.string.numerateCompareRegExp_), count = Math.min(tokens1.length, tokens2.length), i = 0;i < count;i++) { |
| var a = tokens1[i], b = tokens2[i]; |
| if(a != b) { |
| var num1 = parseInt(a, 10); |
| if(!isNaN(num1)) { |
| var num2 = parseInt(b, 10); |
| if(!isNaN(num2) && num1 - num2) { |
| return num1 - num2 |
| } |
| } |
| return a < b ? -1 : 1 |
| } |
| } |
| if(tokens1.length != tokens2.length) { |
| return tokens1.length - tokens2.length |
| } |
| return str1 < str2 ? -1 : 1 |
| }; |
| goog.string.encodeUriRegExp_ = /^[a-zA-Z0-9\-_.!~*'()]*$/; |
| goog.string.urlEncode = function(str) { |
| str = String(str); |
| if(!goog.string.encodeUriRegExp_.test(str)) { |
| return encodeURIComponent(str) |
| } |
| return str |
| }; |
| goog.string.urlDecode = function(str) { |
| return decodeURIComponent(str.replace(/\+/g, " ")) |
| }; |
| goog.string.newLineToBr = function(str, opt_xml) { |
| return str.replace(/(\r\n|\r|\n)/g, opt_xml ? "<br />" : "<br>") |
| }; |
| goog.string.htmlEscape = function(str, opt_isLikelyToContainHtmlChars) { |
| if(opt_isLikelyToContainHtmlChars) { |
| return str.replace(goog.string.amperRe_, "&").replace(goog.string.ltRe_, "<").replace(goog.string.gtRe_, ">").replace(goog.string.quotRe_, """) |
| }else { |
| if(!goog.string.allRe_.test(str)) { |
| return str |
| } |
| if(str.indexOf("&") != -1) { |
| str = str.replace(goog.string.amperRe_, "&") |
| } |
| if(str.indexOf("<") != -1) { |
| str = str.replace(goog.string.ltRe_, "<") |
| } |
| if(str.indexOf(">") != -1) { |
| str = str.replace(goog.string.gtRe_, ">") |
| } |
| if(str.indexOf('"') != -1) { |
| str = str.replace(goog.string.quotRe_, """) |
| } |
| return str |
| } |
| }; |
| goog.string.amperRe_ = /&/g; |
| goog.string.ltRe_ = /</g; |
| goog.string.gtRe_ = />/g; |
| goog.string.quotRe_ = /\"/g; |
| goog.string.allRe_ = /[&<>\"]/; |
| goog.string.unescapeEntities = function(str) { |
| if(goog.string.contains(str, "&")) { |
| return"document" in goog.global && !goog.string.contains(str, "<") ? goog.string.unescapeEntitiesUsingDom_(str) : goog.string.unescapePureXmlEntities_(str) |
| } |
| return str |
| }; |
| goog.string.unescapeEntitiesUsingDom_ = function(str) { |
| var el = goog.global.document.createElement("div"); |
| el.innerHTML = "<pre>x" + str + "</pre>"; |
| if(el.firstChild[goog.string.NORMALIZE_FN_]) { |
| el.firstChild[goog.string.NORMALIZE_FN_]() |
| } |
| str = el.firstChild.firstChild.nodeValue.slice(1); |
| el.innerHTML = ""; |
| return goog.string.canonicalizeNewlines(str) |
| }; |
| goog.string.unescapePureXmlEntities_ = function(str) { |
| return str.replace(/&([^;]+);/g, function(s, entity) { |
| switch(entity) { |
| case "amp": |
| return"&"; |
| case "lt": |
| return"<"; |
| case "gt": |
| return">"; |
| case "quot": |
| return'"'; |
| default: |
| if(entity.charAt(0) == "#") { |
| var n = Number("0" + entity.substr(1)); |
| if(!isNaN(n)) { |
| return String.fromCharCode(n) |
| } |
| } |
| return s |
| } |
| }) |
| }; |
| goog.string.NORMALIZE_FN_ = "normalize"; |
| goog.string.whitespaceEscape = function(str, opt_xml) { |
| return goog.string.newLineToBr(str.replace(/ /g, "  "), opt_xml) |
| }; |
| goog.string.stripQuotes = function(str, quoteChars) { |
| for(var length = quoteChars.length, i = 0;i < length;i++) { |
| var quoteChar = length == 1 ? quoteChars : quoteChars.charAt(i); |
| if(str.charAt(0) == quoteChar && str.charAt(str.length - 1) == quoteChar) { |
| return str.substring(1, str.length - 1) |
| } |
| } |
| return str |
| }; |
| goog.string.truncate = function(str, chars, opt_protectEscapedCharacters) { |
| if(opt_protectEscapedCharacters) { |
| str = goog.string.unescapeEntities(str) |
| } |
| if(str.length > chars) { |
| str = str.substring(0, chars - 3) + "..." |
| } |
| if(opt_protectEscapedCharacters) { |
| str = goog.string.htmlEscape(str) |
| } |
| return str |
| }; |
| goog.string.truncateMiddle = function(str, chars, opt_protectEscapedCharacters) { |
| if(opt_protectEscapedCharacters) { |
| str = goog.string.unescapeEntities(str) |
| } |
| if(str.length > chars) { |
| var half = Math.floor(chars / 2), endPos = str.length - half; |
| half += chars % 2; |
| str = str.substring(0, half) + "..." + str.substring(endPos) |
| } |
| if(opt_protectEscapedCharacters) { |
| str = goog.string.htmlEscape(str) |
| } |
| return str |
| }; |
| goog.string.specialEscapeChars_ = {"\u0000":"\\0", "\u0008":"\\b", "\u000c":"\\f", "\n":"\\n", "\r":"\\r", "\t":"\\t", "\u000b":"\\x0B", '"':'\\"', "\\":"\\\\"}; |
| goog.string.jsEscapeCache_ = {"'":"\\'"}; |
| goog.string.quote = function(s) { |
| s = String(s); |
| if(s.quote) { |
| return s.quote() |
| }else { |
| for(var sb = ['"'], i = 0;i < s.length;i++) { |
| var ch = s.charAt(i), cc = ch.charCodeAt(0); |
| sb[i + 1] = goog.string.specialEscapeChars_[ch] || (cc > 31 && cc < 127 ? ch : goog.string.escapeChar(ch)) |
| } |
| sb.push('"'); |
| return sb.join("") |
| } |
| }; |
| goog.string.escapeString = function(str) { |
| for(var sb = [], i = 0;i < str.length;i++) { |
| sb[i] = goog.string.escapeChar(str.charAt(i)) |
| } |
| return sb.join("") |
| }; |
| goog.string.escapeChar = function(c) { |
| if(c in goog.string.jsEscapeCache_) { |
| return goog.string.jsEscapeCache_[c] |
| } |
| if(c in goog.string.specialEscapeChars_) { |
| return goog.string.jsEscapeCache_[c] = goog.string.specialEscapeChars_[c] |
| } |
| var rv = c, cc = c.charCodeAt(0); |
| if(cc > 31 && cc < 127) { |
| rv = c |
| }else { |
| if(cc < 256) { |
| rv = "\\x"; |
| if(cc < 16 || cc > 256) { |
| rv += "0" |
| } |
| }else { |
| rv = "\\u"; |
| if(cc < 4096) { |
| rv += "0" |
| } |
| } |
| rv += cc.toString(16).toUpperCase() |
| } |
| return goog.string.jsEscapeCache_[c] = rv |
| }; |
| goog.string.toMap = function(s) { |
| for(var rv = {}, i = 0;i < s.length;i++) { |
| rv[s.charAt(i)] = true |
| } |
| return rv |
| }; |
| goog.string.contains = function(s, ss) { |
| return s.indexOf(ss) != -1 |
| }; |
| goog.string.removeAt = function(s, index, stringLength) { |
| var resultStr = s; |
| if(index >= 0 && index < s.length && stringLength > 0) { |
| resultStr = s.substr(0, index) + s.substr(index + stringLength, s.length - index - stringLength) |
| } |
| return resultStr |
| }; |
| goog.string.remove = function(s, ss) { |
| var re = RegExp(goog.string.regExpEscape(ss), ""); |
| return s.replace(re, "") |
| }; |
| goog.string.removeAll = function(s, ss) { |
| var re = RegExp(goog.string.regExpEscape(ss), "g"); |
| return s.replace(re, "") |
| }; |
| goog.string.regExpEscape = function(s) { |
| return String(s).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, "\\$1").replace(/\x08/g, "\\x08") |
| }; |
| goog.string.repeat = function(string, length) { |
| return Array(length + 1).join(string) |
| }; |
| goog.string.padNumber = function(num, length, opt_precision) { |
| var s = goog.isDef(opt_precision) ? num.toFixed(opt_precision) : String(num), index = s.indexOf("."); |
| if(index == -1) { |
| index = s.length |
| } |
| return goog.string.repeat("0", Math.max(0, length - index)) + s |
| }; |
| goog.string.makeSafe = function(obj) { |
| return obj == null ? "" : String(obj) |
| }; |
| goog.string.buildString = function() { |
| return Array.prototype.join.call(arguments, "") |
| }; |
| goog.string.getRandomString = function() { |
| var x = 2147483648; |
| return Math.floor(Math.random() * x).toString(36) + Math.abs(Math.floor(Math.random() * x) ^ goog.now()).toString(36) |
| }; |
| goog.string.compareVersions = function(version1, version2) { |
| for(var order = 0, v1Subs = goog.string.trim(String(version1)).split("."), v2Subs = goog.string.trim(String(version2)).split("."), subCount = Math.max(v1Subs.length, v2Subs.length), subIdx = 0;order == 0 && subIdx < subCount;subIdx++) { |
| var v1Sub = v1Subs[subIdx] || "", v2Sub = v2Subs[subIdx] || "", v1CompParser = RegExp("(\\d*)(\\D*)", "g"), v2CompParser = RegExp("(\\d*)(\\D*)", "g"); |
| do { |
| var v1Comp = v1CompParser.exec(v1Sub) || ["", "", ""], v2Comp = v2CompParser.exec(v2Sub) || ["", "", ""]; |
| if(v1Comp[0].length == 0 && v2Comp[0].length == 0) { |
| break |
| } |
| var v1CompNum = v1Comp[1].length == 0 ? 0 : parseInt(v1Comp[1], 10), v2CompNum = v2Comp[1].length == 0 ? 0 : parseInt(v2Comp[1], 10); |
| order = goog.string.compareElements_(v1CompNum, v2CompNum) || goog.string.compareElements_(v1Comp[2].length == 0, v2Comp[2].length == 0) || goog.string.compareElements_(v1Comp[2], v2Comp[2]) |
| }while(order == 0) |
| } |
| return order |
| }; |
| goog.string.compareElements_ = function(left, right) { |
| if(left < right) { |
| return-1 |
| }else { |
| if(left > right) { |
| return 1 |
| } |
| } |
| return 0 |
| }; |
| goog.string.HASHCODE_MAX_ = 4294967296; |
| goog.string.hashCode = function(str) { |
| for(var result = 0, i = 0;i < str.length;++i) { |
| result = 31 * result + str.charCodeAt(i); |
| result %= goog.string.HASHCODE_MAX_ |
| } |
| return result |
| }; |
| goog.string.uniqueStringCounter_ = Math.random() * 2147483648 | 0; |
| goog.string.createUniqueString = function() { |
| return"goog_" + goog.string.uniqueStringCounter_++ |
| }; |
| goog.string.toNumber = function(str) { |
| var num = Number(str); |
| if(num == 0 && goog.string.isEmpty(str)) { |
| return NaN |
| } |
| return num |
| }; |
| goog.string.toCamelCaseCache_ = {}; |
| goog.string.toCamelCase = function(str) { |
| return goog.string.toCamelCaseCache_[str] || (goog.string.toCamelCaseCache_[str] = String(str).replace(/\-([a-z])/g, function(all, match) { |
| return match.toUpperCase() |
| })) |
| }; |
| goog.string.toSelectorCaseCache_ = {}; |
| goog.string.toSelectorCase = function(str) { |
| return goog.string.toSelectorCaseCache_[str] || (goog.string.toSelectorCaseCache_[str] = String(str).replace(/([A-Z])/g, "-$1").toLowerCase()) |
| }; |
| goog.asserts = {}; |
| goog.asserts.ENABLE_ASSERTS = goog.DEBUG; |
| goog.asserts.AssertionError = function(messagePattern, messageArgs) { |
| messageArgs.unshift(messagePattern); |
| goog.debug.Error.call(this, goog.string.subs.apply(null, messageArgs)); |
| messageArgs.shift(); |
| this.messagePattern = messagePattern |
| }; |
| goog.inherits(goog.asserts.AssertionError, goog.debug.Error); |
| goog.asserts.AssertionError.prototype.name = "AssertionError"; |
| goog.asserts.doAssertFailure_ = function(defaultMessage, defaultArgs, givenMessage, givenArgs) { |
| var message = "Assertion failed"; |
| if(givenMessage) { |
| message += ": " + givenMessage; |
| var args = givenArgs |
| }else { |
| if(defaultMessage) { |
| message += ": " + defaultMessage; |
| args = defaultArgs |
| } |
| } |
| throw new goog.asserts.AssertionError("" + message, args || []); |
| }; |
| goog.asserts.assert = function(condition, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !condition && goog.asserts.doAssertFailure_("", null, opt_message, Array.prototype.slice.call(arguments, 2)); |
| return condition |
| }; |
| goog.asserts.fail = function(opt_message) { |
| if(goog.asserts.ENABLE_ASSERTS) { |
| throw new goog.asserts.AssertionError("Failure" + (opt_message ? ": " + opt_message : ""), Array.prototype.slice.call(arguments, 1)); |
| } |
| }; |
| goog.asserts.assertNumber = function(value, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !goog.isNumber(value) && goog.asserts.doAssertFailure_("Expected number but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); |
| return value |
| }; |
| goog.asserts.assertString = function(value, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !goog.isString(value) && goog.asserts.doAssertFailure_("Expected string but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); |
| return value |
| }; |
| goog.asserts.assertFunction = function(value, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !goog.isFunction(value) && goog.asserts.doAssertFailure_("Expected function but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); |
| return value |
| }; |
| goog.asserts.assertObject = function(value, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !goog.isObject(value) && goog.asserts.doAssertFailure_("Expected object but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); |
| return value |
| }; |
| goog.asserts.assertArray = function(value, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !goog.isArray(value) && goog.asserts.doAssertFailure_("Expected array but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); |
| return value |
| }; |
| goog.asserts.assertBoolean = function(value, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !goog.isBoolean(value) && goog.asserts.doAssertFailure_("Expected boolean but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2)); |
| return value |
| }; |
| goog.asserts.assertInstanceof = function(value, type, opt_message) { |
| goog.asserts.ENABLE_ASSERTS && !(value instanceof type) && goog.asserts.doAssertFailure_("instanceof check failed.", null, opt_message, Array.prototype.slice.call(arguments, 3)) |
| }; |
| goog.array = {}; |
| goog.array.ArrayLike = {}; |
| goog.array.peek = function(array) { |
| return array[array.length - 1] |
| }; |
| goog.array.ARRAY_PROTOTYPE_ = Array.prototype; |
| goog.array.indexOf = goog.array.ARRAY_PROTOTYPE_.indexOf ? function(arr, obj, opt_fromIndex) { |
| goog.asserts.assert(arr.length != null); |
| return goog.array.ARRAY_PROTOTYPE_.indexOf.call(arr, obj, opt_fromIndex) |
| } : function(arr, obj, opt_fromIndex) { |
| var fromIndex = opt_fromIndex == null ? 0 : opt_fromIndex < 0 ? Math.max(0, arr.length + opt_fromIndex) : opt_fromIndex; |
| if(goog.isString(arr)) { |
| if(!goog.isString(obj) || obj.length != 1) { |
| return-1 |
| } |
| return arr.indexOf(obj, fromIndex) |
| } |
| for(var i = fromIndex;i < arr.length;i++) { |
| if(i in arr && arr[i] === obj) { |
| return i |
| } |
| } |
| return-1 |
| }; |
| goog.array.lastIndexOf = goog.array.ARRAY_PROTOTYPE_.lastIndexOf ? function(arr, obj, opt_fromIndex) { |
| goog.asserts.assert(arr.length != null); |
| var fromIndex = opt_fromIndex == null ? arr.length - 1 : opt_fromIndex; |
| return goog.array.ARRAY_PROTOTYPE_.lastIndexOf.call(arr, obj, fromIndex) |
| } : function(arr, obj, opt_fromIndex) { |
| var fromIndex = opt_fromIndex == null ? arr.length - 1 : opt_fromIndex; |
| if(fromIndex < 0) { |
| fromIndex = Math.max(0, arr.length + fromIndex) |
| } |
| if(goog.isString(arr)) { |
| if(!goog.isString(obj) || obj.length != 1) { |
| return-1 |
| } |
| return arr.lastIndexOf(obj, fromIndex) |
| } |
| for(var i = fromIndex;i >= 0;i--) { |
| if(i in arr && arr[i] === obj) { |
| return i |
| } |
| } |
| return-1 |
| }; |
| goog.array.forEach = goog.array.ARRAY_PROTOTYPE_.forEach ? function(arr, f, opt_obj) { |
| goog.asserts.assert(arr.length != null); |
| goog.array.ARRAY_PROTOTYPE_.forEach.call(arr, f, opt_obj) |
| } : function(arr, f, opt_obj) { |
| for(var l = arr.length, arr2 = goog.isString(arr) ? arr.split("") : arr, i = 0;i < l;i++) { |
| i in arr2 && f.call(opt_obj, arr2[i], i, arr) |
| } |
| }; |
| goog.array.forEachRight = function(arr, f, opt_obj) { |
| for(var l = arr.length, arr2 = goog.isString(arr) ? arr.split("") : arr, i = l - 1;i >= 0;--i) { |
| i in arr2 && f.call(opt_obj, arr2[i], i, arr) |
| } |
| }; |
| goog.array.filter = goog.array.ARRAY_PROTOTYPE_.filter ? function(arr, f, opt_obj) { |
| goog.asserts.assert(arr.length != null); |
| return goog.array.ARRAY_PROTOTYPE_.filter.call(arr, f, opt_obj) |
| } : function(arr, f, opt_obj) { |
| for(var l = arr.length, res = [], resLength = 0, arr2 = goog.isString(arr) ? arr.split("") : arr, i = 0;i < l;i++) { |
| if(i in arr2) { |
| var val = arr2[i]; |
| if(f.call(opt_obj, val, i, arr)) { |
| res[resLength++] = val |
| } |
| } |
| } |
| return res |
| }; |
| goog.array.map = goog.array.ARRAY_PROTOTYPE_.map ? function(arr, f, opt_obj) { |
| goog.asserts.assert(arr.length != null); |
| return goog.array.ARRAY_PROTOTYPE_.map.call(arr, f, opt_obj) |
| } : function(arr, f, opt_obj) { |
| for(var l = arr.length, res = Array(l), arr2 = goog.isString(arr) ? arr.split("") : arr, i = 0;i < l;i++) { |
| if(i in arr2) { |
| res[i] = f.call(opt_obj, arr2[i], i, arr) |
| } |
| } |
| return res |
| }; |
| goog.array.reduce = function(arr, f, val$$0, opt_obj) { |
| if(arr.reduce) { |
| return opt_obj ? arr.reduce(goog.bind(f, opt_obj), val$$0) : arr.reduce(f, val$$0) |
| } |
| var rval = val$$0; |
| goog.array.forEach(arr, function(val, index) { |
| rval = f.call(opt_obj, rval, val, index, arr) |
| }); |
| return rval |
| }; |
| goog.array.reduceRight = function(arr, f, val$$0, opt_obj) { |
| if(arr.reduceRight) { |
| return opt_obj ? arr.reduceRight(goog.bind(f, opt_obj), val$$0) : arr.reduceRight(f, val$$0) |
| } |
| var rval = val$$0; |
| goog.array.forEachRight(arr, function(val, index) { |
| rval = f.call(opt_obj, rval, val, index, arr) |
| }); |
| return rval |
| }; |
| goog.array.some = goog.array.ARRAY_PROTOTYPE_.some ? function(arr, f, opt_obj) { |
| goog.asserts.assert(arr.length != null); |
| return goog.array.ARRAY_PROTOTYPE_.some.call(arr, f, opt_obj) |
| } : function(arr, f, opt_obj) { |
| for(var l = arr.length, arr2 = goog.isString(arr) ? arr.split("") : arr, i = 0;i < l;i++) { |
| if(i in arr2 && f.call(opt_obj, arr2[i], i, arr)) { |
| return true |
| } |
| } |
| return false |
| }; |
| goog.array.every = goog.array.ARRAY_PROTOTYPE_.every ? function(arr, f, opt_obj) { |
| goog.asserts.assert(arr.length != null); |
| return goog.array.ARRAY_PROTOTYPE_.every.call(arr, f, opt_obj) |
| } : function(arr, f, opt_obj) { |
| for(var l = arr.length, arr2 = goog.isString(arr) ? arr.split("") : arr, i = 0;i < l;i++) { |
| if(i in arr2 && !f.call(opt_obj, arr2[i], i, arr)) { |
| return false |
| } |
| } |
| return true |
| }; |
| goog.array.find = function(arr, f, opt_obj) { |
| var i = goog.array.findIndex(arr, f, opt_obj); |
| return i < 0 ? null : goog.isString(arr) ? arr.charAt(i) : arr[i] |
| }; |
| goog.array.findIndex = function(arr, f, opt_obj) { |
| for(var l = arr.length, arr2 = goog.isString(arr) ? arr.split("") : arr, i = 0;i < l;i++) { |
| if(i in arr2 && f.call(opt_obj, arr2[i], i, arr)) { |
| return i |
| } |
| } |
| return-1 |
| }; |
| goog.array.findRight = function(arr, f, opt_obj) { |
| var i = goog.array.findIndexRight(arr, f, opt_obj); |
| return i < 0 ? null : goog.isString(arr) ? arr.charAt(i) : arr[i] |
| }; |
| goog.array.findIndexRight = function(arr, f, opt_obj) { |
| for(var l = arr.length, arr2 = goog.isString(arr) ? arr.split("") : arr, i = l - 1;i >= 0;i--) { |
| if(i in arr2 && f.call(opt_obj, arr2[i], i, arr)) { |
| return i |
| } |
| } |
| return-1 |
| }; |
| goog.array.contains = function(arr, obj) { |
| return goog.array.indexOf(arr, obj) >= 0 |
| }; |
| goog.array.isEmpty = function(arr) { |
| return arr.length == 0 |
| }; |
| goog.array.clear = function(arr) { |
| if(!goog.isArray(arr)) { |
| for(var i = arr.length - 1;i >= 0;i--) { |
| delete arr[i] |
| } |
| } |
| arr.length = 0 |
| }; |
| goog.array.insert = function(arr, obj) { |
| goog.array.contains(arr, obj) || arr.push(obj) |
| }; |
| goog.array.insertAt = function(arr, obj, opt_i) { |
| goog.array.splice(arr, opt_i, 0, obj) |
| }; |
| goog.array.insertArrayAt = function(arr, elementsToAdd, opt_i) { |
| goog.partial(goog.array.splice, arr, opt_i, 0).apply(null, elementsToAdd) |
| }; |
| goog.array.insertBefore = function(arr, obj, opt_obj2) { |
| var i; |
| arguments.length == 2 || (i = goog.array.indexOf(arr, opt_obj2)) < 0 ? arr.push(obj) : goog.array.insertAt(arr, obj, i) |
| }; |
| goog.array.remove = function(arr, obj) { |
| var i = goog.array.indexOf(arr, obj), rv; |
| if(rv = i >= 0) { |
| goog.array.removeAt(arr, i) |
| } |
| return rv |
| }; |
| goog.array.removeAt = function(arr, i) { |
| goog.asserts.assert(arr.length != null); |
| return goog.array.ARRAY_PROTOTYPE_.splice.call(arr, i, 1).length == 1 |
| }; |
| goog.array.removeIf = function(arr, f, opt_obj) { |
| var i = goog.array.findIndex(arr, f, opt_obj); |
| if(i >= 0) { |
| goog.array.removeAt(arr, i); |
| return true |
| } |
| return false |
| }; |
| goog.array.concat = function() { |
| return goog.array.ARRAY_PROTOTYPE_.concat.apply(goog.array.ARRAY_PROTOTYPE_, arguments) |
| }; |
| goog.array.clone = function(arr) { |
| if(goog.isArray(arr)) { |
| return goog.array.concat(arr) |
| }else { |
| for(var rv = [], i = 0, len = arr.length;i < len;i++) { |
| rv[i] = arr[i] |
| } |
| return rv |
| } |
| }; |
| goog.array.toArray = function(object) { |
| if(goog.isArray(object)) { |
| return goog.array.concat(object) |
| } |
| return goog.array.clone(object) |
| }; |
| goog.array.extend = function(arr1) { |
| for(var i = 1;i < arguments.length;i++) { |
| var arr2 = arguments[i], isArrayLike; |
| if(goog.isArray(arr2) || (isArrayLike = goog.isArrayLike(arr2)) && arr2.hasOwnProperty("callee")) { |
| arr1.push.apply(arr1, arr2) |
| }else { |
| if(isArrayLike) { |
| for(var len1 = arr1.length, len2 = arr2.length, j = 0;j < len2;j++) { |
| arr1[len1 + j] = arr2[j] |
| } |
| }else { |
| arr1.push(arr2) |
| } |
| } |
| } |
| }; |
| goog.array.splice = function(arr) { |
| goog.asserts.assert(arr.length != null); |
| return goog.array.ARRAY_PROTOTYPE_.splice.apply(arr, goog.array.slice(arguments, 1)) |
| }; |
| goog.array.slice = function(arr, start, opt_end) { |
| goog.asserts.assert(arr.length != null); |
| return arguments.length <= 2 ? goog.array.ARRAY_PROTOTYPE_.slice.call(arr, start) : goog.array.ARRAY_PROTOTYPE_.slice.call(arr, start, opt_end) |
| }; |
| goog.array.removeDuplicates = function(arr, opt_rv) { |
| for(var returnArray = opt_rv || arr, seen = {}, cursorInsert = 0, cursorRead = 0;cursorRead < arr.length;) { |
| var current = arr[cursorRead++], key = goog.isObject(current) ? "o" + goog.getUid(current) : (typeof current).charAt(0) + current; |
| if(!Object.prototype.hasOwnProperty.call(seen, key)) { |
| seen[key] = true; |
| returnArray[cursorInsert++] = current |
| } |
| } |
| returnArray.length = cursorInsert |
| }; |
| goog.array.binarySearch = function(arr, target, opt_compareFn) { |
| return goog.array.binarySearch_(arr, opt_compareFn || goog.array.defaultCompare, false, target) |
| }; |
| goog.array.binarySelect = function(arr, evaluator, opt_obj) { |
| return goog.array.binarySearch_(arr, evaluator, true, undefined, opt_obj) |
| }; |
| goog.array.binarySearch_ = function(arr, compareFn, isEvaluator, opt_target, opt_selfObj) { |
| for(var left = 0, right = arr.length, found;left < right;) { |
| var middle = left + right >> 1, compareResult; |
| compareResult = isEvaluator ? compareFn.call(opt_selfObj, arr[middle], middle, arr) : compareFn(opt_target, arr[middle]); |
| if(compareResult > 0) { |
| left = middle + 1 |
| }else { |
| right = middle; |
| found = !compareResult |
| } |
| } |
| return found ? left : ~left |
| }; |
| goog.array.sort = function(arr, opt_compareFn) { |
| goog.asserts.assert(arr.length != null); |
| goog.array.ARRAY_PROTOTYPE_.sort.call(arr, opt_compareFn || goog.array.defaultCompare) |
| }; |
| goog.array.stableSort = function(arr, opt_compareFn) { |
| function stableCompareFn(obj1, obj2) { |
| return valueCompareFn(obj1.value, obj2.value) || obj1.index - obj2.index |
| } |
| for(var i = 0;i < arr.length;i++) { |
| arr[i] = {index:i, value:arr[i]} |
| } |
| var valueCompareFn = opt_compareFn || goog.array.defaultCompare; |
| goog.array.sort(arr, stableCompareFn); |
| for(i = 0;i < arr.length;i++) { |
| arr[i] = arr[i].value |
| } |
| }; |
| goog.array.sortObjectsByKey = function(arr, key, opt_compareFn) { |
| var compare = opt_compareFn || goog.array.defaultCompare; |
| goog.array.sort(arr, function(a, b) { |
| return compare(a[key], b[key]) |
| }) |
| }; |
| goog.array.isSorted = function(arr, opt_compareFn, opt_strict) { |
| for(var compare = opt_compareFn || goog.array.defaultCompare, i = 1;i < arr.length;i++) { |
| var compareResult = compare(arr[i - 1], arr[i]); |
| if(compareResult > 0 || compareResult == 0 && opt_strict) { |
| return false |
| } |
| } |
| return true |
| }; |
| goog.array.equals = function(arr1, arr2, opt_equalsFn) { |
| if(!goog.isArrayLike(arr1) || !goog.isArrayLike(arr2) || arr1.length != arr2.length) { |
| return false |
| } |
| for(var l = arr1.length, equalsFn = opt_equalsFn || goog.array.defaultCompareEquality, i = 0;i < l;i++) { |
| if(!equalsFn(arr1[i], arr2[i])) { |
| return false |
| } |
| } |
| return true |
| }; |
| goog.array.compare = function(arr1, arr2, opt_equalsFn) { |
| return goog.array.equals(arr1, arr2, opt_equalsFn) |
| }; |
| goog.array.defaultCompare = function(a, b) { |
| return a > b ? 1 : a < b ? -1 : 0 |
| }; |
| goog.array.defaultCompareEquality = function(a, b) { |
| return a === b |
| }; |
| goog.array.binaryInsert = function(array, value, opt_compareFn) { |
| var index = goog.array.binarySearch(array, value, opt_compareFn); |
| if(index < 0) { |
| goog.array.insertAt(array, value, -(index + 1)); |
| return true |
| } |
| return false |
| }; |
| goog.array.binaryRemove = function(array, value, opt_compareFn) { |
| var index = goog.array.binarySearch(array, value, opt_compareFn); |
| return index >= 0 ? goog.array.removeAt(array, index) : false |
| }; |
| goog.array.bucket = function(array, sorter) { |
| for(var buckets = {}, i = 0;i < array.length;i++) { |
| var value = array[i], key = sorter(value, i, array); |
| if(goog.isDef(key)) { |
| var bucket = buckets[key] || (buckets[key] = []); |
| bucket.push(value) |
| } |
| } |
| return buckets |
| }; |
| goog.array.repeat = function(value, n) { |
| for(var array = [], i = 0;i < n;i++) { |
| array[i] = value |
| } |
| return array |
| }; |
| goog.array.flatten = function() { |
| for(var result = [], i = 0;i < arguments.length;i++) { |
| var element = arguments[i]; |
| goog.isArray(element) ? result.push.apply(result, goog.array.flatten.apply(null, element)) : result.push(element) |
| } |
| return result |
| }; |
| goog.array.rotate = function(array, n) { |
| goog.asserts.assert(array.length != null); |
| if(array.length) { |
| n %= array.length; |
| if(n > 0) { |
| goog.array.ARRAY_PROTOTYPE_.unshift.apply(array, array.splice(-n, n)) |
| }else { |
| n < 0 && goog.array.ARRAY_PROTOTYPE_.push.apply(array, array.splice(0, -n)) |
| } |
| } |
| return array |
| }; |
| goog.array.zip = function() { |
| if(!arguments.length) { |
| return[] |
| } |
| for(var result = [], i = 0;;i++) { |
| for(var value = [], j = 0;j < arguments.length;j++) { |
| var arr = arguments[j]; |
| if(i >= arr.length) { |
| return result |
| } |
| value.push(arr[i]) |
| } |
| result.push(value) |
| } |
| }; |
| goog.array.shuffle = function(arr, opt_randFn) { |
| for(var randFn = opt_randFn || Math.random, i = arr.length - 1;i > 0;i--) { |
| var j = Math.floor(randFn() * (i + 1)), tmp = arr[i]; |
| arr[i] = arr[j]; |
| arr[j] = tmp |
| } |
| }; |
| goog.math = {}; |
| goog.math.Coordinate = function(opt_x, opt_y) { |
| this.x = goog.isDef(opt_x) ? opt_x : 0; |
| this.y = goog.isDef(opt_y) ? opt_y : 0 |
| }; |
| goog.math.Coordinate.prototype.clone = function() { |
| return new goog.math.Coordinate(this.x, this.y) |
| }; |
| if(goog.DEBUG) { |
| goog.math.Coordinate.prototype.toString = function() { |
| return"(" + this.x + ", " + this.y + ")" |
| } |
| } |
| goog.math.Coordinate.equals = function(a, b) { |
| if(a == b) { |
| return true |
| } |
| if(!a || !b) { |
| return false |
| } |
| return a.x == b.x && a.y == b.y |
| }; |
| goog.math.Coordinate.distance = function(a, b) { |
| var dx = a.x - b.x, dy = a.y - b.y; |
| return Math.sqrt(dx * dx + dy * dy) |
| }; |
| goog.math.Coordinate.squaredDistance = function(a, b) { |
| var dx = a.x - b.x, dy = a.y - b.y; |
| return dx * dx + dy * dy |
| }; |
| goog.math.Coordinate.difference = function(a, b) { |
| return new goog.math.Coordinate(a.x - b.x, a.y - b.y) |
| }; |
| goog.math.Coordinate.sum = function(a, b) { |
| return new goog.math.Coordinate(a.x + b.x, a.y + b.y) |
| }; |
| goog.math.Size = function(width, height) { |
| this.width = width; |
| this.height = height |
| }; |
| goog.math.Size.equals = function(a, b) { |
| if(a == b) { |
| return true |
| } |
| if(!a || !b) { |
| return false |
| } |
| return a.width == b.width && a.height == b.height |
| }; |
| goog.math.Size.prototype.clone = function() { |
| return new goog.math.Size(this.width, this.height) |
| }; |
| if(goog.DEBUG) { |
| goog.math.Size.prototype.toString = function() { |
| return"(" + this.width + " x " + this.height + ")" |
| } |
| } |
| goog.math.Size.prototype.area = function() { |
| return this.width * this.height |
| }; |
| goog.math.Size.prototype.isEmpty = function() { |
| return!this.area() |
| }; |
| goog.math.Size.prototype.ceil = function() { |
| this.width = Math.ceil(this.width); |
| this.height = Math.ceil(this.height); |
| return this |
| }; |
| goog.math.Size.prototype.floor = function() { |
| this.width = Math.floor(this.width); |
| this.height = Math.floor(this.height); |
| return this |
| }; |
| goog.math.Size.prototype.round = function() { |
| this.width = Math.round(this.width); |
| this.height = Math.round(this.height); |
| return this |
| }; |
| goog.math.Size.prototype.scale = function(s) { |
| this.width *= s; |
| this.height *= s; |
| return this |
| }; |
| goog.object = {}; |
| goog.object.forEach = function(obj, f, opt_obj) { |
| for(var key in obj) { |
| f.call(opt_obj, obj[key], key, obj) |
| } |
| }; |
| goog.object.filter = function(obj, f, opt_obj) { |
| var res = {}, key; |
| for(key in obj) { |
| if(f.call(opt_obj, obj[key], key, obj)) { |
| res[key] = obj[key] |
| } |
| } |
| return res |
| }; |
| goog.object.map = function(obj, f, opt_obj) { |
| var res = {}, key; |
| for(key in obj) { |
| res[key] = f.call(opt_obj, obj[key], key, obj) |
| } |
| return res |
| }; |
| goog.object.some = function(obj, f, opt_obj) { |
| for(var key in obj) { |
| if(f.call(opt_obj, obj[key], key, obj)) { |
| return true |
| } |
| } |
| return false |
| }; |
| goog.object.every = function(obj, f, opt_obj) { |
| for(var key in obj) { |
| if(!f.call(opt_obj, obj[key], key, obj)) { |
| return false |
| } |
| } |
| return true |
| }; |
| goog.object.getCount = function(obj) { |
| var rv = 0, key; |
| for(key in obj) { |
| rv++ |
| } |
| return rv |
| }; |
| goog.object.getAnyKey = function(obj) { |
| for(var key in obj) { |
| return key |
| } |
| }; |
| goog.object.getAnyValue = function(obj) { |
| for(var key in obj) { |
| return obj[key] |
| } |
| }; |
| goog.object.contains = function(obj, val) { |
| return goog.object.containsValue(obj, val) |
| }; |
| goog.object.getValues = function(obj) { |
| var res = [], i = 0, key; |
| for(key in obj) { |
| res[i++] = obj[key] |
| } |
| return res |
| }; |
| goog.object.getKeys = function(obj) { |
| var res = [], i = 0, key; |
| for(key in obj) { |
| res[i++] = key |
| } |
| return res |
| }; |
| goog.object.getValueByKeys = function(obj, var_args) { |
| for(var isArrayLike = goog.isArrayLike(var_args), keys = isArrayLike ? var_args : arguments, i = isArrayLike ? 0 : 1;i < keys.length;i++) { |
| obj = obj[keys[i]]; |
| if(!goog.isDef(obj)) { |
| break |
| } |
| } |
| return obj |
| }; |
| goog.object.containsKey = function(obj, key) { |
| return key in obj |
| }; |
| goog.object.containsValue = function(obj, val) { |
| for(var key in obj) { |
| if(obj[key] == val) { |
| return true |
| } |
| } |
| return false |
| }; |
| goog.object.findKey = function(obj, f, opt_this) { |
| for(var key in obj) { |
| if(f.call(opt_this, obj[key], key, obj)) { |
| return key |
| } |
| } |
| }; |
| goog.object.findValue = function(obj, f, opt_this) { |
| var key = goog.object.findKey(obj, f, opt_this); |
| return key && obj[key] |
| }; |
| goog.object.isEmpty = function(obj) { |
| for(var key in obj) { |
| return false |
| } |
| return true |
| }; |
| goog.object.clear = function(obj) { |
| for(var i in obj) { |
| delete obj[i] |
| } |
| }; |
| goog.object.remove = function(obj, key) { |
| var rv; |
| if(rv = key in obj) { |
| delete obj[key] |
| } |
| return rv |
| }; |
| goog.object.add = function(obj, key, val) { |
| if(key in obj) { |
| throw Error('The object already contains the key "' + key + '"'); |
| } |
| goog.object.set(obj, key, val) |
| }; |
| goog.object.get = function(obj, key, opt_val) { |
| if(key in obj) { |
| return obj[key] |
| } |
| return opt_val |
| }; |
| goog.object.set = function(obj, key, value) { |
| obj[key] = value |
| }; |
| goog.object.setIfUndefined = function(obj, key, value) { |
| return key in obj ? obj[key] : obj[key] = value |
| }; |
| goog.object.clone = function(obj) { |
| var res = {}, key; |
| for(key in obj) { |
| res[key] = obj[key] |
| } |
| return res |
| }; |
| goog.object.transpose = function(obj) { |
| var transposed = {}, key; |
| for(key in obj) { |
| transposed[obj[key]] = key |
| } |
| return transposed |
| }; |
| goog.object.PROTOTYPE_FIELDS_ = ["constructor", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString", "toString", "valueOf"]; |
| goog.object.extend = function(target) { |
| for(var key, source, i = 1;i < arguments.length;i++) { |
| source = arguments[i]; |
| for(key in source) { |
| target[key] = source[key] |
| } |
| for(var j = 0;j < goog.object.PROTOTYPE_FIELDS_.length;j++) { |
| key = goog.object.PROTOTYPE_FIELDS_[j]; |
| if(Object.prototype.hasOwnProperty.call(source, key)) { |
| target[key] = source[key] |
| } |
| } |
| } |
| }; |
| goog.object.create = function() { |
| var argLength = arguments.length; |
| if(argLength == 1 && goog.isArray(arguments[0])) { |
| return goog.object.create.apply(null, arguments[0]) |
| } |
| if(argLength % 2) { |
| throw Error("Uneven number of arguments"); |
| } |
| for(var rv = {}, i = 0;i < argLength;i += 2) { |
| rv[arguments[i]] = arguments[i + 1] |
| } |
| return rv |
| }; |
| goog.object.createSet = function() { |
| var argLength = arguments.length; |
| if(argLength == 1 && goog.isArray(arguments[0])) { |
| return goog.object.createSet.apply(null, arguments[0]) |
| } |
| for(var rv = {}, i = 0;i < argLength;i++) { |
| rv[arguments[i]] = true |
| } |
| return rv |
| }; |
| goog.userAgent = {}; |
| goog.userAgent.ASSUME_IE = false; |
| goog.userAgent.ASSUME_GECKO = false; |
| goog.userAgent.ASSUME_WEBKIT = false; |
| goog.userAgent.ASSUME_MOBILE_WEBKIT = false; |
| goog.userAgent.ASSUME_OPERA = false; |
| goog.userAgent.BROWSER_KNOWN_ = goog.userAgent.ASSUME_IE || goog.userAgent.ASSUME_GECKO || goog.userAgent.ASSUME_MOBILE_WEBKIT || goog.userAgent.ASSUME_WEBKIT || goog.userAgent.ASSUME_OPERA; |
| goog.userAgent.getUserAgentString = function() { |
| return goog.global.navigator ? goog.global.navigator.userAgent : null |
| }; |
| goog.userAgent.getNavigator = function() { |
| return goog.global.navigator |
| }; |
| goog.userAgent.init_ = function() { |
| goog.userAgent.detectedOpera_ = false; |
| goog.userAgent.detectedIe_ = false; |
| goog.userAgent.detectedWebkit_ = false; |
| goog.userAgent.detectedMobile_ = false; |
| goog.userAgent.detectedGecko_ = false; |
| var ua; |
| if(!goog.userAgent.BROWSER_KNOWN_ && (ua = goog.userAgent.getUserAgentString())) { |
| var navigator = goog.userAgent.getNavigator(); |
| goog.userAgent.detectedOpera_ = ua.indexOf("Opera") == 0; |
| goog.userAgent.detectedIe_ = !goog.userAgent.detectedOpera_ && ua.indexOf("MSIE") != -1; |
| goog.userAgent.detectedWebkit_ = !goog.userAgent.detectedOpera_ && ua.indexOf("WebKit") != -1; |
| goog.userAgent.detectedMobile_ = goog.userAgent.detectedWebkit_ && ua.indexOf("Mobile") != -1; |
| goog.userAgent.detectedGecko_ = !goog.userAgent.detectedOpera_ && !goog.userAgent.detectedWebkit_ && navigator.product == "Gecko" |
| } |
| }; |
| goog.userAgent.BROWSER_KNOWN_ || goog.userAgent.init_(); |
| goog.userAgent.OPERA = goog.userAgent.BROWSER_KNOWN_ ? goog.userAgent.ASSUME_OPERA : goog.userAgent.detectedOpera_; |
| goog.userAgent.IE = goog.userAgent.BROWSER_KNOWN_ ? goog.userAgent.ASSUME_IE : goog.userAgent.detectedIe_; |
| goog.userAgent.GECKO = goog.userAgent.BROWSER_KNOWN_ ? goog.userAgent.ASSUME_GECKO : goog.userAgent.detectedGecko_; |
| goog.userAgent.WEBKIT = goog.userAgent.BROWSER_KNOWN_ ? goog.userAgent.ASSUME_WEBKIT || goog.userAgent.ASSUME_MOBILE_WEBKIT : goog.userAgent.detectedWebkit_; |
| goog.userAgent.MOBILE = goog.userAgent.ASSUME_MOBILE_WEBKIT || goog.userAgent.detectedMobile_; |
| goog.userAgent.SAFARI = goog.userAgent.WEBKIT; |
| goog.userAgent.determinePlatform_ = function() { |
| var navigator = goog.userAgent.getNavigator(); |
| return navigator && navigator.platform || "" |
| }; |
| goog.userAgent.PLATFORM = goog.userAgent.determinePlatform_(); |
| goog.userAgent.ASSUME_MAC = false; |
| goog.userAgent.ASSUME_WINDOWS = false; |
| goog.userAgent.ASSUME_LINUX = false; |
| goog.userAgent.ASSUME_X11 = false; |
| goog.userAgent.PLATFORM_KNOWN_ = goog.userAgent.ASSUME_MAC || goog.userAgent.ASSUME_WINDOWS || goog.userAgent.ASSUME_LINUX || goog.userAgent.ASSUME_X11; |
| goog.userAgent.initPlatform_ = function() { |
| goog.userAgent.detectedMac_ = goog.string.contains(goog.userAgent.PLATFORM, "Mac"); |
| goog.userAgent.detectedWindows_ = goog.string.contains(goog.userAgent.PLATFORM, "Win"); |
| goog.userAgent.detectedLinux_ = goog.string.contains(goog.userAgent.PLATFORM, "Linux"); |
| goog.userAgent.detectedX11_ = !!goog.userAgent.getNavigator() && goog.string.contains(goog.userAgent.getNavigator().appVersion || "", "X11") |
| }; |
| goog.userAgent.PLATFORM_KNOWN_ || goog.userAgent.initPlatform_(); |
| goog.userAgent.MAC = goog.userAgent.PLATFORM_KNOWN_ ? goog.userAgent.ASSUME_MAC : goog.userAgent.detectedMac_; |
| goog.userAgent.WINDOWS = goog.userAgent.PLATFORM_KNOWN_ ? goog.userAgent.ASSUME_WINDOWS : goog.userAgent.detectedWindows_; |
| goog.userAgent.LINUX = goog.userAgent.PLATFORM_KNOWN_ ? goog.userAgent.ASSUME_LINUX : goog.userAgent.detectedLinux_; |
| goog.userAgent.X11 = goog.userAgent.PLATFORM_KNOWN_ ? goog.userAgent.ASSUME_X11 : goog.userAgent.detectedX11_; |
| goog.userAgent.determineVersion_ = function() { |
| var version = "", re; |
| if(goog.userAgent.OPERA && goog.global.opera) { |
| var operaVersion = goog.global.opera.version; |
| version = typeof operaVersion == "function" ? operaVersion() : operaVersion |
| }else { |
| if(goog.userAgent.GECKO) { |
| re = /rv\:([^\);]+)(\)|;)/ |
| }else { |
| if(goog.userAgent.IE) { |
| re = /MSIE\s+([^\);]+)(\)|;)/ |
| }else { |
| if(goog.userAgent.WEBKIT) { |
| re = /WebKit\/(\S+)/ |
| } |
| } |
| } |
| if(re) { |
| var arr = re.exec(goog.userAgent.getUserAgentString()); |
| version = arr ? arr[1] : "" |
| } |
| } |
| if(goog.userAgent.IE) { |
| var docMode = goog.userAgent.getDocumentMode_(); |
| if(docMode > parseFloat(version)) { |
| return String(docMode) |
| } |
| } |
| return version |
| }; |
| goog.userAgent.getDocumentMode_ = function() { |
| var doc = goog.global.document; |
| return doc ? doc.documentMode : undefined |
| }; |
| goog.userAgent.VERSION = goog.userAgent.determineVersion_(); |
| goog.userAgent.compare = function(v1, v2) { |
| return goog.string.compareVersions(v1, v2) |
| }; |
| goog.userAgent.isVersionCache_ = {}; |
| goog.userAgent.isVersion = function(version) { |
| return goog.userAgent.isVersionCache_[version] || (goog.userAgent.isVersionCache_[version] = goog.string.compareVersions(goog.userAgent.VERSION, version) >= 0) |
| }; |
| goog.dom = {}; |
| goog.dom.BrowserFeature = {CAN_ADD_NAME_OR_TYPE_ATTRIBUTES:!goog.userAgent.IE || goog.userAgent.isVersion("9"), CAN_USE_CHILDREN_ATTRIBUTE:!goog.userAgent.GECKO && !goog.userAgent.IE || goog.userAgent.IE && goog.userAgent.isVersion("9") || goog.userAgent.GECKO && goog.userAgent.isVersion("3.5"), CAN_USE_INNER_TEXT:goog.userAgent.IE && !goog.userAgent.isVersion("9"), INNER_HTML_NEEDS_SCOPED_ELEMENT:goog.userAgent.IE}; |
| goog.dom.classes = {}; |
| goog.dom.classes.set = function(element, className) { |
| element.className = className |
| }; |
| goog.dom.classes.get = function(element) { |
| var className = element.className; |
| return className && typeof className.split == "function" ? className.split(/\s+/) : [] |
| }; |
| goog.dom.classes.add = function(element) { |
| var classes = goog.dom.classes.get(element), args = goog.array.slice(arguments, 1), b = goog.dom.classes.add_(classes, args); |
| element.className = classes.join(" "); |
| return b |
| }; |
| goog.dom.classes.remove = function(element) { |
| var classes = goog.dom.classes.get(element), args = goog.array.slice(arguments, 1), b = goog.dom.classes.remove_(classes, args); |
| element.className = classes.join(" "); |
| return b |
| }; |
| goog.dom.classes.add_ = function(classes, args) { |
| for(var rv = 0, i = 0;i < args.length;i++) { |
| if(!goog.array.contains(classes, args[i])) { |
| classes.push(args[i]); |
| rv++ |
| } |
| } |
| return rv == args.length |
| }; |
| goog.dom.classes.remove_ = function(classes, args) { |
| for(var rv = 0, i = 0;i < classes.length;i++) { |
| if(goog.array.contains(args, classes[i])) { |
| goog.array.splice(classes, i--, 1); |
| rv++ |
| } |
| } |
| return rv == args.length |
| }; |
| goog.dom.classes.swap = function(element, fromClass, toClass) { |
| for(var classes = goog.dom.classes.get(element), removed = false, i = 0;i < classes.length;i++) { |
| if(classes[i] == fromClass) { |
| goog.array.splice(classes, i--, 1); |
| removed = true |
| } |
| } |
| if(removed) { |
| classes.push(toClass); |
| element.className = classes.join(" ") |
| } |
| return removed |
| }; |
| goog.dom.classes.addRemove = function(element, classesToRemove, classesToAdd) { |
| var classes = goog.dom.classes.get(element); |
| if(goog.isString(classesToRemove)) { |
| goog.array.remove(classes, classesToRemove) |
| }else { |
| goog.isArray(classesToRemove) && goog.dom.classes.remove_(classes, classesToRemove) |
| } |
| if(goog.isString(classesToAdd) && !goog.array.contains(classes, classesToAdd)) { |
| classes.push(classesToAdd) |
| }else { |
| goog.isArray(classesToAdd) && goog.dom.classes.add_(classes, classesToAdd) |
| } |
| element.className = classes.join(" ") |
| }; |
| goog.dom.classes.has = function(element, className) { |
| return goog.array.contains(goog.dom.classes.get(element), className) |
| }; |
| goog.dom.classes.enable = function(element, className, enabled) { |
| enabled ? goog.dom.classes.add(element, className) : goog.dom.classes.remove(element, className) |
| }; |
| goog.dom.classes.toggle = function(element, className) { |
| var add = !goog.dom.classes.has(element, className); |
| goog.dom.classes.enable(element, className, add); |
| return add |
| }; |
| goog.dom.TagName = {A:"A", ABBR:"ABBR", ACRONYM:"ACRONYM", ADDRESS:"ADDRESS", APPLET:"APPLET", AREA:"AREA", B:"B", BASE:"BASE", BASEFONT:"BASEFONT", BDO:"BDO", BIG:"BIG", BLOCKQUOTE:"BLOCKQUOTE", BODY:"BODY", BR:"BR", BUTTON:"BUTTON", CANVAS:"CANVAS", CAPTION:"CAPTION", CENTER:"CENTER", CITE:"CITE", CODE:"CODE", COL:"COL", COLGROUP:"COLGROUP", DD:"DD", DEL:"DEL", DFN:"DFN", DIR:"DIR", DIV:"DIV", DL:"DL", DT:"DT", EM:"EM", FIELDSET:"FIELDSET", FONT:"FONT", FORM:"FORM", FRAME:"FRAME", FRAMESET:"FRAMESET", |
| H1:"H1", H2:"H2", H3:"H3", H4:"H4", H5:"H5", H6:"H6", HEAD:"HEAD", HR:"HR", HTML:"HTML", I:"I", IFRAME:"IFRAME", IMG:"IMG", INPUT:"INPUT", INS:"INS", ISINDEX:"ISINDEX", KBD:"KBD", LABEL:"LABEL", LEGEND:"LEGEND", LI:"LI", LINK:"LINK", MAP:"MAP", MENU:"MENU", META:"META", NOFRAMES:"NOFRAMES", NOSCRIPT:"NOSCRIPT", OBJECT:"OBJECT", OL:"OL", OPTGROUP:"OPTGROUP", OPTION:"OPTION", P:"P", PARAM:"PARAM", PRE:"PRE", Q:"Q", S:"S", SAMP:"SAMP", SCRIPT:"SCRIPT", SELECT:"SELECT", SMALL:"SMALL", SPAN:"SPAN", STRIKE:"STRIKE", |
| STRONG:"STRONG", STYLE:"STYLE", SUB:"SUB", SUP:"SUP", TABLE:"TABLE", TBODY:"TBODY", TD:"TD", TEXTAREA:"TEXTAREA", TFOOT:"TFOOT", TH:"TH", THEAD:"THEAD", TITLE:"TITLE", TR:"TR", TT:"TT", U:"U", UL:"UL", VAR:"VAR"}; |
| goog.dom.ASSUME_QUIRKS_MODE = false; |
| goog.dom.ASSUME_STANDARDS_MODE = false; |
| goog.dom.COMPAT_MODE_KNOWN_ = goog.dom.ASSUME_QUIRKS_MODE || goog.dom.ASSUME_STANDARDS_MODE; |
| goog.dom.NodeType = {ELEMENT:1, ATTRIBUTE:2, TEXT:3, CDATA_SECTION:4, ENTITY_REFERENCE:5, ENTITY:6, PROCESSING_INSTRUCTION:7, COMMENT:8, DOCUMENT:9, DOCUMENT_TYPE:10, DOCUMENT_FRAGMENT:11, NOTATION:12}; |
| goog.dom.getDomHelper = function(opt_element) { |
| return opt_element ? new goog.dom.DomHelper(goog.dom.getOwnerDocument(opt_element)) : goog.dom.defaultDomHelper_ || (goog.dom.defaultDomHelper_ = new goog.dom.DomHelper) |
| }; |
| goog.dom.getDocument = function() { |
| return document |
| }; |
| goog.dom.getElement = function(element) { |
| return goog.isString(element) ? document.getElementById(element) : element |
| }; |
| goog.dom.$ = goog.dom.getElement; |
| goog.dom.getElementsByTagNameAndClass = function(opt_tag, opt_class, opt_el) { |
| return goog.dom.getElementsByTagNameAndClass_(document, opt_tag, opt_class, opt_el) |
| }; |
| goog.dom.getElementsByClass = function(className, opt_el) { |
| var parent = opt_el || document; |
| if(goog.dom.canUseQuerySelector_(parent)) { |
| return parent.querySelectorAll("." + className) |
| }else { |
| if(parent.getElementsByClassName) { |
| return parent.getElementsByClassName(className) |
| } |
| } |
| return goog.dom.getElementsByTagNameAndClass_(document, "*", className, opt_el) |
| }; |
| goog.dom.getElementByClass = function(className, opt_el) { |
| var parent = opt_el || document, retVal = null; |
| return(retVal = goog.dom.canUseQuerySelector_(parent) ? parent.querySelector("." + className) : goog.dom.getElementsByClass(className, opt_el)[0]) || null |
| }; |
| goog.dom.canUseQuerySelector_ = function(parent) { |
| return parent.querySelectorAll && parent.querySelector && (!goog.userAgent.WEBKIT || goog.dom.isCss1CompatMode_(document) || goog.userAgent.isVersion("528")) |
| }; |
| goog.dom.getElementsByTagNameAndClass_ = function(doc, opt_tag, opt_class, opt_el) { |
| var parent = opt_el || doc, tagName = opt_tag && opt_tag != "*" ? opt_tag.toUpperCase() : ""; |
| if(goog.dom.canUseQuerySelector_(parent) && (tagName || opt_class)) { |
| var query = tagName + (opt_class ? "." + opt_class : ""); |
| return parent.querySelectorAll(query) |
| } |
| if(opt_class && parent.getElementsByClassName) { |
| var els = parent.getElementsByClassName(opt_class); |
| if(tagName) { |
| for(var arrayLike = {}, len = 0, i = 0, el;el = els[i];i++) { |
| if(tagName == el.nodeName) { |
| arrayLike[len++] = el |
| } |
| } |
| arrayLike.length = len; |
| return arrayLike |
| }else { |
| return els |
| } |
| } |
| els = parent.getElementsByTagName(tagName || "*"); |
| if(opt_class) { |
| arrayLike = {}; |
| for(i = len = 0;el = els[i];i++) { |
| var className = el.className; |
| if(typeof className.split == "function" && goog.array.contains(className.split(/\s+/), opt_class)) { |
| arrayLike[len++] = el |
| } |
| } |
| arrayLike.length = len; |
| return arrayLike |
| }else { |
| return els |
| } |
| }; |
| goog.dom.$$ = goog.dom.getElementsByTagNameAndClass; |
| goog.dom.setProperties = function(element, properties) { |
| goog.object.forEach(properties, function(val, key) { |
| if(key == "style") { |
| element.style.cssText = val |
| }else { |
| if(key == "class") { |
| element.className = val |
| }else { |
| if(key == "for") { |
| element.htmlFor = val |
| }else { |
| if(key in goog.dom.DIRECT_ATTRIBUTE_MAP_) { |
| element.setAttribute(goog.dom.DIRECT_ATTRIBUTE_MAP_[key], val) |
| }else { |
| element[key] = val |
| } |
| } |
| } |
| } |
| }) |
| }; |
| goog.dom.DIRECT_ATTRIBUTE_MAP_ = {cellpadding:"cellPadding", cellspacing:"cellSpacing", colspan:"colSpan", rowspan:"rowSpan", valign:"vAlign", height:"height", width:"width", usemap:"useMap", frameborder:"frameBorder", maxlength:"maxLength", type:"type"}; |
| goog.dom.getViewportSize = function(opt_window) { |
| return goog.dom.getViewportSize_(opt_window || window) |
| }; |
| goog.dom.getViewportSize_ = function(win) { |
| var doc = win.document; |
| if(goog.userAgent.WEBKIT && !goog.userAgent.isVersion("500") && !goog.userAgent.MOBILE) { |
| if(typeof win.innerHeight == "undefined") { |
| win = window |
| } |
| var innerHeight = win.innerHeight, scrollHeight = win.document.documentElement.scrollHeight; |
| if(win == win.top) { |
| if(scrollHeight < innerHeight) { |
| innerHeight -= 15 |
| } |
| } |
| return new goog.math.Size(win.innerWidth, innerHeight) |
| } |
| var el = goog.dom.isCss1CompatMode_(doc) ? doc.documentElement : doc.body; |
| return new goog.math.Size(el.clientWidth, el.clientHeight) |
| }; |
| goog.dom.getDocumentHeight = function() { |
| return goog.dom.getDocumentHeight_(window) |
| }; |
| goog.dom.getDocumentHeight_ = function(win) { |
| var doc = win.document, height = 0; |
| if(doc) { |
| var vh = goog.dom.getViewportSize_(win).height, body = doc.body, docEl = doc.documentElement; |
| if(goog.dom.isCss1CompatMode_(doc) && docEl.scrollHeight) { |
| height = docEl.scrollHeight != vh ? docEl.scrollHeight : docEl.offsetHeight |
| }else { |
| var sh = docEl.scrollHeight, oh = docEl.offsetHeight; |
| if(docEl.clientHeight != oh) { |
| sh = body.scrollHeight; |
| oh = body.offsetHeight |
| } |
| height = sh > vh ? sh > oh ? sh : oh : sh < oh ? sh : oh |
| } |
| } |
| return height |
| }; |
| goog.dom.getPageScroll = function(opt_window) { |
| var win = opt_window || goog.global || window; |
| return goog.dom.getDomHelper(win.document).getDocumentScroll() |
| }; |
| goog.dom.getDocumentScroll = function() { |
| return goog.dom.getDocumentScroll_(document) |
| }; |
| goog.dom.getDocumentScroll_ = function(doc) { |
| var el = goog.dom.getDocumentScrollElement_(doc); |
| return new goog.math.Coordinate(el.scrollLeft, el.scrollTop) |
| }; |
| goog.dom.getDocumentScrollElement = function() { |
| return goog.dom.getDocumentScrollElement_(document) |
| }; |
| goog.dom.getDocumentScrollElement_ = function(doc) { |
| return!goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc) ? doc.documentElement : doc.body |
| }; |
| goog.dom.getWindow = function(opt_doc) { |
| return opt_doc ? goog.dom.getWindow_(opt_doc) : window |
| }; |
| goog.dom.getWindow_ = function(doc) { |
| return doc.parentWindow || doc.defaultView |
| }; |
| goog.dom.createDom = function() { |
| return goog.dom.createDom_(document, arguments) |
| }; |
| goog.dom.createDom_ = function(doc, args) { |
| var tagName = args[0], attributes = args[1]; |
| if(!goog.dom.BrowserFeature.CAN_ADD_NAME_OR_TYPE_ATTRIBUTES && attributes && (attributes.name || attributes.type)) { |
| var tagNameArr = ["<", tagName]; |
| attributes.name && tagNameArr.push(' name="', goog.string.htmlEscape(attributes.name), '"'); |
| if(attributes.type) { |
| tagNameArr.push(' type="', goog.string.htmlEscape(attributes.type), '"'); |
| var clone = {}; |
| goog.object.extend(clone, attributes); |
| attributes = clone; |
| delete attributes.type |
| } |
| tagNameArr.push(">"); |
| tagName = tagNameArr.join("") |
| } |
| var element = doc.createElement(tagName); |
| if(attributes) { |
| if(goog.isString(attributes)) { |
| element.className = attributes |
| }else { |
| goog.isArray(attributes) ? goog.dom.classes.add.apply(null, [element].concat(attributes)) : goog.dom.setProperties(element, attributes) |
| } |
| } |
| args.length > 2 && goog.dom.append_(doc, element, args, 2); |
| return element |
| }; |
| goog.dom.append_ = function(doc, parent, args, startIndex) { |
| function childHandler(child) { |
| if(child) { |
| parent.appendChild(goog.isString(child) ? doc.createTextNode(child) : child) |
| } |
| } |
| for(var i = startIndex;i < args.length;i++) { |
| var arg = args[i]; |
| goog.isArrayLike(arg) && !goog.dom.isNodeLike(arg) ? goog.array.forEach(goog.dom.isNodeList(arg) ? goog.array.clone(arg) : arg, childHandler) : childHandler(arg) |
| } |
| }; |
| goog.dom.$dom = goog.dom.createDom; |
| goog.dom.createElement = function(name) { |
| return document.createElement(name) |
| }; |
| goog.dom.createTextNode = function(content) { |
| return document.createTextNode(content) |
| }; |
| goog.dom.createTable = function(rows, columns, opt_fillWithNbsp) { |
| return goog.dom.createTable_(document, rows, columns, !!opt_fillWithNbsp) |
| }; |
| goog.dom.createTable_ = function(doc, rows, columns, fillWithNbsp) { |
| for(var rowHtml = ["<tr>"], i = 0;i < columns;i++) { |
| rowHtml.push(fillWithNbsp ? "<td> </td>" : "<td></td>") |
| } |
| rowHtml.push("</tr>"); |
| rowHtml = rowHtml.join(""); |
| var totalHtml = ["<table>"]; |
| for(i = 0;i < rows;i++) { |
| totalHtml.push(rowHtml) |
| } |
| totalHtml.push("</table>"); |
| var elem = doc.createElement(goog.dom.TagName.DIV); |
| elem.innerHTML = totalHtml.join(""); |
| return elem.removeChild(elem.firstChild) |
| }; |
| goog.dom.htmlToDocumentFragment = function(htmlString) { |
| return goog.dom.htmlToDocumentFragment_(document, htmlString) |
| }; |
| goog.dom.htmlToDocumentFragment_ = function(doc, htmlString) { |
| var tempDiv = doc.createElement("div"); |
| if(goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT) { |
| tempDiv.innerHTML = "<br>" + htmlString; |
| tempDiv.removeChild(tempDiv.firstChild) |
| }else { |
| tempDiv.innerHTML = htmlString |
| } |
| if(tempDiv.childNodes.length == 1) { |
| return tempDiv.removeChild(tempDiv.firstChild) |
| }else { |
| for(var fragment = doc.createDocumentFragment();tempDiv.firstChild;) { |
| fragment.appendChild(tempDiv.firstChild) |
| } |
| return fragment |
| } |
| }; |
| goog.dom.getCompatMode = function() { |
| return goog.dom.isCss1CompatMode() ? "CSS1Compat" : "BackCompat" |
| }; |
| goog.dom.isCss1CompatMode = function() { |
| return goog.dom.isCss1CompatMode_(document) |
| }; |
| goog.dom.isCss1CompatMode_ = function(doc) { |
| if(goog.dom.COMPAT_MODE_KNOWN_) { |
| return goog.dom.ASSUME_STANDARDS_MODE |
| } |
| return doc.compatMode == "CSS1Compat" |
| }; |
| goog.dom.canHaveChildren = function(node) { |
| if(node.nodeType != goog.dom.NodeType.ELEMENT) { |
| return false |
| } |
| switch(node.tagName) { |
| case goog.dom.TagName.APPLET: |
| ; |
| case goog.dom.TagName.AREA: |
| ; |
| case goog.dom.TagName.BASE: |
| ; |
| case goog.dom.TagName.BR: |
| ; |
| case goog.dom.TagName.COL: |
| ; |
| case goog.dom.TagName.FRAME: |
| ; |
| case goog.dom.TagName.HR: |
| ; |
| case goog.dom.TagName.IMG: |
| ; |
| case goog.dom.TagName.INPUT: |
| ; |
| case goog.dom.TagName.IFRAME: |
| ; |
| case goog.dom.TagName.ISINDEX: |
| ; |
| case goog.dom.TagName.LINK: |
| ; |
| case goog.dom.TagName.NOFRAMES: |
| ; |
| case goog.dom.TagName.NOSCRIPT: |
| ; |
| case goog.dom.TagName.META: |
| ; |
| case goog.dom.TagName.OBJECT: |
| ; |
| case goog.dom.TagName.PARAM: |
| ; |
| case goog.dom.TagName.SCRIPT: |
| ; |
| case goog.dom.TagName.STYLE: |
| return false |
| } |
| return true |
| }; |
| goog.dom.appendChild = function(parent, child) { |
| parent.appendChild(child) |
| }; |
| goog.dom.append = function(parent) { |
| goog.dom.append_(goog.dom.getOwnerDocument(parent), parent, arguments, 1) |
| }; |
| goog.dom.removeChildren = function(node) { |
| for(var child;child = node.firstChild;) { |
| node.removeChild(child) |
| } |
| }; |
| goog.dom.insertSiblingBefore = function(newNode, refNode) { |
| refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode) |
| }; |
| goog.dom.insertSiblingAfter = function(newNode, refNode) { |
| refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode.nextSibling) |
| }; |
| goog.dom.removeNode = function(node) { |
| return node && node.parentNode ? node.parentNode.removeChild(node) : null |
| }; |
| goog.dom.replaceNode = function(newNode, oldNode) { |
| var parent = oldNode.parentNode; |
| parent && parent.replaceChild(newNode, oldNode) |
| }; |
| goog.dom.flattenElement = function(element) { |
| var child, parent = element.parentNode; |
| if(parent && parent.nodeType != goog.dom.NodeType.DOCUMENT_FRAGMENT) { |
| if(element.removeNode) { |
| return element.removeNode(false) |
| }else { |
| for(;child = element.firstChild;) { |
| parent.insertBefore(child, element) |
| } |
| return goog.dom.removeNode(element) |
| } |
| } |
| }; |
| goog.dom.getChildren = function(element) { |
| if(goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE) { |
| return element.children |
| } |
| return goog.array.filter(element.childNodes, function(node) { |
| return node.nodeType == goog.dom.NodeType.ELEMENT |
| }) |
| }; |
| goog.dom.getFirstElementChild = function(node) { |
| if(goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE && node.nodeType == goog.dom.NodeType.ELEMENT) { |
| return node.firstElementChild |
| } |
| return goog.dom.getNextElementNode_(node.firstChild, true) |
| }; |
| goog.dom.getLastElementChild = function(node) { |
| if(goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE && node.nodeType == goog.dom.NodeType.ELEMENT) { |
| return node.lastElementChild |
| } |
| return goog.dom.getNextElementNode_(node.lastChild, false) |
| }; |
| goog.dom.getNextElementSibling = function(node) { |
| if(goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE && node.nodeType == goog.dom.NodeType.ELEMENT) { |
| return node.nextElementSibling |
| } |
| return goog.dom.getNextElementNode_(node.nextSibling, true) |
| }; |
| goog.dom.getPreviousElementSibling = function(node) { |
| if(goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE && node.nodeType == goog.dom.NodeType.ELEMENT) { |
| return node.previousElementSibling |
| } |
| return goog.dom.getNextElementNode_(node.previousSibling, false) |
| }; |
| goog.dom.getNextElementNode_ = function(node, forward) { |
| for(;node && node.nodeType != goog.dom.NodeType.ELEMENT;) { |
| node = forward ? node.nextSibling : node.previousSibling |
| } |
| return node |
| }; |
| goog.dom.getNextNode = function(node) { |
| if(!node) { |
| return null |
| } |
| if(node.firstChild) { |
| return node.firstChild |
| } |
| for(;node && !node.nextSibling;) { |
| node = node.parentNode |
| } |
| return node ? node.nextSibling : null |
| }; |
| goog.dom.getPreviousNode = function(node) { |
| if(!node) { |
| return null |
| } |
| if(!node.previousSibling) { |
| return node.parentNode |
| } |
| for(node = node.previousSibling;node && node.lastChild;) { |
| node = node.lastChild |
| } |
| return node |
| }; |
| goog.dom.isNodeLike = function(obj) { |
| return goog.isObject(obj) && obj.nodeType > 0 |
| }; |
| goog.dom.isWindow = function(obj) { |
| return goog.isObject(obj) && obj.window == obj |
| }; |
| goog.dom.contains = function(parent, descendant) { |
| if(parent.contains && descendant.nodeType == goog.dom.NodeType.ELEMENT) { |
| return parent == descendant || parent.contains(descendant) |
| } |
| if(typeof parent.compareDocumentPosition != "undefined") { |
| return parent == descendant || Boolean(parent.compareDocumentPosition(descendant) & 16) |
| } |
| for(;descendant && parent != descendant;) { |
| descendant = descendant.parentNode |
| } |
| return descendant == parent |
| }; |
| goog.dom.compareNodeOrder = function(node1, node2) { |
| if(node1 == node2) { |
| return 0 |
| } |
| if(node1.compareDocumentPosition) { |
| return node1.compareDocumentPosition(node2) & 2 ? 1 : -1 |
| } |
| if("sourceIndex" in node1 || node1.parentNode && "sourceIndex" in node1.parentNode) { |
| var isElement1 = node1.nodeType == goog.dom.NodeType.ELEMENT, isElement2 = node2.nodeType == goog.dom.NodeType.ELEMENT; |
| if(isElement1 && isElement2) { |
| return node1.sourceIndex - node2.sourceIndex |
| }else { |
| var parent1 = node1.parentNode, parent2 = node2.parentNode; |
| if(parent1 == parent2) { |
| return goog.dom.compareSiblingOrder_(node1, node2) |
| } |
| if(!isElement1 && goog.dom.contains(parent1, node2)) { |
| return-1 * goog.dom.compareParentsDescendantNodeIe_(node1, node2) |
| } |
| if(!isElement2 && goog.dom.contains(parent2, node1)) { |
| return goog.dom.compareParentsDescendantNodeIe_(node2, node1) |
| } |
| return(isElement1 ? node1.sourceIndex : parent1.sourceIndex) - (isElement2 ? node2.sourceIndex : parent2.sourceIndex) |
| } |
| } |
| var doc = goog.dom.getOwnerDocument(node1), range1, range2; |
| range1 = doc.createRange(); |
| range1.selectNode(node1); |
| range1.collapse(true); |
| range2 = doc.createRange(); |
| range2.selectNode(node2); |
| range2.collapse(true); |
| return range1.compareBoundaryPoints(goog.global.Range.START_TO_END, range2) |
| }; |
| goog.dom.compareParentsDescendantNodeIe_ = function(textNode, node) { |
| var parent = textNode.parentNode; |
| if(parent == node) { |
| return-1 |
| } |
| for(var sibling = node;sibling.parentNode != parent;) { |
| sibling = sibling.parentNode |
| } |
| return goog.dom.compareSiblingOrder_(sibling, textNode) |
| }; |
| goog.dom.compareSiblingOrder_ = function(node1, node2) { |
| for(var s = node2;s = s.previousSibling;) { |
| if(s == node1) { |
| return-1 |
| } |
| } |
| return 1 |
| }; |
| goog.dom.findCommonAncestor = function() { |
| var i, count = arguments.length; |
| if(count) { |
| if(count == 1) { |
| return arguments[0] |
| } |
| }else { |
| return null |
| } |
| var paths = [], minLength = Infinity; |
| for(i = 0;i < count;i++) { |
| for(var ancestors = [], node = arguments[i];node;) { |
| ancestors.unshift(node); |
| node = node.parentNode |
| } |
| paths.push(ancestors); |
| minLength = Math.min(minLength, ancestors.length) |
| } |
| var output = null; |
| for(i = 0;i < minLength;i++) { |
| for(var first = paths[0][i], j = 1;j < count;j++) { |
| if(first != paths[j][i]) { |
| return output |
| } |
| } |
| output = first |
| } |
| return output |
| }; |
| goog.dom.getOwnerDocument = function(node) { |
| return node.nodeType == goog.dom.NodeType.DOCUMENT ? node : node.ownerDocument || node.document |
| }; |
| goog.dom.getFrameContentDocument = function(frame) { |
| var doc; |
| return doc = goog.userAgent.WEBKIT ? frame.document || frame.contentWindow.document : frame.contentDocument || frame.contentWindow.document |
| }; |
| goog.dom.getFrameContentWindow = function(frame) { |
| return frame.contentWindow || goog.dom.getWindow_(goog.dom.getFrameContentDocument(frame)) |
| }; |
| goog.dom.setTextContent = function(element, text) { |
| if("textContent" in element) { |
| element.textContent = text |
| }else { |
| if(element.firstChild && element.firstChild.nodeType == goog.dom.NodeType.TEXT) { |
| for(;element.lastChild != element.firstChild;) { |
| element.removeChild(element.lastChild) |
| } |
| element.firstChild.data = text |
| }else { |
| goog.dom.removeChildren(element); |
| var doc = goog.dom.getOwnerDocument(element); |
| element.appendChild(doc.createTextNode(text)) |
| } |
| } |
| }; |
| goog.dom.getOuterHtml = function(element) { |
| if("outerHTML" in element) { |
| return element.outerHTML |
| }else { |
| var doc = goog.dom.getOwnerDocument(element), div = doc.createElement("div"); |
| div.appendChild(element.cloneNode(true)); |
| return div.innerHTML |
| } |
| }; |
| goog.dom.findNode = function(root, p) { |
| var rv = [], found = goog.dom.findNodes_(root, p, rv, true); |
| return found ? rv[0] : undefined |
| }; |
| goog.dom.findNodes = function(root, p) { |
| var rv = []; |
| goog.dom.findNodes_(root, p, rv, false); |
| return rv |
| }; |
| goog.dom.findNodes_ = function(root, p, rv, findOne) { |
| if(root != null) { |
| for(var i = 0, child;child = root.childNodes[i];i++) { |
| if(p(child)) { |
| rv.push(child); |
| if(findOne) { |
| return true |
| } |
| } |
| if(goog.dom.findNodes_(child, p, rv, findOne)) { |
| return true |
| } |
| } |
| } |
| return false |
| }; |
| goog.dom.TAGS_TO_IGNORE_ = {SCRIPT:1, STYLE:1, HEAD:1, IFRAME:1, OBJECT:1}; |
| goog.dom.PREDEFINED_TAG_VALUES_ = {IMG:" ", BR:"\n"}; |
| goog.dom.isFocusableTabIndex = function(element) { |
| var attrNode = element.getAttributeNode("tabindex"); |
| if(attrNode && attrNode.specified) { |
| var index = element.tabIndex; |
| return goog.isNumber(index) && index >= 0 |
| } |
| return false |
| }; |
| goog.dom.setFocusableTabIndex = function(element, enable) { |
| if(enable) { |
| element.tabIndex = 0 |
| }else { |
| element.removeAttribute("tabIndex") |
| } |
| }; |
| goog.dom.getTextContent = function(node) { |
| var textContent; |
| if(goog.dom.BrowserFeature.CAN_USE_INNER_TEXT && "innerText" in node) { |
| textContent = goog.string.canonicalizeNewlines(node.innerText) |
| }else { |
| var buf = []; |
| goog.dom.getTextContent_(node, buf, true); |
| textContent = buf.join("") |
| } |
| textContent = textContent.replace(/ \xAD /g, " ").replace(/\xAD/g, ""); |
| textContent = textContent.replace(/\u200B/g, ""); |
| goog.userAgent.IE || (textContent = textContent.replace(/ +/g, " ")); |
| if(textContent != " ") { |
| textContent = textContent.replace(/^\s*/, "") |
| } |
| return textContent |
| }; |
| goog.dom.getRawTextContent = function(node) { |
| var buf = []; |
| goog.dom.getTextContent_(node, buf, false); |
| return buf.join("") |
| }; |
| goog.dom.getTextContent_ = function(node, buf, normalizeWhitespace) { |
| if(!(node.nodeName in goog.dom.TAGS_TO_IGNORE_)) { |
| if(node.nodeType == goog.dom.NodeType.TEXT) { |
| normalizeWhitespace ? buf.push(String(node.nodeValue).replace(/(\r\n|\r|\n)/g, "")) : buf.push(node.nodeValue) |
| }else { |
| if(node.nodeName in goog.dom.PREDEFINED_TAG_VALUES_) { |
| buf.push(goog.dom.PREDEFINED_TAG_VALUES_[node.nodeName]) |
| }else { |
| for(var child = node.firstChild;child;) { |
| goog.dom.getTextContent_(child, buf, normalizeWhitespace); |
| child = child.nextSibling |
| } |
| } |
| } |
| } |
| }; |
| goog.dom.getNodeTextLength = function(node) { |
| return goog.dom.getTextContent(node).length |
| }; |
| goog.dom.getNodeTextOffset = function(node, opt_offsetParent) { |
| for(var root = opt_offsetParent || goog.dom.getOwnerDocument(node).body, buf = [];node && node != root;) { |
| for(var cur = node;cur = cur.previousSibling;) { |
| buf.unshift(goog.dom.getTextContent(cur)) |
| } |
| node = node.parentNode |
| } |
| return goog.string.trimLeft(buf.join("")).replace(/ +/g, " ").length |
| }; |
| goog.dom.getNodeAtOffset = function(parent, offset, opt_result) { |
| for(var stack = [parent], pos = 0, cur;stack.length > 0 && pos < offset;) { |
| cur = stack.pop(); |
| if(!(cur.nodeName in goog.dom.TAGS_TO_IGNORE_)) { |
| if(cur.nodeType == goog.dom.NodeType.TEXT) { |
| var text = cur.nodeValue.replace(/(\r\n|\r|\n)/g, "").replace(/ +/g, " "); |
| pos += text.length |
| }else { |
| if(cur.nodeName in goog.dom.PREDEFINED_TAG_VALUES_) { |
| pos += goog.dom.PREDEFINED_TAG_VALUES_[cur.nodeName].length |
| }else { |
| for(var i = cur.childNodes.length - 1;i >= 0;i--) { |
| stack.push(cur.childNodes[i]) |
| } |
| } |
| } |
| } |
| } |
| if(goog.isObject(opt_result)) { |
| opt_result.remainder = cur ? cur.nodeValue.length + offset - pos - 1 : 0; |
| opt_result.node = cur |
| } |
| return cur |
| }; |
| goog.dom.isNodeList = function(val) { |
| if(val && typeof val.length == "number") { |
| if(goog.isObject(val)) { |
| return typeof val.item == "function" || typeof val.item == "string" |
| }else { |
| if(goog.isFunction(val)) { |
| return typeof val.item == "function" |
| } |
| } |
| } |
| return false |
| }; |
| goog.dom.getAncestorByTagNameAndClass = function(element, opt_tag, opt_class) { |
| var tagName = opt_tag ? opt_tag.toUpperCase() : null; |
| return goog.dom.getAncestor(element, function(node) { |
| return(!tagName || node.nodeName == tagName) && (!opt_class || goog.dom.classes.has(node, opt_class)) |
| }, true) |
| }; |
| goog.dom.getAncestorByClass = function(element, opt_class) { |
| return goog.dom.getAncestorByTagNameAndClass(element, null, opt_class) |
| }; |
| goog.dom.getAncestor = function(element, matcher, opt_includeNode, opt_maxSearchSteps) { |
| if(!opt_includeNode) { |
| element = element.parentNode |
| } |
| for(var ignoreSearchSteps = opt_maxSearchSteps == null, steps = 0;element && (ignoreSearchSteps || steps <= opt_maxSearchSteps);) { |
| if(matcher(element)) { |
| return element |
| } |
| element = element.parentNode; |
| steps++ |
| } |
| return null |
| }; |
| goog.dom.DomHelper = function(opt_document) { |
| this.document_ = opt_document || goog.global.document || document |
| }; |
| goog.dom.DomHelper.prototype.getDomHelper = goog.dom.getDomHelper; |
| goog.dom.DomHelper.prototype.getDocument = function() { |
| return this.document_ |
| }; |
| goog.dom.DomHelper.prototype.getElement = function(element) { |
| return goog.isString(element) ? this.document_.getElementById(element) : element |
| }; |
| goog.dom.DomHelper.prototype.$ = goog.dom.DomHelper.prototype.getElement; |
| goog.dom.DomHelper.prototype.getElementsByTagNameAndClass = function(opt_tag, opt_class, opt_el) { |
| return goog.dom.getElementsByTagNameAndClass_(this.document_, opt_tag, opt_class, opt_el) |
| }; |
| goog.dom.DomHelper.prototype.getElementsByClass = function(className, opt_el) { |
| var doc = opt_el || this.document_; |
| return goog.dom.getElementsByClass(className, doc) |
| }; |
| goog.dom.DomHelper.prototype.getElementByClass = function(className, opt_el) { |
| var doc = opt_el || this.document_; |
| return goog.dom.getElementByClass(className, doc) |
| }; |
| goog.dom.DomHelper.prototype.$$ = goog.dom.DomHelper.prototype.getElementsByTagNameAndClass; |
| goog.dom.DomHelper.prototype.setProperties = goog.dom.setProperties; |
| goog.dom.DomHelper.prototype.getViewportSize = function(opt_window) { |
| return goog.dom.getViewportSize(opt_window || this.getWindow()) |
| }; |
| goog.dom.DomHelper.prototype.getDocumentHeight = function() { |
| return goog.dom.getDocumentHeight_(this.getWindow()) |
| }; |
| goog.dom.DomHelper.prototype.createDom = function() { |
| return goog.dom.createDom_(this.document_, arguments) |
| }; |
| goog.dom.DomHelper.prototype.$dom = goog.dom.DomHelper.prototype.createDom; |
| goog.dom.DomHelper.prototype.createElement = function(name) { |
| return this.document_.createElement(name) |
| }; |
| goog.dom.DomHelper.prototype.createTextNode = function(content) { |
| return this.document_.createTextNode(content) |
| }; |
| goog.dom.DomHelper.prototype.createTable = function(rows, columns, opt_fillWithNbsp) { |
| return goog.dom.createTable_(this.document_, rows, columns, !!opt_fillWithNbsp) |
| }; |
| goog.dom.DomHelper.prototype.htmlToDocumentFragment = function(htmlString) { |
| return goog.dom.htmlToDocumentFragment_(this.document_, htmlString) |
| }; |
| goog.dom.DomHelper.prototype.getCompatMode = function() { |
| return this.isCss1CompatMode() ? "CSS1Compat" : "BackCompat" |
| }; |
| goog.dom.DomHelper.prototype.isCss1CompatMode = function() { |
| return goog.dom.isCss1CompatMode_(this.document_) |
| }; |
| goog.dom.DomHelper.prototype.getWindow = function() { |
| return goog.dom.getWindow_(this.document_) |
| }; |
| goog.dom.DomHelper.prototype.getDocumentScrollElement = function() { |
| return goog.dom.getDocumentScrollElement_(this.document_) |
| }; |
| goog.dom.DomHelper.prototype.getDocumentScroll = function() { |
| return goog.dom.getDocumentScroll_(this.document_) |
| }; |
| goog.dom.DomHelper.prototype.appendChild = goog.dom.appendChild; |
| goog.dom.DomHelper.prototype.append = goog.dom.append; |
| goog.dom.DomHelper.prototype.removeChildren = goog.dom.removeChildren; |
| goog.dom.DomHelper.prototype.insertSiblingBefore = goog.dom.insertSiblingBefore; |
| goog.dom.DomHelper.prototype.insertSiblingAfter = goog.dom.insertSiblingAfter; |
| goog.dom.DomHelper.prototype.removeNode = goog.dom.removeNode; |
| goog.dom.DomHelper.prototype.replaceNode = goog.dom.replaceNode; |
| goog.dom.DomHelper.prototype.flattenElement = goog.dom.flattenElement; |
| goog.dom.DomHelper.prototype.getFirstElementChild = goog.dom.getFirstElementChild; |
| goog.dom.DomHelper.prototype.getLastElementChild = goog.dom.getLastElementChild; |
| goog.dom.DomHelper.prototype.getNextElementSibling = goog.dom.getNextElementSibling; |
| goog.dom.DomHelper.prototype.getPreviousElementSibling = goog.dom.getPreviousElementSibling; |
| goog.dom.DomHelper.prototype.getNextNode = goog.dom.getNextNode; |
| goog.dom.DomHelper.prototype.getPreviousNode = goog.dom.getPreviousNode; |
| goog.dom.DomHelper.prototype.isNodeLike = goog.dom.isNodeLike; |
| goog.dom.DomHelper.prototype.contains = goog.dom.contains; |
| goog.dom.DomHelper.prototype.getOwnerDocument = goog.dom.getOwnerDocument; |
| goog.dom.DomHelper.prototype.getFrameContentDocument = goog.dom.getFrameContentDocument; |
| goog.dom.DomHelper.prototype.getFrameContentWindow = goog.dom.getFrameContentWindow; |
| goog.dom.DomHelper.prototype.setTextContent = goog.dom.setTextContent; |
| goog.dom.DomHelper.prototype.findNode = goog.dom.findNode; |
| goog.dom.DomHelper.prototype.findNodes = goog.dom.findNodes; |
| goog.dom.DomHelper.prototype.getTextContent = goog.dom.getTextContent; |
| goog.dom.DomHelper.prototype.getNodeTextLength = goog.dom.getNodeTextLength; |
| goog.dom.DomHelper.prototype.getNodeTextOffset = goog.dom.getNodeTextOffset; |
| goog.dom.DomHelper.prototype.getAncestorByTagNameAndClass = goog.dom.getAncestorByTagNameAndClass; |
| goog.dom.DomHelper.prototype.getAncestor = goog.dom.getAncestor; |
| goog.debug.entryPointRegistry = {}; |
| goog.debug.EntryPointMonitor = function() { |
| }; |
| goog.debug.entryPointRegistry.refList_ = []; |
| goog.debug.entryPointRegistry.register = function(callback) { |
| goog.debug.entryPointRegistry.refList_[goog.debug.entryPointRegistry.refList_.length] = callback |
| }; |
| goog.debug.entryPointRegistry.monitorAll = function(monitor) { |
| for(var transformer = goog.bind(monitor.wrap, monitor), i = 0;i < goog.debug.entryPointRegistry.refList_.length;i++) { |
| goog.debug.entryPointRegistry.refList_[i](transformer) |
| } |
| }; |
| goog.debug.entryPointRegistry.unmonitorAllIfPossible = function(monitor) { |
| for(var transformer = goog.bind(monitor.unwrap, monitor), i = 0;i < goog.debug.entryPointRegistry.refList_.length;i++) { |
| goog.debug.entryPointRegistry.refList_[i](transformer) |
| } |
| }; |
| goog.debug.errorHandlerWeakDep = {protectEntryPoint:function(fn) { |
| return fn |
| }}; |
| goog.iter = {}; |
| goog.iter.StopIteration = "StopIteration" in goog.global ? goog.global.StopIteration : Error("StopIteration"); |
| goog.iter.Iterator = function() { |
| }; |
| goog.iter.Iterator.prototype.next = function() { |
| throw goog.iter.StopIteration; |
| }; |
| goog.iter.Iterator.prototype.__iterator__ = function() { |
| return this |
| }; |
| goog.iter.toIterator = function(iterable) { |
| if(iterable instanceof goog.iter.Iterator) { |
| return iterable |
| } |
| if(typeof iterable.__iterator__ == "function") { |
| return iterable.__iterator__(false) |
| } |
| if(goog.isArrayLike(iterable)) { |
| var i = 0, newIter = new goog.iter.Iterator; |
| newIter.next = function() { |
| for(;;) { |
| if(i >= iterable.length) { |
| throw goog.iter.StopIteration; |
| } |
| if(i in iterable) { |
| return iterable[i++] |
| }else { |
| i++ |
| } |
| } |
| }; |
| return newIter |
| } |
| throw Error("Not implemented"); |
| }; |
| goog.iter.forEach = function(iterable, f, opt_obj) { |
| if(goog.isArrayLike(iterable)) { |
| try { |
| goog.array.forEach(iterable, f, opt_obj) |
| }catch(ex) { |
| if(ex !== goog.iter.StopIteration) { |
| throw ex; |
| } |
| } |
| }else { |
| iterable = goog.iter.toIterator(iterable); |
| try { |
| for(;;) { |
| f.call(opt_obj, iterable.next(), undefined, iterable) |
| } |
| }catch(ex$$0) { |
| if(ex$$0 !== goog.iter.StopIteration) { |
| throw ex$$0; |
| } |
| } |
| } |
| }; |
| goog.iter.filter = function(iterable, f, opt_obj) { |
| iterable = goog.iter.toIterator(iterable); |
| var newIter = new goog.iter.Iterator; |
| newIter.next = function() { |
| for(;;) { |
| var val = iterable.next(); |
| if(f.call(opt_obj, val, undefined, iterable)) { |
| return val |
| } |
| } |
| }; |
| return newIter |
| }; |
| goog.iter.range = function(startOrStop, opt_stop, opt_step) { |
| var start = 0, stop = startOrStop, step = opt_step || 1; |
| if(arguments.length > 1) { |
| start = startOrStop; |
| stop = opt_stop |
| } |
| if(step == 0) { |
| throw Error("Range step argument must not be zero"); |
| } |
| var newIter = new goog.iter.Iterator; |
| newIter.next = function() { |
| if(step > 0 && start >= stop || step < 0 && start <= stop) { |
| throw goog.iter.StopIteration; |
| } |
| var rv = start; |
| start += step; |
| return rv |
| }; |
| return newIter |
| }; |
| goog.iter.join = function(iterable, deliminator) { |
| return goog.iter.toArray(iterable).join(deliminator) |
| }; |
| goog.iter.map = function(iterable, f, opt_obj) { |
| iterable = goog.iter.toIterator(iterable); |
| var newIter = new goog.iter.Iterator; |
| newIter.next = function() { |
| for(;;) { |
| var val = iterable.next(); |
| return f.call(opt_obj, val, undefined, iterable) |
| } |
| }; |
| return newIter |
| }; |
| goog.iter.reduce = function(iterable, f, val$$0, opt_obj) { |
| var rval = val$$0; |
| goog.iter.forEach(iterable, function(val) { |
| rval = f.call(opt_obj, rval, val) |
| }); |
| return rval |
| }; |
| goog.iter.some = function(iterable, f, opt_obj) { |
| iterable = goog.iter.toIterator(iterable); |
| try { |
| for(;;) { |
| if(f.call(opt_obj, iterable.next(), undefined, iterable)) { |
| return true |
| } |
| } |
| }catch(ex) { |
| if(ex !== goog.iter.StopIteration) { |
| throw ex; |
| } |
| } |
| return false |
| }; |
| goog.iter.every = function(iterable, f, opt_obj) { |
| iterable = goog.iter.toIterator(iterable); |
| try { |
| for(;;) { |
| if(!f.call(opt_obj, iterable.next(), undefined, iterable)) { |
| return false |
| } |
| } |
| }catch(ex) { |
| if(ex !== goog.iter.StopIteration) { |
| throw ex; |
| } |
| } |
| return true |
| }; |
| goog.iter.chain = function() { |
| var args = arguments, length = args.length, i = 0, newIter = new goog.iter.Iterator; |
| newIter.next = function() { |
| try { |
| if(i >= length) { |
| throw goog.iter.StopIteration; |
| } |
| var current = goog.iter.toIterator(args[i]); |
| return current.next() |
| }catch(ex) { |
| if(ex !== goog.iter.StopIteration || i >= length) { |
| throw ex; |
| }else { |
| i++; |
| return this.next() |
| } |
| } |
| }; |
| return newIter |
| }; |
| goog.iter.dropWhile = function(iterable, f, opt_obj) { |
| iterable = goog.iter.toIterator(iterable); |
| var newIter = new goog.iter.Iterator, dropping = true; |
| newIter.next = function() { |
| for(;;) { |
| var val = iterable.next(); |
| if(!(dropping && f.call(opt_obj, val, undefined, iterable))) { |
| dropping = false; |
| return val |
| } |
| } |
| }; |
| return newIter |
| }; |
| goog.iter.takeWhile = function(iterable, f, opt_obj) { |
| iterable = goog.iter.toIterator(iterable); |
| var newIter = new goog.iter.Iterator, taking = true; |
| newIter.next = function() { |
| for(;;) { |
| if(taking) { |
| var val = iterable.next(); |
| if(f.call(opt_obj, val, undefined, iterable)) { |
| return val |
| }else { |
| taking = false |
| } |
| }else { |
| throw goog.iter.StopIteration; |
| } |
| } |
| }; |
| return newIter |
| }; |
| goog.iter.toArray = function(iterable) { |
| if(goog.isArrayLike(iterable)) { |
| return goog.array.toArray(iterable) |
| } |
| iterable = goog.iter.toIterator(iterable); |
| var array = []; |
| goog.iter.forEach(iterable, function(val) { |
| array.push(val) |
| }); |
| return array |
| }; |
| goog.iter.equals = function(iterable1, iterable2) { |
| iterable1 = goog.iter.toIterator(iterable1); |
| iterable2 = goog.iter.toIterator(iterable2); |
| var b1, b2; |
| try { |
| for(;;) { |
| b1 = b2 = false; |
| var val1 = iterable1.next(); |
| b1 = true; |
| var val2 = iterable2.next(); |
| b2 = true; |
| if(val1 != val2) { |
| break |
| } |
| } |
| }catch(ex) { |
| if(ex !== goog.iter.StopIteration) { |
| throw ex; |
| }else { |
| if(b1 && !b2) { |
| return false |
| } |
| if(!b2) { |
| try { |
| iterable2.next() |
| }catch(ex1) { |
| if(ex1 !== goog.iter.StopIteration) { |
| throw ex1; |
| } |
| return true |
| } |
| } |
| } |
| } |
| return false |
| }; |
| goog.iter.nextOrValue = function(iterable, defaultValue) { |
| try { |
| return goog.iter.toIterator(iterable).next() |
| }catch(e) { |
| if(e != goog.iter.StopIteration) { |
| throw e; |
| } |
| return defaultValue |
| } |
| }; |
| goog.iter.product = function() { |
| var someArrayEmpty = goog.array.some(arguments, function(arr) { |
| return!arr.length |
| }); |
| if(someArrayEmpty || !arguments.length) { |
| return new goog.iter.Iterator |
| } |
| var iter = new goog.iter.Iterator, arrays = arguments, indicies = goog.array.repeat(0, arrays.length); |
| iter.next = function() { |
| if(indicies) { |
| for(var retVal = goog.array.map(indicies, function(valueIndex, arrayIndex) { |
| return arrays[arrayIndex][valueIndex] |
| }), i = indicies.length - 1;i >= 0;i--) { |
| goog.asserts.assert(indicies); |
| if(indicies[i] < arrays[i].length - 1) { |
| indicies[i]++; |
| break |
| } |
| if(i == 0) { |
| indicies = null; |
| break |
| } |
| indicies[i] = 0 |
| } |
| return retVal |
| } |
| throw goog.iter.StopIteration; |
| }; |
| return iter |
| }; |
| goog.structs = {}; |
| goog.structs.getCount = function(col) { |
| if(typeof col.getCount == "function") { |
| return col.getCount() |
| } |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| return col.length |
| } |
| return goog.object.getCount(col) |
| }; |
| goog.structs.getValues = function(col) { |
| if(typeof col.getValues == "function") { |
| return col.getValues() |
| } |
| if(goog.isString(col)) { |
| return col.split("") |
| } |
| if(goog.isArrayLike(col)) { |
| for(var rv = [], l = col.length, i = 0;i < l;i++) { |
| rv.push(col[i]) |
| } |
| return rv |
| } |
| return goog.object.getValues(col) |
| }; |
| goog.structs.getKeys = function(col) { |
| if(typeof col.getKeys == "function") { |
| return col.getKeys() |
| } |
| if(typeof col.getValues != "function") { |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| for(var rv = [], l = col.length, i = 0;i < l;i++) { |
| rv.push(i) |
| } |
| return rv |
| } |
| return goog.object.getKeys(col) |
| } |
| }; |
| goog.structs.contains = function(col, val) { |
| if(typeof col.contains == "function") { |
| return col.contains(val) |
| } |
| if(typeof col.containsValue == "function") { |
| return col.containsValue(val) |
| } |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| return goog.array.contains(col, val) |
| } |
| return goog.object.containsValue(col, val) |
| }; |
| goog.structs.isEmpty = function(col) { |
| if(typeof col.isEmpty == "function") { |
| return col.isEmpty() |
| } |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| return goog.array.isEmpty(col) |
| } |
| return goog.object.isEmpty(col) |
| }; |
| goog.structs.clear = function(col) { |
| if(typeof col.clear == "function") { |
| col.clear() |
| }else { |
| goog.isArrayLike(col) ? goog.array.clear(col) : goog.object.clear(col) |
| } |
| }; |
| goog.structs.forEach = function(col, f, opt_obj) { |
| if(typeof col.forEach == "function") { |
| col.forEach(f, opt_obj) |
| }else { |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| goog.array.forEach(col, f, opt_obj) |
| }else { |
| for(var keys = goog.structs.getKeys(col), values = goog.structs.getValues(col), l = values.length, i = 0;i < l;i++) { |
| f.call(opt_obj, values[i], keys && keys[i], col) |
| } |
| } |
| } |
| }; |
| goog.structs.filter = function(col, f, opt_obj) { |
| if(typeof col.filter == "function") { |
| return col.filter(f, opt_obj) |
| } |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| return goog.array.filter(col, f, opt_obj) |
| } |
| var rv, keys = goog.structs.getKeys(col), values = goog.structs.getValues(col), l = values.length; |
| if(keys) { |
| rv = {}; |
| for(var i = 0;i < l;i++) { |
| if(f.call(opt_obj, values[i], keys[i], col)) { |
| rv[keys[i]] = values[i] |
| } |
| } |
| }else { |
| rv = []; |
| for(i = 0;i < l;i++) { |
| f.call(opt_obj, values[i], undefined, col) && rv.push(values[i]) |
| } |
| } |
| return rv |
| }; |
| goog.structs.map = function(col, f, opt_obj) { |
| if(typeof col.map == "function") { |
| return col.map(f, opt_obj) |
| } |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| return goog.array.map(col, f, opt_obj) |
| } |
| var rv, keys = goog.structs.getKeys(col), values = goog.structs.getValues(col), l = values.length; |
| if(keys) { |
| rv = {}; |
| for(var i = 0;i < l;i++) { |
| rv[keys[i]] = f.call(opt_obj, values[i], keys[i], col) |
| } |
| }else { |
| rv = []; |
| for(i = 0;i < l;i++) { |
| rv[i] = f.call(opt_obj, values[i], undefined, col) |
| } |
| } |
| return rv |
| }; |
| goog.structs.some = function(col, f, opt_obj) { |
| if(typeof col.some == "function") { |
| return col.some(f, opt_obj) |
| } |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| return goog.array.some(col, f, opt_obj) |
| } |
| for(var keys = goog.structs.getKeys(col), values = goog.structs.getValues(col), l = values.length, i = 0;i < l;i++) { |
| if(f.call(opt_obj, values[i], keys && keys[i], col)) { |
| return true |
| } |
| } |
| return false |
| }; |
| goog.structs.every = function(col, f, opt_obj) { |
| if(typeof col.every == "function") { |
| return col.every(f, opt_obj) |
| } |
| if(goog.isArrayLike(col) || goog.isString(col)) { |
| return goog.array.every(col, f, opt_obj) |
| } |
| for(var keys = goog.structs.getKeys(col), values = goog.structs.getValues(col), l = values.length, i = 0;i < l;i++) { |
| if(!f.call(opt_obj, values[i], keys && keys[i], col)) { |
| return false |
| } |
| } |
| return true |
| }; |
| goog.structs.Map = function(opt_map) { |
| this.map_ = {}; |
| this.keys_ = []; |
| var argLength = arguments.length; |
| if(argLength > 1) { |
| if(argLength % 2) { |
| throw Error("Uneven number of arguments"); |
| } |
| for(var i = 0;i < argLength;i += 2) { |
| this.set(arguments[i], arguments[i + 1]) |
| } |
| }else { |
| opt_map && this.addAll(opt_map) |
| } |
| }; |
| goog.structs.Map.prototype.count_ = 0; |
| goog.structs.Map.prototype.version_ = 0; |
| goog.structs.Map.prototype.getCount = function() { |
| return this.count_ |
| }; |
| goog.structs.Map.prototype.getValues = function() { |
| this.cleanupKeysArray_(); |
| for(var rv = [], i = 0;i < this.keys_.length;i++) { |
| var key = this.keys_[i]; |
| rv.push(this.map_[key]) |
| } |
| return rv |
| }; |
| goog.structs.Map.prototype.getKeys = function() { |
| this.cleanupKeysArray_(); |
| return this.keys_.concat() |
| }; |
| goog.structs.Map.prototype.containsKey = function(key) { |
| return goog.structs.Map.hasKey_(this.map_, key) |
| }; |
| goog.structs.Map.prototype.containsValue = function(val) { |
| for(var i = 0;i < this.keys_.length;i++) { |
| var key = this.keys_[i]; |
| if(goog.structs.Map.hasKey_(this.map_, key) && this.map_[key] == val) { |
| return true |
| } |
| } |
| return false |
| }; |
| goog.structs.Map.prototype.equals = function(otherMap, opt_equalityFn) { |
| if(this === otherMap) { |
| return true |
| } |
| if(this.count_ != otherMap.getCount()) { |
| return false |
| } |
| var equalityFn = opt_equalityFn || goog.structs.Map.defaultEquals; |
| this.cleanupKeysArray_(); |
| for(var key, i = 0;key = this.keys_[i];i++) { |
| if(!equalityFn(this.get(key), otherMap.get(key))) { |
| return false |
| } |
| } |
| return true |
| }; |
| goog.structs.Map.defaultEquals = function(a, b) { |
| return a === b |
| }; |
| goog.structs.Map.prototype.isEmpty = function() { |
| return this.count_ == 0 |
| }; |
| goog.structs.Map.prototype.clear = function() { |
| this.map_ = {}; |
| this.version_ = this.count_ = this.keys_.length = 0 |
| }; |
| goog.structs.Map.prototype.remove = function(key) { |
| if(goog.structs.Map.hasKey_(this.map_, key)) { |
| delete this.map_[key]; |
| this.count_--; |
| this.version_++; |
| this.keys_.length > 2 * this.count_ && this.cleanupKeysArray_(); |
| return true |
| } |
| return false |
| }; |
| goog.structs.Map.prototype.cleanupKeysArray_ = function() { |
| if(this.count_ != this.keys_.length) { |
| for(var srcIndex = 0, destIndex = 0;srcIndex < this.keys_.length;) { |
| var key = this.keys_[srcIndex]; |
| if(goog.structs.Map.hasKey_(this.map_, key)) { |
| this.keys_[destIndex++] = key |
| } |
| srcIndex++ |
| } |
| this.keys_.length = destIndex |
| } |
| if(this.count_ != this.keys_.length) { |
| var seen = {}; |
| for(destIndex = srcIndex = 0;srcIndex < this.keys_.length;) { |
| key = this.keys_[srcIndex]; |
| if(!goog.structs.Map.hasKey_(seen, key)) { |
| this.keys_[destIndex++] = key; |
| seen[key] = 1 |
| } |
| srcIndex++ |
| } |
| this.keys_.length = destIndex |
| } |
| }; |
| goog.structs.Map.prototype.get = function(key, opt_val) { |
| if(goog.structs.Map.hasKey_(this.map_, key)) { |
| return this.map_[key] |
| } |
| return opt_val |
| }; |
| goog.structs.Map.prototype.set = function(key, value) { |
| if(!goog.structs.Map.hasKey_(this.map_, key)) { |
| this.count_++; |
| this.keys_.push(key); |
| this.version_++ |
| } |
| this.map_[key] = value |
| }; |
| goog.structs.Map.prototype.addAll = function(map) { |
| var keys, values; |
| if(map instanceof goog.structs.Map) { |
| keys = map.getKeys(); |
| values = map.getValues() |
| }else { |
| keys = goog.object.getKeys(map); |
| values = goog.object.getValues(map) |
| } |
| for(var i = 0;i < keys.length;i++) { |
| this.set(keys[i], values[i]) |
| } |
| }; |
| goog.structs.Map.prototype.clone = function() { |
| return new goog.structs.Map(this) |
| }; |
| goog.structs.Map.prototype.transpose = function() { |
| for(var transposed = new goog.structs.Map, i = 0;i < this.keys_.length;i++) { |
| var key = this.keys_[i], value = this.map_[key]; |
| transposed.set(value, key) |
| } |
| return transposed |
| }; |
| goog.structs.Map.prototype.__iterator__ = function(opt_keys) { |
| this.cleanupKeysArray_(); |
| var i = 0, keys = this.keys_, map = this.map_, version = this.version_, selfObj = this, newIter = new goog.iter.Iterator; |
| newIter.next = function() { |
| for(;;) { |
| if(version != selfObj.version_) { |
| throw Error("The map has changed since the iterator was created"); |
| } |
| if(i >= keys.length) { |
| throw goog.iter.StopIteration; |
| } |
| var key = keys[i++]; |
| return opt_keys ? key : map[key] |
| } |
| }; |
| return newIter |
| }; |
| goog.structs.Map.hasKey_ = function(obj, key) { |
| return Object.prototype.hasOwnProperty.call(obj, key) |
| }; |
| goog.structs.Set = function(opt_values) { |
| this.map_ = new goog.structs.Map; |
| opt_values && this.addAll(opt_values) |
| }; |
| goog.structs.Set.getKey_ = function(val) { |
| var type = typeof val; |
| return type == "object" && val || type == "function" ? "o" + goog.getUid(val) : type.substr(0, 1) + val |
| }; |
| goog.structs.Set.prototype.getCount = function() { |
| return this.map_.getCount() |
| }; |
| goog.structs.Set.prototype.add = function(element) { |
| this.map_.set(goog.structs.Set.getKey_(element), element) |
| }; |
| goog.structs.Set.prototype.addAll = function(col) { |
| for(var values = goog.structs.getValues(col), l = values.length, i = 0;i < l;i++) { |
| this.add(values[i]) |
| } |
| }; |
| goog.structs.Set.prototype.removeAll = function(col) { |
| for(var values = goog.structs.getValues(col), l = values.length, i = 0;i < l;i++) { |
| this.remove(values[i]) |
| } |
| }; |
| goog.structs.Set.prototype.remove = function(element) { |
| return this.map_.remove(goog.structs.Set.getKey_(element)) |
| }; |
| goog.structs.Set.prototype.clear = function() { |
| this.map_.clear() |
| }; |
| goog.structs.Set.prototype.isEmpty = function() { |
| return this.map_.isEmpty() |
| }; |
| goog.structs.Set.prototype.contains = function(element) { |
| return this.map_.containsKey(goog.structs.Set.getKey_(element)) |
| }; |
| goog.structs.Set.prototype.getValues = function() { |
| return this.map_.getValues() |
| }; |
| goog.structs.Set.prototype.clone = function() { |
| return new goog.structs.Set(this) |
| }; |
| goog.structs.Set.prototype.equals = function(col) { |
| return this.getCount() == goog.structs.getCount(col) && this.isSubsetOf(col) |
| }; |
| goog.structs.Set.prototype.isSubsetOf = function(col) { |
| var colCount = goog.structs.getCount(col); |
| if(this.getCount() > colCount) { |
| return false |
| } |
| if(!(col instanceof goog.structs.Set) && colCount > 5) { |
| col = new goog.structs.Set(col) |
| } |
| return goog.structs.every(this, function(value) { |
| return goog.structs.contains(col, value) |
| }) |
| }; |
| goog.structs.Set.prototype.__iterator__ = function() { |
| return this.map_.__iterator__(false) |
| }; |
| goog.debug.catchErrors = function(logFunc, opt_cancel, opt_target) { |
| var target = opt_target || goog.global, oldErrorHandler = target.onerror; |
| target.onerror = function(message, url, line) { |
| oldErrorHandler && oldErrorHandler(message, url, line); |
| logFunc({message:message, fileName:url, line:line}); |
| return Boolean(opt_cancel) |
| } |
| }; |
| goog.debug.expose = function(obj, opt_showFn) { |
| if(typeof obj == "undefined") { |
| return"undefined" |
| } |
| if(obj == null) { |
| return"NULL" |
| } |
| var str = [], x; |
| for(x in obj) { |
| if(!(!opt_showFn && goog.isFunction(obj[x]))) { |
| var s = x + " = "; |
| try { |
| s += obj[x] |
| }catch(e) { |
| s += "*** " + e + " ***" |
| } |
| str.push(s) |
| } |
| } |
| return str.join("\n") |
| }; |
| goog.debug.deepExpose = function(obj$$0, opt_showFn) { |
| var previous = new goog.structs.Set, str = [], helper = function(obj, space) { |
| var nestspace = space + " "; |
| try { |
| if(goog.isDef(obj)) { |
| if(goog.isNull(obj)) { |
| str.push("NULL") |
| }else { |
| if(goog.isString(obj)) { |
| str.push('"' + obj.replace(/\n/g, "\n" + space) + '"') |
| }else { |
| if(goog.isFunction(obj)) { |
| str.push(String(obj).replace(/\n/g, "\n" + space)) |
| }else { |
| if(goog.isObject(obj)) { |
| if(previous.contains(obj)) { |
| str.push("*** reference loop detected ***") |
| }else { |
| previous.add(obj); |
| str.push("{"); |
| for(var x in obj) { |
| if(!(!opt_showFn && goog.isFunction(obj[x]))) { |
| str.push("\n"); |
| str.push(nestspace); |
| str.push(x + " = "); |
| helper(obj[x], nestspace) |
| } |
| } |
| str.push("\n" + space + "}") |
| } |
| }else { |
| str.push(obj) |
| } |
| } |
| } |
| } |
| }else { |
| str.push("undefined") |
| } |
| }catch(e) { |
| str.push("*** " + e + " ***") |
| } |
| }; |
| helper(obj$$0, ""); |
| return str.join("") |
| }; |
| goog.debug.exposeArray = function(arr) { |
| for(var str = [], i = 0;i < arr.length;i++) { |
| goog.isArray(arr[i]) ? str.push(goog.debug.exposeArray(arr[i])) : str.push(arr[i]) |
| } |
| return"[ " + str.join(", ") + " ]" |
| }; |
| goog.debug.exposeException = function(err, opt_fn) { |
| try { |
| var e = goog.debug.normalizeErrorObject(err), error = "Message: " + goog.string.htmlEscape(e.message) + '\nUrl: <a href="view-source:' + e.fileName + '" target="_new">' + e.fileName + "</a>\nLine: " + e.lineNumber + "\n\nBrowser stack:\n" + goog.string.htmlEscape(e.stack + "-> ") + "[end]\n\nJS stack traversal:\n" + goog.string.htmlEscape(goog.debug.getStacktrace(opt_fn) + "-> "); |
| return error |
| }catch(e2) { |
| return"Exception trying to expose exception! You win, we lose. " + e2 |
| } |
| }; |
| goog.debug.normalizeErrorObject = function(err) { |
| var href = goog.getObjectByName("window.location.href"); |
| if(goog.isString(err)) { |
| return{message:err, name:"Unknown error", lineNumber:"Not available", fileName:href, stack:"Not available"} |
| } |
| var lineNumber, fileName, threwError = false; |
| try { |
| lineNumber = err.lineNumber || err.line || "Not available" |
| }catch(e) { |
| lineNumber = "Not available"; |
| threwError = true |
| } |
| try { |
| fileName = err.fileName || err.filename || err.sourceURL || href |
| }catch(e$$0) { |
| fileName = "Not available"; |
| threwError = true |
| } |
| if(threwError || !err.lineNumber || !err.fileName || !err.stack) { |
| return{message:err.message, name:err.name, lineNumber:lineNumber, fileName:fileName, stack:err.stack || "Not available"} |
| } |
| return err |
| }; |
| goog.debug.enhanceError = function(err, opt_message) { |
| var error = typeof err == "string" ? Error(err) : err; |
| if(!error.stack) { |
| error.stack = goog.debug.getStacktrace(arguments.callee.caller) |
| } |
| if(opt_message) { |
| for(var x = 0;error["message" + x];) { |
| ++x |
| } |
| error["message" + x] = String(opt_message) |
| } |
| return error |
| }; |
| goog.debug.getStacktraceSimple = function(opt_depth) { |
| for(var sb = [], fn = arguments.callee.caller, depth = 0;fn && (!opt_depth || depth < opt_depth);) { |
| sb.push(goog.debug.getFunctionName(fn)); |
| sb.push("()\n"); |
| try { |
| fn = fn.caller |
| }catch(e) { |
| sb.push("[exception trying to get caller]\n"); |
| break |
| } |
| depth++; |
| if(depth >= goog.debug.MAX_STACK_DEPTH) { |
| sb.push("[...long stack...]"); |
| break |
| } |
| } |
| opt_depth && depth >= opt_depth ? sb.push("[...reached max depth limit...]") : sb.push("[end]"); |
| return sb.join("") |
| }; |
| goog.debug.MAX_STACK_DEPTH = 50; |
| goog.debug.getStacktrace = function(opt_fn) { |
| return goog.debug.getStacktraceHelper_(opt_fn || arguments.callee.caller, []) |
| }; |
| goog.debug.getStacktraceHelper_ = function(fn, visited) { |
| var sb = []; |
| if(goog.array.contains(visited, fn)) { |
| sb.push("[...circular reference...]") |
| }else { |
| if(fn && visited.length < goog.debug.MAX_STACK_DEPTH) { |
| sb.push(goog.debug.getFunctionName(fn) + "("); |
| for(var args = fn.arguments, i = 0;i < args.length;i++) { |
| i > 0 && sb.push(", "); |
| var argDesc, arg = args[i]; |
| switch(typeof arg) { |
| case "object": |
| argDesc = arg ? "object" : "null"; |
| break; |
| case "string": |
| argDesc = arg; |
| break; |
| case "number": |
| argDesc = String(arg); |
| break; |
| case "boolean": |
| argDesc = arg ? "true" : "false"; |
| break; |
| case "function": |
| argDesc = (argDesc = goog.debug.getFunctionName(arg)) ? argDesc : "[fn]"; |
| break; |
| default: |
| argDesc = typeof arg |
| } |
| if(argDesc.length > 40) { |
| argDesc = argDesc.substr(0, 40) + "..." |
| } |
| sb.push(argDesc) |
| } |
| visited.push(fn); |
| sb.push(")\n"); |
| try { |
| sb.push(goog.debug.getStacktraceHelper_(fn.caller, visited)) |
| }catch(e) { |
| sb.push("[exception trying to get caller]\n") |
| } |
| }else { |
| fn ? sb.push("[...long stack...]") : sb.push("[end]") |
| } |
| } |
| return sb.join("") |
| }; |
| goog.debug.getFunctionName = function(fn) { |
| var functionSource = String(fn); |
| if(!goog.debug.fnNameCache_[functionSource]) { |
| var matches = /function ([^\(]+)/.exec(functionSource); |
| if(matches) { |
| var method = matches[1]; |
| goog.debug.fnNameCache_[functionSource] = method |
| }else { |
| goog.debug.fnNameCache_[functionSource] = "[Anonymous]" |
| } |
| } |
| return goog.debug.fnNameCache_[functionSource] |
| }; |
| goog.debug.makeWhitespaceVisible = function(string) { |
| return string.replace(/ /g, "[_]").replace(/\f/g, "[f]").replace(/\n/g, "[n]\n").replace(/\r/g, "[r]").replace(/\t/g, "[t]") |
| }; |
| goog.debug.fnNameCache_ = {}; |
| goog.debug.LogRecord = function(level, msg, loggerName, opt_time, opt_sequenceNumber) { |
| this.reset(level, msg, loggerName, opt_time, opt_sequenceNumber) |
| }; |
| goog.debug.LogRecord.prototype.sequenceNumber_ = 0; |
| goog.debug.LogRecord.prototype.exception_ = null; |
| goog.debug.LogRecord.prototype.exceptionText_ = null; |
| goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS = true; |
| goog.debug.LogRecord.nextSequenceNumber_ = 0; |
| goog.debug.LogRecord.prototype.reset = function(level, msg, loggerName, opt_time, opt_sequenceNumber) { |
| if(goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS) { |
| this.sequenceNumber_ = typeof opt_sequenceNumber == "number" ? opt_sequenceNumber : goog.debug.LogRecord.nextSequenceNumber_++ |
| } |
| this.time_ = opt_time || goog.now(); |
| this.level_ = level; |
| this.msg_ = msg; |
| this.loggerName_ = loggerName; |
| delete this.exception_; |
| delete this.exceptionText_ |
| }; |
| goog.debug.LogRecord.prototype.setException = function(exception) { |
| this.exception_ = exception |
| }; |
| goog.debug.LogRecord.prototype.setExceptionText = function(text) { |
| this.exceptionText_ = text |
| }; |
| goog.debug.LogRecord.prototype.setLevel = function(level) { |
| this.level_ = level |
| }; |
| goog.debug.LogRecord.prototype.getMessage = function() { |
| return this.msg_ |
| }; |
| goog.debug.LogBuffer = function() { |
| goog.asserts.assert(goog.debug.LogBuffer.isBufferingEnabled(), "Cannot use goog.debug.LogBuffer without defining goog.debug.LogBuffer.CAPACITY."); |
| this.clear() |
| }; |
| goog.debug.LogBuffer.getInstance = function() { |
| if(!goog.debug.LogBuffer.instance_) { |
| goog.debug.LogBuffer.instance_ = new goog.debug.LogBuffer |
| } |
| return goog.debug.LogBuffer.instance_ |
| }; |
| goog.debug.LogBuffer.CAPACITY = 0; |
| goog.debug.LogBuffer.prototype.addRecord = function(level, msg, loggerName) { |
| var curIndex = (this.curIndex_ + 1) % goog.debug.LogBuffer.CAPACITY; |
| this.curIndex_ = curIndex; |
| if(this.isFull_) { |
| var ret = this.buffer_[curIndex]; |
| ret.reset(level, msg, loggerName); |
| return ret |
| } |
| this.isFull_ = curIndex == goog.debug.LogBuffer.CAPACITY - 1; |
| return this.buffer_[curIndex] = new goog.debug.LogRecord(level, msg, loggerName) |
| }; |
| goog.debug.LogBuffer.isBufferingEnabled = function() { |
| return goog.debug.LogBuffer.CAPACITY > 0 |
| }; |
| goog.debug.LogBuffer.prototype.clear = function() { |
| this.buffer_ = Array(goog.debug.LogBuffer.CAPACITY); |
| this.curIndex_ = -1; |
| this.isFull_ = false |
| }; |
| goog.debug.Logger = function(name) { |
| this.name_ = name |
| }; |
| goog.debug.Logger.prototype.parent_ = null; |
| goog.debug.Logger.prototype.level_ = null; |
| goog.debug.Logger.prototype.children_ = null; |
| goog.debug.Logger.prototype.handlers_ = null; |
| goog.debug.Logger.ENABLE_HIERARCHY = true; |
| if(!goog.debug.Logger.ENABLE_HIERARCHY) { |
| goog.debug.Logger.rootHandlers_ = [] |
| } |
| goog.debug.Logger.Level = function(name, value) { |
| this.name = name; |
| this.value = value |
| }; |
| goog.debug.Logger.Level.prototype.toString = function() { |
| return this.name |
| }; |
| goog.debug.Logger.Level.OFF = new goog.debug.Logger.Level("OFF", Infinity); |
| goog.debug.Logger.Level.SHOUT = new goog.debug.Logger.Level("SHOUT", 1200); |
| goog.debug.Logger.Level.SEVERE = new goog.debug.Logger.Level("SEVERE", 1E3); |
| goog.debug.Logger.Level.WARNING = new goog.debug.Logger.Level("WARNING", 900); |
| goog.debug.Logger.Level.INFO = new goog.debug.Logger.Level("INFO", 800); |
| goog.debug.Logger.Level.CONFIG = new goog.debug.Logger.Level("CONFIG", 700); |
| goog.debug.Logger.Level.FINE = new goog.debug.Logger.Level("FINE", 500); |
| goog.debug.Logger.Level.FINER = new goog.debug.Logger.Level("FINER", 400); |
| goog.debug.Logger.Level.FINEST = new goog.debug.Logger.Level("FINEST", 300); |
| goog.debug.Logger.Level.ALL = new goog.debug.Logger.Level("ALL", 0); |
| goog.debug.Logger.Level.PREDEFINED_LEVELS = [goog.debug.Logger.Level.OFF, goog.debug.Logger.Level.SHOUT, goog.debug.Logger.Level.SEVERE, goog.debug.Logger.Level.WARNING, goog.debug.Logger.Level.INFO, goog.debug.Logger.Level.CONFIG, goog.debug.Logger.Level.FINE, goog.debug.Logger.Level.FINER, goog.debug.Logger.Level.FINEST, goog.debug.Logger.Level.ALL]; |
| goog.debug.Logger.Level.predefinedLevelsCache_ = null; |
| goog.debug.Logger.Level.createPredefinedLevelsCache_ = function() { |
| goog.debug.Logger.Level.predefinedLevelsCache_ = {}; |
| for(var i = 0, level;level = goog.debug.Logger.Level.PREDEFINED_LEVELS[i];i++) { |
| goog.debug.Logger.Level.predefinedLevelsCache_[level.value] = level; |
| goog.debug.Logger.Level.predefinedLevelsCache_[level.name] = level |
| } |
| }; |
| goog.debug.Logger.Level.getPredefinedLevel = function(name) { |
| goog.debug.Logger.Level.predefinedLevelsCache_ || goog.debug.Logger.Level.createPredefinedLevelsCache_(); |
| return goog.debug.Logger.Level.predefinedLevelsCache_[name] || null |
| }; |
| goog.debug.Logger.Level.getPredefinedLevelByValue = function(value) { |
| goog.debug.Logger.Level.predefinedLevelsCache_ || goog.debug.Logger.Level.createPredefinedLevelsCache_(); |
| if(value in goog.debug.Logger.Level.predefinedLevelsCache_) { |
| return goog.debug.Logger.Level.predefinedLevelsCache_[value] |
| } |
| for(var i = 0;i < goog.debug.Logger.Level.PREDEFINED_LEVELS.length;++i) { |
| var level = goog.debug.Logger.Level.PREDEFINED_LEVELS[i]; |
| if(level.value <= value) { |
| return level |
| } |
| } |
| return null |
| }; |
| goog.debug.Logger.getLogger = function(name) { |
| return goog.debug.LogManager.getLogger(name) |
| }; |
| goog.debug.Logger.prototype.getParent = function() { |
| return this.parent_ |
| }; |
| goog.debug.Logger.prototype.getChildren = function() { |
| if(!this.children_) { |
| this.children_ = {} |
| } |
| return this.children_ |
| }; |
| goog.debug.Logger.prototype.setLevel = function(level) { |
| if(goog.debug.Logger.ENABLE_HIERARCHY) { |
| this.level_ = level |
| }else { |
| goog.asserts.assert(!this.name_, "Cannot call setLevel() on a non-root logger when goog.debug.Logger.ENABLE_HIERARCHY is false."); |
| goog.debug.Logger.rootLevel_ = level |
| } |
| }; |
| goog.debug.Logger.prototype.getEffectiveLevel = function() { |
| if(!goog.debug.Logger.ENABLE_HIERARCHY) { |
| return goog.debug.Logger.rootLevel_ |
| } |
| if(this.level_) { |
| return this.level_ |
| } |
| if(this.parent_) { |
| return this.parent_.getEffectiveLevel() |
| } |
| goog.asserts.fail("Root logger has no level set."); |
| return null |
| }; |
| goog.debug.Logger.prototype.isLoggable = function(level) { |
| return level.value >= this.getEffectiveLevel().value |
| }; |
| goog.debug.Logger.prototype.log = function(level, msg, opt_exception) { |
| this.isLoggable(level) && this.doLogRecord_(this.getLogRecord(level, msg, opt_exception)) |
| }; |
| goog.debug.Logger.prototype.getLogRecord = function(level, msg, opt_exception) { |
| var logRecord = goog.debug.LogBuffer.isBufferingEnabled() ? goog.debug.LogBuffer.getInstance().addRecord(level, msg, this.name_) : new goog.debug.LogRecord(level, String(msg), this.name_); |
| if(opt_exception) { |
| logRecord.setException(opt_exception); |
| logRecord.setExceptionText(goog.debug.exposeException(opt_exception, arguments.callee.caller)) |
| } |
| return logRecord |
| }; |
| goog.debug.Logger.prototype.severe = function(msg, opt_exception) { |
| this.log(goog.debug.Logger.Level.SEVERE, msg, opt_exception) |
| }; |
| goog.debug.Logger.prototype.warning = function(msg, opt_exception) { |
| this.log(goog.debug.Logger.Level.WARNING, msg, opt_exception) |
| }; |
| goog.debug.Logger.prototype.fine = function(msg, opt_exception) { |
| this.log(goog.debug.Logger.Level.FINE, msg, opt_exception) |
| }; |
| goog.debug.Logger.prototype.finest = function(msg, opt_exception) { |
| this.log(goog.debug.Logger.Level.FINEST, msg, opt_exception) |
| }; |
| goog.debug.Logger.prototype.logToSpeedTracer_ = function(msg) { |
| if(goog.global.console && goog.global.console.markTimeline) { |
| goog.global.console.markTimeline(msg) |
| } |
| }; |
| goog.debug.Logger.prototype.doLogRecord_ = function(logRecord) { |
| this.logToSpeedTracer_("log:" + logRecord.getMessage()); |
| if(goog.debug.Logger.ENABLE_HIERARCHY) { |
| for(var target = this;target;) { |
| target.callPublish_(logRecord); |
| target = target.getParent() |
| } |
| }else { |
| for(var i = 0, handler;handler = goog.debug.Logger.rootHandlers_[i++];) { |
| handler(logRecord) |
| } |
| } |
| }; |
| goog.debug.Logger.prototype.callPublish_ = function(logRecord) { |
| if(this.handlers_) { |
| for(var i = 0, handler;handler = this.handlers_[i];i++) { |
| handler(logRecord) |
| } |
| } |
| }; |
| goog.debug.Logger.prototype.setParent_ = function(parent) { |
| this.parent_ = parent |
| }; |
| goog.debug.Logger.prototype.addChild_ = function(name, logger) { |
| this.getChildren()[name] = logger |
| }; |
| goog.debug.LogManager = {}; |
| goog.debug.LogManager.loggers_ = {}; |
| goog.debug.LogManager.rootLogger_ = null; |
| goog.debug.LogManager.initialize = function() { |
| if(!goog.debug.LogManager.rootLogger_) { |
| goog.debug.LogManager.rootLogger_ = new goog.debug.Logger(""); |
| goog.debug.LogManager.loggers_[""] = goog.debug.LogManager.rootLogger_; |
| goog.debug.LogManager.rootLogger_.setLevel(goog.debug.Logger.Level.CONFIG) |
| } |
| }; |
| goog.debug.LogManager.getLoggers = function() { |
| return goog.debug.LogManager.loggers_ |
| }; |
| goog.debug.LogManager.getRoot = function() { |
| goog.debug.LogManager.initialize(); |
| return goog.debug.LogManager.rootLogger_ |
| }; |
| goog.debug.LogManager.getLogger = function(name) { |
| goog.debug.LogManager.initialize(); |
| var ret = goog.debug.LogManager.loggers_[name]; |
| return ret || goog.debug.LogManager.createLogger_(name) |
| }; |
| goog.debug.LogManager.createFunctionForCatchErrors = function(opt_logger) { |
| return function(info) { |
| var logger = opt_logger || goog.debug.LogManager.getRoot(); |
| logger.severe("Error: " + info.message + " (" + info.fileName + " @ Line: " + info.line + ")") |
| } |
| }; |
| goog.debug.LogManager.createLogger_ = function(name) { |
| var logger = new goog.debug.Logger(name); |
| if(goog.debug.Logger.ENABLE_HIERARCHY) { |
| var lastDotIndex = name.lastIndexOf("."), parentName = name.substr(0, lastDotIndex), leafName = name.substr(lastDotIndex + 1), parentLogger = goog.debug.LogManager.getLogger(parentName); |
| parentLogger.addChild_(leafName, logger); |
| logger.setParent_(parentLogger) |
| } |
| return goog.debug.LogManager.loggers_[name] = logger |
| }; |
| goog.Disposable = function() { |
| if(goog.Disposable.ENABLE_MONITORING) { |
| goog.Disposable.instances_[goog.getUid(this)] = this |
| } |
| }; |
| goog.Disposable.ENABLE_MONITORING = false; |
| goog.Disposable.instances_ = {}; |
| goog.Disposable.getUndisposedObjects = function() { |
| var ret = [], id; |
| for(id in goog.Disposable.instances_) { |
| goog.Disposable.instances_.hasOwnProperty(id) && ret.push(goog.Disposable.instances_[Number(id)]) |
| } |
| return ret |
| }; |
| goog.Disposable.clearUndisposedObjects = function() { |
| goog.Disposable.instances_ = {} |
| }; |
| goog.Disposable.prototype.disposed_ = false; |
| goog.Disposable.prototype.dispose = function() { |
| if(!this.disposed_) { |
| this.disposed_ = true; |
| this.disposeInternal(); |
| if(goog.Disposable.ENABLE_MONITORING) { |
| var uid = goog.getUid(this); |
| if(!goog.Disposable.instances_.hasOwnProperty(uid)) { |
| throw Error(this + " did not call the goog.Disposable base constructor or was disposed of after a clearUndisposedObjects call"); |
| } |
| delete goog.Disposable.instances_[uid] |
| } |
| } |
| }; |
| goog.Disposable.prototype.disposeInternal = function() { |
| }; |
| goog.dispose = function(obj) { |
| obj && typeof obj.dispose == "function" && obj.dispose() |
| }; |
| goog.reflect = {}; |
| goog.reflect.object = function(type, object) { |
| return object |
| }; |
| goog.reflect.sinkValue = new Function("a", "return a"); |
| goog.events = {}; |
| goog.events.BrowserFeature = {HAS_W3C_BUTTON:!goog.userAgent.IE || goog.userAgent.isVersion("9"), SET_KEY_CODE_TO_PREVENT_DEFAULT:goog.userAgent.IE && !goog.userAgent.isVersion("8")}; |
| goog.events.Event = function(type, opt_target) { |
| goog.Disposable.call(this); |
| this.type = type; |
| this.currentTarget = this.target = opt_target |
| }; |
| goog.inherits(goog.events.Event, goog.Disposable); |
| goog.events.Event.prototype.disposeInternal = function() { |
| delete this.type; |
| delete this.target; |
| delete this.currentTarget |
| }; |
| goog.events.Event.prototype.propagationStopped_ = false; |
| goog.events.Event.prototype.returnValue_ = true; |
| goog.events.Event.prototype.stopPropagation = function() { |
| this.propagationStopped_ = true |
| }; |
| goog.events.Event.prototype.preventDefault = function() { |
| this.returnValue_ = false |
| }; |
| goog.events.Event.stopPropagation = function(e) { |
| e.stopPropagation() |
| }; |
| goog.events.Event.preventDefault = function(e) { |
| e.preventDefault() |
| }; |
| goog.events.EventType = {CLICK:"click", DBLCLICK:"dblclick", MOUSEDOWN:"mousedown", MOUSEUP:"mouseup", MOUSEOVER:"mouseover", MOUSEOUT:"mouseout", MOUSEMOVE:"mousemove", SELECTSTART:"selectstart", KEYPRESS:"keypress", KEYDOWN:"keydown", KEYUP:"keyup", BLUR:"blur", FOCUS:"focus", DEACTIVATE:"deactivate", FOCUSIN:goog.userAgent.IE ? "focusin" : "DOMFocusIn", FOCUSOUT:goog.userAgent.IE ? "focusout" : "DOMFocusOut", CHANGE:"change", SELECT:"select", SUBMIT:"submit", INPUT:"input", PROPERTYCHANGE:"propertychange", |
| DRAGSTART:"dragstart", DRAGENTER:"dragenter", DRAGOVER:"dragover", DRAGLEAVE:"dragleave", DROP:"drop", TOUCHSTART:"touchstart", TOUCHMOVE:"touchmove", TOUCHEND:"touchend", TOUCHCANCEL:"touchcancel", CONTEXTMENU:"contextmenu", ERROR:"error", HELP:"help", LOAD:"load", LOSECAPTURE:"losecapture", READYSTATECHANGE:"readystatechange", RESIZE:"resize", SCROLL:"scroll", UNLOAD:"unload", HASHCHANGE:"hashchange", PAGEHIDE:"pagehide", PAGESHOW:"pageshow", POPSTATE:"popstate", COPY:"copy", PASTE:"paste", CUT:"cut", |
| MESSAGE:"message", CONNECT:"connect"}; |
| goog.events.BrowserEvent = function(opt_e, opt_currentTarget) { |
| opt_e && this.init(opt_e, opt_currentTarget) |
| }; |
| goog.inherits(goog.events.BrowserEvent, goog.events.Event); |
| goog.events.BrowserEvent.MouseButton = {LEFT:0, MIDDLE:1, RIGHT:2}; |
| goog.events.BrowserEvent.IEButtonMap = [1, 4, 2]; |
| goog.events.BrowserEvent.prototype.target = null; |
| goog.events.BrowserEvent.prototype.relatedTarget = null; |
| goog.events.BrowserEvent.prototype.offsetX = 0; |
| goog.events.BrowserEvent.prototype.offsetY = 0; |
| goog.events.BrowserEvent.prototype.clientX = 0; |
| goog.events.BrowserEvent.prototype.clientY = 0; |
| goog.events.BrowserEvent.prototype.screenX = 0; |
| goog.events.BrowserEvent.prototype.screenY = 0; |
| goog.events.BrowserEvent.prototype.button = 0; |
| goog.events.BrowserEvent.prototype.keyCode = 0; |
| goog.events.BrowserEvent.prototype.charCode = 0; |
| goog.events.BrowserEvent.prototype.ctrlKey = false; |
| goog.events.BrowserEvent.prototype.altKey = false; |
| goog.events.BrowserEvent.prototype.shiftKey = false; |
| goog.events.BrowserEvent.prototype.metaKey = false; |
| goog.events.BrowserEvent.prototype.platformModifierKey = false; |
| goog.events.BrowserEvent.prototype.event_ = null; |
| goog.events.BrowserEvent.prototype.init = function(e, opt_currentTarget) { |
| var type = this.type = e.type; |
| goog.events.Event.call(this, type); |
| this.target = e.target || e.srcElement; |
| this.currentTarget = opt_currentTarget; |
| var relatedTarget = e.relatedTarget; |
| if(relatedTarget) { |
| if(goog.userAgent.GECKO) { |
| try { |
| goog.reflect.sinkValue(relatedTarget.nodeName) |
| }catch(err) { |
| relatedTarget = null |
| } |
| } |
| }else { |
| if(type == goog.events.EventType.MOUSEOVER) { |
| relatedTarget = e.fromElement |
| }else { |
| if(type == goog.events.EventType.MOUSEOUT) { |
| relatedTarget = e.toElement |
| } |
| } |
| } |
| this.relatedTarget = relatedTarget; |
| this.offsetX = e.offsetX !== undefined ? e.offsetX : e.layerX; |
| this.offsetY = e.offsetY !== undefined ? e.offsetY : e.layerY; |
| this.clientX = e.clientX !== undefined ? e.clientX : e.pageX; |
| this.clientY = e.clientY !== undefined ? e.clientY : e.pageY; |
| this.screenX = e.screenX || 0; |
| this.screenY = e.screenY || 0; |
| this.button = e.button; |
| this.keyCode = e.keyCode || 0; |
| this.charCode = e.charCode || (type == "keypress" ? e.keyCode : 0); |
| this.ctrlKey = e.ctrlKey; |
| this.altKey = e.altKey; |
| this.shiftKey = e.shiftKey; |
| this.metaKey = e.metaKey; |
| this.platformModifierKey = goog.userAgent.MAC ? e.metaKey : e.ctrlKey; |
| this.state = e.state; |
| this.event_ = e; |
| delete this.returnValue_; |
| delete this.propagationStopped_ |
| }; |
| goog.events.BrowserEvent.prototype.stopPropagation = function() { |
| goog.events.BrowserEvent.superClass_.stopPropagation.call(this); |
| if(this.event_.stopPropagation) { |
| this.event_.stopPropagation() |
| }else { |
| this.event_.cancelBubble = true |
| } |
| }; |
| goog.events.BrowserEvent.prototype.preventDefault = function() { |
| goog.events.BrowserEvent.superClass_.preventDefault.call(this); |
| var be = this.event_; |
| if(be.preventDefault) { |
| be.preventDefault() |
| }else { |
| be.returnValue = false; |
| if(goog.events.BrowserFeature.SET_KEY_CODE_TO_PREVENT_DEFAULT) { |
| try { |
| if(be.ctrlKey || be.keyCode >= 112 && be.keyCode <= 123) { |
| be.keyCode = -1 |
| } |
| }catch(ex) { |
| } |
| } |
| } |
| }; |
| goog.events.BrowserEvent.prototype.disposeInternal = function() { |
| goog.events.BrowserEvent.superClass_.disposeInternal.call(this); |
| this.relatedTarget = this.currentTarget = this.target = this.event_ = null |
| }; |
| goog.events.EventWrapper = function() { |
| }; |
| goog.events.EventWrapper.prototype.listen = function() { |
| }; |
| goog.events.EventWrapper.prototype.unlisten = function() { |
| }; |
| goog.structs.SimplePool = function(initialCount, maxCount) { |
| goog.Disposable.call(this); |
| this.maxCount_ = maxCount; |
| this.freeQueue_ = []; |
| this.createInitial_(initialCount) |
| }; |
| goog.inherits(goog.structs.SimplePool, goog.Disposable); |
| goog.structs.SimplePool.prototype.createObjectFn_ = null; |
| goog.structs.SimplePool.prototype.disposeObjectFn_ = null; |
| goog.structs.SimplePool.prototype.setCreateObjectFn = function(createObjectFn) { |
| this.createObjectFn_ = createObjectFn |
| }; |
| goog.structs.SimplePool.prototype.getObject = function() { |
| if(this.freeQueue_.length) { |
| return this.freeQueue_.pop() |
| } |
| return this.createObject() |
| }; |
| goog.structs.SimplePool.prototype.releaseObject = function(obj) { |
| this.freeQueue_.length < this.maxCount_ ? this.freeQueue_.push(obj) : this.disposeObject(obj) |
| }; |
| goog.structs.SimplePool.prototype.createInitial_ = function(initialCount) { |
| if(initialCount > this.maxCount_) { |
| throw Error("[goog.structs.SimplePool] Initial cannot be greater than max"); |
| } |
| for(var i = 0;i < initialCount;i++) { |
| this.freeQueue_.push(this.createObject()) |
| } |
| }; |
| goog.structs.SimplePool.prototype.createObject = function() { |
| return this.createObjectFn_ ? this.createObjectFn_() : {} |
| }; |
| goog.structs.SimplePool.prototype.disposeObject = function(obj) { |
| if(this.disposeObjectFn_) { |
| this.disposeObjectFn_(obj) |
| }else { |
| if(goog.isObject(obj)) { |
| if(goog.isFunction(obj.dispose)) { |
| obj.dispose() |
| }else { |
| for(var i in obj) { |
| delete obj[i] |
| } |
| } |
| } |
| } |
| }; |
| goog.structs.SimplePool.prototype.disposeInternal = function() { |
| goog.structs.SimplePool.superClass_.disposeInternal.call(this); |
| for(var freeQueue = this.freeQueue_;freeQueue.length;) { |
| this.disposeObject(freeQueue.pop()) |
| } |
| delete this.freeQueue_ |
| }; |
| goog.userAgent.jscript = {}; |
| goog.userAgent.jscript.ASSUME_NO_JSCRIPT = false; |
| goog.userAgent.jscript.init_ = function() { |
| var hasScriptEngine = "ScriptEngine" in goog.global; |
| goog.userAgent.jscript.DETECTED_HAS_JSCRIPT_ = hasScriptEngine && goog.global.ScriptEngine() == "JScript"; |
| goog.userAgent.jscript.DETECTED_VERSION_ = goog.userAgent.jscript.DETECTED_HAS_JSCRIPT_ ? goog.global.ScriptEngineMajorVersion() + "." + goog.global.ScriptEngineMinorVersion() + "." + goog.global.ScriptEngineBuildVersion() : "0" |
| }; |
| goog.userAgent.jscript.ASSUME_NO_JSCRIPT || goog.userAgent.jscript.init_(); |
| goog.userAgent.jscript.HAS_JSCRIPT = goog.userAgent.jscript.ASSUME_NO_JSCRIPT ? false : goog.userAgent.jscript.DETECTED_HAS_JSCRIPT_; |
| goog.userAgent.jscript.VERSION = goog.userAgent.jscript.ASSUME_NO_JSCRIPT ? "0" : goog.userAgent.jscript.DETECTED_VERSION_; |
| goog.userAgent.jscript.isVersion = function(version) { |
| return goog.string.compareVersions(goog.userAgent.jscript.VERSION, version) >= 0 |
| }; |
| goog.events.Listener = function() { |
| }; |
| goog.events.Listener.counter_ = 0; |
| goog.events.Listener.prototype.key = 0; |
| goog.events.Listener.prototype.removed = false; |
| goog.events.Listener.prototype.callOnce = false; |
| goog.events.Listener.prototype.init = function(listener, proxy, src, type, capture, opt_handler) { |
| if(goog.isFunction(listener)) { |
| this.isFunctionListener_ = true |
| }else { |
| if(listener && listener.handleEvent && goog.isFunction(listener.handleEvent)) { |
| this.isFunctionListener_ = false |
| }else { |
| throw Error("Invalid listener argument"); |
| } |
| } |
| this.listener = listener; |
| this.proxy = proxy; |
| this.src = src; |
| this.type = type; |
| this.capture = !!capture; |
| this.handler = opt_handler; |
| this.callOnce = false; |
| this.key = ++goog.events.Listener.counter_; |
| this.removed = false |
| }; |
| goog.events.Listener.prototype.handleEvent = function(eventObject) { |
| if(this.isFunctionListener_) { |
| return this.listener.call(this.handler || this.src, eventObject) |
| } |
| return this.listener.handleEvent.call(this.listener, eventObject) |
| }; |
| goog.events.pools = {}; |
| (function() { |
| function getObject() { |
| return{count_:0, remaining_:0} |
| } |
| function getArray() { |
| return[] |
| } |
| function getProxy() { |
| var f = function(eventObject) { |
| return proxyCallbackFunction.call(f.src, f.key, eventObject) |
| }; |
| return f |
| } |
| function getListener() { |
| return new goog.events.Listener |
| } |
| function getEvent() { |
| return new goog.events.BrowserEvent |
| } |
| var BAD_GC = goog.userAgent.jscript.HAS_JSCRIPT && !goog.userAgent.jscript.isVersion("5.7"), proxyCallbackFunction; |
| goog.events.pools.setProxyCallbackFunction = function(cb) { |
| proxyCallbackFunction = cb |
| }; |
| if(BAD_GC) { |
| goog.events.pools.getObject = function() { |
| return objectPool.getObject() |
| }; |
| goog.events.pools.releaseObject = function(obj) { |
| objectPool.releaseObject(obj) |
| }; |
| goog.events.pools.getArray = function() { |
| return arrayPool.getObject() |
| }; |
| goog.events.pools.releaseArray = function(obj) { |
| arrayPool.releaseObject(obj) |
| }; |
| goog.events.pools.getProxy = function() { |
| return proxyPool.getObject() |
| }; |
| goog.events.pools.releaseProxy = function() { |
| proxyPool.releaseObject(getProxy()) |
| }; |
| goog.events.pools.getListener = function() { |
| return listenerPool.getObject() |
| }; |
| goog.events.pools.releaseListener = function(obj) { |
| listenerPool.releaseObject(obj) |
| }; |
| goog.events.pools.getEvent = function() { |
| return eventPool.getObject() |
| }; |
| goog.events.pools.releaseEvent = function(obj) { |
| eventPool.releaseObject(obj) |
| }; |
| var objectPool = new goog.structs.SimplePool(0, 600); |
| objectPool.setCreateObjectFn(getObject); |
| var arrayPool = new goog.structs.SimplePool(0, 600); |
| arrayPool.setCreateObjectFn(getArray); |
| var proxyPool = new goog.structs.SimplePool(0, 600); |
| proxyPool.setCreateObjectFn(getProxy); |
| var listenerPool = new goog.structs.SimplePool(0, 600); |
| listenerPool.setCreateObjectFn(getListener); |
| var eventPool = new goog.structs.SimplePool(0, 600); |
| eventPool.setCreateObjectFn(getEvent) |
| }else { |
| goog.events.pools.getObject = getObject; |
| goog.events.pools.releaseObject = goog.nullFunction; |
| goog.events.pools.getArray = getArray; |
| goog.events.pools.releaseArray = goog.nullFunction; |
| goog.events.pools.getProxy = getProxy; |
| goog.events.pools.releaseProxy = goog.nullFunction; |
| goog.events.pools.getListener = getListener; |
| goog.events.pools.releaseListener = goog.nullFunction; |
| goog.events.pools.getEvent = getEvent; |
| goog.events.pools.releaseEvent = goog.nullFunction |
| } |
| })(); |
| goog.events.listeners_ = {}; |
| goog.events.listenerTree_ = {}; |
| goog.events.sources_ = {}; |
| goog.events.onString_ = "on"; |
| goog.events.onStringMap_ = {}; |
| goog.events.keySeparator_ = "_"; |
| goog.events.listen = function(src, type, listener, opt_capt, opt_handler) { |
| if(type) { |
| if(goog.isArray(type)) { |
| for(var i = 0;i < type.length;i++) { |
| goog.events.listen(src, type[i], listener, opt_capt, opt_handler) |
| } |
| return null |
| }else { |
| var capture = !!opt_capt, map = goog.events.listenerTree_; |
| type in map || (map[type] = goog.events.pools.getObject()); |
| map = map[type]; |
| if(!(capture in map)) { |
| map[capture] = goog.events.pools.getObject(); |
| map.count_++ |
| } |
| map = map[capture]; |
| var srcUid = goog.getUid(src), listenerArray, listenerObj; |
| map.remaining_++; |
| if(map[srcUid]) { |
| listenerArray = map[srcUid]; |
| for(i = 0;i < listenerArray.length;i++) { |
| listenerObj = listenerArray[i]; |
| if(listenerObj.listener == listener && listenerObj.handler == opt_handler) { |
| if(listenerObj.removed) { |
| break |
| } |
| return listenerArray[i].key |
| } |
| } |
| }else { |
| listenerArray = map[srcUid] = goog.events.pools.getArray(); |
| map.count_++ |
| } |
| var proxy = goog.events.pools.getProxy(); |
| proxy.src = src; |
| listenerObj = goog.events.pools.getListener(); |
| listenerObj.init(listener, proxy, src, type, capture, opt_handler); |
| var key = listenerObj.key; |
| proxy.key = key; |
| listenerArray.push(listenerObj); |
| goog.events.listeners_[key] = listenerObj; |
| goog.events.sources_[srcUid] || (goog.events.sources_[srcUid] = goog.events.pools.getArray()); |
| goog.events.sources_[srcUid].push(listenerObj); |
| if(src.addEventListener) { |
| if(src == goog.global || !src.customEvent_) { |
| src.addEventListener(type, proxy, capture) |
| } |
| }else { |
| src.attachEvent(goog.events.getOnString_(type), proxy) |
| } |
| return key |
| } |
| }else { |
| throw Error("Invalid event type"); |
| } |
| }; |
| goog.events.listenOnce = function(src, type, listener, opt_capt, opt_handler) { |
| if(goog.isArray(type)) { |
| for(var i = 0;i < type.length;i++) { |
| goog.events.listenOnce(src, type[i], listener, opt_capt, opt_handler) |
| } |
| return null |
| } |
| var key = goog.events.listen(src, type, listener, opt_capt, opt_handler), listenerObj = goog.events.listeners_[key]; |
| listenerObj.callOnce = true; |
| return key |
| }; |
| goog.events.listenWithWrapper = function(src, wrapper, listener, opt_capt, opt_handler) { |
| wrapper.listen(src, listener, opt_capt, opt_handler) |
| }; |
| goog.events.unlisten = function(src, type, listener, opt_capt, opt_handler) { |
| if(goog.isArray(type)) { |
| for(var i = 0;i < type.length;i++) { |
| goog.events.unlisten(src, type[i], listener, opt_capt, opt_handler) |
| } |
| return null |
| } |
| var capture = !!opt_capt, listenerArray = goog.events.getListeners_(src, type, capture); |
| if(!listenerArray) { |
| return false |
| } |
| for(i = 0;i < listenerArray.length;i++) { |
| if(listenerArray[i].listener == listener && listenerArray[i].capture == capture && listenerArray[i].handler == opt_handler) { |
| return goog.events.unlistenByKey(listenerArray[i].key) |
| } |
| } |
| return false |
| }; |
| goog.events.unlistenByKey = function(key) { |
| if(!goog.events.listeners_[key]) { |
| return false |
| } |
| var listener = goog.events.listeners_[key]; |
| if(listener.removed) { |
| return false |
| } |
| var src = listener.src, type = listener.type, proxy = listener.proxy, capture = listener.capture; |
| if(src.removeEventListener) { |
| if(src == goog.global || !src.customEvent_) { |
| src.removeEventListener(type, proxy, capture) |
| } |
| }else { |
| src.detachEvent && src.detachEvent(goog.events.getOnString_(type), proxy) |
| } |
| var srcUid = goog.getUid(src), listenerArray = goog.events.listenerTree_[type][capture][srcUid]; |
| if(goog.events.sources_[srcUid]) { |
| var sourcesArray = goog.events.sources_[srcUid]; |
| goog.array.remove(sourcesArray, listener); |
| sourcesArray.length == 0 && delete goog.events.sources_[srcUid] |
| } |
| listener.removed = true; |
| listenerArray.needsCleanup_ = true; |
| goog.events.cleanUp_(type, capture, srcUid, listenerArray); |
| delete goog.events.listeners_[key]; |
| return true |
| }; |
| goog.events.unlistenWithWrapper = function(src, wrapper, listener, opt_capt, opt_handler) { |
| wrapper.unlisten(src, listener, opt_capt, opt_handler) |
| }; |
| goog.events.cleanUp_ = function(type, capture, srcUid, listenerArray) { |
| if(!listenerArray.locked_) { |
| if(listenerArray.needsCleanup_) { |
| for(var oldIndex = 0, newIndex = 0;oldIndex < listenerArray.length;oldIndex++) { |
| if(listenerArray[oldIndex].removed) { |
| var proxy = listenerArray[oldIndex].proxy; |
| proxy.src = null; |
| goog.events.pools.releaseProxy(proxy); |
| goog.events.pools.releaseListener(listenerArray[oldIndex]) |
| }else { |
| if(oldIndex != newIndex) { |
| listenerArray[newIndex] = listenerArray[oldIndex] |
| } |
| newIndex++ |
| } |
| } |
| listenerArray.length = newIndex; |
| listenerArray.needsCleanup_ = false; |
| if(newIndex == 0) { |
| goog.events.pools.releaseArray(listenerArray); |
| delete goog.events.listenerTree_[type][capture][srcUid]; |
| goog.events.listenerTree_[type][capture].count_--; |
| if(goog.events.listenerTree_[type][capture].count_ == 0) { |
| goog.events.pools.releaseObject(goog.events.listenerTree_[type][capture]); |
| delete goog.events.listenerTree_[type][capture]; |
| goog.events.listenerTree_[type].count_-- |
| } |
| if(goog.events.listenerTree_[type].count_ == 0) { |
| goog.events.pools.releaseObject(goog.events.listenerTree_[type]); |
| delete goog.events.listenerTree_[type] |
| } |
| } |
| } |
| } |
| }; |
| goog.events.removeAll = function(opt_obj, opt_type, opt_capt) { |
| var count = 0, noObj = opt_obj == null, noType = opt_type == null, noCapt = opt_capt == null; |
| opt_capt = !!opt_capt; |
| if(noObj) { |
| goog.object.forEach(goog.events.sources_, function(listeners) { |
| for(var i = listeners.length - 1;i >= 0;i--) { |
| var listener = listeners[i]; |
| if((noType || opt_type == listener.type) && (noCapt || opt_capt == listener.capture)) { |
| goog.events.unlistenByKey(listener.key); |
| count++ |
| } |
| } |
| }) |
| }else { |
| var srcUid = goog.getUid(opt_obj); |
| if(goog.events.sources_[srcUid]) { |
| for(var sourcesArray = goog.events.sources_[srcUid], i$$0 = sourcesArray.length - 1;i$$0 >= 0;i$$0--) { |
| var listener$$0 = sourcesArray[i$$0]; |
| if((noType || opt_type == listener$$0.type) && (noCapt || opt_capt == listener$$0.capture)) { |
| goog.events.unlistenByKey(listener$$0.key); |
| count++ |
| } |
| } |
| } |
| } |
| return count |
| }; |
| goog.events.getListeners = function(obj, type, capture) { |
| return goog.events.getListeners_(obj, type, capture) || [] |
| }; |
| goog.events.getListeners_ = function(obj, type, capture) { |
| var map = goog.events.listenerTree_; |
| if(type in map) { |
| map = map[type]; |
| if(capture in map) { |
| map = map[capture]; |
| var objUid = goog.getUid(obj); |
| if(map[objUid]) { |
| return map[objUid] |
| } |
| } |
| } |
| return null |
| }; |
| goog.events.getListener = function(src, type, listener, opt_capt, opt_handler) { |
| var capture = !!opt_capt, listenerArray = goog.events.getListeners_(src, type, capture); |
| if(listenerArray) { |
| for(var i = 0;i < listenerArray.length;i++) { |
| if(listenerArray[i].listener == listener && listenerArray[i].capture == capture && listenerArray[i].handler == opt_handler) { |
| return listenerArray[i] |
| } |
| } |
| } |
| return null |
| }; |
| goog.events.hasListener = function(obj, opt_type, opt_capture) { |
| var objUid = goog.getUid(obj), listeners = goog.events.sources_[objUid]; |
| if(listeners) { |
| var hasType = goog.isDef(opt_type), hasCapture = goog.isDef(opt_capture); |
| if(hasType && hasCapture) { |
| var map = goog.events.listenerTree_[opt_type]; |
| return!!map && !!map[opt_capture] && objUid in map[opt_capture] |
| }else { |
| return hasType || hasCapture ? goog.array.some(listeners, function(listener) { |
| return hasType && listener.type == opt_type || hasCapture && listener.capture == opt_capture |
| }) : true |
| } |
| } |
| return false |
| }; |
| goog.events.expose = function(e) { |
| var str = [], key; |
| for(key in e) { |
| e[key] && e[key].id ? str.push(key + " = " + e[key] + " (" + e[key].id + ")") : str.push(key + " = " + e[key]) |
| } |
| return str.join("\n") |
| }; |
| goog.events.getOnString_ = function(type) { |
| if(type in goog.events.onStringMap_) { |
| return goog.events.onStringMap_[type] |
| } |
| return goog.events.onStringMap_[type] = goog.events.onString_ + type |
| }; |
| goog.events.fireListeners = function(obj, type, capture, eventObject) { |
| var map = goog.events.listenerTree_; |
| if(type in map) { |
| map = map[type]; |
| if(capture in map) { |
| return goog.events.fireListeners_(map[capture], obj, type, capture, eventObject) |
| } |
| } |
| return true |
| }; |
| goog.events.fireListeners_ = function(map, obj, type, capture, eventObject) { |
| var retval = 1, objUid = goog.getUid(obj); |
| if(map[objUid]) { |
| map.remaining_--; |
| var listenerArray = map[objUid]; |
| if(listenerArray.locked_) { |
| listenerArray.locked_++ |
| }else { |
| listenerArray.locked_ = 1 |
| } |
| try { |
| for(var length = listenerArray.length, i = 0;i < length;i++) { |
| var listener = listenerArray[i]; |
| if(listener && !listener.removed) { |
| retval &= goog.events.fireListener(listener, eventObject) !== false |
| } |
| } |
| }finally { |
| listenerArray.locked_--; |
| goog.events.cleanUp_(type, capture, objUid, listenerArray) |
| } |
| } |
| return Boolean(retval) |
| }; |
| goog.events.fireListener = function(listener, eventObject) { |
| var rv = listener.handleEvent(eventObject); |
| listener.callOnce && goog.events.unlistenByKey(listener.key); |
| return rv |
| }; |
| goog.events.getTotalListenerCount = function() { |
| return goog.object.getCount(goog.events.listeners_) |
| }; |
| goog.events.dispatchEvent = function(src, e) { |
| var type = e.type || e, map = goog.events.listenerTree_; |
| if(!(type in map)) { |
| return true |
| } |
| if(goog.isString(e)) { |
| e = new goog.events.Event(e, src) |
| }else { |
| if(e instanceof goog.events.Event) { |
| e.target = e.target || src |
| }else { |
| var oldEvent = e; |
| e = new goog.events.Event(type, src); |
| goog.object.extend(e, oldEvent) |
| } |
| } |
| var rv = 1, ancestors; |
| map = map[type]; |
| var hasCapture = true in map, targetsMap; |
| if(hasCapture) { |
| ancestors = []; |
| for(var parent = src;parent;parent = parent.getParentEventTarget()) { |
| ancestors.push(parent) |
| } |
| targetsMap = map[true]; |
| targetsMap.remaining_ = targetsMap.count_; |
| for(var i = ancestors.length - 1;!e.propagationStopped_ && i >= 0 && targetsMap.remaining_;i--) { |
| e.currentTarget = ancestors[i]; |
| rv &= goog.events.fireListeners_(targetsMap, ancestors[i], e.type, true, e) && e.returnValue_ != false |
| } |
| } |
| var hasBubble = false in map; |
| if(hasBubble) { |
| targetsMap = map[false]; |
| targetsMap.remaining_ = targetsMap.count_; |
| if(hasCapture) { |
| for(i = 0;!e.propagationStopped_ && i < ancestors.length && targetsMap.remaining_;i++) { |
| e.currentTarget = ancestors[i]; |
| rv &= goog.events.fireListeners_(targetsMap, ancestors[i], e.type, false, e) && e.returnValue_ != false |
| } |
| }else { |
| for(var current = src;!e.propagationStopped_ && current && targetsMap.remaining_;current = current.getParentEventTarget()) { |
| e.currentTarget = current; |
| rv &= goog.events.fireListeners_(targetsMap, current, e.type, false, e) && e.returnValue_ != false |
| } |
| } |
| } |
| return Boolean(rv) |
| }; |
| goog.events.protectBrowserEventEntryPoint = function(errorHandler) { |
| goog.events.handleBrowserEvent_ = errorHandler.protectEntryPoint(goog.events.handleBrowserEvent_); |
| goog.events.pools.setProxyCallbackFunction(goog.events.handleBrowserEvent_) |
| }; |
| goog.events.handleBrowserEvent_ = function(key, opt_evt) { |
| if(!goog.events.listeners_[key]) { |
| return true |
| } |
| var listener = goog.events.listeners_[key], type = listener.type, map = goog.events.listenerTree_; |
| if(!(type in map)) { |
| return true |
| } |
| map = map[type]; |
| var retval, targetsMap; |
| if(goog.events.synthesizeEventPropagation_()) { |
| var ieEvent = opt_evt || goog.getObjectByName("window.event"), hasCapture = true in map, hasBubble = false in map; |
| if(hasCapture) { |
| if(goog.events.isMarkedIeEvent_(ieEvent)) { |
| return true |
| } |
| goog.events.markIeEvent_(ieEvent) |
| } |
| var evt = goog.events.pools.getEvent(); |
| evt.init(ieEvent, this); |
| retval = true; |
| try { |
| if(hasCapture) { |
| for(var ancestors = goog.events.pools.getArray(), parent = evt.currentTarget;parent;parent = parent.parentNode) { |
| ancestors.push(parent) |
| } |
| targetsMap = map[true]; |
| targetsMap.remaining_ = targetsMap.count_; |
| for(var i = ancestors.length - 1;!evt.propagationStopped_ && i >= 0 && targetsMap.remaining_;i--) { |
| evt.currentTarget = ancestors[i]; |
| retval &= goog.events.fireListeners_(targetsMap, ancestors[i], type, true, evt) |
| } |
| if(hasBubble) { |
| targetsMap = map[false]; |
| targetsMap.remaining_ = targetsMap.count_; |
| for(i = 0;!evt.propagationStopped_ && i < ancestors.length && targetsMap.remaining_;i++) { |
| evt.currentTarget = ancestors[i]; |
| retval &= goog.events.fireListeners_(targetsMap, ancestors[i], type, false, evt) |
| } |
| } |
| }else { |
| retval = goog.events.fireListener(listener, evt) |
| } |
| }finally { |
| if(ancestors) { |
| ancestors.length = 0; |
| goog.events.pools.releaseArray(ancestors) |
| } |
| evt.dispose(); |
| goog.events.pools.releaseEvent(evt) |
| } |
| return retval |
| } |
| var be = new goog.events.BrowserEvent(opt_evt, this); |
| try { |
| retval = goog.events.fireListener(listener, be) |
| }finally { |
| be.dispose() |
| } |
| return retval |
| }; |
| goog.events.pools.setProxyCallbackFunction(goog.events.handleBrowserEvent_); |
| goog.events.markIeEvent_ = function(e) { |
| var useReturnValue = false; |
| if(e.keyCode == 0) { |
| try { |
| e.keyCode = -1; |
| return |
| }catch(ex) { |
| useReturnValue = true |
| } |
| } |
| if(useReturnValue || e.returnValue == undefined) { |
| e.returnValue = true |
| } |
| }; |
| goog.events.isMarkedIeEvent_ = function(e) { |
| return e.keyCode < 0 || e.returnValue != undefined |
| }; |
| goog.events.uniqueIdCounter_ = 0; |
| goog.events.getUniqueId = function(identifier) { |
| return identifier + "_" + goog.events.uniqueIdCounter_++ |
| }; |
| goog.events.synthesizeEventPropagation_ = function() { |
| if(goog.events.requiresSyntheticEventPropagation_ === undefined) { |
| goog.events.requiresSyntheticEventPropagation_ = goog.userAgent.IE && !goog.global.addEventListener |
| } |
| return goog.events.requiresSyntheticEventPropagation_ |
| }; |
| goog.debug.entryPointRegistry.register(function(transformer) { |
| goog.events.handleBrowserEvent_ = transformer(goog.events.handleBrowserEvent_); |
| goog.events.pools.setProxyCallbackFunction(goog.events.handleBrowserEvent_) |
| }); |
| goog.events.EventTarget = function() { |
| goog.Disposable.call(this) |
| }; |
| goog.inherits(goog.events.EventTarget, goog.Disposable); |
| goog.events.EventTarget.prototype.customEvent_ = true; |
| goog.events.EventTarget.prototype.parentEventTarget_ = null; |
| goog.events.EventTarget.prototype.getParentEventTarget = function() { |
| return this.parentEventTarget_ |
| }; |
| goog.events.EventTarget.prototype.addEventListener = function(type, handler, opt_capture, opt_handlerScope) { |
| goog.events.listen(this, type, handler, opt_capture, opt_handlerScope) |
| }; |
| goog.events.EventTarget.prototype.removeEventListener = function(type, handler, opt_capture, opt_handlerScope) { |
| goog.events.unlisten(this, type, handler, opt_capture, opt_handlerScope) |
| }; |
| goog.events.EventTarget.prototype.dispatchEvent = function(e) { |
| return goog.events.dispatchEvent(this, e) |
| }; |
| goog.events.EventTarget.prototype.disposeInternal = function() { |
| goog.events.EventTarget.superClass_.disposeInternal.call(this); |
| goog.events.removeAll(this); |
| this.parentEventTarget_ = null |
| }; |
| goog.json = {}; |
| goog.json.isValid_ = function(s) { |
| if(/^\s*$/.test(s)) { |
| return false |
| } |
| var backslashesRe = /\\["\\\/bfnrtu]/g, simpleValuesRe = /"[^"\\\n\r\u2028\u2029\x00-\x08\x10-\x1f\x80-\x9f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, openBracketsRe = /(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g, remainderRe = /^[\],:{}\s\u2028\u2029]*$/; |
| return remainderRe.test(s.replace(backslashesRe, "@").replace(simpleValuesRe, "]").replace(openBracketsRe, "")) |
| }; |
| goog.json.parse = function(s) { |
| var o = String(s); |
| if(goog.json.isValid_(o)) { |
| try { |
| return eval("(" + o + ")") |
| }catch(ex) { |
| } |
| } |
| throw Error("Invalid JSON string: " + o); |
| }; |
| goog.json.unsafeParse = function(s) { |
| return eval("(" + s + ")") |
| }; |
| goog.json.serialize = function(object) { |
| return(new goog.json.Serializer).serialize(object) |
| }; |
| goog.json.Serializer = function() { |
| }; |
| goog.json.Serializer.prototype.serialize = function(object) { |
| var sb = []; |
| this.serialize_(object, sb); |
| return sb.join("") |
| }; |
| goog.json.Serializer.prototype.serialize_ = function(object, sb) { |
| switch(typeof object) { |
| case "string": |
| this.serializeString_(object, sb); |
| break; |
| case "number": |
| this.serializeNumber_(object, sb); |
| break; |
| case "boolean": |
| sb.push(object); |
| break; |
| case "undefined": |
| sb.push("null"); |
| break; |
| case "object": |
| if(object == null) { |
| sb.push("null"); |
| break |
| } |
| if(goog.isArray(object)) { |
| this.serializeArray_(object, sb); |
| break |
| } |
| this.serializeObject_(object, sb); |
| break; |
| case "function": |
| break; |
| default: |
| throw Error("Unknown type: " + typeof object); |
| } |
| }; |
| goog.json.Serializer.charToJsonCharCache_ = {'"':'\\"', "\\":"\\\\", "/":"\\/", "\u0008":"\\b", "\u000c":"\\f", "\n":"\\n", "\r":"\\r", "\t":"\\t", "\u000b":"\\u000b"}; |
| goog.json.Serializer.charsToReplace_ = /\uffff/.test("\uffff") ? /[\\\"\x00-\x1f\x7f-\uffff]/g : /[\\\"\x00-\x1f\x7f-\xff]/g; |
| goog.json.Serializer.prototype.serializeString_ = function(s, sb) { |
| sb.push('"', s.replace(goog.json.Serializer.charsToReplace_, function(c) { |
| if(c in goog.json.Serializer.charToJsonCharCache_) { |
| return goog.json.Serializer.charToJsonCharCache_[c] |
| } |
| var cc = c.charCodeAt(0), rv = "\\u"; |
| if(cc < 16) { |
| rv += "000" |
| }else { |
| if(cc < 256) { |
| rv += "00" |
| }else { |
| if(cc < 4096) { |
| rv += "0" |
| } |
| } |
| } |
| return goog.json.Serializer.charToJsonCharCache_[c] = rv + cc.toString(16) |
| }), '"') |
| }; |
| goog.json.Serializer.prototype.serializeNumber_ = function(n, sb) { |
| sb.push(isFinite(n) && !isNaN(n) ? n : "null") |
| }; |
| goog.json.Serializer.prototype.serializeArray_ = function(arr, sb) { |
| var l = arr.length; |
| sb.push("["); |
| for(var sep = "", i = 0;i < l;i++) { |
| sb.push(sep); |
| this.serialize_(arr[i], sb); |
| sep = "," |
| } |
| sb.push("]") |
| }; |
| goog.json.Serializer.prototype.serializeObject_ = function(obj, sb) { |
| sb.push("{"); |
| var sep = "", key; |
| for(key in obj) { |
| if(Object.prototype.hasOwnProperty.call(obj, key)) { |
| var value = obj[key]; |
| if(typeof value != "function") { |
| sb.push(sep); |
| this.serializeString_(key, sb); |
| sb.push(":"); |
| this.serialize_(value, sb); |
| sep = "," |
| } |
| } |
| } |
| sb.push("}") |
| }; |
| goog.Timer = function(opt_interval, opt_timerObject) { |
| goog.events.EventTarget.call(this); |
| this.interval_ = opt_interval || 1; |
| this.timerObject_ = opt_timerObject || goog.Timer.defaultTimerObject; |
| this.boundTick_ = goog.bind(this.tick_, this); |
| this.last_ = goog.now() |
| }; |
| goog.inherits(goog.Timer, goog.events.EventTarget); |
| goog.Timer.MAX_TIMEOUT_ = 2147483647; |
| goog.Timer.prototype.enabled = false; |
| goog.Timer.defaultTimerObject = goog.global.window; |
| goog.Timer.intervalScale = 0.8; |
| goog.Timer.prototype.timer_ = null; |
| goog.Timer.prototype.setInterval = function(interval) { |
| this.interval_ = interval; |
| if(this.timer_ && this.enabled) { |
| this.stop(); |
| this.start() |
| }else { |
| this.timer_ && this.stop() |
| } |
| }; |
| goog.Timer.prototype.tick_ = function() { |
| if(this.enabled) { |
| var elapsed = goog.now() - this.last_; |
| if(elapsed > 0 && elapsed < this.interval_ * goog.Timer.intervalScale) { |
| this.timer_ = this.timerObject_.setTimeout(this.boundTick_, this.interval_ - elapsed) |
| }else { |
| this.dispatchTick(); |
| if(this.enabled) { |
| this.timer_ = this.timerObject_.setTimeout(this.boundTick_, this.interval_); |
| this.last_ = goog.now() |
| } |
| } |
| } |
| }; |
| goog.Timer.prototype.dispatchTick = function() { |
| this.dispatchEvent(goog.Timer.TICK) |
| }; |
| goog.Timer.prototype.start = function() { |
| this.enabled = true; |
| if(!this.timer_) { |
| this.timer_ = this.timerObject_.setTimeout(this.boundTick_, this.interval_); |
| this.last_ = goog.now() |
| } |
| }; |
| goog.Timer.prototype.stop = function() { |
| this.enabled = false; |
| if(this.timer_) { |
| this.timerObject_.clearTimeout(this.timer_); |
| this.timer_ = null |
| } |
| }; |
| goog.Timer.prototype.disposeInternal = function() { |
| goog.Timer.superClass_.disposeInternal.call(this); |
| this.stop(); |
| delete this.timerObject_ |
| }; |
| goog.Timer.TICK = "tick"; |
| goog.Timer.callOnce = function(listener, opt_delay, opt_handler) { |
| if(goog.isFunction(listener)) { |
| if(opt_handler) { |
| listener = goog.bind(listener, opt_handler) |
| } |
| }else { |
| if(listener && typeof listener.handleEvent == "function") { |
| listener = goog.bind(listener.handleEvent, listener) |
| }else { |
| throw Error("Invalid listener argument"); |
| } |
| } |
| return opt_delay > goog.Timer.MAX_TIMEOUT_ ? -1 : goog.Timer.defaultTimerObject.setTimeout(listener, opt_delay || 0) |
| }; |
| goog.Timer.clear = function(timerId) { |
| goog.Timer.defaultTimerObject.clearTimeout(timerId) |
| }; |
| goog.uri = {}; |
| goog.uri.utils = {}; |
| goog.uri.utils.CharCode_ = {AMPERSAND:38, EQUAL:61, HASH:35, QUESTION:63}; |
| goog.uri.utils.buildFromEncodedParts = function(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) { |
| var out = []; |
| opt_scheme && out.push(opt_scheme, ":"); |
| if(opt_domain) { |
| out.push("//"); |
| opt_userInfo && out.push(opt_userInfo, "@"); |
| out.push(opt_domain); |
| opt_port && out.push(":", opt_port) |
| } |
| opt_path && out.push(opt_path); |
| opt_queryData && out.push("?", opt_queryData); |
| opt_fragment && out.push("#", opt_fragment); |
| return out.join("") |
| }; |
| goog.uri.utils.splitRe_ = RegExp("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([\\w\\d\\-\\u0100-\\uffff.%]*)(?::([0-9]+))?)?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$"); |
| goog.uri.utils.ComponentIndex = {SCHEME:1, USER_INFO:2, DOMAIN:3, PORT:4, PATH:5, QUERY_DATA:6, FRAGMENT:7}; |
| goog.uri.utils.split = function(uri) { |
| return uri.match(goog.uri.utils.splitRe_) |
| }; |
| goog.uri.utils.decodeIfPossible_ = function(uri) { |
| return uri && decodeURIComponent(uri) |
| }; |
| goog.uri.utils.getComponentByIndex_ = function(componentIndex, uri) { |
| return goog.uri.utils.split(uri)[componentIndex] || null |
| }; |
| goog.uri.utils.getScheme = function(uri) { |
| return goog.uri.utils.getComponentByIndex_(goog.uri.utils.ComponentIndex.SCHEME, uri) |
| }; |
| goog.uri.utils.getUserInfoEncoded = function(uri) { |
| return goog.uri.utils.getComponentByIndex_(goog.uri.utils.ComponentIndex.USER_INFO, uri) |
| }; |
| goog.uri.utils.getUserInfo = function(uri) { |
| return goog.uri.utils.decodeIfPossible_(goog.uri.utils.getUserInfoEncoded(uri)) |
| }; |
| goog.uri.utils.getDomainEncoded = function(uri) { |
| return goog.uri.utils.getComponentByIndex_(goog.uri.utils.ComponentIndex.DOMAIN, uri) |
| }; |
| goog.uri.utils.getDomain = function(uri) { |
| return goog.uri.utils.decodeIfPossible_(goog.uri.utils.getDomainEncoded(uri)) |
| }; |
| goog.uri.utils.getPort = function(uri) { |
| return Number(goog.uri.utils.getComponentByIndex_(goog.uri.utils.ComponentIndex.PORT, uri)) || null |
| }; |
| goog.uri.utils.getPathEncoded = function(uri) { |
| return goog.uri.utils.getComponentByIndex_(goog.uri.utils.ComponentIndex.PATH, uri) |
| }; |
| goog.uri.utils.getPath = function(uri) { |
| return goog.uri.utils.decodeIfPossible_(goog.uri.utils.getPathEncoded(uri)) |
| }; |
| goog.uri.utils.getQueryData = function(uri) { |
| return goog.uri.utils.getComponentByIndex_(goog.uri.utils.ComponentIndex.QUERY_DATA, uri) |
| }; |
| goog.uri.utils.getFragmentEncoded = function(uri) { |
| var hashIndex = uri.indexOf("#"); |
| return hashIndex < 0 ? null : uri.substr(hashIndex + 1) |
| }; |
| goog.uri.utils.setFragmentEncoded = function(uri, fragment) { |
| return goog.uri.utils.removeFragment(uri) + (fragment ? "#" + fragment : "") |
| }; |
| goog.uri.utils.getFragment = function(uri) { |
| return goog.uri.utils.decodeIfPossible_(goog.uri.utils.getFragmentEncoded(uri)) |
| }; |
| goog.uri.utils.getHost = function(uri) { |
| var pieces = goog.uri.utils.split(uri); |
| return goog.uri.utils.buildFromEncodedParts(pieces[goog.uri.utils.ComponentIndex.SCHEME], pieces[goog.uri.utils.ComponentIndex.USER_INFO], pieces[goog.uri.utils.ComponentIndex.DOMAIN], pieces[goog.uri.utils.ComponentIndex.PORT]) |
| }; |
| goog.uri.utils.getPathAndAfter = function(uri) { |
| var pieces = goog.uri.utils.split(uri); |
| return goog.uri.utils.buildFromEncodedParts(null, null, null, null, pieces[goog.uri.utils.ComponentIndex.PATH], pieces[goog.uri.utils.ComponentIndex.QUERY_DATA], pieces[goog.uri.utils.ComponentIndex.FRAGMENT]) |
| }; |
| goog.uri.utils.removeFragment = function(uri) { |
| var hashIndex = uri.indexOf("#"); |
| return hashIndex < 0 ? uri : uri.substr(0, hashIndex) |
| }; |
| goog.uri.utils.haveSameDomain = function(uri1, uri2) { |
| var pieces1 = goog.uri.utils.split(uri1), pieces2 = goog.uri.utils.split(uri2); |
| return pieces1[goog.uri.utils.ComponentIndex.DOMAIN] == pieces2[goog.uri.utils.ComponentIndex.DOMAIN] && pieces1[goog.uri.utils.ComponentIndex.SCHEME] == pieces2[goog.uri.utils.ComponentIndex.SCHEME] && pieces1[goog.uri.utils.ComponentIndex.PORT] == pieces2[goog.uri.utils.ComponentIndex.PORT] |
| }; |
| goog.uri.utils.assertNoFragmentsOrQueries_ = function(uri) { |
| if(goog.DEBUG && (uri.indexOf("#") >= 0 || uri.indexOf("?") >= 0)) { |
| throw Error("goog.uri.utils: Fragment or query identifiers are not supported: [" + uri + "]"); |
| } |
| }; |
| goog.uri.utils.appendQueryData_ = function(buffer) { |
| if(buffer[1]) { |
| var baseUri = buffer[0], hashIndex = baseUri.indexOf("#"); |
| if(hashIndex >= 0) { |
| buffer.push(baseUri.substr(hashIndex)); |
| buffer[0] = baseUri = baseUri.substr(0, hashIndex) |
| } |
| var questionIndex = baseUri.indexOf("?"); |
| if(questionIndex < 0) { |
| buffer[1] = "?" |
| }else { |
| if(questionIndex == baseUri.length - 1) { |
| buffer[1] = undefined |
| } |
| } |
| } |
| return buffer.join("") |
| }; |
| goog.uri.utils.appendKeyValuePairs_ = function(key, value, pairs) { |
| if(goog.isArray(value)) { |
| for(var j = 0;j < value.length;j++) { |
| pairs.push("&", key); |
| value[j] !== "" && pairs.push("=", goog.string.urlEncode(value[j])) |
| } |
| }else { |
| if(value != null) { |
| pairs.push("&", key); |
| value !== "" && pairs.push("=", goog.string.urlEncode(value)) |
| } |
| } |
| }; |
| goog.uri.utils.buildQueryDataBuffer_ = function(buffer, keysAndValues, opt_startIndex) { |
| goog.asserts.assert(Math.max(keysAndValues.length - (opt_startIndex || 0), 0) % 2 == 0, "goog.uri.utils: Key/value lists must be even in length."); |
| for(var i = opt_startIndex || 0;i < keysAndValues.length;i += 2) { |
| goog.uri.utils.appendKeyValuePairs_(keysAndValues[i], keysAndValues[i + 1], buffer) |
| } |
| return buffer |
| }; |
| goog.uri.utils.buildQueryData = function(keysAndValues, opt_startIndex) { |
| var buffer = goog.uri.utils.buildQueryDataBuffer_([], keysAndValues, opt_startIndex); |
| buffer[0] = ""; |
| return buffer.join("") |
| }; |
| goog.uri.utils.buildQueryDataBufferFromMap_ = function(buffer, map) { |
| for(var key in map) { |
| goog.uri.utils.appendKeyValuePairs_(key, map[key], buffer) |
| } |
| return buffer |
| }; |
| goog.uri.utils.buildQueryDataFromMap = function(map) { |
| var buffer = goog.uri.utils.buildQueryDataBufferFromMap_([], map); |
| buffer[0] = ""; |
| return buffer.join("") |
| }; |
| goog.uri.utils.appendParams = function(uri) { |
| return goog.uri.utils.appendQueryData_(arguments.length == 2 ? goog.uri.utils.buildQueryDataBuffer_([uri], arguments[1], 0) : goog.uri.utils.buildQueryDataBuffer_([uri], arguments, 1)) |
| }; |
| goog.uri.utils.appendParamsFromMap = function(uri, map) { |
| return goog.uri.utils.appendQueryData_(goog.uri.utils.buildQueryDataBufferFromMap_([uri], map)) |
| }; |
| goog.uri.utils.appendParam = function(uri, key, value) { |
| return goog.uri.utils.appendQueryData_([uri, "&", key, "=", goog.string.urlEncode(value)]) |
| }; |
| goog.uri.utils.findParam_ = function(uri, startIndex, keyEncoded, hashOrEndIndex) { |
| for(var index = startIndex, keyLength = keyEncoded.length;(index = uri.indexOf(keyEncoded, index)) >= 0 && index < hashOrEndIndex;) { |
| var precedingChar = uri.charCodeAt(index - 1); |
| if(precedingChar == goog.uri.utils.CharCode_.AMPERSAND || precedingChar == goog.uri.utils.CharCode_.QUESTION) { |
| var followingChar = uri.charCodeAt(index + keyLength); |
| if(!followingChar || followingChar == goog.uri.utils.CharCode_.EQUAL || followingChar == goog.uri.utils.CharCode_.AMPERSAND || followingChar == goog.uri.utils.CharCode_.HASH) { |
| return index |
| } |
| } |
| index += keyLength + 1 |
| } |
| return-1 |
| }; |
| goog.uri.utils.hashOrEndRe_ = /#|$/; |
| goog.uri.utils.hasParam = function(uri, keyEncoded) { |
| return goog.uri.utils.findParam_(uri, 0, keyEncoded, uri.search(goog.uri.utils.hashOrEndRe_)) >= 0 |
| }; |
| goog.uri.utils.getParamValue = function(uri, keyEncoded) { |
| var hashOrEndIndex = uri.search(goog.uri.utils.hashOrEndRe_), foundIndex = goog.uri.utils.findParam_(uri, 0, keyEncoded, hashOrEndIndex); |
| if(foundIndex < 0) { |
| return null |
| }else { |
| var endPosition = uri.indexOf("&", foundIndex); |
| if(endPosition < 0 || endPosition > hashOrEndIndex) { |
| endPosition = hashOrEndIndex |
| } |
| foundIndex += keyEncoded.length + 1; |
| return goog.string.urlDecode(uri.substr(foundIndex, endPosition - foundIndex)) |
| } |
| }; |
| goog.uri.utils.getParamValues = function(uri, keyEncoded) { |
| for(var hashOrEndIndex = uri.search(goog.uri.utils.hashOrEndRe_), position = 0, foundIndex, result = [];(foundIndex = goog.uri.utils.findParam_(uri, position, keyEncoded, hashOrEndIndex)) >= 0;) { |
| position = uri.indexOf("&", foundIndex); |
| if(position < 0 || position > hashOrEndIndex) { |
| position = hashOrEndIndex |
| } |
| foundIndex += keyEncoded.length + 1; |
| result.push(goog.string.urlDecode(uri.substr(foundIndex, position - foundIndex))) |
| } |
| return result |
| }; |
| goog.uri.utils.trailingQueryPunctuationRe_ = /[?&]($|#)/; |
| goog.uri.utils.removeParam = function(uri, keyEncoded) { |
| for(var hashOrEndIndex = uri.search(goog.uri.utils.hashOrEndRe_), position = 0, foundIndex, buffer = [];(foundIndex = goog.uri.utils.findParam_(uri, position, keyEncoded, hashOrEndIndex)) >= 0;) { |
| buffer.push(uri.substring(position, foundIndex)); |
| position = Math.min(uri.indexOf("&", foundIndex) + 1 || hashOrEndIndex, hashOrEndIndex) |
| } |
| buffer.push(uri.substr(position)); |
| return buffer.join("").replace(goog.uri.utils.trailingQueryPunctuationRe_, "$1") |
| }; |
| goog.uri.utils.setParam = function(uri, keyEncoded, value) { |
| return goog.uri.utils.appendParam(goog.uri.utils.removeParam(uri, keyEncoded), keyEncoded, value) |
| }; |
| goog.uri.utils.appendPath = function(baseUri, path) { |
| goog.uri.utils.assertNoFragmentsOrQueries_(baseUri); |
| if(goog.string.endsWith(baseUri, "/")) { |
| baseUri = baseUri.substr(0, baseUri.length - 1) |
| } |
| if(goog.string.startsWith(path, "/")) { |
| path = path.substr(1) |
| } |
| return goog.string.buildString(baseUri, "/", path) |
| }; |
| goog.uri.utils.StandardQueryParam = {RANDOM:"zx"}; |
| goog.uri.utils.makeUnique = function(uri) { |
| return goog.uri.utils.setParam(uri, goog.uri.utils.StandardQueryParam.RANDOM, goog.string.getRandomString()) |
| }; |
| goog.net = {}; |
| goog.net.ErrorCode = {NO_ERROR:0, ACCESS_DENIED:1, FILE_NOT_FOUND:2, FF_SILENT_ERROR:3, CUSTOM_ERROR:4, EXCEPTION:5, HTTP_ERROR:6, ABORT:7, TIMEOUT:8, OFFLINE:9}; |
| goog.net.ErrorCode.getDebugMessage = function(errorCode) { |
| switch(errorCode) { |
| case goog.net.ErrorCode.NO_ERROR: |
| return"No Error"; |
| case goog.net.ErrorCode.ACCESS_DENIED: |
| return"Access denied to content document"; |
| case goog.net.ErrorCode.FILE_NOT_FOUND: |
| return"File not found"; |
| case goog.net.ErrorCode.FF_SILENT_ERROR: |
| return"Firefox silently errored"; |
| case goog.net.ErrorCode.CUSTOM_ERROR: |
| return"Application custom error"; |
| case goog.net.ErrorCode.EXCEPTION: |
| return"An exception occurred"; |
| case goog.net.ErrorCode.HTTP_ERROR: |
| return"Http response at 400 or 500 level"; |
| case goog.net.ErrorCode.ABORT: |
| return"Request was aborted"; |
| case goog.net.ErrorCode.TIMEOUT: |
| return"Request timed out"; |
| case goog.net.ErrorCode.OFFLINE: |
| return"The resource is not available offline"; |
| default: |
| return"Unrecognized error code" |
| } |
| }; |
| goog.net.EventType = {COMPLETE:"complete", SUCCESS:"success", ERROR:"error", ABORT:"abort", READY:"ready", READY_STATE_CHANGE:"readystatechange", TIMEOUT:"timeout", INCREMENTAL_DATA:"incrementaldata", PROGRESS:"progress"}; |
| goog.net.XhrMonitor_ = function() { |
| if(goog.userAgent.GECKO) { |
| this.contextsToXhr_ = {}; |
| this.xhrToContexts_ = {}; |
| this.stack_ = [] |
| } |
| }; |
| goog.net.XhrMonitor_.getKey = function(obj) { |
| return goog.isString(obj) ? obj : goog.isObject(obj) ? goog.getUid(obj) : "" |
| }; |
| goog.net.XhrMonitor_.prototype.logger_ = goog.debug.Logger.getLogger("goog.net.xhrMonitor"); |
| goog.net.XhrMonitor_.prototype.enabled_ = goog.userAgent.GECKO; |
| goog.net.XhrMonitor_.prototype.pushContext = function(context) { |
| if(this.enabled_) { |
| var key = goog.net.XhrMonitor_.getKey(context); |
| this.logger_.finest("Pushing context: " + context + " (" + key + ")"); |
| this.stack_.push(key) |
| } |
| }; |
| goog.net.XhrMonitor_.prototype.popContext = function() { |
| if(this.enabled_) { |
| var context = this.stack_.pop(); |
| this.logger_.finest("Popping context: " + context); |
| this.updateDependentContexts_(context) |
| } |
| }; |
| goog.net.XhrMonitor_.prototype.markXhrOpen = function(xhr) { |
| if(this.enabled_) { |
| var uid = goog.getUid(xhr); |
| this.logger_.fine("Opening XHR : " + uid); |
| for(var i = 0;i < this.stack_.length;i++) { |
| var context = this.stack_[i]; |
| this.addToMap_(this.contextsToXhr_, context, uid); |
| this.addToMap_(this.xhrToContexts_, uid, context) |
| } |
| } |
| }; |
| goog.net.XhrMonitor_.prototype.markXhrClosed = function(xhr) { |
| if(this.enabled_) { |
| var uid = goog.getUid(xhr); |
| this.logger_.fine("Closing XHR : " + uid); |
| delete this.xhrToContexts_[uid]; |
| for(var context in this.contextsToXhr_) { |
| goog.array.remove(this.contextsToXhr_[context], uid); |
| this.contextsToXhr_[context].length == 0 && delete this.contextsToXhr_[context] |
| } |
| } |
| }; |
| goog.net.XhrMonitor_.prototype.updateDependentContexts_ = function(xhrUid) { |
| var contexts = this.xhrToContexts_[xhrUid], xhrs = this.contextsToXhr_[xhrUid]; |
| if(contexts && xhrs) { |
| this.logger_.finest("Updating dependent contexts"); |
| goog.array.forEach(contexts, function(context) { |
| goog.array.forEach(xhrs, function(xhr) { |
| this.addToMap_(this.contextsToXhr_, context, xhr); |
| this.addToMap_(this.xhrToContexts_, xhr, context) |
| }, this) |
| }, this) |
| } |
| }; |
| goog.net.XhrMonitor_.prototype.addToMap_ = function(map, key, value) { |
| map[key] || (map[key] = []); |
| goog.array.contains(map[key], value) || map[key].push(value) |
| }; |
| goog.net.xhrMonitor = new goog.net.XhrMonitor_; |
| goog.net.XmlHttpFactory = function() { |
| }; |
| goog.net.XmlHttpFactory.prototype.cachedOptions_ = null; |
| goog.net.XmlHttpFactory.prototype.getOptions = function() { |
| return this.cachedOptions_ || (this.cachedOptions_ = this.internalGetOptions()) |
| }; |
| goog.net.WrapperXmlHttpFactory = function(xhrFactory, optionsFactory) { |
| this.xhrFactory_ = xhrFactory; |
| this.optionsFactory_ = optionsFactory |
| }; |
| goog.inherits(goog.net.WrapperXmlHttpFactory, goog.net.XmlHttpFactory); |
| goog.net.WrapperXmlHttpFactory.prototype.createInstance = function() { |
| return this.xhrFactory_() |
| }; |
| goog.net.WrapperXmlHttpFactory.prototype.getOptions = function() { |
| return this.optionsFactory_() |
| }; |
| goog.net.XmlHttp = function() { |
| return goog.net.XmlHttp.factory_.createInstance() |
| }; |
| goog.net.XmlHttp.getOptions = function() { |
| return goog.net.XmlHttp.factory_.getOptions() |
| }; |
| goog.net.XmlHttp.OptionType = {USE_NULL_FUNCTION:0, LOCAL_REQUEST_ERROR:1}; |
| goog.net.XmlHttp.ReadyState = {UNINITIALIZED:0, LOADING:1, LOADED:2, INTERACTIVE:3, COMPLETE:4}; |
| goog.net.XmlHttp.setFactory = function(factory, optionsFactory) { |
| goog.net.XmlHttp.setGlobalFactory(new goog.net.WrapperXmlHttpFactory(factory, optionsFactory)) |
| }; |
| goog.net.XmlHttp.setGlobalFactory = function(factory) { |
| goog.net.XmlHttp.factory_ = factory |
| }; |
| goog.net.DefaultXmlHttpFactory = function() { |
| }; |
| goog.inherits(goog.net.DefaultXmlHttpFactory, goog.net.XmlHttpFactory); |
| goog.net.DefaultXmlHttpFactory.prototype.createInstance = function() { |
| var progId = this.getProgId_(); |
| return progId ? new ActiveXObject(progId) : new XMLHttpRequest |
| }; |
| goog.net.DefaultXmlHttpFactory.prototype.internalGetOptions = function() { |
| var progId = this.getProgId_(), options = {}; |
| if(progId) { |
| options[goog.net.XmlHttp.OptionType.USE_NULL_FUNCTION] = true; |
| options[goog.net.XmlHttp.OptionType.LOCAL_REQUEST_ERROR] = true |
| } |
| return options |
| }; |
| goog.net.DefaultXmlHttpFactory.prototype.ieProgId_ = null; |
| goog.net.DefaultXmlHttpFactory.prototype.getProgId_ = function() { |
| if(!this.ieProgId_ && typeof XMLHttpRequest == "undefined" && typeof ActiveXObject != "undefined") { |
| for(var ACTIVE_X_IDENTS = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"], i = 0;i < ACTIVE_X_IDENTS.length;i++) { |
| var candidate = ACTIVE_X_IDENTS[i]; |
| try { |
| new ActiveXObject(candidate); |
| return this.ieProgId_ = candidate |
| }catch(e) { |
| } |
| } |
| throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed"); |
| } |
| return this.ieProgId_ |
| }; |
| goog.net.XmlHttp.setGlobalFactory(new goog.net.DefaultXmlHttpFactory); |
| goog.net.XhrIo = function(opt_xmlHttpFactory) { |
| goog.events.EventTarget.call(this); |
| this.headers = new goog.structs.Map; |
| this.xmlHttpFactory_ = opt_xmlHttpFactory || null |
| }; |
| goog.inherits(goog.net.XhrIo, goog.events.EventTarget); |
| goog.net.XhrIo.ResponseType = {DEFAULT:"", TEXT:"text", DOCUMENT:"document", BLOB:"blob", ARRAY_BUFFER:"arraybuffer"}; |
| goog.net.XhrIo.prototype.logger_ = goog.debug.Logger.getLogger("goog.net.XhrIo"); |
| goog.net.XhrIo.CONTENT_TYPE_HEADER = "Content-Type"; |
| goog.net.XhrIo.HTTP_SCHEME_PATTERN = /^https?:?$/i; |
| goog.net.XhrIo.FORM_CONTENT_TYPE = "application/x-www-form-urlencoded;charset=utf-8"; |
| goog.net.XhrIo.sendInstances_ = []; |
| goog.net.XhrIo.send = function(url, opt_callback, opt_method, opt_content, opt_headers, opt_timeoutInterval) { |
| var x = new goog.net.XhrIo; |
| goog.net.XhrIo.sendInstances_.push(x); |
| opt_callback && goog.events.listen(x, goog.net.EventType.COMPLETE, opt_callback); |
| goog.events.listen(x, goog.net.EventType.READY, goog.partial(goog.net.XhrIo.cleanupSend_, x)); |
| opt_timeoutInterval && x.setTimeoutInterval(opt_timeoutInterval); |
| x.send(url, opt_method, opt_content, opt_headers) |
| }; |
| goog.net.XhrIo.cleanup = function() { |
| for(var instances = goog.net.XhrIo.sendInstances_;instances.length;) { |
| instances.pop().dispose() |
| } |
| }; |
| goog.net.XhrIo.protectEntryPoints = function(errorHandler) { |
| goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_ = errorHandler.protectEntryPoint(goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_) |
| }; |
| goog.net.XhrIo.cleanupSend_ = function(XhrIo) { |
| XhrIo.dispose(); |
| goog.array.remove(goog.net.XhrIo.sendInstances_, XhrIo) |
| }; |
| goog.net.XhrIo.prototype.active_ = false; |
| goog.net.XhrIo.prototype.xhr_ = null; |
| goog.net.XhrIo.prototype.xhrOptions_ = null; |
| goog.net.XhrIo.prototype.lastUri_ = ""; |
| goog.net.XhrIo.prototype.lastMethod_ = ""; |
| goog.net.XhrIo.prototype.lastErrorCode_ = goog.net.ErrorCode.NO_ERROR; |
| goog.net.XhrIo.prototype.lastError_ = ""; |
| goog.net.XhrIo.prototype.errorDispatched_ = false; |
| goog.net.XhrIo.prototype.inSend_ = false; |
| goog.net.XhrIo.prototype.inOpen_ = false; |
| goog.net.XhrIo.prototype.inAbort_ = false; |
| goog.net.XhrIo.prototype.timeoutInterval_ = 0; |
| goog.net.XhrIo.prototype.timeoutId_ = null; |
| goog.net.XhrIo.prototype.responseType_ = goog.net.XhrIo.ResponseType.DEFAULT; |
| goog.net.XhrIo.prototype.withCredentials_ = false; |
| goog.net.XhrIo.prototype.setTimeoutInterval = function(ms) { |
| this.timeoutInterval_ = Math.max(0, ms) |
| }; |
| goog.net.XhrIo.prototype.send = function(url, opt_method, opt_content, opt_headers) { |
| if(this.xhr_) { |
| throw Error("[goog.net.XhrIo] Object is active with another request"); |
| } |
| var method = opt_method || "GET"; |
| this.lastUri_ = url; |
| this.lastError_ = ""; |
| this.lastErrorCode_ = goog.net.ErrorCode.NO_ERROR; |
| this.lastMethod_ = method; |
| this.errorDispatched_ = false; |
| this.active_ = true; |
| this.xhr_ = this.createXhr(); |
| this.xhrOptions_ = this.xmlHttpFactory_ ? this.xmlHttpFactory_.getOptions() : goog.net.XmlHttp.getOptions(); |
| goog.net.xhrMonitor.markXhrOpen(this.xhr_); |
| this.xhr_.onreadystatechange = goog.bind(this.onReadyStateChange_, this); |
| try { |
| this.logger_.fine(this.formatMsg_("Opening Xhr")); |
| this.inOpen_ = true; |
| this.xhr_.open(method, url, true); |
| this.inOpen_ = false |
| }catch(err) { |
| this.logger_.fine(this.formatMsg_("Error opening Xhr: " + err.message)); |
| this.error_(goog.net.ErrorCode.EXCEPTION, err); |
| return |
| } |
| var content = opt_content || "", headers = this.headers.clone(); |
| opt_headers && goog.structs.forEach(opt_headers, function(value, key) { |
| headers.set(key, value) |
| }); |
| method == "POST" && !headers.containsKey(goog.net.XhrIo.CONTENT_TYPE_HEADER) && headers.set(goog.net.XhrIo.CONTENT_TYPE_HEADER, goog.net.XhrIo.FORM_CONTENT_TYPE); |
| goog.structs.forEach(headers, function(value, key) { |
| this.xhr_.setRequestHeader(key, value) |
| }, this); |
| if(this.responseType_) { |
| this.xhr_.responseType = this.responseType_ |
| } |
| if(goog.object.containsKey(this.xhr_, "withCredentials")) { |
| this.xhr_.withCredentials = this.withCredentials_ |
| } |
| try { |
| if(this.timeoutId_) { |
| goog.Timer.defaultTimerObject.clearTimeout(this.timeoutId_); |
| this.timeoutId_ = null |
| } |
| if(this.timeoutInterval_ > 0) { |
| this.logger_.fine(this.formatMsg_("Will abort after " + this.timeoutInterval_ + "ms if incomplete")); |
| this.timeoutId_ = goog.Timer.defaultTimerObject.setTimeout(goog.bind(this.timeout_, this), this.timeoutInterval_) |
| } |
| this.logger_.fine(this.formatMsg_("Sending request")); |
| this.inSend_ = true; |
| this.xhr_.send(content); |
| this.inSend_ = false |
| }catch(err$$0) { |
| this.logger_.fine(this.formatMsg_("Send error: " + err$$0.message)); |
| this.error_(goog.net.ErrorCode.EXCEPTION, err$$0) |
| } |
| }; |
| goog.net.XhrIo.prototype.createXhr = function() { |
| return this.xmlHttpFactory_ ? this.xmlHttpFactory_.createInstance() : new goog.net.XmlHttp |
| }; |
| goog.net.XhrIo.prototype.dispatchEvent = function(e) { |
| if(this.xhr_) { |
| goog.net.xhrMonitor.pushContext(this.xhr_); |
| try { |
| return goog.net.XhrIo.superClass_.dispatchEvent.call(this, e) |
| }finally { |
| goog.net.xhrMonitor.popContext() |
| } |
| }else { |
| return goog.net.XhrIo.superClass_.dispatchEvent.call(this, e) |
| } |
| }; |
| goog.net.XhrIo.prototype.timeout_ = function() { |
| if(typeof goog != "undefined") { |
| if(this.xhr_) { |
| this.lastError_ = "Timed out after " + this.timeoutInterval_ + "ms, aborting"; |
| this.lastErrorCode_ = goog.net.ErrorCode.TIMEOUT; |
| this.logger_.fine(this.formatMsg_(this.lastError_)); |
| this.dispatchEvent(goog.net.EventType.TIMEOUT); |
| this.abort(goog.net.ErrorCode.TIMEOUT) |
| } |
| } |
| }; |
| goog.net.XhrIo.prototype.error_ = function(errorCode, err) { |
| this.active_ = false; |
| if(this.xhr_) { |
| this.inAbort_ = true; |
| this.xhr_.abort(); |
| this.inAbort_ = false |
| } |
| this.lastError_ = err; |
| this.lastErrorCode_ = errorCode; |
| this.dispatchErrors_(); |
| this.cleanUpXhr_() |
| }; |
| goog.net.XhrIo.prototype.dispatchErrors_ = function() { |
| if(!this.errorDispatched_) { |
| this.errorDispatched_ = true; |
| this.dispatchEvent(goog.net.EventType.COMPLETE); |
| this.dispatchEvent(goog.net.EventType.ERROR) |
| } |
| }; |
| goog.net.XhrIo.prototype.abort = function(opt_failureCode) { |
| if(this.xhr_ && this.active_) { |
| this.logger_.fine(this.formatMsg_("Aborting")); |
| this.active_ = false; |
| this.inAbort_ = true; |
| this.xhr_.abort(); |
| this.inAbort_ = false; |
| this.lastErrorCode_ = opt_failureCode || goog.net.ErrorCode.ABORT; |
| this.dispatchEvent(goog.net.EventType.COMPLETE); |
| this.dispatchEvent(goog.net.EventType.ABORT); |
| this.cleanUpXhr_() |
| } |
| }; |
| goog.net.XhrIo.prototype.disposeInternal = function() { |
| if(this.xhr_) { |
| if(this.active_) { |
| this.active_ = false; |
| this.inAbort_ = true; |
| this.xhr_.abort(); |
| this.inAbort_ = false |
| } |
| this.cleanUpXhr_(true) |
| } |
| goog.net.XhrIo.superClass_.disposeInternal.call(this) |
| }; |
| goog.net.XhrIo.prototype.onReadyStateChange_ = function() { |
| if(!this.inOpen_ && !this.inSend_ && !this.inAbort_) { |
| this.onReadyStateChangeEntryPoint_() |
| }else { |
| this.onReadyStateChangeHelper_() |
| } |
| }; |
| goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_ = function() { |
| this.onReadyStateChangeHelper_() |
| }; |
| goog.net.XhrIo.prototype.onReadyStateChangeHelper_ = function() { |
| if(this.active_) { |
| if(typeof goog != "undefined") { |
| if(this.xhrOptions_[goog.net.XmlHttp.OptionType.LOCAL_REQUEST_ERROR] && this.getReadyState() == goog.net.XmlHttp.ReadyState.COMPLETE && this.getStatus() == 2) { |
| this.logger_.fine(this.formatMsg_("Local request error detected and ignored")) |
| }else { |
| if(this.inSend_ && this.getReadyState() == goog.net.XmlHttp.ReadyState.COMPLETE) { |
| goog.Timer.defaultTimerObject.setTimeout(goog.bind(this.onReadyStateChange_, this), 0) |
| }else { |
| this.dispatchEvent(goog.net.EventType.READY_STATE_CHANGE); |
| if(this.isComplete()) { |
| this.logger_.fine(this.formatMsg_("Request complete")); |
| this.active_ = false; |
| if(this.isSuccess()) { |
| this.dispatchEvent(goog.net.EventType.COMPLETE); |
| this.dispatchEvent(goog.net.EventType.SUCCESS) |
| }else { |
| this.lastErrorCode_ = goog.net.ErrorCode.HTTP_ERROR; |
| this.lastError_ = this.getStatusText() + " [" + this.getStatus() + "]"; |
| this.dispatchErrors_() |
| } |
| this.cleanUpXhr_() |
| } |
| } |
| } |
| } |
| } |
| }; |
| goog.net.XhrIo.prototype.cleanUpXhr_ = function(opt_fromDispose) { |
| if(this.xhr_) { |
| var xhr = this.xhr_, clearedOnReadyStateChange = this.xhrOptions_[goog.net.XmlHttp.OptionType.USE_NULL_FUNCTION] ? goog.nullFunction : null; |
| this.xhrOptions_ = this.xhr_ = null; |
| if(this.timeoutId_) { |
| goog.Timer.defaultTimerObject.clearTimeout(this.timeoutId_); |
| this.timeoutId_ = null |
| } |
| if(!opt_fromDispose) { |
| goog.net.xhrMonitor.pushContext(xhr); |
| this.dispatchEvent(goog.net.EventType.READY); |
| goog.net.xhrMonitor.popContext() |
| } |
| goog.net.xhrMonitor.markXhrClosed(xhr); |
| try { |
| xhr.onreadystatechange = clearedOnReadyStateChange |
| }catch(e) { |
| this.logger_.severe("Problem encountered resetting onreadystatechange: " + e.message) |
| } |
| } |
| }; |
| goog.net.XhrIo.prototype.isComplete = function() { |
| return this.getReadyState() == goog.net.XmlHttp.ReadyState.COMPLETE |
| }; |
| goog.net.XhrIo.prototype.isSuccess = function() { |
| switch(this.getStatus()) { |
| case 0: |
| return!this.isLastUriEffectiveSchemeHttp_(); |
| case 200: |
| ; |
| case 204: |
| ; |
| case 304: |
| return true; |
| default: |
| return false |
| } |
| }; |
| goog.net.XhrIo.prototype.isLastUriEffectiveSchemeHttp_ = function() { |
| var lastUriScheme = goog.isString(this.lastUri_) ? goog.uri.utils.getScheme(this.lastUri_) : this.lastUri_.getScheme(); |
| if(lastUriScheme) { |
| return goog.net.XhrIo.HTTP_SCHEME_PATTERN.test(lastUriScheme) |
| } |
| return self.location ? goog.net.XhrIo.HTTP_SCHEME_PATTERN.test(self.location.protocol) : true |
| }; |
| goog.net.XhrIo.prototype.getReadyState = function() { |
| return this.xhr_ ? this.xhr_.readyState : goog.net.XmlHttp.ReadyState.UNINITIALIZED |
| }; |
| goog.net.XhrIo.prototype.getStatus = function() { |
| try { |
| return this.getReadyState() > goog.net.XmlHttp.ReadyState.LOADED ? this.xhr_.status : -1 |
| }catch(e) { |
| this.logger_.warning("Can not get status: " + e.message); |
| return-1 |
| } |
| }; |
| goog.net.XhrIo.prototype.getStatusText = function() { |
| try { |
| return this.getReadyState() > goog.net.XmlHttp.ReadyState.LOADED ? this.xhr_.statusText : "" |
| }catch(e) { |
| this.logger_.fine("Can not get status: " + e.message); |
| return"" |
| } |
| }; |
| goog.net.XhrIo.prototype.getResponseText = function() { |
| try { |
| return this.xhr_ ? this.xhr_.responseText : "" |
| }catch(e) { |
| this.logger_.fine("Can not get responseText: " + e.message); |
| return"" |
| } |
| }; |
| goog.net.XhrIo.prototype.getResponseHeader = function(key) { |
| return this.xhr_ && this.isComplete() ? this.xhr_.getResponseHeader(key) : undefined |
| }; |
| goog.net.XhrIo.prototype.getAllResponseHeaders = function() { |
| return this.xhr_ && this.isComplete() ? this.xhr_.getAllResponseHeaders() : "" |
| }; |
| goog.net.XhrIo.prototype.formatMsg_ = function(msg) { |
| return msg + " [" + this.lastMethod_ + " " + this.lastUri_ + " " + this.getStatus() + "]" |
| }; |
| goog.debug.entryPointRegistry.register(function(transformer) { |
| goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_ = transformer(goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_) |
| }); |
| goog.Uri = function(opt_uri, opt_ignoreCase) { |
| var m; |
| if(opt_uri instanceof goog.Uri) { |
| this.setIgnoreCase(opt_ignoreCase == null ? opt_uri.getIgnoreCase() : opt_ignoreCase); |
| this.setScheme(opt_uri.getScheme()); |
| this.setUserInfo(opt_uri.getUserInfo()); |
| this.setDomain(opt_uri.getDomain()); |
| this.setPort(opt_uri.getPort()); |
| this.setPath(opt_uri.getPath()); |
| this.setQueryData(opt_uri.getQueryData().clone()); |
| this.setFragment(opt_uri.getFragment()) |
| }else { |
| if(opt_uri && (m = goog.uri.utils.split(String(opt_uri)))) { |
| this.setIgnoreCase(!!opt_ignoreCase); |
| this.setScheme(m[goog.uri.utils.ComponentIndex.SCHEME] || "", true); |
| this.setUserInfo(m[goog.uri.utils.ComponentIndex.USER_INFO] || "", true); |
| this.setDomain(m[goog.uri.utils.ComponentIndex.DOMAIN] || "", true); |
| this.setPort(m[goog.uri.utils.ComponentIndex.PORT]); |
| this.setPath(m[goog.uri.utils.ComponentIndex.PATH] || "", true); |
| this.setQuery(m[goog.uri.utils.ComponentIndex.QUERY_DATA] || "", true); |
| this.setFragment(m[goog.uri.utils.ComponentIndex.FRAGMENT] || "", true) |
| }else { |
| this.setIgnoreCase(!!opt_ignoreCase); |
| this.queryData_ = new goog.Uri.QueryData(null, this, this.ignoreCase_) |
| } |
| } |
| }; |
| goog.Uri.RANDOM_PARAM = goog.uri.utils.StandardQueryParam.RANDOM; |
| goog.Uri.prototype.scheme_ = ""; |
| goog.Uri.prototype.userInfo_ = ""; |
| goog.Uri.prototype.domain_ = ""; |
| goog.Uri.prototype.port_ = null; |
| goog.Uri.prototype.path_ = ""; |
| goog.Uri.prototype.fragment_ = ""; |
| goog.Uri.prototype.isReadOnly_ = false; |
| goog.Uri.prototype.ignoreCase_ = false; |
| goog.Uri.prototype.toString = function() { |
| if(this.cachedToString_) { |
| return this.cachedToString_ |
| } |
| var out = []; |
| this.scheme_ && out.push(goog.Uri.encodeSpecialChars_(this.scheme_, goog.Uri.reDisallowedInSchemeOrUserInfo_), ":"); |
| if(this.domain_) { |
| out.push("//"); |
| this.userInfo_ && out.push(goog.Uri.encodeSpecialChars_(this.userInfo_, goog.Uri.reDisallowedInSchemeOrUserInfo_), "@"); |
| out.push(goog.Uri.encodeString_(this.domain_)); |
| this.port_ != null && out.push(":", String(this.getPort())) |
| } |
| if(this.path_) { |
| this.hasDomain() && this.path_.charAt(0) != "/" && out.push("/"); |
| out.push(goog.Uri.encodeSpecialChars_(this.path_, goog.Uri.reDisallowedInPath_)) |
| } |
| var query = String(this.queryData_); |
| query && out.push("?", query); |
| this.fragment_ && out.push("#", goog.Uri.encodeSpecialChars_(this.fragment_, goog.Uri.reDisallowedInFragment_)); |
| return this.cachedToString_ = out.join("") |
| }; |
| goog.Uri.prototype.resolve = function(relativeUri) { |
| var absoluteUri = this.clone(), overridden = relativeUri.hasScheme(); |
| if(overridden) { |
| absoluteUri.setScheme(relativeUri.getScheme()) |
| }else { |
| overridden = relativeUri.hasUserInfo() |
| } |
| if(overridden) { |
| absoluteUri.setUserInfo(relativeUri.getUserInfo()) |
| }else { |
| overridden = relativeUri.hasDomain() |
| } |
| if(overridden) { |
| absoluteUri.setDomain(relativeUri.getDomain()) |
| }else { |
| overridden = relativeUri.hasPort() |
| } |
| var path = relativeUri.getPath(); |
| if(overridden) { |
| absoluteUri.setPort(relativeUri.getPort()) |
| }else { |
| if(overridden = relativeUri.hasPath()) { |
| if(path.charAt(0) != "/") { |
| if(this.hasDomain() && !this.hasPath()) { |
| path = "/" + path |
| }else { |
| var lastSlashIndex = absoluteUri.getPath().lastIndexOf("/"); |
| if(lastSlashIndex != -1) { |
| path = absoluteUri.getPath().substr(0, lastSlashIndex + 1) + path |
| } |
| } |
| } |
| path = goog.Uri.removeDotSegments(path) |
| } |
| } |
| if(overridden) { |
| absoluteUri.setPath(path) |
| }else { |
| overridden = relativeUri.hasQuery() |
| } |
| if(overridden) { |
| absoluteUri.setQuery(relativeUri.getDecodedQuery()) |
| }else { |
| overridden = relativeUri.hasFragment() |
| } |
| overridden && absoluteUri.setFragment(relativeUri.getFragment()); |
| return absoluteUri |
| }; |
| goog.Uri.prototype.clone = function() { |
| return goog.Uri.create(this.scheme_, this.userInfo_, this.domain_, this.port_, this.path_, this.queryData_.clone(), this.fragment_, this.ignoreCase_) |
| }; |
| goog.Uri.prototype.getScheme = function() { |
| return this.scheme_ |
| }; |
| goog.Uri.prototype.setScheme = function(newScheme, opt_decode) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| if(this.scheme_ = opt_decode ? goog.Uri.decodeOrEmpty_(newScheme) : newScheme) { |
| this.scheme_ = this.scheme_.replace(/:$/, "") |
| } |
| return this |
| }; |
| goog.Uri.prototype.hasScheme = function() { |
| return!!this.scheme_ |
| }; |
| goog.Uri.prototype.getUserInfo = function() { |
| return this.userInfo_ |
| }; |
| goog.Uri.prototype.setUserInfo = function(newUserInfo, opt_decode) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| this.userInfo_ = opt_decode ? goog.Uri.decodeOrEmpty_(newUserInfo) : newUserInfo; |
| return this |
| }; |
| goog.Uri.prototype.hasUserInfo = function() { |
| return!!this.userInfo_ |
| }; |
| goog.Uri.prototype.getDomain = function() { |
| return this.domain_ |
| }; |
| goog.Uri.prototype.setDomain = function(newDomain, opt_decode) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| this.domain_ = opt_decode ? goog.Uri.decodeOrEmpty_(newDomain) : newDomain; |
| return this |
| }; |
| goog.Uri.prototype.hasDomain = function() { |
| return!!this.domain_ |
| }; |
| goog.Uri.prototype.getPort = function() { |
| return this.port_ |
| }; |
| goog.Uri.prototype.setPort = function(newPort) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| if(newPort) { |
| newPort = Number(newPort); |
| if(isNaN(newPort) || newPort < 0) { |
| throw Error("Bad port number " + newPort); |
| } |
| this.port_ = newPort |
| }else { |
| this.port_ = null |
| } |
| return this |
| }; |
| goog.Uri.prototype.hasPort = function() { |
| return this.port_ != null |
| }; |
| goog.Uri.prototype.getPath = function() { |
| return this.path_ |
| }; |
| goog.Uri.prototype.setPath = function(newPath, opt_decode) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| this.path_ = opt_decode ? goog.Uri.decodeOrEmpty_(newPath) : newPath; |
| return this |
| }; |
| goog.Uri.prototype.hasPath = function() { |
| return!!this.path_ |
| }; |
| goog.Uri.prototype.hasQuery = function() { |
| return this.queryData_.toString() !== "" |
| }; |
| goog.Uri.prototype.setQueryData = function(queryData, opt_decode) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| if(queryData instanceof goog.Uri.QueryData) { |
| this.queryData_ = queryData; |
| this.queryData_.uri_ = this; |
| this.queryData_.setIgnoreCase(this.ignoreCase_) |
| }else { |
| opt_decode || (queryData = goog.Uri.encodeSpecialChars_(queryData, goog.Uri.reDisallowedInQuery_)); |
| this.queryData_ = new goog.Uri.QueryData(queryData, this, this.ignoreCase_) |
| } |
| return this |
| }; |
| goog.Uri.prototype.setQuery = function(newQuery, opt_decode) { |
| return this.setQueryData(newQuery, opt_decode) |
| }; |
| goog.Uri.prototype.getDecodedQuery = function() { |
| return this.queryData_.toDecodedString() |
| }; |
| goog.Uri.prototype.getQueryData = function() { |
| return this.queryData_ |
| }; |
| goog.Uri.prototype.setParameterValue = function(key, value) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| this.queryData_.set(key, value); |
| return this |
| }; |
| goog.Uri.prototype.getFragment = function() { |
| return this.fragment_ |
| }; |
| goog.Uri.prototype.setFragment = function(newFragment, opt_decode) { |
| this.enforceReadOnly(); |
| delete this.cachedToString_; |
| this.fragment_ = opt_decode ? goog.Uri.decodeOrEmpty_(newFragment) : newFragment; |
| return this |
| }; |
| goog.Uri.prototype.hasFragment = function() { |
| return!!this.fragment_ |
| }; |
| goog.Uri.prototype.makeUnique = function() { |
| this.enforceReadOnly(); |
| this.setParameterValue(goog.Uri.RANDOM_PARAM, goog.string.getRandomString()); |
| return this |
| }; |
| goog.Uri.prototype.removeParameter = function(key) { |
| this.enforceReadOnly(); |
| this.queryData_.remove(key); |
| return this |
| }; |
| goog.Uri.prototype.enforceReadOnly = function() { |
| if(this.isReadOnly_) { |
| throw Error("Tried to modify a read-only Uri"); |
| } |
| }; |
| goog.Uri.prototype.setIgnoreCase = function(ignoreCase) { |
| this.ignoreCase_ = ignoreCase; |
| this.queryData_ && this.queryData_.setIgnoreCase(ignoreCase); |
| return this |
| }; |
| goog.Uri.prototype.getIgnoreCase = function() { |
| return this.ignoreCase_ |
| }; |
| goog.Uri.parse = function(uri, opt_ignoreCase) { |
| return uri instanceof goog.Uri ? uri.clone() : new goog.Uri(uri, opt_ignoreCase) |
| }; |
| goog.Uri.create = function(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_query, opt_fragment, opt_ignoreCase) { |
| var uri = new goog.Uri(null, opt_ignoreCase); |
| opt_scheme && uri.setScheme(opt_scheme); |
| opt_userInfo && uri.setUserInfo(opt_userInfo); |
| opt_domain && uri.setDomain(opt_domain); |
| opt_port && uri.setPort(opt_port); |
| opt_path && uri.setPath(opt_path); |
| opt_query && uri.setQueryData(opt_query); |
| opt_fragment && uri.setFragment(opt_fragment); |
| return uri |
| }; |
| goog.Uri.resolve = function(base, rel) { |
| base instanceof goog.Uri || (base = goog.Uri.parse(base)); |
| rel instanceof goog.Uri || (rel = goog.Uri.parse(rel)); |
| return base.resolve(rel) |
| }; |
| goog.Uri.removeDotSegments = function(path) { |
| if(path == ".." || path == ".") { |
| return"" |
| }else { |
| if(!goog.string.contains(path, "./") && !goog.string.contains(path, "/.")) { |
| return path |
| }else { |
| for(var leadingSlash = goog.string.startsWith(path, "/"), segments = path.split("/"), out = [], pos = 0;pos < segments.length;) { |
| var segment = segments[pos++]; |
| if(segment == ".") { |
| leadingSlash && pos == segments.length && out.push("") |
| }else { |
| if(segment == "..") { |
| if(out.length > 1 || out.length == 1 && out[0] != "") { |
| out.pop() |
| } |
| leadingSlash && pos == segments.length && out.push("") |
| }else { |
| out.push(segment); |
| leadingSlash = true |
| } |
| } |
| } |
| return out.join("/") |
| } |
| } |
| }; |
| goog.Uri.decodeOrEmpty_ = function(val) { |
| return val ? decodeURIComponent(val) : "" |
| }; |
| goog.Uri.encodeString_ = function(unescapedPart) { |
| if(goog.isString(unescapedPart)) { |
| return encodeURIComponent(unescapedPart) |
| } |
| return null |
| }; |
| goog.Uri.encodeSpecialRegExp_ = /^[a-zA-Z0-9\-_.!~*'():\/;?]*$/; |
| goog.Uri.encodeSpecialChars_ = function(unescapedPart, extra) { |
| var ret = null; |
| if(goog.isString(unescapedPart)) { |
| ret = unescapedPart; |
| goog.Uri.encodeSpecialRegExp_.test(ret) || (ret = encodeURI(unescapedPart)); |
| if(ret.search(extra) >= 0) { |
| ret = ret.replace(extra, goog.Uri.encodeChar_) |
| } |
| } |
| return ret |
| }; |
| goog.Uri.encodeChar_ = function(ch) { |
| var n = ch.charCodeAt(0); |
| return"%" + (n >> 4 & 15).toString(16) + (n & 15).toString(16) |
| }; |
| goog.Uri.reDisallowedInSchemeOrUserInfo_ = /[#\/\?@]/g; |
| goog.Uri.reDisallowedInPath_ = /[\#\?]/g; |
| goog.Uri.reDisallowedInQuery_ = /[\#\?@]/g; |
| goog.Uri.reDisallowedInFragment_ = /#/g; |
| goog.Uri.haveSameDomain = function(uri1String, uri2String) { |
| var pieces1 = goog.uri.utils.split(uri1String), pieces2 = goog.uri.utils.split(uri2String); |
| return pieces1[goog.uri.utils.ComponentIndex.DOMAIN] == pieces2[goog.uri.utils.ComponentIndex.DOMAIN] && pieces1[goog.uri.utils.ComponentIndex.PORT] == pieces2[goog.uri.utils.ComponentIndex.PORT] |
| }; |
| goog.Uri.QueryData = function(opt_query, opt_uri, opt_ignoreCase) { |
| this.encodedQuery_ = opt_query || null; |
| this.uri_ = opt_uri || null; |
| this.ignoreCase_ = !!opt_ignoreCase |
| }; |
| goog.Uri.QueryData.prototype.ensureKeyMapInitialized_ = function() { |
| if(!this.keyMap_) { |
| this.keyMap_ = new goog.structs.Map; |
| if(this.encodedQuery_) { |
| for(var pairs = this.encodedQuery_.split("&"), i = 0;i < pairs.length;i++) { |
| var indexOfEquals = pairs[i].indexOf("="), name = null, value = null; |
| if(indexOfEquals >= 0) { |
| name = pairs[i].substring(0, indexOfEquals); |
| value = pairs[i].substring(indexOfEquals + 1) |
| }else { |
| name = pairs[i] |
| } |
| name = goog.string.urlDecode(name); |
| name = this.getKeyName_(name); |
| this.add(name, value ? goog.string.urlDecode(value) : "") |
| } |
| } |
| } |
| }; |
| goog.Uri.QueryData.createFromMap = function(map, opt_uri, opt_ignoreCase) { |
| var keys = goog.structs.getKeys(map); |
| if(typeof keys == "undefined") { |
| throw Error("Keys are undefined"); |
| } |
| return goog.Uri.QueryData.createFromKeysValues(keys, goog.structs.getValues(map), opt_uri, opt_ignoreCase) |
| }; |
| goog.Uri.QueryData.createFromKeysValues = function(keys, values, opt_uri, opt_ignoreCase) { |
| if(keys.length != values.length) { |
| throw Error("Mismatched lengths for keys/values"); |
| } |
| for(var queryData = new goog.Uri.QueryData(null, opt_uri, opt_ignoreCase), i = 0;i < keys.length;i++) { |
| queryData.add(keys[i], values[i]) |
| } |
| return queryData |
| }; |
| goog.Uri.QueryData.prototype.keyMap_ = null; |
| goog.Uri.QueryData.prototype.count_ = null; |
| goog.Uri.QueryData.decodedQuery_ = null; |
| goog.Uri.QueryData.prototype.getCount = function() { |
| this.ensureKeyMapInitialized_(); |
| return this.count_ |
| }; |
| goog.Uri.QueryData.prototype.add = function(key, value) { |
| this.ensureKeyMapInitialized_(); |
| this.invalidateCache_(); |
| key = this.getKeyName_(key); |
| if(this.containsKey(key)) { |
| var current = this.keyMap_.get(key); |
| goog.isArray(current) ? current.push(value) : this.keyMap_.set(key, [current, value]) |
| }else { |
| this.keyMap_.set(key, value) |
| } |
| this.count_++; |
| return this |
| }; |
| goog.Uri.QueryData.prototype.remove = function(key) { |
| this.ensureKeyMapInitialized_(); |
| key = this.getKeyName_(key); |
| if(this.keyMap_.containsKey(key)) { |
| this.invalidateCache_(); |
| var old = this.keyMap_.get(key); |
| if(goog.isArray(old)) { |
| this.count_ -= old.length |
| }else { |
| this.count_-- |
| } |
| return this.keyMap_.remove(key) |
| } |
| return false |
| }; |
| goog.Uri.QueryData.prototype.clear = function() { |
| this.invalidateCache_(); |
| this.keyMap_ && this.keyMap_.clear(); |
| this.count_ = 0 |
| }; |
| goog.Uri.QueryData.prototype.isEmpty = function() { |
| this.ensureKeyMapInitialized_(); |
| return this.count_ == 0 |
| }; |
| goog.Uri.QueryData.prototype.containsKey = function(key) { |
| this.ensureKeyMapInitialized_(); |
| key = this.getKeyName_(key); |
| return this.keyMap_.containsKey(key) |
| }; |
| goog.Uri.QueryData.prototype.containsValue = function(value) { |
| var vals = this.getValues(); |
| return goog.array.contains(vals, value) |
| }; |
| goog.Uri.QueryData.prototype.getKeys = function() { |
| this.ensureKeyMapInitialized_(); |
| for(var vals = this.keyMap_.getValues(), keys = this.keyMap_.getKeys(), rv = [], i = 0;i < keys.length;i++) { |
| var val = vals[i]; |
| if(goog.isArray(val)) { |
| for(var j = 0;j < val.length;j++) { |
| rv.push(keys[i]) |
| } |
| }else { |
| rv.push(keys[i]) |
| } |
| } |
| return rv |
| }; |
| goog.Uri.QueryData.prototype.getValues = function(opt_key) { |
| this.ensureKeyMapInitialized_(); |
| var rv; |
| if(opt_key) { |
| var key = this.getKeyName_(opt_key); |
| if(this.containsKey(key)) { |
| var value = this.keyMap_.get(key); |
| if(goog.isArray(value)) { |
| return value |
| }else { |
| rv = []; |
| rv.push(value) |
| } |
| }else { |
| rv = [] |
| } |
| }else { |
| var vals = this.keyMap_.getValues(); |
| rv = []; |
| for(var i = 0;i < vals.length;i++) { |
| var val = vals[i]; |
| goog.isArray(val) ? goog.array.extend(rv, val) : rv.push(val) |
| } |
| } |
| return rv |
| }; |
| goog.Uri.QueryData.prototype.set = function(key, value) { |
| this.ensureKeyMapInitialized_(); |
| this.invalidateCache_(); |
| key = this.getKeyName_(key); |
| if(this.containsKey(key)) { |
| var old = this.keyMap_.get(key); |
| if(goog.isArray(old)) { |
| this.count_ -= old.length |
| }else { |
| this.count_-- |
| } |
| } |
| this.keyMap_.set(key, value); |
| this.count_++; |
| return this |
| }; |
| goog.Uri.QueryData.prototype.get = function(key, opt_default) { |
| this.ensureKeyMapInitialized_(); |
| key = this.getKeyName_(key); |
| if(this.containsKey(key)) { |
| var val = this.keyMap_.get(key); |
| return goog.isArray(val) ? val[0] : val |
| }else { |
| return opt_default |
| } |
| }; |
| goog.Uri.QueryData.prototype.toString = function() { |
| if(this.encodedQuery_) { |
| return this.encodedQuery_ |
| } |
| if(!this.keyMap_) { |
| return"" |
| } |
| for(var sb = [], count = 0, keys = this.keyMap_.getKeys(), i = 0;i < keys.length;i++) { |
| var key = keys[i], encodedKey = goog.string.urlEncode(key), val = this.keyMap_.get(key); |
| if(goog.isArray(val)) { |
| for(var j = 0;j < val.length;j++) { |
| count > 0 && sb.push("&"); |
| sb.push(encodedKey); |
| val[j] !== "" && sb.push("=", goog.string.urlEncode(val[j])); |
| count++ |
| } |
| }else { |
| count > 0 && sb.push("&"); |
| sb.push(encodedKey); |
| val !== "" && sb.push("=", goog.string.urlEncode(val)); |
| count++ |
| } |
| } |
| return this.encodedQuery_ = sb.join("") |
| }; |
| goog.Uri.QueryData.prototype.toDecodedString = function() { |
| if(!this.decodedQuery_) { |
| this.decodedQuery_ = goog.Uri.decodeOrEmpty_(this.toString()) |
| } |
| return this.decodedQuery_ |
| }; |
| goog.Uri.QueryData.prototype.invalidateCache_ = function() { |
| delete this.decodedQuery_; |
| delete this.encodedQuery_; |
| this.uri_ && delete this.uri_.cachedToString_ |
| }; |
| goog.Uri.QueryData.prototype.clone = function() { |
| var rv = new goog.Uri.QueryData; |
| if(this.decodedQuery_) { |
| rv.decodedQuery_ = this.decodedQuery_ |
| } |
| if(this.encodedQuery_) { |
| rv.encodedQuery_ = this.encodedQuery_ |
| } |
| if(this.keyMap_) { |
| rv.keyMap_ = this.keyMap_.clone() |
| } |
| return rv |
| }; |
| goog.Uri.QueryData.prototype.getKeyName_ = function(arg) { |
| var keyName = String(arg); |
| if(this.ignoreCase_) { |
| keyName = keyName.toLowerCase() |
| } |
| return keyName |
| }; |
| goog.Uri.QueryData.prototype.setIgnoreCase = function(ignoreCase) { |
| var resetKeys = ignoreCase && !this.ignoreCase_; |
| if(resetKeys) { |
| this.ensureKeyMapInitialized_(); |
| this.invalidateCache_(); |
| goog.structs.forEach(this.keyMap_, function(value, key) { |
| var lowerCase = key.toLowerCase(); |
| if(key != lowerCase) { |
| this.remove(key); |
| this.add(lowerCase, value) |
| } |
| }, this) |
| } |
| this.ignoreCase_ = ignoreCase |
| }; |
| goog.Uri.QueryData.prototype.extend = function() { |
| for(var i = 0;i < arguments.length;i++) { |
| var data = arguments[i]; |
| goog.structs.forEach(data, function(value, key) { |
| this.add(key, value) |
| }, this) |
| } |
| }; |
| goog.appengine = {}; |
| goog.appengine.DevChannel = function(channelId) { |
| this.channelId_ = channelId |
| }; |
| goog.appengine.DevChannel.prototype.open = function(opt_handler) { |
| opt_handler = opt_handler || new goog.appengine.DevSocket.Handler; |
| return new goog.appengine.DevSocket(this.channelId_, opt_handler) |
| }; |
| goog.appengine.DevSocket = function(channelId, handler) { |
| this.readyState = goog.appengine.DevSocket.ReadyState.CONNECTING; |
| this.channelId_ = channelId; |
| this.applicationKey_ = channelId.substring(channelId.lastIndexOf("-") + 1); |
| this.clientId_ = null; |
| this.onopen = handler.onopen; |
| this.onmessage = handler.onmessage; |
| this.onerror = handler.onerror; |
| this.onclose = handler.onclose; |
| this.doc_ = goog.dom.getDocument(); |
| this.win_ = goog.dom.getWindow(); |
| goog.net.XhrIo.send(this.getUrl_("connect"), goog.bind(this.connect_, this)); |
| goog.events.listen(this.win_, "beforeunload", goog.bind(this.beforeunload_, this)); |
| if(!document.body) { |
| throw"document.body is not defined -- do not create socket from script in <head>."; |
| } |
| }; |
| goog.appengine.DevSocket.POLLING_TIMEOUT_MS = 500; |
| goog.appengine.DevSocket.BASE_URL = "/_ah/channel/"; |
| goog.appengine.DevSocket.ReadyState = {CONNECTING:0, OPEN:1, CLOSING:2, CLOSED:3}; |
| goog.appengine.DevSocket.prototype.getUrl_ = function(command) { |
| var url = goog.appengine.DevSocket.BASE_URL + "dev?command=" + command + "&channel=" + this.channelId_; |
| if(this.clientId_) { |
| url += "&client=" + this.clientId_ |
| } |
| return url |
| }; |
| goog.appengine.DevSocket.prototype.connect_ = function(e) { |
| var xhr = e.target; |
| if(xhr.isSuccess()) { |
| this.clientId_ = xhr.getResponseText(); |
| this.readyState = goog.appengine.DevSocket.ReadyState.OPEN; |
| this.onopen(); |
| this.win_.setTimeout(goog.bind(this.poll_, this), goog.appengine.DevSocket.POLLING_TIMEOUT_MS) |
| }else { |
| this.readyState = goog.appengine.DevSocket.ReadyState.CLOSING; |
| var evt = {}; |
| evt.description = xhr.getStatusText(); |
| evt.code = xhr.getStatus(); |
| this.onerror(evt); |
| this.readyState = goog.appengine.DevSocket.ReadyState.CLOSED; |
| this.onclose() |
| } |
| }; |
| goog.appengine.DevSocket.prototype.disconnect_ = function() { |
| this.readyState = goog.appengine.DevSocket.ReadyState.CLOSED; |
| this.onclose() |
| }; |
| goog.appengine.DevSocket.prototype.forwardMessage_ = function(e) { |
| var xhr = e.target; |
| if(xhr.isSuccess()) { |
| var evt = {}; |
| evt.data = xhr.getResponseText(); |
| if(evt.data.length) { |
| this.onmessage(evt) |
| } |
| this.win_.setTimeout(goog.bind(this.poll_, this), goog.appengine.DevSocket.POLLING_TIMEOUT_MS) |
| }else { |
| evt = {}; |
| evt.description = xhr.getStatusText(); |
| evt.code = xhr.getStatus(); |
| this.onerror(evt) |
| } |
| }; |
| goog.appengine.DevSocket.prototype.poll_ = function() { |
| goog.net.XhrIo.send(this.getUrl_("poll"), goog.bind(this.forwardMessage_, this)) |
| }; |
| goog.appengine.DevSocket.prototype.beforeunload_ = function() { |
| var xhr = new goog.net.XmlHttp; |
| xhr.open("GET", this.getUrl_("disconnect"), false); |
| xhr.send() |
| }; |
| goog.appengine.DevSocket.prototype.forwardSendComplete_ = function(e) { |
| var xhr = e.target; |
| if(!xhr.isSuccess()) { |
| var evt = {}; |
| evt.description = xhr.getStatusText(); |
| evt.code = xhr.getStatus(); |
| this.onerror(evt) |
| } |
| }; |
| goog.appengine.DevSocket.prototype.send = function(data) { |
| if(this.readyState != goog.appengine.DevSocket.ReadyState.OPEN) { |
| return false |
| } |
| var url = goog.appengine.DevSocket.BASE_URL + "receive", sendData = new goog.Uri.QueryData; |
| sendData.set("key", this.applicationKey_); |
| sendData.set("msg", data); |
| goog.net.XhrIo.send(url, goog.bind(this.forwardSendComplete_, this), "POST", sendData.toString()); |
| return true |
| }; |
| goog.appengine.DevSocket.prototype.close = function() { |
| this.readyState = goog.appengine.DevSocket.ReadyState.CLOSING; |
| goog.net.XhrIo.send(this.getUrl_("disconnect"), goog.bind(this.disconnect_, this)) |
| }; |
| goog.appengine.DevSocket.Handler = function() { |
| }; |
| goog.appengine.DevSocket.Handler.prototype.onopen = function() { |
| }; |
| goog.appengine.DevSocket.Handler.prototype.onmessage = function() { |
| }; |
| goog.appengine.DevSocket.Handler.prototype.onerror = function() { |
| }; |
| goog.appengine.DevSocket.Handler.prototype.onclose = function() { |
| }; |
| goog.exportSymbol("goog.appengine.Channel", goog.appengine.DevChannel); |
| goog.exportSymbol("goog.appengine.Channel.prototype.open", goog.appengine.DevChannel.prototype.open); |
| goog.exportSymbol("goog.appengine.Socket.Handler", goog.appengine.DevSocket.Handler); |
| goog.exportSymbol("goog.appengine.Socket.Handler.prototype.onopen", goog.appengine.DevChannel.prototype.onopen); |
| goog.exportSymbol("goog.appengine.Socket.Handler.prototype.onmessage", goog.appengine.DevSocket.Handler.prototype.onmessage); |
| goog.exportSymbol("goog.appengine.Socket.Handler.prototype.onerror", goog.appengine.DevSocket.Handler.prototype.onerror); |
| goog.exportSymbol("goog.appengine.Socket.Handler.prototype.onclose", goog.appengine.DevSocket.Handler.prototype.onclose); |
| goog.exportSymbol("goog.appengine.Socket", goog.appengine.DevSocket); |
| goog.exportSymbol("goog.appengine.Socket.ReadyState", goog.appengine.DevSocket.ReadyState); |
| goog.exportSymbol("goog.appengine.Socket.prototype.send", goog.appengine.DevSocket.prototype.send); |
| goog.exportSymbol("goog.appengine.Socket.prototype.close", goog.appengine.DevSocket.prototype.close); |
| })() |