TEST_DIR = ${PREFIX}/test
DIST_DIR = ${PREFIX}/dist
SPEED_DIR = ${PREFIX}/speed
-PLUG_DIR = ../plugins
BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/data.js\
${SRC_DIR}/offset.js\
${SRC_DIR}/dimensions.js
-PLUGINS = ${PLUG_DIR}/button/*\
- ${PLUG_DIR}/center/*\
- ${PLUG_DIR}/cookie/*\
- ${PLUG_DIR}/dimensions/*\
- ${PLUG_DIR}/metadata/*\
- ${PLUG_DIR}/form/*\
- ${PLUG_DIR}/greybox/greybox.js\
- ${PLUG_DIR}/interface/*\
- ${PLUG_DIR}/pager/*\
- ${PLUG_DIR}/tablesorter/*\
- ${PLUG_DIR}/tabs/*\
- ${PLUG_DIR}/tooltip/jquery.tooltip.js\
- ${PLUG_DIR}/accordion/jquery.accordion.js
-
MODULES = ${SRC_DIR}/intro.js\
${BASE_FILES}\
${SRC_DIR}/outro.js
-MODULES_WITH_PLUGINS = ${SRC_DIR}/intro.js\
- ${BASE_FILES}\
- ${PLUGINS}\
- ${SRC_DIR}/outro.js
-
JQ = ${DIST_DIR}/jquery.js
JQ_LITE = ${DIST_DIR}/jquery.lite.js
JQ_MIN = ${DIST_DIR}/jquery.min.js
-JQ_PACK = ${DIST_DIR}/jquery.pack.js
JQ_VER = `cat version.txt`
VER = sed s/@VERSION/${JQ_VER}/
-JAR = java -Dfile.encoding=utf-8 -jar ${BUILD_DIR}/js.jar
MINJAR = java -jar ${BUILD_DIR}/yuicompressor-2.4.2.jar
DATE=`svn info . | grep Date: | sed 's/.*: //g'`
REV=`svn info . | grep Rev: | sed 's/.*: //g'`
-all: jquery min speed
+all: jquery test min speed
@@echo "jQuery build complete."
${DIST_DIR}:
@@echo ${JQ} "Built"
@@echo
-with_plugins: ${MODULES_WITH_PLUGINS}
- @@echo "Building" ${JQ}
-
- @@mkdir -p ${DIST_DIR}
- @@cat ${MODULES_WITH_PLUGINS} | ${VER} > ${JQ};
-
- @@echo ${JQ} "Built"
- @@echo
-
lite: ${JQ_LITE}
${JQ_LITE}: ${JQ}
@@echo ${JQ_LITE} "Built"
@@echo
-pack: ${JQ_PACK}
-
-${JQ_PACK}: ${JQ}
- @@echo "Building" ${JQ_PACK}
-
- @@echo " - Compressing using Packer"
- @@${JAR} ${BUILD_DIR}/build/pack.js ${JQ} ${JQ_PACK}
-
- @@echo ${JQ_PACK} "Built"
- @@echo
-
min: ${JQ_MIN}
${JQ_MIN}: ${JQ}
git submodule init
git submodule update
-runtest: ${JQ} test
- @@echo "Running Automated Test Suite"
- @@${JAR} ${BUILD_DIR}/runtest/test.js
-
- @@echo "Test Suite Finished"
- @@echo
-
speed: ${JQ}
@@echo "Building Speed Test Suite"
+++ /dev/null
-load("build/js/jsmin.js", "build/js/writeFile.js");
-
-// arguments
-var inFile = arguments[0];
-var outFile = arguments[1] || inFile.replace(/\.js$/, ".min.js");
-
-var script = readFile(inFile);
-var header = script.match(/\/\*(.|\n)*?\*\//)[0];
-var minifiedScript = jsmin('', script, 3);
-
-writeFile( outFile, header + minifiedScript );
+++ /dev/null
-load("build/js/writeFile.js");
-load("build/js/base2.js");
-load("build/js/Packer.js");
-load("build/js/Words.js");
-
-// arguments
-var inFile = arguments[0];
-var outFile = arguments[1] || inFile.replace(/\.js$/, ".pack.js");
-
-// options
-var base62 = true;
-var shrink = true;
-
-var script = readFile(inFile);
-var header = script.match(/\/\*(.|\n)*?\*\//)[0];
-var packer = new Packer;
-var packedScript = packer.pack(script, base62, shrink);
-
-writeFile(outFile, header + "\n" + packedScript);
+++ /dev/null
-/*\r
- Packer version 3.0 (beta 8) - copyright 2004-2007, Dean Edwards\r
- http://www.opensource.org/licenses/mit-license\r
-*/\r
-\r
-eval(base2.namespace);\r
-\r
-var IGNORE = RegGrp.IGNORE;\r
-var REMOVE = "";\r
-var SPACE = " ";\r
-var WORDS = /\w+/g;\r
-\r
-var Packer = Base.extend({\r
- minify: function(script) {\r
- script = script.replace(Packer.CONTINUE, "");\r
- script = Packer.data.exec(script);\r
- script = Packer.whitespace.exec(script);\r
- script = Packer.clean.exec(script);\r
- return script;\r
- },\r
- \r
- pack: function(script, base62, shrink) {\r
- script = this.minify(script + "\n");\r
- if (shrink) script = this._shrinkVariables(script);\r
- if (base62) script = this._base62Encode(script); \r
- return script;\r
- },\r
- \r
- _base62Encode: function(script) {\r
- var words = new Words(script);\r
- var encode = function(word) {\r
- return words.fetch(word).encoded;\r
- };\r
- \r
- /* build the packed script */\r
- \r
- var p = this._escape(script.replace(WORDS, encode)); \r
- var a = Math.min(Math.max(words.count(), 2), 62); \r
- var c = words.count(); \r
- var k = words;\r
- var e = Packer["ENCODE" + (a > 10 ? a > 36 ? 62 : 36 : 10)];\r
- var r = a > 10 ? "e(c)" : "c";\r
- \r
- // the whole thing\r
- return format(Packer.UNPACK, p,a,c,k,e,r);\r
- },\r
- \r
- _escape: function(script) {\r
- // single quotes wrap the final string so escape them\r
- // also escape new lines required by conditional comments\r
- return script.replace(/([\\'])/g, "\\$1").replace(/[\r\n]+/g, "\\n");\r
- },\r
- \r
- _shrinkVariables: function(script) {\r
- // Windows Scripting Host cannot do regexp.test() on global regexps.\r
- var global = function(regexp) {\r
- // This function creates a global version of the passed regexp.\r
- return new RegExp(regexp.source, "g");\r
- };\r
- \r
- var data = []; // encoded strings and regular expressions\r
- var REGEXP = /^[^'"]\//;\r
- var store = function(string) {\r
- var replacement = "#" + data.length;\r
- if (REGEXP.test(string)) {\r
- replacement = string.charAt(0) + replacement;\r
- string = string.slice(1);\r
- }\r
- data.push(string);\r
- return replacement;\r
- };\r
- \r
- // Base52 encoding (a-Z)\r
- var encode52 = function(c) {\r
- return (c < 52 ? '' : arguments.callee(parseInt(c / 52))) +\r
- ((c = c % 52) > 25 ? String.fromCharCode(c + 39) : String.fromCharCode(c + 97));\r
- };\r
- \r
- // identify blocks, particularly identify function blocks (which define scope)\r
- var BLOCK = /(function\s*[\w$]*\s*\(\s*([^\)]*)\s*\)\s*)?(\{([^{}]*)\})/;\r
- var VAR_ = /var\s+/g;\r
- var VAR_NAME = /var\s+[\w$]+/g;\r
- var COMMA = /\s*,\s*/;\r
- var blocks = []; // store program blocks (anything between braces {})\r
- // encoder for program blocks\r
- var encode = function(block, func, args) {\r
- if (func) { // the block is a function block\r
- \r
- // decode the function block (THIS IS THE IMPORTANT BIT)\r
- // We are retrieving all sub-blocks and will re-parse them in light\r
- // of newly shrunk variables\r
- block = decode(block);\r
- \r
- // create the list of variable and argument names \r
- var vars = match(block, VAR_NAME).join(",").replace(VAR_, "");\r
- var ids = Array2.combine(args.split(COMMA).concat(vars.split(COMMA)));\r
- \r
- // process each identifier\r
- var count = 0, shortId;\r
- forEach (ids, function(id) {\r
- id = trim(id);\r
- if (id && id.length > 1) { // > 1 char\r
- id = rescape(id);\r
- // find the next free short name (check everything in the current scope)\r
- do shortId = encode52(count++);\r
- while (new RegExp("[^\\w$.]" + shortId + "[^\\w$:]").test(block));\r
- // replace the long name with the short name\r
- var reg = new RegExp("([^\\w$.])" + id + "([^\\w$:])");\r
- while (reg.test(block)) block = block.replace(global(reg), "$1" + shortId + "$2");\r
- var reg = new RegExp("([^{,])" + id + ":", "g");\r
- block = block.replace(reg, "$1" + shortId + ":");\r
- }\r
- });\r
- }\r
- var replacement = "~" + blocks.length + "~";\r
- blocks.push(block);\r
- return replacement;\r
- };\r
- \r
- // decoder for program blocks\r
- var ENCODED = /~(\d+)~/;\r
- var decode = function(script) {\r
- while (ENCODED.test(script)) {\r
- script = script.replace(global(ENCODED), function(match, index) {\r
- return blocks[index];\r
- });\r
- }\r
- return script;\r
- };\r
- \r
- // encode strings and regular expressions\r
- script = Packer.data.exec(script, store);\r
- \r
- // remove closures (this is for base2 namespaces only)\r
- script = script.replace(/new function\(_\)\s*\{/g, "{;#;");\r
- \r
- // encode blocks, as we encode we replace variable and argument names\r
- while (BLOCK.test(script)) {\r
- script = script.replace(global(BLOCK), encode);\r
- }\r
- \r
- // put the blocks back\r
- script = decode(script);\r
- \r
- // put back the closure (for base2 namespaces only)\r
- script = script.replace(/\{;#;/g, "new function(_){");\r
- \r
- // put strings and regular expressions back\r
- script = script.replace(/#(\d+)/g, function(match, index) { \r
- return data[index];\r
- });\r
- \r
- return script;\r
- }\r
-}, {\r
- CONTINUE: /\\\r?\n/g,\r
- \r
- ENCODE10: "String",\r
- ENCODE36: "function(c){return c.toString(a)}",\r
- ENCODE62: "function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))}",\r
- \r
- UNPACK: "eval(function(p,a,c,k,e,r){e=%5;if(!''.replace(/^/,String)){while(c--)r[%6]=k[c]" +\r
- "||%6;k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p." +\r
- "replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('%1',%2,%3,'%4'.split('|'),0,{}))",\r
- \r
- init: function() {\r
- this.data = reduce(this.data, function(data, replacement, expression) {\r
- data.store(this.javascript.exec(expression), replacement);\r
- return data;\r
- }, new RegGrp, this);\r
- this.clean = this.data.union(this.clean);\r
- this.whitespace = this.data.union(this.whitespace);\r
- },\r
- \r
- clean: {\r
- "\\(\\s*;\\s*;\\s*\\)": "(;;)", // for (;;) loops\r
- "throw[^};]+[};]": IGNORE, // a safari 1.3 bug\r
- ";+\\s*([};])": "$1"\r
- },\r
- \r
- data: {\r
- // strings\r
- "STRING1": IGNORE,\r
- 'STRING2': IGNORE,\r
- "CONDITIONAL": IGNORE, // conditional comments\r
- "(COMMENT1)\\n\\s*(REGEXP)?": "\n$3",\r
- "(COMMENT2)\\s*(REGEXP)?": " $3",\r
- "([\\[(\\^=,{}:;&|!*?])\\s*(REGEXP)": "$1$2"\r
- },\r
- \r
- javascript: new RegGrp({\r
- COMMENT1: /(\/\/|;;;)[^\n]*/.source,\r
- COMMENT2: /\/\*[^*]*\*+([^\/][^*]*\*+)*\//.source,\r
- CONDITIONAL: /\/\*@|@\*\/|\/\/@[^\n]*\n/.source,\r
- REGEXP: /\/(\\[\/\\]|[^*\/])(\\.|[^\/\n\\])*\/[gim]*/.source,\r
- STRING1: /'(\\.|[^'\\])*'/.source,\r
- STRING2: /"(\\.|[^"\\])*"/.source\r
- }),\r
- \r
- whitespace: {\r
- "(\\d)\\s+(\\.\\s*[a-z\\$_\\[(])": "$1 $2", // http://dean.edwards.name/weblog/2007/04/packer3/#comment84066\r
- "([+-])\\s+([+-])": "$1 $2", // c = a++ +b;\r
- "\\b\\s+\\$\\s+\\b": " $ ", // var $ in\r
- "\\$\\s+\\b": "$ ", // object$ in\r
- "\\b\\s+\\$": " $", // return $object\r
- "\\b\\s+\\b": SPACE,\r
- "\\s+": REMOVE\r
- }\r
-});\r
+++ /dev/null
-/*
- ParseMaster, version 1.0.2 (2005-08-19)
- Copyright 2005, Dean Edwards
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-
-/* a multi-pattern parser */
-
-// KNOWN BUG: erroneous behavior when using escapeChar with a replacement value that is a function
-
-function ParseMaster() {
- // constants
- var $EXPRESSION = 0, $REPLACEMENT = 1, $LENGTH = 2;
- // used to determine nesting levels
- var $GROUPS = /\(/g, $SUB_REPLACE = /\$\d/, $INDEXED = /^\$\d+$/,
- $TRIM = /(['"])\1\+(.*)\+\1\1$/, $$ESCAPE = /\\./g, $QUOTE = /'/,
- $$DELETED = /\x01[^\x01]*\x01/g;
- var self = this;
- // public
- this.add = function($expression, $replacement) {
- if (!$replacement) $replacement = "";
- // count the number of sub-expressions
- // - add one because each pattern is itself a sub-expression
- var $length = (_internalEscape(String($expression)).match($GROUPS) || "").length + 1;
- // does the pattern deal with sub-expressions?
- if ($SUB_REPLACE.test($replacement)) {
- // a simple lookup? (e.g. "$2")
- if ($INDEXED.test($replacement)) {
- // store the index (used for fast retrieval of matched strings)
- $replacement = parseInt($replacement.slice(1)) - 1;
- } else { // a complicated lookup (e.g. "Hello $2 $1")
- // build a function to do the lookup
- var i = $length;
- var $quote = $QUOTE.test(_internalEscape($replacement)) ? '"' : "'";
- while (i) $replacement = $replacement.split("$" + i--).join($quote + "+a[o+" + i + "]+" + $quote);
- $replacement = new Function("a,o", "return" + $quote + $replacement.replace($TRIM, "$1") + $quote);
- }
- }
- // pass the modified arguments
- _add($expression || "/^$/", $replacement, $length);
- };
- // execute the global replacement
- this.exec = function($string) {
- _escaped.length = 0;
- return _unescape(_escape($string, this.escapeChar).replace(
- new RegExp(_patterns, this.ignoreCase ? "gi" : "g"), _replacement), this.escapeChar).replace($$DELETED, "");
- };
- // clear the patterns collection so that this object may be re-used
- this.reset = function() {
- _patterns.length = 0;
- };
-
- // private
- var _escaped = []; // escaped characters
- var _patterns = []; // patterns stored by index
- var _toString = function(){return "(" + String(this[$EXPRESSION]).slice(1, -1) + ")"};
- _patterns.toString = function(){return this.join("|")};
- // create and add a new pattern to the patterns collection
- function _add() {
- arguments.toString = _toString;
- // store the pattern - as an arguments object (i think this is quicker..?)
- _patterns[_patterns.length] = arguments;
- }
- // this is the global replace function (it's quite complicated)
- function _replacement() {
- if (!arguments[0]) return "";
- var i = 1, j = 0, $pattern;
- // loop through the patterns
- while ($pattern = _patterns[j++]) {
- // do we have a result?
- if (arguments[i]) {
- var $replacement = $pattern[$REPLACEMENT];
- switch (typeof $replacement) {
- case "function": return $replacement(arguments, i);
- case "number": return arguments[$replacement + i];
- }
- var $delete = (arguments[i].indexOf(self.escapeChar) == -1) ? "" :
- "\x01" + arguments[i] + "\x01";
- return $delete + $replacement;
- // skip over references to sub-expressions
- } else i += $pattern[$LENGTH];
- }
- };
- // encode escaped characters
- function _escape($string, $escapeChar) {
- return $escapeChar ? $string.replace(new RegExp("\\" + $escapeChar + "(.)", "g"), function($match, $char) {
- _escaped[_escaped.length] = $char;
- return $escapeChar;
- }) : $string;
- };
- // decode escaped characters
- function _unescape($string, $escapeChar) {
- var i = 0;
- return $escapeChar ? $string.replace(new RegExp("\\" + $escapeChar, "g"), function() {
- return $escapeChar + (_escaped[i++] || "");
- }) : $string;
- };
- function _internalEscape($string) {
- return $string.replace($$ESCAPE, "");
- };
-};
-ParseMaster.prototype = {
- constructor: ParseMaster,
- ignoreCase: false,
- escapeChar: ""
-};
+++ /dev/null
-\r
-var Words = Collection.extend({\r
- constructor: function(script) {\r
- this.base();\r
- forEach (script.match(WORDS), this.add, this);\r
- this.encode();\r
- },\r
- \r
- add: function(word) {\r
- if (!this.exists(word)) this.base(word);\r
- word = this.fetch(word);\r
- word.count++;\r
- return word;\r
- },\r
- \r
- encode: function() {\r
- // sort by frequency\r
- this.sort(function(word1, word2) {\r
- return word2.count - word1.count;\r
- });\r
- \r
- eval("var a=62,e=" + Packer.ENCODE62);\r
- var encode = e; \r
- var encoded = new Collection; // a dictionary of base62 -> base10\r
- var count = this.count();\r
- for (var i = 0; i < count; i++) {\r
- encoded.store(encode(i), i);\r
- }\r
- \r
- var empty = function() {return ""};\r
- var index = 0;\r
- forEach (this, function(word) {\r
- if (encoded.exists(word)) {\r
- word.index = encoded.fetch(word);\r
- word.toString = empty;\r
- } else {\r
- while (this.exists(encode(index))) index++;\r
- word.index = index++;\r
- }\r
- word.encoded = encode(word.index);\r
- }, this);\r
- \r
- // sort by encoding\r
- this.sort(function(word1, word2) {\r
- return word1.index - word2.index;\r
- });\r
- },\r
- \r
- toString: function() {\r
- return this.values().join("|");\r
- }\r
-}, {\r
- Item: {\r
- constructor: function(word) {\r
- this.toString = function() {return word};\r
- },\r
- \r
- count: 0,\r
- encoded: "",\r
- index: -1\r
- }\r
-});\r
+++ /dev/null
-// timestamp: Tue, 01 May 2007 19:13:00\r
-/*\r
- base2.js - copyright 2007, Dean Edwards\r
- http://www.opensource.org/licenses/mit-license\r
-*/\r
-\r
-var base2 = {};\r
-\r
-// You know, writing a javascript library is awfully time consuming.\r
-\r
-new function(_) { //////////////////// BEGIN: CLOSURE ////////////////////\r
-\r
-// =========================================================================\r
-// base2/Base.js\r
-// =========================================================================\r
-\r
-// version 1.1\r
-\r
-var Base = function() {\r
- // call this method from any other method to invoke that method's ancestor\r
-};\r
-\r
-Base.prototype = { \r
- extend: function(source) {\r
- if (arguments.length > 1) { // extending with a name/value pair\r
- var ancestor = this[source];\r
- var value = arguments[1];\r
- if (typeof value == "function" && ancestor && /\bbase\b/.test(value)) {\r
- var method = value; \r
- value = function() { // override\r
- var previous = this.base;\r
- this.base = ancestor;\r
- var returnValue = method.apply(this, arguments);\r
- this.base = previous;\r
- return returnValue;\r
- };\r
- value.method = method;\r
- value.ancestor = ancestor;\r
- }\r
- this[source] = value;\r
- } else if (source) { // extending with an object literal\r
- var extend = Base.prototype.extend;\r
- if (Base._prototyping) {\r
- var key, i = 0, members = ["constructor", "toString", "valueOf"];\r
- while (key = members[i++]) if (source[key] != Object.prototype[key]) {\r
- extend.call(this, key, source[key]);\r
- }\r
- } else if (typeof this != "function") {\r
- // if the object has a customised extend() method then use it\r
- extend = this.extend || extend;\r
- } \r
- // copy each of the source object's properties to this object\r
- for (key in source) if (!Object.prototype[key]) {\r
- extend.call(this, key, source[key]);\r
- }\r
- }\r
- return this;\r
- },\r
-\r
- base: Base\r
-};\r
-\r
-Base.extend = function(_instance, _static) { // subclass\r
- var extend = Base.prototype.extend;\r
- \r
- // build the prototype\r
- Base._prototyping = true;\r
- var proto = new this;\r
- extend.call(proto, _instance);\r
- delete Base._prototyping;\r
- \r
- // create the wrapper for the constructor function\r
- var constructor = proto.constructor;\r
- var klass = proto.constructor = function() {\r
- if (!Base._prototyping) {\r
- if (this._constructing || this.constructor == klass) { // instantiation\r
- this._constructing = true;\r
- constructor.apply(this, arguments);\r
- delete this._constructing;\r
- } else { // casting\r
- var object = arguments[0];\r
- if (object != null) {\r
- (object.extend || extend).call(object, proto);\r
- }\r
- return object;\r
- }\r
- }\r
- };\r
- \r
- // build the class interface\r
- for (var i in Base) klass[i] = this[i];\r
- klass.ancestor = this;\r
- klass.base = Base.base;\r
- klass.prototype = proto;\r
- klass.toString = this.toString;\r
- extend.call(klass, _static);\r
- // class initialisation\r
- if (typeof klass.init == "function") klass.init();\r
- return klass;\r
-};\r
-\r
-// initialise\r
-Base = Base.extend({\r
- constructor: function() {\r
- this.extend(arguments[0]);\r
- }\r
-}, {\r
- ancestor: Object,\r
- base: Base,\r
- \r
- implement: function(_interface) {\r
- if (typeof _interface == "function") {\r
- // if it's a function, call it\r
- _interface(this.prototype);\r
- } else {\r
- // add the interface using the extend() method\r
- this.prototype.extend(_interface);\r
- }\r
- return this;\r
- }\r
-});\r
-\r
-// =========================================================================\r
-// lang/main.js\r
-// =========================================================================\r
-\r
-var Legacy = typeof $Legacy == "undefined" ? {} : $Legacy;\r
-\r
-var K = function(k) {return k};\r
-\r
-var assert = function(condition, message, Err) {\r
- if (!condition) {\r
- throw new (Err || Error)(message || "Assertion failed.");\r
- }\r
-};\r
-\r
-var assertType = function(object, type, message) {\r
- if (type) {\r
- var condition = typeof type == "function" ? instanceOf(object, type) : typeof object == type;\r
- assert(condition, message || "Invalid type.", TypeError);\r
- }\r
-};\r
-\r
-var copy = function(object) {\r
- var fn = new Function;\r
- fn.prototype = object;\r
- return new fn;\r
-};\r
-\r
-var format = function(string) {\r
- // replace %n with arguments[n]\r
- // e.g. format("%1 %2%3 %2a %1%3", "she", "se", "lls");\r
- // ==> "she sells sea shells"\r
- // only supports nine replacements: %1 - %9\r
- var args = arguments;\r
- return String(string).replace(/%([1-9])/g, function(match, index) {\r
- return index < args.length ? args[index] : match;\r
- });\r
-};\r
-\r
-var $instanceOf = Legacy.instanceOf || new Function("o,k", "return o instanceof k");\r
-var instanceOf = function(object, klass) {\r
- assertType(klass, "function", "Invalid 'instanceOf' operand.");\r
- if ($instanceOf(object, klass)) return true;\r
- // handle exceptions where the target object originates from another frame\r
- // this is handy for JSON parsing (amongst other things)\r
- if (object != null) switch (klass) {\r
- case Object:\r
- return true;\r
- case Number:\r
- case Boolean:\r
- case Function:\r
- case String:\r
- return typeof object == typeof klass.prototype.valueOf();\r
- case Array:\r
- // this is the only troublesome one\r
- return !!(object.join && object.splice && !arguments.callee(object, Function));\r
- case Date:\r
- return !!object.getTimezoneOffset;\r
- case RegExp:\r
- return String(object.constructor.prototype) == String(new RegExp);\r
- }\r
- return false;\r
-};\r
- \r
-var match = function(string, expression) {\r
- // same as String.match() except that this function will return an empty \r
- // array if there is no match\r
- return String(string).match(expression) || [];\r
-};\r
-\r
-var RESCAPE = /([\/()[\]{}|*+-.,^$?\\])/g;\r
-var rescape = function(string) {\r
- // make a string safe for creating a RegExp\r
- return String(string).replace(RESCAPE, "\\$1");\r
-};\r
-\r
-var $slice = Array.prototype.slice;\r
-var slice = function(object) {\r
- // slice an array-like object\r
- return $slice.apply(object, $slice.call(arguments, 1));\r
-};\r
-\r
-var TRIM = /^\s+|\s+$/g;\r
-var trim = function(string) {\r
- return String(string).replace(TRIM, ""); \r
-};\r
-\r
-// =========================================================================\r
-// lang/extend.js\r
-// =========================================================================\r
-\r
-var base = function(object, args) {\r
- // invoke the base method with all supplied arguments\r
- return object.base.apply(object, args);\r
-};\r
-\r
-var extend = function(object) {\r
- assert(object != Object.prototype, "Object.prototype is verboten!");\r
- return Base.prototype.extend.apply(object, slice(arguments, 1));\r
-};\r
-\r
-// =========================================================================\r
-// lang/assignID.js\r
-// =========================================================================\r
-\r
-var $ID = 1;\r
-var assignID = function(object) {\r
- // assign a unique id\r
- if (!object.base2ID) object.base2ID = "b2_" + $ID++;\r
- return object.base2ID;\r
-};\r
-\r
-// =========================================================================\r
-// lang/forEach.js\r
-// =========================================================================\r
-\r
-if (typeof StopIteration == "undefined") {\r
- StopIteration = new Error("StopIteration");\r
-}\r
-\r
-var forEach = function(object, block, context) {\r
- if (object == null) return;\r
- if (typeof object == "function") {\r
- // functions are a special case\r
- var fn = Function;\r
- } else if (typeof object.forEach == "function" && object.forEach != arguments.callee) {\r
- // the object implements a custom forEach method\r
- object.forEach(block, context);\r
- return;\r
- } else if (typeof object.length == "number") {\r
- // the object is array-like\r
- forEach.Array(object, block, context);\r
- return;\r
- }\r
- forEach.Function(fn || Object, object, block, context);\r
-};\r
-\r
-// these are the two core enumeration methods. all other forEach methods\r
-// eventually call one of these two.\r
-\r
-forEach.Array = function(array, block, context) {\r
- var i, length = array.length; // preserve\r
- if (typeof array == "string") {\r
- for (i = 0; i < length; i++) {\r
- block.call(context, array.charAt(i), i, array);\r
- }\r
- } else {\r
- for (i = 0; i < length; i++) {\r
- block.call(context, array[i], i, array);\r
- }\r
- }\r
-};\r
-\r
-forEach.Function = Legacy.forEach || function(fn, object, block, context) {\r
- // enumerate an object and compare its keys with fn's prototype\r
- for (var key in object) {\r
- if (fn.prototype[key] === undefined) {\r
- block.call(context, object[key], key, object);\r
- }\r
- }\r
-};\r
-\r
-// =========================================================================\r
-// base2/Base/forEach.js\r
-// =========================================================================\r
-\r
-Base.forEach = function(object, block, context) {\r
- forEach.Function(this, object, block, context);\r
-};\r
-\r
-// =========================================================================\r
-// base2/../Function.js\r
-// =========================================================================\r
-\r
-// some browsers don't define this\r
-\r
-Function.prototype.prototype = {};\r
-\r
-\r
-// =========================================================================\r
-// base2/../String.js\r
-// =========================================================================\r
-\r
-// fix String.replace (Safari/IE5.0)\r
-\r
-if ("".replace(/^/, String)) {\r
- extend(String.prototype, "replace", function(expression, replacement) {\r
- if (typeof replacement == "function") { // Safari doesn't like functions\r
- if (instanceOf(expression, RegExp)) {\r
- var regexp = expression;\r
- var global = regexp.global;\r
- if (global == null) global = /(g|gi)$/.test(regexp);\r
- // we have to convert global RexpExps for exec() to work consistently\r
- if (global) regexp = new RegExp(regexp.source); // non-global\r
- } else {\r
- regexp = new RegExp(rescape(expression));\r
- }\r
- var match, string = this, result = "";\r
- while (string && (match = regexp.exec(string))) {\r
- result += string.slice(0, match.index) + replacement.apply(this, match);\r
- string = string.slice(match.index + match[0].length);\r
- if (!global) break;\r
- }\r
- return result + string;\r
- } else {\r
- return base(this, arguments);\r
- }\r
- });\r
-}\r
-\r
-// =========================================================================\r
-// base2/Abstract.js\r
-// =========================================================================\r
-\r
-var Abstract = Base.extend({\r
- constructor: function() {\r
- throw new TypeError("Class cannot be instantiated.");\r
- }\r
-});\r
-\r
-// =========================================================================\r
-// base2/Module.js\r
-// =========================================================================\r
-\r
-// based on ruby's Module class and Mozilla's Array generics:\r
-// http://www.ruby-doc.org/core/classes/Module.html\r
-// http://developer.mozilla.org/en/docs/New_in_JavaScript_1.6#Array_and_String_generics\r
-\r
-// A Module is used as the basis for creating interfaces that can be\r
-// applied to other classes. *All* properties and methods are static.\r
-// When a module is used as a mixin, methods defined on what would normally be\r
-// the instance interface become instance methods of the target object.\r
-\r
-// Modules cannot be instantiated. Static properties and methods are inherited.\r
-\r
-var Module = Abstract.extend(null, {\r
- extend: function(_interface, _static) {\r
- // extend a module to create a new module\r
- var module = this.base();\r
- // inherit static methods\r
- forEach (this, function(property, name) {\r
- if (!Module[name] && name != "init") {\r
- extend(module, name, property);\r
- }\r
- });\r
- // implement module (instance AND static) methods\r
- module.implement(_interface);\r
- // implement static properties and methods\r
- extend(module, _static);\r
- // Make the submarine noises Larry!\r
- if (typeof module.init == "function") module.init();\r
- return module;\r
- },\r
- \r
- implement: function(_interface) {\r
- // implement an interface on BOTH the instance and static interfaces\r
- var module = this;\r
- if (typeof _interface == "function") {\r
- module.base(_interface);\r
- forEach (_interface, function(property, name) {\r
- if (!Module[name] && name != "init") {\r
- extend(module, name, property);\r
- }\r
- });\r
- } else {\r
- // create the instance interface\r
- Base.forEach (extend({}, _interface), function(property, name) {\r
- // instance methods call the equivalent static method\r
- if (typeof property == "function") {\r
- property = function() {\r
- base; // force inheritance\r
- return module[name].apply(module, [this].concat(slice(arguments)));\r
- };\r
- }\r
- if (!Module[name]) extend(this, name, property);\r
- }, module.prototype);\r
- // add the static interface\r
- extend(module, _interface);\r
- }\r
- return module;\r
- }\r
-});\r
-\r
-\r
-// =========================================================================\r
-// base2/Enumerable.js\r
-// =========================================================================\r
-\r
-var Enumerable = Module.extend({\r
- every: function(object, test, context) {\r
- var result = true;\r
- try {\r
- this.forEach (object, function(value, key) {\r
- result = test.call(context, value, key, object);\r
- if (!result) throw StopIteration;\r
- });\r
- } catch (error) {\r
- if (error != StopIteration) throw error;\r
- }\r
- return !!result; // cast to boolean\r
- },\r
- \r
- filter: function(object, test, context) {\r
- return this.reduce(object, function(result, value, key) {\r
- if (test.call(context, value, key, object)) {\r
- result[result.length] = value;\r
- }\r
- return result;\r
- }, new Array2);\r
- },\r
-\r
- invoke: function(object, method) {\r
- // apply a method to each item in the enumerated object\r
- var args = slice(arguments, 2);\r
- return this.map(object, (typeof method == "function") ? function(item) {\r
- if (item != null) return method.apply(item, args);\r
- } : function(item) {\r
- if (item != null) return item[method].apply(item, args);\r
- });\r
- },\r
- \r
- map: function(object, block, context) {\r
- var result = new Array2;\r
- this.forEach (object, function(value, key) {\r
- result[result.length] = block.call(context, value, key, object);\r
- });\r
- return result;\r
- },\r
- \r
- pluck: function(object, key) {\r
- return this.map(object, function(item) {\r
- if (item != null) return item[key];\r
- });\r
- },\r
- \r
- reduce: function(object, block, result, context) {\r
- this.forEach (object, function(value, key) {\r
- result = block.call(context, result, value, key, object);\r
- });\r
- return result;\r
- },\r
- \r
- some: function(object, test, context) {\r
- return !this.every(object, function(value, key) {\r
- return !test.call(context, value, key, object);\r
- });\r
- }\r
-}, {\r
- forEach: forEach\r
-});\r
-\r
-// =========================================================================\r
-// base2/Array2.js\r
-// =========================================================================\r
-\r
-// The IArray module implements all Array methods.\r
-// This module is not public but its methods are accessible through the Array2 object (below). \r
-\r
-var IArray = Module.extend({\r
- combine: function(keys, values) {\r
- // combine two arrays to make a hash\r
- if (!values) values = keys;\r
- return this.reduce(keys, function(object, key, index) {\r
- object[key] = values[index];\r
- return object;\r
- }, {});\r
- },\r
- \r
- copy: function(array) {\r
- return this.concat(array);\r
- },\r
- \r
- contains: function(array, item) {\r
- return this.indexOf(array, item) != -1;\r
- },\r
- \r
- forEach: forEach.Array,\r
- \r
- indexOf: function(array, item, fromIndex) {\r
- var length = array.length;\r
- if (fromIndex == null) {\r
- fromIndex = 0;\r
- } else if (fromIndex < 0) {\r
- fromIndex = Math.max(0, length + fromIndex);\r
- }\r
- for (var i = fromIndex; i < length; i++) {\r
- if (array[i] === item) return i;\r
- }\r
- return -1;\r
- },\r
- \r
- insertAt: function(array, item, index) {\r
- this.splice(array, index, 0, item);\r
- return item;\r
- },\r
- \r
- insertBefore: function(array, item, before) {\r
- var index = this.indexOf(array, before);\r
- if (index == -1) this.push(array, item);\r
- else this.splice(array, index, 0, item);\r
- return item;\r
- },\r
- \r
- lastIndexOf: function(array, item, fromIndex) {\r
- var length = array.length;\r
- if (fromIndex == null) {\r
- fromIndex = length - 1;\r
- } else if (from < 0) {\r
- fromIndex = Math.max(0, length + fromIndex);\r
- }\r
- for (var i = fromIndex; i >= 0; i--) {\r
- if (array[i] === item) return i;\r
- }\r
- return -1;\r
- },\r
- \r
- remove: function(array, item) {\r
- var index = this.indexOf(array, item);\r
- if (index != -1) this.removeAt(array, index);\r
- return item;\r
- },\r
- \r
- removeAt: function(array, index) {\r
- var item = array[index];\r
- this.splice(array, index, 1);\r
- return item;\r
- }\r
-});\r
-\r
-IArray.prototype.forEach = function(block, context) {\r
- forEach.Array(this, block, context);\r
-};\r
-\r
-IArray.implement(Enumerable);\r
-\r
-forEach ("concat,join,pop,push,reverse,shift,slice,sort,splice,unshift".split(","), function(name) {\r
- IArray[name] = function(array) {\r
- return Array.prototype[name].apply(array, slice(arguments, 1));\r
- };\r
-});\r
-\r
-// create a faux constructor that augments the built-in Array object\r
-var Array2 = function() {\r
- return IArray(this.constructor == IArray ? Array.apply(null, arguments) : arguments[0]);\r
-};\r
-// expose IArray.prototype so that it can be extended\r
-Array2.prototype = IArray.prototype;\r
-\r
-forEach (IArray, function(method, name, proto) {\r
- if (Array[name]) {\r
- IArray[name] = Array[name];\r
- delete IArray.prototype[name];\r
- }\r
- Array2[name] = IArray[name];\r
-});\r
-\r
-// =========================================================================\r
-// base2/Hash.js\r
-// =========================================================================\r
-\r
-var HASH = "#" + Number(new Date);\r
-var KEYS = HASH + "keys";\r
-var VALUES = HASH + "values";\r
-\r
-var Hash = Base.extend({\r
- constructor: function(values) {\r
- this[KEYS] = new Array2;\r
- this[VALUES] = {};\r
- this.merge(values);\r
- },\r
-\r
- copy: function() {\r
- var copy = new this.constructor(this);\r
- Base.forEach (this, function(property, name) {\r
- if (typeof property != "function" && name.charAt(0) != "#") {\r
- copy[name] = property;\r
- }\r
- });\r
- return copy;\r
- },\r
-\r
- // ancient browsers throw an error when we use "in" as an operator \r
- // so we must create the function dynamically\r
- exists: Legacy.exists || new Function("k", format("return('%1'+k)in this['%2']", HASH, VALUES)),\r
-\r
- fetch: function(key) {\r
- return this[VALUES][HASH + key];\r
- },\r
-\r
- forEach: function(block, context) {\r
- forEach (this[KEYS], function(key) {\r
- block.call(context, this.fetch(key), key, this);\r
- }, this);\r
- },\r
-\r
- keys: function(index, length) {\r
- var keys = this[KEYS] || new Array2;\r
- switch (arguments.length) {\r
- case 0: return keys.copy();\r
- case 1: return keys[index];\r
- default: return keys.slice(index, length);\r
- }\r
- },\r
-\r
- merge: function(values) {\r
- forEach (arguments, function(values) {\r
- forEach (values, function(value, key) {\r
- this.store(key, value);\r
- }, this);\r
- }, this);\r
- return this;\r
- },\r
-\r
- remove: function(key) {\r
- var value = this.fetch(key);\r
- this[KEYS].remove(String(key));\r
- delete this[VALUES][HASH + key];\r
- return value;\r
- },\r
-\r
- store: function(key, value) {\r
- if (arguments.length == 1) value = key;\r
- // only store the key for a new entry\r
- if (!this.exists(key)) {\r
- this[KEYS].push(String(key));\r
- }\r
- // create the new entry (or overwrite the old entry)\r
- this[VALUES][HASH + key] = value;\r
- return value;\r
- },\r
-\r
- toString: function() {\r
- return String(this[KEYS]);\r
- },\r
-\r
- union: function(values) {\r
- return this.merge.apply(this.copy(), arguments);\r
- },\r
-\r
- values: function(index, length) {\r
- var values = this.map(K);\r
- switch (arguments.length) {\r
- case 0: return values;\r
- case 1: return values[index];\r
- default: return values.slice(index, length);\r
- }\r
- }\r
-});\r
-\r
-Hash.implement(Enumerable);\r
-\r
-// =========================================================================\r
-// base2/Collection.js\r
-// =========================================================================\r
-\r
-// A Hash that is more array-like (accessible by index).\r
-\r
-// Collection classes have a special (optional) property: Item\r
-// The Item property points to a constructor function.\r
-// Members of the collection must be an instance of Item.\r
-// e.g.\r
-// var Dates = Collection.extend(); // create a collection class\r
-// Dates.Item = Date; // only JavaScript Date objects allowed as members\r
-// var appointments = new Dates(); // instantiate the class\r
-// appointments.add(appointmentId, new Date); // add a date\r
-// appointments.add(appointmentId, "tomorrow"); // ERROR!\r
-\r
-// The static create() method is responsible for all construction of collection items.\r
-// Instance methods that add new items (add, store, insertAt, replaceAt) pass *all* of their arguments\r
-// to the static create() method. If you want to modify the way collection items are \r
-// created then you only need to override this method for custom collections.\r
-\r
-var Collection = Hash.extend({\r
- add: function(key, item) {\r
- // Duplicates not allowed using add().\r
- // - but you can still overwrite entries using store()\r
- assert(!this.exists(key), "Duplicate key.");\r
- return this.store.apply(this, arguments);\r
- },\r
-\r
- count: function() {\r
- return this[KEYS].length;\r
- },\r
-\r
- indexOf: function(key) {\r
- return this[KEYS].indexOf(String(key));\r
- },\r
-\r
- insertAt: function(index, key, item) {\r
- assert(!this.exists(key), "Duplicate key.");\r
- this[KEYS].insertAt(index, String(key));\r
- return this.store.apply(this, slice(arguments, 1));\r
- },\r
-\r
- item: function(index) {\r
- return this.fetch(this[KEYS][index]);\r
- },\r
-\r
- removeAt: function(index) {\r
- return this.remove(this[KEYS][index]);\r
- },\r
-\r
- reverse: function() {\r
- this[KEYS].reverse();\r
- return this;\r
- },\r
-\r
- sort: function(compare) {\r
- if (compare) {\r
- var self = this;\r
- this[KEYS].sort(function(key1, key2) {\r
- return compare(self.fetch(key1), self.fetch(key2), key1, key2);\r
- });\r
- } else this[KEYS].sort();\r
- return this;\r
- },\r
-\r
- store: function(key, item) {\r
- if (arguments.length == 1) item = key;\r
- item = this.constructor.create.apply(this.constructor, arguments);\r
- return this.base(key, item);\r
- },\r
-\r
- storeAt: function(index, item) {\r
- //-dean: get rid of this?\r
- assert(index < this.count(), "Index out of bounds.");\r
- arguments[0] = this[KEYS][index];\r
- return this.store.apply(this, arguments);\r
- }\r
-}, {\r
- Item: null, // if specified, all members of the Collection must be instances of Item\r
- \r
- create: function(key, item) {\r
- if (this.Item && !instanceOf(item, this.Item)) {\r
- item = new this.Item(key, item);\r
- }\r
- return item;\r
- },\r
- \r
- extend: function(_instance, _static) {\r
- var klass = this.base(_instance);\r
- klass.create = this.create;\r
- extend(klass, _static);\r
- if (!klass.Item) {\r
- klass.Item = this.Item;\r
- } else if (typeof klass.Item != "function") {\r
- klass.Item = (this.Item || Base).extend(klass.Item);\r
- }\r
- if (typeof klass.init == "function") klass.init();\r
- return klass;\r
- }\r
-});\r
-\r
-// =========================================================================\r
-// base2/RegGrp.js\r
-// =========================================================================\r
-\r
-var RegGrp = Collection.extend({\r
- constructor: function(values, flags) {\r
- this.base(values);\r
- if (typeof flags == "string") {\r
- this.global = /g/.test(flags);\r
- this.ignoreCase = /i/.test(flags);\r
- }\r
- },\r
-\r
- global: true, // global is the default setting\r
- ignoreCase: false,\r
-\r
- exec: function(string, replacement) {\r
- if (arguments.length == 1) {\r
- var keys = this[KEYS];\r
- var values = this[VALUES];\r
- replacement = function(match) {\r
- if (!match) return "";\r
- var offset = 1, i = 0;\r
- // loop through the values\r
- while (match = values[HASH + keys[i++]]) {\r
- // do we have a result?\r
- if (arguments[offset]) {\r
- var replacement = match.replacement;\r
- switch (typeof replacement) {\r
- case "function":\r
- return replacement.apply(null, slice(arguments, offset));\r
- case "number":\r
- return arguments[offset + replacement];\r
- default:\r
- return replacement;\r
- }\r
- // no? then skip over references to sub-expressions\r
- } else offset += match.length + 1;\r
- }\r
- };\r
- }\r
- var flags = (this.global ? "g" : "") + (this.ignoreCase ? "i" : "");\r
- return String(string).replace(new RegExp(this, flags), replacement);\r
- },\r
-\r
- test: function(string) {\r
- return this.exec(string) != string;\r
- },\r
- \r
- toString: function() {\r
- var length = 0;\r
- return "(" + this.map(function(item) {\r
- // fix back references\r
- var expression = String(item).replace(/\\(\d+)/g, function($, index) {\r
- return "\\" + (1 + Number(index) + length);\r
- });\r
- length += item.length + 1;\r
- return expression;\r
- }).join(")|(") + ")";\r
- }\r
-}, {\r
- IGNORE: "$0",\r
- \r
- init: function() {\r
- forEach ("add,exists,fetch,remove,store".split(","), function(name) {\r
- extend(this, name, function(expression) {\r
- if (instanceOf(expression, RegExp)) {\r
- expression = expression.source;\r
- }\r
- return base(this, arguments);\r
- });\r
- }, this.prototype);\r
- }\r
-});\r
-\r
-// =========================================================================\r
-// base2/RegGrp/Item.js\r
-// =========================================================================\r
-\r
-RegGrp.Item = Base.extend({\r
- constructor: function(expression, replacement) {\r
- var ESCAPE = /\\./g;\r
- var STRING = /(['"])\1\+(.*)\+\1\1$/;\r
- \r
- expression = instanceOf(expression, RegExp) ? expression.source : String(expression);\r
- \r
- if (typeof replacement == "number") replacement = String(replacement);\r
- else if (replacement == null) replacement = "";\r
- \r
- // count the number of sub-expressions\r
- // - add one because each pattern is itself a sub-expression\r
- this.length = match(expression.replace(ESCAPE, "").replace(/\[[^\]]+\]/g, ""), /\(/g).length;\r
- \r
- // does the pattern use sub-expressions?\r
- if (typeof replacement == "string" && /\$(\d+)/.test(replacement)) {\r
- // a simple lookup? (e.g. "$2")\r
- if (/^\$\d+$/.test(replacement)) {\r
- // store the index (used for fast retrieval of matched strings)\r
- replacement = parseInt(replacement.slice(1));\r
- } else { // a complicated lookup (e.g. "Hello $2 $1")\r
- // build a function to do the lookup\r
- var i = this.length + 1;\r
- var Q = /'/.test(replacement.replace(ESCAPE, "")) ? '"' : "'";\r
- replacement = replacement.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\$(\d+)/g, Q +\r
- "+(arguments[$1]||" + Q+Q + ")+" + Q);\r
- replacement = new Function("return " + Q + replacement.replace(STRING, "$1") + Q);\r
- }\r
- }\r
- this.replacement = replacement;\r
- this.toString = function() {\r
- return expression || "";\r
- };\r
- },\r
- \r
- length: 0,\r
- replacement: ""\r
-});\r
-\r
-// =========================================================================\r
-// base2/Namespace.js\r
-// =========================================================================\r
-\r
-var Namespace = Base.extend({\r
- constructor: function(_private, _public) {\r
- this.extend(_public);\r
- this.toString = function() {\r
- return format("[base2.%1]", this.name);\r
- };\r
- \r
- // initialise\r
- if (typeof this.init == "function") this.init();\r
- \r
- if (this.name != "base2") {\r
- this.namespace = format("var %1=base2.%1;", this.name);\r
- }\r
- \r
- var namespace = "var base=" + base + ";";\r
- var imports = ("base2,lang," + this.imports).split(",");\r
- _private.imports = Enumerable.reduce(imports, function(namespace, name) {\r
- if (base2[name]) namespace += base2[name].namespace;\r
- return namespace;\r
- }, namespace);\r
- \r
- var namespace = format("base2.%1=%1;", this.name);\r
- var exports = this.exports.split(",");\r
- _private.exports = Enumerable.reduce(exports, function(namespace, name) {\r
- if (name) {\r
- this.namespace += format("var %2=%1.%2;", this.name, name);\r
- namespace += format("if(!%1.%2)%1.%2=%2;base2.%2=%1.%2;", this.name, name);\r
- }\r
- return namespace;\r
- }, namespace, this);\r
- \r
- if (this.name != "base2") {\r
- base2.namespace += format("var %1=base2.%1;", this.name);\r
- }\r
- },\r
-\r
- exports: "",\r
- imports: "",\r
- namespace: "",\r
- name: ""\r
-});\r
-\r
-base2 = new Namespace(this, {\r
- name: "base2",\r
- version: "0.8 (alpha)",\r
- exports: "Base,Abstract,Module,Enumerable,Array2,Hash,Collection,RegGrp,Namespace"\r
-});\r
-\r
-base2.toString = function() {\r
- return "[base2]";\r
-};\r
-\r
-eval(this.exports);\r
-\r
-// =========================================================================\r
-// base2/lang/namespace.js\r
-// =========================================================================\r
-\r
-var lang = new Namespace(this, {\r
- name: "lang",\r
- version: base2.version,\r
- exports: "K,assert,assertType,assignID,copy,instanceOf,extend,format,forEach,match,rescape,slice,trim",\r
- \r
- init: function() {\r
- this.extend = extend;\r
- // add the Enumerable methods to the lang object\r
- forEach (Enumerable.prototype, function(method, name) {\r
- if (!Module[name]) {\r
- this[name] = function() {\r
- return Enumerable[name].apply(Enumerable, arguments);\r
- };\r
- this.exports += "," + name;\r
- }\r
- }, this);\r
- }\r
-});\r
-\r
-eval(this.exports);\r
-\r
-base2.namespace += lang.namespace;\r
-\r
-}; //////////////////// END: CLOSURE /////////////////////////////////////\r
+++ /dev/null
-/* jsmin.js - 2006-08-31
-Author: Franck Marcia
-This work is an adaptation of jsminc.c published by Douglas Crockford.
-Permission is hereby granted to use the Javascript version under the same
-conditions as the jsmin.c on which it is based.
-
-jsmin.c
-2006-05-04
-
-Copyright (c) 2002 Douglas Crockford (www.crockford.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-Update:
- add level:
- 1: minimal, keep linefeeds if single
- 2: normal, the standard algorithm
- 3: agressive, remove any linefeed and doesn't take care of potential
- missing semicolons (can be regressive)
- store stats
- jsmin.oldSize
- jsmin.newSize
-*/
-
-String.prototype.has = function(c) {
- return this.indexOf(c) > -1;
-};
-
-function jsmin(comment, input, level) {
-
- if (input === undefined) {
- input = comment;
- comment = '';
- level = 2;
- } else if (level === undefined || level < 1 || level > 3) {
- level = 2;
- }
-
- if (comment.length > 0) {
- comment += '\n';
- }
-
- var a = '',
- b = '',
- EOF = -1,
- LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
- DIGITS = '0123456789',
- ALNUM = LETTERS + DIGITS + '_$\\',
- theLookahead = EOF;
-
-
- /* isAlphanum -- return true if the character is a letter, digit, underscore,
- dollar sign, or non-ASCII character.
- */
-
- function isAlphanum(c) {
- return c != EOF && (ALNUM.has(c) || c.charCodeAt(0) > 126);
- }
-
-
- /* get -- return the next character. Watch out for lookahead. If the
- character is a control character, translate it to a space or
- linefeed.
- */
-
- function get() {
-
- var c = theLookahead;
- if (get.i == get.l) {
- return EOF;
- }
- theLookahead = EOF;
- if (c == EOF) {
- c = input.charAt(get.i);
- ++get.i;
- }
- if (c >= ' ' || c == '\n') {
- return c;
- }
- if (c == '\r') {
- return '\n';
- }
- return ' ';
- }
-
- get.i = 0;
- get.l = input.length;
-
-
- /* peek -- get the next character without getting it.
- */
-
- function peek() {
- theLookahead = get();
- return theLookahead;
- }
-
-
- /* next -- get the next character, excluding comments. peek() is used to see
- if a '/' is followed by a '/' or '*'.
- */
-
- function next() {
-
- var c = get();
- if (c == '/') {
- switch (peek()) {
- case '/':
- for (;;) {
- c = get();
- if (c <= '\n') {
- return c;
- }
- }
- break;
- case '*':
- get();
- for (;;) {
- switch (get()) {
- case '*':
- if (peek() == '/') {
- get();
- return ' ';
- }
- break;
- case EOF:
- throw 'Error: Unterminated comment.';
- }
- }
- break;
- default:
- return c;
- }
- }
- return c;
- }
-
-
- /* action -- do something! What you do is determined by the argument:
- 1 Output A. Copy B to A. Get the next B.
- 2 Copy B to A. Get the next B. (Delete A).
- 3 Get the next B. (Delete B).
- action treats a string as a single character. Wow!
- action recognizes a regular expression if it is preceded by ( or , or =.
- */
-
- function action(d) {
-
- var r = [];
-
- if (d == 1) {
- r.push(a);
- }
-
- if (d < 3) {
- a = b;
- if (a == '\'' || a == '"') {
- for (;;) {
- r.push(a);
- a = get();
- if (a == b) {
- break;
- }
- if (a <= '\n') {
- throw 'Error: unterminated string literal: ' + a;
- }
- if (a == '\\') {
- r.push(a);
- a = get();
- }
- }
- }
- }
-
- b = next();
-
- if (b == '/' && '(,=:[!&|'.has(a)) {
- r.push(a);
- r.push(b);
- for (;;) {
- a = get();
- if (a == '/') {
- break;
- } else if (a =='\\') {
- r.push(a);
- a = get();
- } else if (a <= '\n') {
- throw 'Error: unterminated Regular Expression literal';
- }
- r.push(a);
- }
- b = next();
- }
-
- return r.join('');
- }
-
-
- /* m -- Copy the input to the output, deleting the characters which are
- insignificant to JavaScript. Comments will be removed. Tabs will be
- replaced with spaces. Carriage returns will be replaced with
- linefeeds.
- Most spaces and linefeeds will be removed.
- */
-
- function m() {
-
- var r = [];
- a = '\n';
-
- r.push(action(3));
-
- while (a != EOF) {
- switch (a) {
- case ' ':
- if (isAlphanum(b)) {
- r.push(action(1));
- } else {
- r.push(action(2));
- }
- break;
- case '\n':
- switch (b) {
- case '{':
- case '[':
- case '(':
- case '+':
- case '-':
- r.push(action(1));
- break;
- case ' ':
- r.push(action(3));
- break;
- default:
- if (isAlphanum(b)) {
- r.push(action(1));
- } else {
- if (level == 1 && b != '\n') {
- r.push(action(1));
- } else {
- r.push(action(2));
- }
- }
- }
- break;
- default:
- switch (b) {
- case ' ':
- if (isAlphanum(a)) {
- r.push(action(1));
- break;
- }
- r.push(action(3));
- break;
- case '\n':
- if (level == 1 && a != '\n') {
- r.push(action(1));
- } else {
- switch (a) {
- case '}':
- case ']':
- case ')':
- case '+':
- case '-':
- case '"':
- case '\'':
- if (level == 3) {
- r.push(action(3));
- } else {
- r.push(action(1));
- }
- break;
- default:
- if (isAlphanum(a)) {
- r.push(action(1));
- } else {
- r.push(action(3));
- }
- }
- }
- break;
- default:
- r.push(action(1));
- break;
- }
- }
- }
-
- return r.join('');
- }
-
- jsmin.oldSize = input.length;
- var r = m(input);
- jsmin.newSize = r.length;
-
- return comment + r;
-
-}
+++ /dev/null
-/*
- json.js
- 2006-04-28
-
- This file adds these methods to JavaScript:
-
- object.toJSONString()
-
- This method produces a JSON text from an object. The
- object must not contain any cyclical references.
-
- array.toJSONString()
-
- This method produces a JSON text from an array. The
- array must not contain any cyclical references.
-
- string.parseJSON()
-
- This method parses a JSON text to produce an object or
- array. It will return false if there is an error.
-*/
-(function () {
- var m = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- },
- s = {
- array: function (x) {
- var a = ['['], b, f, i, l = x.length, v;
- for (i = 0; i < l; i += 1) {
- v = x[i];
- f = s[typeof v];
- if (f) {
- v = f(v);
- if (typeof v == 'string') {
- if (b) {
- a[a.length] = ',';
- }
- a[a.length] = v;
- b = true;
- }
- }
- }
- a[a.length] = ']';
- return a.join('');
- },
- 'boolean': function (x) {
- return String(x);
- },
- 'null': function (x) {
- return "null";
- },
- number: function (x) {
- return isFinite(x) ? String(x) : 'null';
- },
- object: function (x) {
- if (x) {
- if (x instanceof Array) {
- return s.array(x);
- }
- var a = ['{'], b, f, i, v;
- for (i in x) {
- v = x[i];
- f = s[typeof v];
- if (f) {
- v = f(v);
- if (typeof v == 'string') {
- if (b) {
- a[a.length] = ',';
- }
- a.push(s.string(i), ':', v);
- b = true;
- }
- }
- }
- a[a.length] = '}';
- return a.join('');
- }
- return 'null';
- },
- string: function (x) {
- if (/["\\\x00-\x1f]/.test(x)) {
- x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
- var c = m[b];
- if (c) {
- return c;
- }
- c = b.charCodeAt();
- return '\\u00' +
- Math.floor(c / 16).toString(16) +
- (c % 16).toString(16);
- });
- }
- return '"' + x + '"';
- }
- };
-
- Object.toJSON = function(obj) {
- return s.object(obj);
- };
-})();
-
-String.prototype.parseJSON = function () {
- try {
- return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
- this.replace(/"(\\.|[^"\\])*"/g, ''))) &&
- eval('(' + this + ')');
- } catch (e) {
- return false;
- }
-};
-
+++ /dev/null
-/*
- packer, version 2.0.2 (2005-08-19)
- Copyright 2004-2005, Dean Edwards
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-
-function pack(_script, _encoding, _fastDecode, _specialChars) {
- // constants
- var $IGNORE = "$1";
-
- // validate parameters
- _script += "\n";
- _encoding = Math.min(parseInt(_encoding), 95);
-
- // apply all parsing routines
- function _pack($script) {
- var i, $parse;
- for (i = 0; ($parse = _parsers[i]); i++) {
- $script = $parse($script);
- }
- return $script;
- };
-
- // unpacking function - this is the boot strap function
- // data extracted from this packing routine is passed to
- // this function when decoded in the target
- var _unpack = function($packed, $ascii, $count, $keywords, $encode, $decode) {
- while ($count--)
- if ($keywords[$count])
- $packed = $packed.replace(new RegExp('\\b' + $encode($count) + '\\b', 'g'), $keywords[$count]);
- return $packed;
- };
-
- // code-snippet inserted into the unpacker to speed up decoding
- var _decode = function() {
- // does the browser support String.replace where the
- // replacement value is a function?
- if (!''.replace(/^/, String)) {
- // decode all the values we need
- while ($count--) $decode[$encode($count)] = $keywords[$count] || $encode($count);
- // global replacement function
- $keywords = [function($encoded){return $decode[$encoded]}];
- // generic match
- $encode = function(){return'\\w+'};
- // reset the loop counter - we are now doing a global replace
- $count = 1;
- }
- };
-
- // keep a list of parsing functions, they'll be executed all at once
- var _parsers = [];
- function _addParser($parser) {
- _parsers[_parsers.length] = $parser;
- };
-
- // zero encoding - just removal of white space and comments
- function _basicCompression($script) {
- var $parser = new ParseMaster;
- // make safe
- $parser.escapeChar = "\\";
- // protect strings
- $parser.add(/'[^'\n\r]*'/, $IGNORE);
- $parser.add(/"[^"\n\r]*"/, $IGNORE);
- // remove comments
- $parser.add(/\/\/[^\n\r]*[\n\r]/, " ");
- $parser.add(/\/\*[^*]*\*+([^\/][^*]*\*+)*\//, " ");
- // protect regular expressions
- $parser.add(/\s+(\/[^\/\n\r\*][^\/\n\r]*\/g?i?)/, "$2"); // IGNORE
- $parser.add(/[^\w\x24\/'"*)\?:]\/[^\/\n\r\*][^\/\n\r]*\/g?i?/, $IGNORE);
- // remove: ;;; doSomething();
- if (_specialChars) $parser.add(/;;;[^\n\r]+[\n\r]/);
- // remove redundant semi-colons
- $parser.add(/\(;;\)/, $IGNORE); // protect for (;;) loops
- $parser.add(/;+\s*([};])/, "$2");
- // apply the above
- $script = $parser.exec($script);
-
- // remove white-space
- $parser.add(/(\b|\x24)\s+(\b|\x24)/, "$2 $3");
- $parser.add(/([+\-])\s+([+\-])/, "$2 $3");
- $parser.add(/\s+/, "");
- // done
- return $parser.exec($script);
- };
-
- function _encodeSpecialChars($script) {
- var $parser = new ParseMaster;
- // replace: $name -> n, $$name -> na
- $parser.add(/((\x24+)([a-zA-Z$_]+))(\d*)/, function($match, $offset) {
- var $length = $match[$offset + 2].length;
- var $start = $length - Math.max($length - $match[$offset + 3].length, 0);
- return $match[$offset + 1].substr($start, $length) + $match[$offset + 4];
- });
- // replace: _name -> _0, double-underscore (__name) is ignored
- var $regexp = /\b_[A-Za-z\d]\w*/;
- // build the word list
- var $keywords = _analyze($script, _globalize($regexp), _encodePrivate);
- // quick ref
- var $encoded = $keywords.$encoded;
- $parser.add($regexp, function($match, $offset) {
- return $encoded[$match[$offset]];
- });
- return $parser.exec($script);
- };
-
- function _encodeKeywords($script) {
- // escape high-ascii values already in the script (i.e. in strings)
- if (_encoding > 62) $script = _escape95($script);
- // create the parser
- var $parser = new ParseMaster;
- var $encode = _getEncoder(_encoding);
- // for high-ascii, don't encode single character low-ascii
- var $regexp = (_encoding > 62) ? /\w\w+/ : /\w+/;
- // build the word list
- $keywords = _analyze($script, _globalize($regexp), $encode);
- var $encoded = $keywords.$encoded;
- // encode
- $parser.add($regexp, function($match, $offset) {
- return $encoded[$match[$offset]];
- });
- // if encoded, wrap the script in a decoding function
- return $script && _bootStrap($parser.exec($script), $keywords);
- };
-
- function _analyze($script, $regexp, $encode) {
- // analyse
- // retreive all words in the script
- var $all = $script.match($regexp);
- var $$sorted = []; // list of words sorted by frequency
- var $$encoded = {}; // dictionary of word->encoding
- var $$protected = {}; // instances of "protected" words
- if ($all) {
- var $unsorted = []; // same list, not sorted
- var $protected = {}; // "protected" words (dictionary of word->"word")
- var $values = {}; // dictionary of charCode->encoding (eg. 256->ff)
- var $count = {}; // word->count
- var i = $all.length, j = 0, $word;
- // count the occurrences - used for sorting later
- do {
- $word = "$" + $all[--i];
- if (!$count[$word]) {
- $count[$word] = 0;
- $unsorted[j] = $word;
- // make a dictionary of all of the protected words in this script
- // these are words that might be mistaken for encoding
- $protected["$" + ($values[j] = $encode(j))] = j++;
- }
- // increment the word counter
- $count[$word]++;
- } while (i);
- // prepare to sort the word list, first we must protect
- // words that are also used as codes. we assign them a code
- // equivalent to the word itself.
- // e.g. if "do" falls within our encoding range
- // then we store keywords["do"] = "do";
- // this avoids problems when decoding
- i = $unsorted.length;
- do {
- $word = $unsorted[--i];
- if ($protected[$word] != null) {
- $$sorted[$protected[$word]] = $word.slice(1);
- $$protected[$protected[$word]] = true;
- $count[$word] = 0;
- }
- } while (i);
- // sort the words by frequency
- $unsorted.sort(function($match1, $match2) {
- return $count[$match2] - $count[$match1];
- });
- j = 0;
- // because there are "protected" words in the list
- // we must add the sorted words around them
- do {
- if ($$sorted[i] == null) $$sorted[i] = $unsorted[j++].slice(1);
- $$encoded[$$sorted[i]] = $values[i];
- } while (++i < $unsorted.length);
- }
- return {$sorted: $$sorted, $encoded: $$encoded, $protected: $$protected};
- };
-
- // build the boot function used for loading and decoding
- function _bootStrap($packed, $keywords) {
- var $ENCODE = _safeRegExp("$encode\\($count\\)", "g");
-
- // $packed: the packed script
- $packed = "'" + _escape($packed) + "'";
-
- // $ascii: base for encoding
- var $ascii = Math.min($keywords.$sorted.length, _encoding) || 1;
-
- // $count: number of words contained in the script
- var $count = $keywords.$sorted.length;
-
- // $keywords: list of words contained in the script
- for (var i in $keywords.$protected) $keywords.$sorted[i] = "";
- // convert from a string to an array
- $keywords = "'" + $keywords.$sorted.join("|") + "'.split('|')";
-
- // $encode: encoding function (used for decoding the script)
- var $encode = _encoding > 62 ? _encode95 : _getEncoder($ascii);
- $encode = String($encode).replace(/_encoding/g, "$ascii").replace(/arguments\.callee/g, "$encode");
- var $inline = "$count" + ($ascii > 10 ? ".toString($ascii)" : "");
-
- // $decode: code snippet to speed up decoding
- if (_fastDecode) {
- // create the decoder
- var $decode = _getFunctionBody(_decode);
- if (_encoding > 62) $decode = $decode.replace(/\\\\w/g, "[\\xa1-\\xff]");
- // perform the encoding inline for lower ascii values
- else if ($ascii < 36) $decode = $decode.replace($ENCODE, $inline);
- // special case: when $count==0 there are no keywords. I want to keep
- // the basic shape of the unpacking funcion so i'll frig the code...
- if (!$count) $decode = $decode.replace(_safeRegExp("($count)\\s*=\\s*1"), "$1=0");
- }
-
- // boot function
- var $unpack = String(_unpack);
- if (_fastDecode) {
- // insert the decoder
- $unpack = $unpack.replace(/\{/, "{" + $decode + ";");
- }
- $unpack = $unpack.replace(/"/g, "'");
- if (_encoding > 62) { // high-ascii
- // get rid of the word-boundaries for regexp matches
- $unpack = $unpack.replace(/'\\\\b'\s*\+|\+\s*'\\\\b'/g, "");
- }
- if ($ascii > 36 || _encoding > 62 || _fastDecode) {
- // insert the encode function
- $unpack = $unpack.replace(/\{/, "{$encode=" + $encode + ";");
- } else {
- // perform the encoding inline
- $unpack = $unpack.replace($ENCODE, $inline);
- }
- // pack the boot function too
- $unpack = pack($unpack, 0, false, true);
-
- // arguments
- var $params = [$packed, $ascii, $count, $keywords];
- if (_fastDecode) {
- // insert placeholders for the decoder
- $params = $params.concat(0, "{}");
- }
-
- // the whole thing
- return "eval(" + $unpack + "(" + $params + "))\n";
- };
-
- // mmm.. ..which one do i need ??
- function _getEncoder($ascii) {
- return $ascii > 10 ? $ascii > 36 ? $ascii > 62 ? _encode95 : _encode62 : _encode36 : _encode10;
- };
-
- // zero encoding
- // characters: 0123456789
- var _encode10 = function($charCode) {
- return $charCode;
- };
-
- // inherent base36 support
- // characters: 0123456789abcdefghijklmnopqrstuvwxyz
- var _encode36 = function($charCode) {
- return $charCode.toString(36);
- };
-
- // hitch a ride on base36 and add the upper case alpha characters
- // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
- var _encode62 = function($charCode) {
- return ($charCode < _encoding ? '' : arguments.callee(parseInt($charCode / _encoding))) +
- (($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36));
- };
-
- // use high-ascii values
- var _encode95 = function($charCode) {
- return ($charCode < _encoding ? '' : arguments.callee($charCode / _encoding)) +
- String.fromCharCode($charCode % _encoding + 161);
- };
-
- // special _chars
- var _encodePrivate = function($charCode) {
- return "_" + $charCode;
- };
-
- // protect characters used by the parser
- function _escape($script) {
- return $script.replace(/([\\'])/g, "\\$1");
- };
-
- // protect high-ascii characters already in the script
- function _escape95($script) {
- return $script.replace(/[\xa1-\xff]/g, function($match) {
- return "\\x" + $match.charCodeAt(0).toString(16);
- });
- };
-
- function _safeRegExp($string, $flags) {
- return new RegExp($string.replace(/\$/g, "\\$"), $flags);
- };
-
- // extract the body of a function
- function _getFunctionBody($function) {
- with (String($function)) return slice(indexOf("{") + 1, lastIndexOf("}"));
- };
-
- // set the global flag on a RegExp (you have to create a new one)
- function _globalize($regexp) {
- return new RegExp(String($regexp).slice(1, -1), "g");
- };
-
- // build the parsing routine
- _addParser(_basicCompression);
- if (_specialChars) _addParser(_encodeSpecialChars);
- if (_encoding) _addParser(_encodeKeywords);
-
- // go!
- return _pack(_script);
-};
+++ /dev/null
-function parse( f ) {
- var c = [], bm, m;
- var blockMatch = /\/\*\*\s*((.|\n)*?)\s*\*\//g;
- var paramMatch = /\@(\S+) *((.|\n)*?)(?=\n\@|!!!)/m;
-
- while ( bm = blockMatch.exec(f) ) {
- block = bm[1].replace(/^\s*\* ?/mg,"") + "!!!";
- var ret = { params: [], examples: [], tests: [], options: [] };
-
- while ( m = paramMatch.exec( block ) ) {
- block = block.replace( paramMatch, "" );
-
- var n = m[1];
- var v = m[2]
- .replace(/\s*$/g,"")
- .replace(/^\s*/g,"")
- .replace(/&/g, "&")
- .replace(/</g, "<")
- .replace(/>/g, ">")
- //.replace(/\n/g, "<br/>")
- /*.replace(/(\s\s+)/g, function(a){
- var ret = "";
- for ( var i = 0; i < a.length; i++ )
- ret += " ";
- return ret;
- })*/ || 1;
-
- if ( n == 'param' || n == 'option' ) {
- var args = v.split(/\s+/);
- v = args.slice( 2, args.length );
- v = { type: args[0], name: args[1], desc: v.join(' ') };
- n = n + "s";
- } else if ( n == 'example' ) {
- v = { code: v };
- n = "examples";
- } else if ( n == 'test' ) {
- n = "tests";
- }
-
- if ( n == 'desc' || n == 'before' || n == 'after' || n == 'result' ) {
- ret.examples[ ret.examples.length - 1 ][ n ] = v;
- } else {
- if ( ret[ n ] ) {
- if ( ret[ n ].constructor == Array ) {
- ret[ n ].push( v );
- } else {
- ret[ n ] = [ ret[ n ], v ];
- }
- } else {
- ret[ n ] = v;
- }
- }
- }
-
- ret.desc = block.replace(/\s*!!!$/,"")
- .replace(/</g, "<")
- .replace(/>/g, ">");
- //.replace(/\n\n/g, "<br/><br/>")
- //.replace(/\n/g, " ");
-
- var m = /^((.|\n)*?(\.|$))/.exec( ret.desc );
- if ( m ) ret['short'] = m[1];
-
- if ( ret.name ) c.push( ret );
- }
-
- return c;
-}
-
-function categorize( json ) {
- var obj = { cat: [], method: [] };
-
- for ( var i = 0; i < json.length; i++ ) {
- if ( !json[i].cat ) json[i].cat = "";
-
- var cat = json[i].cat.split("/");
-
- var pos = obj;
- for ( var j = 0; j < cat.length; j++ ) {
- var c = cat[j];
- var curCat = null;
-
- // Locate current category
- for ( var n = 0; n < pos.cat.length; n++ )
- if ( pos.cat[n].value == c )
- curCat = pos.cat[n];
-
- // Create current category
- if ( !curCat ) {
- curCat = { value: c, cat: [], method: [] };
- pos.cat.push( curCat )
- }
-
- // If we're at the end, add the method
- if ( j == cat.length - 1 )
- curCat.method.push( json[i] );
-
- // Otherwise, traverse deeper
- else
- pos = curCat;
- }
- }
-
- return obj;
-}
+++ /dev/null
-importPackage(java.io);
-
-function writeFile( file, stream ) {
- var buffer = new PrintWriter( new FileWriter( file ) );
- buffer.print( stream );
- buffer.close();
-}
-
-function read( file ) {
- var jq = new File(file);
- var reader = new BufferedReader(new FileReader(jq));
- var line = null;
- var buffer = new java.lang.StringBuffer(jq.length());
- while( (line = reader.readLine()) != null) {
- buffer.append(line);
- buffer.append("\n");
- }
- return buffer.toString();
-}
\ No newline at end of file
+++ /dev/null
-Object.toXML = function( obj, tag ) {
- if ( obj.constructor == Array ) {
- var ret = "";
- for ( var i = 0; i < obj.length; i++ )
- ret += Object.toXML( obj[i], tag );
- return ret;
- } else if ( obj.constructor == Object ) {
- var tag = tag || "tmp";
- var p = "", child = "";
-
- for ( var i in obj )
- if ( ( obj[i].constructor != String && obj[i].constructor != Number ) || /</.test(obj[i] + "") || Object.toXML.force[i] )
- child += Object.toXML( obj[i], i );
- else
- p += " " + i + "='" + (obj[i] + "").replace(/'/g, "'") + "'";
-
- return "<" + tag + p + ( child ? ">\n" + child + "</" + tag + ">\n" : "/>\n" );
- } else if ( obj.constructor == String || obj.constructor == Number ) {
- return "<" + tag + ">" + obj + "</" + tag + ">\n";
- }
-
- return "";
-};
-
-Object.toXML.force = {};
+++ /dev/null
-/*
- * Simulated browser environment for Rhino
- * By John Resig <http://ejohn.org/>
- * Copyright 2007 John Resig, under the MIT License
- */
-
-// The window Object
-var window = this;
-
-(function(){
-
- // Browser Navigator
-
- window.navigator = {
- get userAgent(){
- return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3";
- }
- };
-
- var curLocation = (new java.io.File("./")).toURL();
-
- window.__defineSetter__("location", function(url){
- var xhr = new XMLHttpRequest();
- xhr.open("GET", url);
- xhr.onreadystatechange = function(){
- curLocation = new java.net.URL( curLocation, url );
- window.document = xhr.responseXML;
-
- var event = document.createEvent();
- event.initEvent("load");
- window.dispatchEvent( event );
- };
- xhr.send();
- });
-
- window.__defineGetter__("location", function(url){
- return {
- get protocol(){
- return curLocation.getProtocol() + ":";
- },
- get href(){
- return curLocation.toString();
- },
- toString: function(){
- return this.href;
- }
- };
- });
-
- // Timers
-
- var timers = [];
-
- window.setTimeout = function(fn, time){
- var num;
- return num = setInterval(function(){
- fn();
- clearInterval(num);
- }, time);
- };
-
- window.setInterval = function(fn, time){
- var num = timers.length;
-
- timers[num] = new java.lang.Thread(new java.lang.Runnable({
- run: function(){
- while (true){
- java.lang.Thread.currentThread().sleep(time);
- fn();
- }
- }
- }));
-
- timers[num].start();
-
- return num;
- };
-
- window.clearInterval = function(num){
- if ( timers[num] ) {
- timers[num].stop();
- delete timers[num];
- }
- };
-
- // Window Events
-
- var events = [{}];
-
- window.addEventListener = function(type, fn){
- if ( !this.uuid || this == window ) {
- this.uuid = events.length;
- events[this.uuid] = {};
- }
-
- if ( !events[this.uuid][type] )
- events[this.uuid][type] = [];
-
- if ( events[this.uuid][type].indexOf( fn ) < 0 )
- events[this.uuid][type].push( fn );
- };
-
- window.removeEventListener = function(type, fn){
- if ( !this.uuid || this == window ) {
- this.uuid = events.length;
- events[this.uuid] = {};
- }
-
- if ( !events[this.uuid][type] )
- events[this.uuid][type] = [];
-
- events[this.uuid][type] =
- events[this.uuid][type].filter(function(f){
- return f != fn;
- });
- };
-
- window.dispatchEvent = function(event){
- if ( event.type ) {
- if ( this.uuid && events[this.uuid][event.type] ) {
- var self = this;
-
- events[this.uuid][event.type].forEach(function(fn){
- fn.call( self, event );
- });
- }
-
- if ( this["on" + event.type] )
- this["on" + event.type].call( self, event );
- }
- };
-
- // DOM Document
-
- window.DOMDocument = function(file){
- this._file = file;
- this._dom = Packages.javax.xml.parsers.
- DocumentBuilderFactory.newInstance()
- .newDocumentBuilder().parse(file);
-
- if ( !obj_nodes.containsKey( this._dom ) )
- obj_nodes.put( this._dom, this );
- };
-
- DOMDocument.prototype = {
- createTextNode: function(text){
- return makeNode( this._dom.createTextNode(
- text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) );
- },
- createElement: function(name){
- return makeNode( this._dom.createElement(name.toLowerCase()) );
- },
- getElementsByTagName: function(name){
- return new DOMNodeList( this._dom.getElementsByTagName(
- name.toLowerCase()) );
- },
- getElementById: function(id){
- var elems = this._dom.getElementsByTagName("*");
-
- for ( var i = 0; i < elems.length; i++ ) {
- var elem = elems.item(i);
- if ( elem.getAttribute("id") == id )
- return makeNode(elem);
- }
-
- return null;
- },
- get body(){
- return this.getElementsByTagName("body")[0];
- },
- get documentElement(){
- return makeNode( this._dom.getDocumentElement() );
- },
- get ownerDocument(){
- return null;
- },
- addEventListener: window.addEventListener,
- removeEventListener: window.removeEventListener,
- dispatchEvent: window.dispatchEvent,
- get nodeName() {
- return "#document";
- },
- importNode: function(node, deep){
- return makeNode( this._dom.importNode(node._dom, deep) );
- },
- toString: function(){
- return "Document" + (typeof this._file == "string" ?
- ": " + this._file : "");
- },
- get innerHTML(){
- return this.documentElement.outerHTML;
- },
-
- get defaultView(){
- return {
- getComputedStyle: function(elem){
- return {
- getPropertyValue: function(prop){
- prop = prop.replace(/\-(\w)/g,function(m,c){
- return c.toUpperCase();
- });
- var val = elem.style[prop];
-
- if ( prop == "opacity" && val == "" )
- val = "1";
-
- return val;
- }
- };
- }
- };
- },
-
- createEvent: function(){
- return {
- type: "",
- initEvent: function(type){
- this.type = type;
- }
- };
- }
- };
-
- function getDocument(node){
- return obj_nodes.get(node);
- }
-
- // DOM NodeList
-
- window.DOMNodeList = function(list){
- this._dom = list;
- this.length = list.getLength();
-
- for ( var i = 0; i < this.length; i++ ) {
- var node = list.item(i);
- this[i] = makeNode( node );
- }
- };
-
- DOMNodeList.prototype = {
- toString: function(){
- return "[ " +
- Array.prototype.join.call( this, ", " ) + " ]";
- },
- get outerHTML(){
- return Array.prototype.map.call(
- this, function(node){return node.outerHTML;}).join('');
- }
- };
-
- // DOM Node
-
- window.DOMNode = function(node){
- this._dom = node;
- };
-
- DOMNode.prototype = {
- get nodeType(){
- return this._dom.getNodeType();
- },
- get nodeValue(){
- return this._dom.getNodeValue();
- },
- get nodeName() {
- return this._dom.getNodeName();
- },
- cloneNode: function(deep){
- return makeNode( this._dom.cloneNode(deep) );
- },
- get ownerDocument(){
- return getDocument( this._dom.ownerDocument );
- },
- get documentElement(){
- return makeNode( this._dom.documentElement );
- },
- get parentNode() {
- return makeNode( this._dom.getParentNode() );
- },
- get nextSibling() {
- return makeNode( this._dom.getNextSibling() );
- },
- get previousSibling() {
- return makeNode( this._dom.getPreviousSibling() );
- },
- toString: function(){
- return '"' + this.nodeValue + '"';
- },
- get outerHTML(){
- return this.nodeValue;
- }
- };
-
- // DOM Element
-
- window.DOMElement = function(elem){
- this._dom = elem;
- this.style = {
- get opacity(){ return this._opacity; },
- set opacity(val){ this._opacity = val + ""; }
- };
-
- // Load CSS info
- var styles = (this.getAttribute("style") || "").split(/\s*;\s*/);
-
- for ( var i = 0; i < styles.length; i++ ) {
- var style = styles[i].split(/\s*:\s*/);
- if ( style.length == 2 )
- this.style[ style[0] ] = style[1];
- }
- };
-
- DOMElement.prototype = extend( new DOMNode(), {
- get nodeName(){
- return this.tagName.toUpperCase();
- },
- get tagName(){
- return this._dom.getTagName();
- },
- toString: function(){
- return "<" + this.tagName + (this.id ? "#" + this.id : "" ) + ">";
- },
- get outerHTML(){
- var ret = "<" + this.tagName, attr = this.attributes;
-
- for ( var i in attr )
- ret += " " + i + "='" + attr[i] + "'";
-
- if ( this.childNodes.length || this.nodeName == "SCRIPT" )
- ret += ">" + this.childNodes.outerHTML +
- "</" + this.tagName + ">";
- else
- ret += "/>";
-
- return ret;
- },
-
- get attributes(){
- var attr = {}, attrs = this._dom.getAttributes();
-
- for ( var i = 0; i < attrs.getLength(); i++ )
- attr[ attrs.item(i).nodeName ] = attrs.item(i).nodeValue;
-
- return attr;
- },
-
- get innerHTML(){
- return this.childNodes.outerHTML;
- },
- set innerHTML(html){
- html = html.replace(/<\/?([A-Z]+)/g, function(m){
- return m.toLowerCase();
- });
-
- var nodes = this.ownerDocument.importNode(
- new DOMDocument( new java.io.ByteArrayInputStream(
- (new java.lang.String("<wrap>" + html + "</wrap>"))
- .getBytes("UTF8"))).documentElement, true).childNodes;
-
- while (this.firstChild)
- this.removeChild( this.firstChild );
-
- for ( var i = 0; i < nodes.length; i++ )
- this.appendChild( nodes[i] );
- },
-
- get textContent(){
- return nav(this.childNodes);
-
- function nav(nodes){
- var str = "";
- for ( var i = 0; i < nodes.length; i++ )
- if ( nodes[i].nodeType == 3 )
- str += nodes[i].nodeValue;
- else if ( nodes[i].nodeType == 1 )
- str += nav(nodes[i].childNodes);
- return str;
- }
- },
- set textContent(text){
- while (this.firstChild)
- this.removeChild( this.firstChild );
- this.appendChild( this.ownerDocument.createTextNode(text));
- },
-
- style: {},
- clientHeight: 0,
- clientWidth: 0,
- offsetHeight: 0,
- offsetWidth: 0,
-
- get disabled() {
- var val = this.getAttribute("disabled");
- return val != "false" && !!val;
- },
- set disabled(val) { return this.setAttribute("disabled",val); },
-
- get checked() {
- var val = this.getAttribute("checked");
- return val != "false" && !!val;
- },
- set checked(val) { return this.setAttribute("checked",val); },
-
- get selected() {
- if ( !this._selectDone ) {
- this._selectDone = true;
-
- if ( this.nodeName == "OPTION" && !this.parentNode.getAttribute("multiple") ) {
- var opt = this.parentNode.getElementsByTagName("option");
-
- if ( this == opt[0] ) {
- var select = true;
-
- for ( var i = 1; i < opt.length; i++ )
- if ( opt[i].selected ) {
- select = false;
- break;
- }
-
- if ( select )
- this.selected = true;
- }
- }
- }
-
- var val = this.getAttribute("selected");
- return val != "false" && !!val;
- },
- set selected(val) { return this.setAttribute("selected",val); },
-
- get className() { return this.getAttribute("class") || ""; },
- set className(val) {
- return this.setAttribute("class",
- val.replace(/(^\s*|\s*$)/g,""));
- },
-
- get type() { return this.getAttribute("type") || ""; },
- set type(val) { return this.setAttribute("type",val); },
-
- get value() { return this.getAttribute("value") || ""; },
- set value(val) { return this.setAttribute("value",val); },
-
- get src() { return this.getAttribute("src") || ""; },
- set src(val) { return this.setAttribute("src",val); },
-
- get id() { return this.getAttribute("id") || ""; },
- set id(val) { return this.setAttribute("id",val); },
-
- getAttribute: function(name){
- return this._dom.hasAttribute(name) ?
- new String( this._dom.getAttribute(name) ) :
- null;
- },
- setAttribute: function(name,value){
- this._dom.setAttribute(name,value);
- },
- removeAttribute: function(name){
- this._dom.removeAttribute(name);
- },
-
- get childNodes(){
- return new DOMNodeList( this._dom.getChildNodes() );
- },
- get firstChild(){
- return makeNode( this._dom.getFirstChild() );
- },
- get lastChild(){
- return makeNode( this._dom.getLastChild() );
- },
- appendChild: function(node){
- this._dom.appendChild( node._dom );
- },
- insertBefore: function(node,before){
- this._dom.insertBefore( node._dom, before ? before._dom : before );
- },
- removeChild: function(node){
- this._dom.removeChild( node._dom );
- },
-
- getElementsByTagName: DOMDocument.prototype.getElementsByTagName,
-
- addEventListener: window.addEventListener,
- removeEventListener: window.removeEventListener,
- dispatchEvent: window.dispatchEvent,
-
- click: function(){
- var event = document.createEvent();
- event.initEvent("click");
- this.dispatchEvent(event);
- },
- submit: function(){
- var event = document.createEvent();
- event.initEvent("submit");
- this.dispatchEvent(event);
- },
- focus: function(){
- var event = document.createEvent();
- event.initEvent("focus");
- this.dispatchEvent(event);
- },
- blur: function(){
- var event = document.createEvent();
- event.initEvent("blur");
- this.dispatchEvent(event);
- },
- get elements(){
- return this.getElementsByTagName("*");
- },
- get contentWindow(){
- return this.nodeName == "IFRAME" ? {
- document: this.contentDocument
- } : null;
- },
- get contentDocument(){
- if ( this.nodeName == "IFRAME" ) {
- if ( !this._doc )
- this._doc = new DOMDocument(
- new java.io.ByteArrayInputStream((new java.lang.String(
- "<html><head><title></title></head><body></body></html>"))
- .getBytes("UTF8")));
- return this._doc;
- } else
- return null;
- }
- });
-
- // Helper method for extending one object with another
-
- function extend(a,b) {
- for ( var i in b ) {
- var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
-
- if ( g || s ) {
- if ( g )
- a.__defineGetter__(i, g);
- if ( s )
- a.__defineSetter__(i, s);
- } else
- a[i] = b[i];
- }
- return a;
- }
-
- // Helper method for generating the right
- // DOM objects based upon the type
-
- var obj_nodes = new java.util.HashMap();
-
- function makeNode(node){
- if ( node ) {
- if ( !obj_nodes.containsKey( node ) )
- obj_nodes.put( node, node.getNodeType() ==
- Packages.org.w3c.dom.Node.ELEMENT_NODE ?
- new DOMElement( node ) : new DOMNode( node ) );
-
- return obj_nodes.get(node);
- } else
- return null;
- }
-
- // XMLHttpRequest
- // Originally implemented by Yehuda Katz
-
- window.XMLHttpRequest = function(){
- this.headers = {};
- this.responseHeaders = {};
- };
-
- XMLHttpRequest.prototype = {
- open: function(method, url, async, user, password){
- this.readyState = 1;
- if (async)
- this.async = true;
- this.method = method || "GET";
- this.url = url;
- this.onreadystatechange();
- },
- setRequestHeader: function(header, value){
- this.headers[header] = value;
- },
- getResponseHeader: function(header){ },
- send: function(data){
- var self = this;
-
- function makeRequest(){
- var url = new java.net.URL(curLocation, self.url);
-
- if ( url.getProtocol() == "file" ) {
- if ( self.method == "PUT" ) {
- var out = new java.io.FileWriter(
- new java.io.File( new java.net.URI( url.toString() ) ) ),
- text = new java.lang.String( data || "" );
-
- out.write( text, 0, text.length() );
- out.flush();
- out.close();
- } else if ( self.method == "DELETE" ) {
- var file = new java.io.File( new java.net.URI( url.toString() ) );
- file["delete"]();
- } else {
- var connection = url.openConnection();
- connection.connect();
- handleResponse();
- }
- } else {
- var connection = url.openConnection();
-
- connection.setRequestMethod( self.method );
-
- // Add headers to Java connection
- for (var header in self.headers)
- connection.addRequestProperty(header, self.headers[header]);
-
- connection.connect();
-
- // Stick the response headers into responseHeaders
- for (var i = 0; ; i++) {
- var headerName = connection.getHeaderFieldKey(i);
- var headerValue = connection.getHeaderField(i);
- if (!headerName && !headerValue) break;
- if (headerName)
- self.responseHeaders[headerName] = headerValue;
- }
-
- handleResponse();
- }
-
- function handleResponse(){
- self.readyState = 4;
- self.status = parseInt(connection.responseCode) || undefined;
- self.statusText = connection.responseMessage || "";
-
- var stream = new java.io.InputStreamReader(connection.getInputStream()),
- buffer = new java.io.BufferedReader(stream), line;
-
- while ((line = buffer.readLine()) != null)
- self.responseText += line;
-
- self.responseXML = null;
-
- if ( self.responseText.match(/^\s*</) ) {
- try {
- self.responseXML = new DOMDocument(
- new java.io.ByteArrayInputStream(
- (new java.lang.String(
- self.responseText)).getBytes("UTF8")));
- } catch(e) {}
- }
- }
-
- self.onreadystatechange();
- }
-
- if (this.async)
- (new java.lang.Thread(new java.lang.Runnable({
- run: makeRequest
- }))).start();
- else
- makeRequest();
- },
- abort: function(){},
- onreadystatechange: function(){},
- getResponseHeader: function(header){
- if (this.readyState < 3)
- throw new Error("INVALID_STATE_ERR");
- else {
- var returnedHeaders = [];
- for (var rHeader in this.responseHeaders) {
- if (rHeader.match(new Regexp(header, "i")))
- returnedHeaders.push(this.responseHeaders[rHeader]);
- }
-
- if (returnedHeaders.length)
- return returnedHeaders.join(", ");
- }
-
- return null;
- },
- getAllResponseHeaders: function(header){
- if (this.readyState < 3)
- throw new Error("INVALID_STATE_ERR");
- else {
- var returnedHeaders = [];
-
- for (var header in this.responseHeaders)
- returnedHeaders.push( header + ": " + this.responseHeaders[header] );
-
- return returnedHeaders.join("\r\n");
- }
- },
- async: true,
- readyState: 0,
- responseText: "",
- status: 0
- };
-})();
+++ /dev/null
-// Init
-load("build/runtest/env.js");
-
-window.location = "test/index.html";
-
-window.onload = function(){
- // Load the test runner
- load("dist/jquery.js","build/runtest/testrunner.js");
-
- // Load the tests
- load(
- "test/unit/core.js",
- "test/unit/selector.js",
- "test/unit/event.js"
- //"test/unit/fx.js",
- //"test/unit/ajax.js"
- );
-
- // Display the results
- results();
-};
+++ /dev/null
-function test(name, fn){
- expected = -1;
- numTests = 0;
- reset();
-
- fn();
-
- if ( expected != -1 && expected != numTests )
- log( false, "Wrong number of tests run. " + numTests + " ran, expected " + expected );
-}
-
-var orig = document.getElementById('main').innerHTML;
-
-/**
- * Resets the test setup. Useful for tests that modify the DOM.
- */
-function reset() {
- document.getElementById('main').innerHTML = orig;
-}
-
-var currentModule = "";
-
-// call on start of module test to prepend name to all tests
-function module(moduleName) {
- currentModule = moduleName;
-}
-
-var expected = -1;
-
-/**
- * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
- */
-function expect(asserts) {
- expected = asserts;
-}
-
-/**
- * Asserts true.
- * @example ok( $("a").size() > 5, "There must be at least 5 anchors" );
- */
-function ok(a, msg) {
- log( !!a, msg );
-}
-
-/**
- * Asserts that two arrays are the same
- */
-function isSet(a, b, msg) {
- var ret = true;
- if ( a && b && a.length != undefined && a.length == b.length ) {
- for ( var i = 0; i < a.length; i++ ) {
- if ( a[i] != b[i] )
- ret = false;
- }
- } else
- ret = false;
- if ( !ret )
- log( ret, msg + " expected: " + serialArray(b) + " result: " + serialArray(a) );
- else
- log( ret, msg );
-}
-
-/**
- * Asserts that two objects are equivalent
- */
-function isObj(a, b, msg) {
- var ret = true;
-
- if ( a && b ) {
- for ( var i in a )
- if ( a[i] != b[i] )
- ret = false;
-
- for ( i in b )
- if ( a[i] != b[i] )
- ret = false;
- } else
- ret = false;
-
- log( ret, msg );
-}
-
-function serialArray( a ) {
- var r = [];
-
- if ( a && a.length )
- for ( var i = 0; i < a.length; i++ ) {
- var str = a[i] ? a[i].nodeName : "";
- if ( str ) {
- str = str.toLowerCase();
- if ( a[i].id )
- str += "#" + a[i].id;
- } else
- str = a[i];
- r.push( str );
- }
-
- return "[ " + r.join(", ") + " ]"
-}
-
-/**
- * Returns an array of elements with the given IDs, eg.
- * @example q("main", "foo", "bar")
- * @result [<div id="main">, <span id="foo">, <input id="bar">]
- */
-function q() {
- var r = [];
- for ( var i = 0; i < arguments.length; i++ )
- r.push( document.getElementById( arguments[i] ) );
- return r;
-}
-
-/**
- * Asserts that a select matches the given IDs
- * @example t("Check for something", "//[a]", ["foo", "baar"]);
- * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
- */
-function t(a,b,c) {
- var f = jQuery(b);
- var s = "";
- for ( var i = 0; i < f.length; i++ )
- s += (s && ",") + '"' + f[i].id + '"';
- isSet(f, q.apply(q,c), a + " (" + b + ")");
-}
-
-/**
- * Checks that the first two arguments are equal, with an optional message.
- * Prints out both expected and actual values on failure.
- *
- * Prefered to ok( expected == actual, message )
- *
- * @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) );
- *
- * @param Object expected
- * @param Object actual
- * @param String message (optional)
- */
-function equals(expected, actual, message) {
- var result = expected == actual;
- message = message || (result ? "okay" : "failed");
- log( result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual );
-}
-
-var numTests = 0, total = 0, pass = 0, fail = 0;
-
-function log(state, msg){
- print( (state ? "PASS" : "FAIL") + " (" + (++total) + ") " +
- (currentModule ? "[" + currentModule + "] " : "") + msg );
-
- numTests++;
-
- if ( state )
- pass++;
- else
- fail++;
-}
-
-function results(){
- print( pass + " Passed, " + fail + " Failed" );
-}
-
-function start(){}
-function stop(){}
-
-/**
- * Trigger an event on an element.
- *
- * @example triggerEvent( document.body, "click" );
- *
- * @param DOMElement elem
- * @param String type
- */
-function triggerEvent( elem, type, event ) {
-/*
- if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
- event = document.createEvent("MouseEvents");
- event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
- 0, 0, 0, 0, 0, false, false, false, false, 0, null);
- elem.dispatchEvent( event );
- } else if ( jQuery.browser.msie ) {
- elem.fireEvent("on"+type);
- }
-*/
-}
-
-/**
- * Add random number to url to stop IE from caching
- *
- * @example url("data/test.html")
- * @result "data/test.html?10538358428943"
- *
- * @example url("data/test.php?foo=bar")
- * @result "data/test.php?foo=bar&10538358345554"
- */
-function url(value) {
- return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
-}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
- <xsl:output method="xml" indent="yes" />
-
- <!-- TODO convert @type array notation to bracket notation, eg. Array<DOMElement> to [DOMElement] -->
- <xsl:template match="/*">
- <api xmlns="http://openajax.org/metadata">
- <class name="jQuery">
- <constructors>
- <xsl:for-each select="//function[@name='jQuery']">
- <constructor>
- <shortDescription><xsl:value-of select="desc" /></shortDescription>
- <description><xsl:value-of select="longdesc" /></description>
- <xsl:call-template name="parameters" />
- <returnType datatype="{@return}" />
- <xsl:call-template name="examples" />
- </constructor>
- </xsl:for-each>
- </constructors>
- <properties>
- <xsl:for-each select="//property">
- <xsl:sort select="translate(@name,'$.','')"/>
- <xsl:sort select="count(params)"/>
- <property name="{@name}" readonly="true" datatype="{@return}" default="">
- <xsl:call-template name="scope" />
- <shortDescription><xsl:value-of select="desc" /></shortDescription>
- <description><xsl:value-of select="longdesc" /></description>
- <xsl:call-template name="examples" />
- </property>
- </xsl:for-each>
- </properties>
- <methods>
- <xsl:for-each select="//function[@name!='jQuery']">
- <xsl:sort select="translate(@name,'$.','')"/>
- <xsl:sort select="count(params)"/>
- <method name="{@name}">
- <xsl:call-template name="scope" />
- <shortDescription><xsl:value-of select="desc" /></shortDescription>
- <description><xsl:value-of select="longdesc" /></description>
- <xsl:call-template name="parameters" />
- <returnType datatype="{@return}" />
- <xsl:call-template name="examples" />
- </method>
- </xsl:for-each>
- </methods>
- </class>
- </api>
- </xsl:template>
-
- <xsl:template name="scope">
- <xsl:attribute name="scope">
- <xsl:choose>
- <xsl:when test="starts-with(@name, 'jQuery.')">static</xsl:when>
- <xsl:when test="not(starts-with(@name, 'jQuery.'))">instance</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- </xsl:template>
-
- <xsl:template name="parameters">
- <parameters>
- <xsl:for-each select="params">
- <parameter name="{@name}" datatype="{@type}">
- <xsl:attribute name="usage">
- <xsl:choose>
- <xsl:when test="not(@optional)">required</xsl:when>
- <xsl:when test="@optional">optional</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- <description><xsl:value-of select="desc" /></description>
- <!-- TODO part of the spec, but with a very different interpretation -->
- <xsl:choose>
- <xsl:when test="../option">
- <properties>
- <xsl:for-each select="../option">
- <property name="{@name}" datatype="{@type}" default="{@default}">
- <description><xsl:value-of select="desc" /></description>
- </property>
- </xsl:for-each>
- </properties>
- </xsl:when>
- </xsl:choose>
- </parameter>
- </xsl:for-each>
- </parameters>
- </xsl:template>
-
- <xsl:template name="examples">
- <examples>
- <xsl:for-each select="example">
- <example>
- <description><xsl:value-of select="desc" /></description>
- <xsl:copy-of select="code|html|css" />
- </example>
- </xsl:for-each>
- </examples>
- </xsl:template>
-
-</xsl:stylesheet>