From df0101a8451221754ec598496770653c2463bb0f Mon Sep 17 00:00:00 2001 From: aausch Date: Tue, 2 Jul 2013 18:54:36 -0400 Subject: [PATCH 01/13] Automatically redirect to avocado.xhtml, make for easier deployment --- public/index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 public/index.html diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..2b4bab1 --- /dev/null +++ b/public/index.html @@ -0,0 +1,16 @@ + + + + + + + Page Redirection + + + + If you are not redirected automatically, follow the link to example + + \ No newline at end of file From c11678ee2aecb9a84fd6bdb99dc1308836c7f990 Mon Sep 17 00:00:00 2001 From: aausch Date: Tue, 2 Jul 2013 19:10:35 -0400 Subject: [PATCH 02/13] Initial INSTALL, README. --- INSTALL.md | 27 +++++++++++++++++++++++++++ README.md | 7 +++++++ 2 files changed, 34 insertions(+) create mode 100644 INSTALL.md create mode 100644 README.md diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..87313eb --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,27 @@ +These installation instructions are not meant for novices. Improvements are welcome. + +# Quick and Simple (Demo purposes) Installation + +If you're looking to demo Avocadojs, your best bet is to throw the public directory somewhere where a webserver can see its contents. For example, on Mac OS X, start up your webserver, and then copy the "public" folder to the "Sites" directory. + +Remember, for the newer versions of OS X you'll have to start apache from the commandline, like so: + +>sudo apachectl start +>sudo apachectl stop +>sudo apachectl restart + +and you might have to do things like play with your user config file, ie: + +>sudo vim /etc/apache2/users/USERNAME.conf + +possibly writing something like this in there: + +> +> Options Indexes Multiviews +> Options FollowSymLinks +> AllowOverride AuthConfig Limit +> Order deny,allow +> Deny from all +> Allow from 127.0.0.1 +> + diff --git a/README.md b/README.md new file mode 100644 index 0000000..b763720 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +A fork of [Adam](https://github.com/AdamSpitz)'s [Avocadojs](https://github.com/AdamSpitz/Avocado). + +Why? Because forks are easier than direct contributions. + +This project doesn't (yet) have any documentation - contributions are welcome. + +See [here](http://avocadojs.com/ "avocadojs.com") for more project information. From abb4f8f44a870204c9187a289e1225efc60809d9 Mon Sep 17 00:00:00 2001 From: aausch Date: Tue, 2 Jul 2013 19:41:35 -0400 Subject: [PATCH 03/13] More installation documentation, better readme. --- INSTALL.md | 19 +++++++++++++++++-- README.md | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 87313eb..d0850c9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,8 +1,14 @@ These installation instructions are not meant for novices. Improvements are welcome. -# Quick and Simple (Demo purposes) Installation +### Quick and Simple (Demo purposes) Installation -If you're looking to demo Avocadojs, your best bet is to throw the public directory somewhere where a webserver can see its contents. For example, on Mac OS X, start up your webserver, and then copy the "public" folder to the "Sites" directory. +If you're looking to demo Avocadojs, your best bet is to go to +avocadojs.com and demo it from there. +Unless you want the most up-to-date version of the code for some +reason, or you're playing with Avocadojs and you want to quickly demo +what you've done. In which case, throw the public directory somewhere +where a webserver can see its contents. For example, on Mac OS X, +start up your webserver, and then copy the "public" folder to the "Sites" directory. Remember, for the newer versions of OS X you'll have to start apache from the commandline, like so: @@ -25,3 +31,12 @@ possibly writing something like this in there: > Allow from 127.0.0.1 > +### More complicated, development installation + +I run Apache with WebDav, and serve the public +directory through there. + +Don't do this alone, unless you're fairly confident you know what +you're doing. Enabling WebDav while Apache is running, without knowing +how to properly secure things, is probably a bad idea. + diff --git a/README.md b/README.md index b763720..7be22c1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ A fork of [Adam](https://github.com/AdamSpitz)'s [Avocadojs](https://github.com/AdamSpitz/Avocado). -Why? Because forks are easier than direct contributions. +Why? Because [forks are easier than direct contributions](http://www.youtube.com/watch?feature=player_detailpage&v=0SARbwvhupQ#t=1697s). This project doesn't (yet) have any documentation - contributions are welcome. From 5308ffd58a9b174d1f589d7d69ea1b2739501a61 Mon Sep 17 00:00:00 2001 From: aausch Date: Tue, 2 Jul 2013 19:42:04 -0400 Subject: [PATCH 04/13] Slightly better localhost check in WebDAV hack. --- public/javascripts/bootstrap.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public/javascripts/bootstrap.js b/public/javascripts/bootstrap.js index 62a45df..40f7bbb 100644 --- a/public/javascripts/bootstrap.js +++ b/public/javascripts/bootstrap.js @@ -1215,10 +1215,7 @@ thisModule.addSlots(avocado.transporter, function(add) { var repoURL = baseURL + "javascripts/"; // aaa - hack because I want saving to keep working on my local machine - if (repoURL.indexOf("http://localhost") === 0) { avocado.kernelModuleSupportsWebDAV = true; } - - // aaa - hack because I haven't managed to get WebDAV working on the real server yet - if (repoURL.indexOf("coolfridgesoftware.com") >= 0) { window.kernelModuleSavingScriptURL = "http://coolfridgesoftware.com/cgi-bin/savefile.cgi"; } + if (repoURL.indexOf("http://localhost") === 0 || repoURL.indexOf("http://127.0.0.1") === 0) { avocado.kernelModuleSupportsWebDAV = true; } var kernelRepo; if (window.kernelModuleSavingScriptURL) { From d1f2c6e6d38987f799b49ab5dde69697230d0cc9 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 2 Jul 2013 19:45:34 -0400 Subject: [PATCH 05/13] Update INSTALL.md added crs --- INSTALL.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index d0850c9..a37f386 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -12,9 +12,9 @@ start up your webserver, and then copy the "public" folder to the "Sites" direct Remember, for the newer versions of OS X you'll have to start apache from the commandline, like so: ->sudo apachectl start ->sudo apachectl stop ->sudo apachectl restart +>sudo apachectl start +>sudo apachectl stop +>sudo apachectl restart and you might have to do things like play with your user config file, ie: @@ -22,14 +22,14 @@ and you might have to do things like play with your user config file, ie: possibly writing something like this in there: -> -> Options Indexes Multiviews -> Options FollowSymLinks -> AllowOverride AuthConfig Limit -> Order deny,allow -> Deny from all -> Allow from 127.0.0.1 -> +> +> Options Indexes Multiviews +> Options FollowSymLinks +> AllowOverride AuthConfig Limit +> Order deny,allow +> Deny from all +> Allow from 127.0.0.1 +> ### More complicated, development installation From 66f577306d78efe6340e0ec7ffa3ef1fd3ed4a57 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 2 Jul 2013 19:46:18 -0400 Subject: [PATCH 06/13] Update INSTALL.md corrected formatting --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a37f386..d0f7923 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -22,14 +22,14 @@ and you might have to do things like play with your user config file, ie: possibly writing something like this in there: -> +> \ > Options Indexes Multiviews > Options FollowSymLinks > AllowOverride AuthConfig Limit > Order deny,allow > Deny from all > Allow from 127.0.0.1 -> +> \ ### More complicated, development installation From c95e7e79255a41c33f8fdd831f28e31c8baea436 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 17 Sep 2013 16:58:31 -0400 Subject: [PATCH 07/13] Bug fix. --- public/javascripts/lk/Base.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/javascripts/lk/Base.js b/public/javascripts/lk/Base.js index 5964d25..66513d4 100644 --- a/public/javascripts/lk/Base.js +++ b/public/javascripts/lk/Base.js @@ -64,6 +64,7 @@ Object.defineProperties(Object, { keys: { value: function(object, optFast) { if (typeof object !== 'object') throw new TypeError('not an object'); + if (typeof object !== 'object' && typeof object !== 'function') throw new TypeError('not an object'); var names = []; // check behavior wrt arrays for (var name in object) { if (object.hasOwnProperty(name)) From bc76b412830c8dee017f8c4524115ae1e9e0b421 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 17 Sep 2013 16:59:24 -0400 Subject: [PATCH 08/13] Optimization. http://jsperf.com/hasownproperty-performance-analysis/2 --- .../core/collections/hash_table.js | 16 ++++---- public/javascripts/core/deep_copy.js | 38 ++++++++++--------- public/javascripts/lk/Base.js | 14 ++++--- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/public/javascripts/core/collections/hash_table.js b/public/javascripts/core/collections/hash_table.js index 13456d0..02bef4c 100644 --- a/public/javascripts/core/collections/hash_table.js +++ b/public/javascripts/core/collections/hash_table.js @@ -167,14 +167,14 @@ thisModule.addSlots(avocado.hashTable, function(add) { }, {category: ['accessing']}); add.method('_each', function (iterator) { - for (var h in this._buckets) { - if (this._buckets.hasOwnProperty(h)) { - var b = this._buckets[h]; - if (b instanceof Array) { - for (var i = 0, n = b.length; i < n; ++i) { - var entry = b[i]; - iterator(entry); - } + var keys = Object.keys(this._buckets); + var length = keys.length; + for (var i = 0; i < length; i++) { + var b = this._buckets[keys[i]]; + if(b && b instanceof Array) { + for (var j = 0, n = b.length; j < n; ++j) { + var entry = b[j]; + iterator(entry); } } } diff --git a/public/javascripts/core/deep_copy.js b/public/javascripts/core/deep_copy.js index d4a31cb..3086cfa 100644 --- a/public/javascripts/core/deep_copy.js +++ b/public/javascripts/core/deep_copy.js @@ -42,20 +42,21 @@ thisModule.addSlots(avocado.deepCopier, function(add) { var isArray = isObj && (o instanceof Array); c = isObj ? (isArray ? [] : Object.create(o['__proto__'])) : eval("(" + o.toString() + ")"); var thisCopier = this; - for (var n in o) { - if (o.hasOwnProperty(n)) { - var contents = o[n]; - if (n === '__annotation__') { - c[n] = contents.copy(); + var keys = Object.keys(o); + var length = keys.length; + for (var j = 0; j < length; ++j){ + var n = keys[j]; + var contents = o[n]; + if (n === '__annotation__') { + c[n] = contents.copy(); + } else if (contents) { + var contentsType = typeof(contents); + var contentsCreatorSlot = (contentsType === 'object' || contentsType === 'function') && avocado.annotator.theCreatorSlotOf(contents); + if (contentsCreatorSlot && contentsCreatorSlot.name === n && contentsCreatorSlot.holder === o) { + c[n] = thisCopier.createCopyOf(contents); + avocado.annotator.annotationOf(c[n]).setCreatorSlot(n, c); } else { - var contentsType = typeof(contents); - var contentsCreatorSlot = (contentsType === 'object' || contentsType === 'function') && avocado.annotator.theCreatorSlotOf(contents); - if (contentsCreatorSlot && contentsCreatorSlot.name === n && contentsCreatorSlot.holder === o) { - c[n] = thisCopier.createCopyOf(contents); - avocado.annotator.annotationOf(c[n]).setCreatorSlot(n, c); - } else { - c[n] = contents; - } + c[n] = contents; } } } @@ -87,12 +88,15 @@ thisModule.addSlots(avocado.deepCopier, function(add) { var thisCopier = this; var originalsAndCopies = this._originalsAndCopies; var originalsAndCopiesCount = originalsAndCopies.length; - for (var n in c) { - if (c.hasOwnProperty(n)) { + var keys = Object.keys(c); + var length = keys.length; + for (var j = 0; j < length; ++j){ + var n = keys[j]; + var contents = c[n]; + if (contents) { if (n === '__annotation__') { // just ignore it, no refs to fix up, I think - oh, actually, could do the creator slot, but we've already done it up above - } else { - var contents = c[n]; + } else { var contentsType = typeof(contents); if (contentsType === 'object' || contentsType === 'function') { var wasInternalRef = false; diff --git a/public/javascripts/lk/Base.js b/public/javascripts/lk/Base.js index 66513d4..5a0df47 100644 --- a/public/javascripts/lk/Base.js +++ b/public/javascripts/lk/Base.js @@ -47,7 +47,8 @@ Object.defineProperties = function(object, descriptorSet) { } return object; } - + +var old_keys = Object.keys; Object.defineProperties(Object, { // I like mine better. -- Adam /* @@ -62,12 +63,15 @@ Object.defineProperties(Object, { */ keys: { - value: function(object, optFast) { - if (typeof object !== 'object') throw new TypeError('not an object'); + value: function(object, optFast) { + if (typeof object !== 'object' && typeof object !== 'function') throw new TypeError('not an object'); var names = []; // check behavior wrt arrays - for (var name in object) { - if (object.hasOwnProperty(name)) + var keys = old_keys(object); + var length = keys.length; + for (var i = 0; i < length; ++i) { + var name = keys[i]; + if (object[name]) names.push(name); } if (!optFast) names.sort(); From 711a72b1bc06c46c0c33e556333be6fdf2a26390 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 17 Sep 2013 18:14:27 -0400 Subject: [PATCH 09/13] pushing the previous optimizations a bit further --- public/javascripts/core/collections/hash_table.js | 2 +- public/javascripts/core/deep_copy.js | 4 ++-- public/javascripts/lk/Base.js | 13 ++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/public/javascripts/core/collections/hash_table.js b/public/javascripts/core/collections/hash_table.js index 02bef4c..6c9b134 100644 --- a/public/javascripts/core/collections/hash_table.js +++ b/public/javascripts/core/collections/hash_table.js @@ -167,7 +167,7 @@ thisModule.addSlots(avocado.hashTable, function(add) { }, {category: ['accessing']}); add.method('_each', function (iterator) { - var keys = Object.keys(this._buckets); + var keys = Object.native_keys(this._buckets); var length = keys.length; for (var i = 0; i < length; i++) { var b = this._buckets[keys[i]]; diff --git a/public/javascripts/core/deep_copy.js b/public/javascripts/core/deep_copy.js index 3086cfa..9e77e01 100644 --- a/public/javascripts/core/deep_copy.js +++ b/public/javascripts/core/deep_copy.js @@ -42,7 +42,7 @@ thisModule.addSlots(avocado.deepCopier, function(add) { var isArray = isObj && (o instanceof Array); c = isObj ? (isArray ? [] : Object.create(o['__proto__'])) : eval("(" + o.toString() + ")"); var thisCopier = this; - var keys = Object.keys(o); + var keys = Object.native_keys(o); var length = keys.length; for (var j = 0; j < length; ++j){ var n = keys[j]; @@ -88,7 +88,7 @@ thisModule.addSlots(avocado.deepCopier, function(add) { var thisCopier = this; var originalsAndCopies = this._originalsAndCopies; var originalsAndCopiesCount = originalsAndCopies.length; - var keys = Object.keys(c); + var keys = Object.native_keys(c); var length = keys.length; for (var j = 0; j < length; ++j){ var n = keys[j]; diff --git a/public/javascripts/lk/Base.js b/public/javascripts/lk/Base.js index 5a0df47..d2c0199 100644 --- a/public/javascripts/lk/Base.js +++ b/public/javascripts/lk/Base.js @@ -48,7 +48,7 @@ Object.defineProperties = function(object, descriptorSet) { return object; } -var old_keys = Object.keys; +Object.native_keys = Object.keys; Object.defineProperties(Object, { // I like mine better. -- Adam /* @@ -64,15 +64,14 @@ Object.defineProperties(Object, { keys: { value: function(object, optFast) { - - if (typeof object !== 'object' && typeof object !== 'function') throw new TypeError('not an object'); - var names = []; // check behavior wrt arrays - var keys = old_keys(object); + if (typeof object !== 'object' && typeof object !== 'function') throw new TypeError('not an object'); + var names = []; // check behavior wrt arrays + var keys = Object.native_keys(object); var length = keys.length; for (var i = 0; i < length; ++i) { var name = keys[i]; - if (object[name]) - names.push(name); + if (object[name]) + names.push(name); } if (!optFast) names.sort(); return names; From 13c663bc236ca95003c5b3be5b4f86031aa5bcc1 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 22 Oct 2013 17:05:52 -0700 Subject: [PATCH 10/13] test --- test | 1 + 1 file changed, 1 insertion(+) create mode 100644 test diff --git a/test b/test new file mode 100644 index 0000000..30d74d2 --- /dev/null +++ b/test @@ -0,0 +1 @@ +test \ No newline at end of file From 418ad6a8a74196c245beec0e59fb9adc9079cad1 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 22 Oct 2013 17:53:16 -0700 Subject: [PATCH 11/13] test From 7c6a9a47e1ef3f673e7e0a426d7909a23197e1f3 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Tue, 22 Oct 2013 21:00:50 -0400 Subject: [PATCH 12/13] removed dependency on prototype.js toJSON implementation --- public/javascripts/bootstrap_lk.js | 1 - public/javascripts/lk/JSON.js | 310 ---------------------- public/javascripts/prototype/prototype.js | 63 +---- 3 files changed, 1 insertion(+), 373 deletions(-) delete mode 100644 public/javascripts/lk/JSON.js diff --git a/public/javascripts/bootstrap_lk.js b/public/javascripts/bootstrap_lk.js index db5d99d..5afdd7c 100644 --- a/public/javascripts/bootstrap_lk.js +++ b/public/javascripts/bootstrap_lk.js @@ -98,7 +98,6 @@ thisModule.addSlots(avocado.transporter.livelyKernelInitializer, function(add) { // Loading LK modules dynamically, in the same order that they are loaded in the xhtml file. avocado.transporter.loadExternal( ["prototype/prototype", - "lk/JSON", "lk/defaultconfig", "local-LK-config", "lk/Base", diff --git a/public/javascripts/lk/JSON.js b/public/javascripts/lk/JSON.js deleted file mode 100644 index 08dab4b..0000000 --- a/public/javascripts/lk/JSON.js +++ /dev/null @@ -1,310 +0,0 @@ -/* - JSON.js - 2007-10-02 - - Based on Doug Crockford's Public Domain - json.js - 2007-09-27 - -............................................................................... - -This file adds these methods to JavaScript: - - JSON.serialize(value, optFilter) - - JSON.serialize(value) does much the same job that - value.toJSONString() is supposed to do in the original - json.js library on normal JSON objects. However, they - provide different hooks for having their behavior extended. - - For json.js, other objects can provide their own - implementation of toJSONString(), in which case JSON - serialization relies on these objects to return a correct - JSON string. But if one object instead returns an - unbalanced part of a JSON string and another object - returns a compensating unbalanced string, then an outer - toJSONString() can produce quoting confusions that invite - XSS-like attacks. The primary purpose of JSON.js is - to prevent such attacks. - - The design of JSON.js borrows ideas from Java's object - serialization streams. - - JSON.unserialize(string, optFilter) - - JSON.unserialize(string, optFilter) acts like json.js's - string.parseJSON(optFilter). This version also fixes a bug - in the original: json.js specifies "If [the optional filter] - returns undefined then the member is deleted." However, - the implemenation in json.js instead defines the property to - have the value undefined. JSON.unserialize() does indeed - delete the property in this case. - - Bug: If the JSON expression to be unserialized contains - the key "__proto__", this will be silently ignored on - Firefox independent of the behavior of optFilter. json.js - exhibits the same bug on Firefox. Whether this is a bug in - these JSON libraries, in the Javascript spec, or in the - Firefox implementation of Javascript is open to debate. In - any case, this problem is unlikely to be fixed. - - JSON.defaultFilter(baseObj, key) - - A filter is a function that takes a baseObj and a key for - indexing into that baseObj -- the name of one of its - properties. A filter can: - * return baseObj[key], in which case serialization - or unserialization proceeds normally. - * return undefined, suppressing the apparent existence - of this property on this baseObj. - * return something else, in which case it will be used - instead of baseObj[key]. - * throw, terminating serialization or unserialization. - - If a filter is provided to serialize(), it is applied in - top-down order, so traversal proceeds only into the - results of filtering. If a filter is provided to - unserialize(), it is applied in bottom-up order, so that - reconstructed parts are available for building - reconstructed wholes. - - If no optFilter argument is provided to serialize(), - this defaultFilter is used. It is part of the API so that - other filters can be built by composing with it. - This default filter will return undefined unless key is a - string and an own-property of baseObj, or if key is a - number and baseObj is an array. If baseObj[key] - implements toJSON(), the default filter will return - baseObj[key].toJSON(), enabling individual objects (such - as dates) to offer replacements for themselves. Otherwise, - it returns baseObj[key]. - - If no optFilter argument is provided to unserialize(), - then the result is just the literal tree of JSON objects. - - Date.toJSON() - - Returns an ISO string encoding the date. When serializing - with the default filter, this brings about the same effect - as json.js's Date.toJSONString(). - -Use your own copy. It is extremely unwise to load untrusted third -party code into your pages. -*/ - - -/** - * Like the date.toJSONString() method defined in json.js, except - * without the surrounding quotes. This should be identical to - * Date.prototype.toISOString when that is defined, as it is in caja.js - */ -Date.prototype.toJSON = function () { - function f(n) { - return n < 10 ? '0' + n : n; - } - return (this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'); -}; - - -CustomJSON = (function () { - - function defaultFilter(baseObj, key) { - var result; - - if (typeof key === 'string') { - if (!Object.prototype.hasOwnProperty.call(baseObj, key)) { - return undefined; - } - } else if (typeof key === 'number') { - if (!(baseObj instanceof Array)) { - return undefined; - } - } else { - return undefined; - } - result = baseObj[key]; - if (result && typeof result.toJSON === 'function') { - return result.toJSON(); - } else { - return result; - } - } - - /** m is a table of character substitutions. */ - var m = { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }; - - return { - defaultFilter: defaultFilter, - - serialize: function(value, optFilter) { - var out = []; // array holding partial texts - // var stack = []; // for diagnosing cycles - var filter = optFilter || defaultFilter; - - /** - * The internal recursive serialization function. - */ - function serialize(value) { - var i,j; // loop counters - var len; // array lengths; - var needComma = false; - var k,v; // property key and value - - // stack.push(value); - - switch (typeof value) { - case 'object': - if (value === null) { - out.push('null'); - - } else if (value instanceof Array) { - len = value.length; - out.push('['); - for (i = 0; i < len; i += 1) { - v = filter(value, i); - if (v !== undefined) { - if (needComma) { - out.push(','); - } else { - needComma = true; - } - serialize(v); - } - } - out.push(']'); - - } else { - out.push('{'); - for (k in value) { - v = filter(value, k); - if (v !== undefined) { - if (needComma) { - out.push(','); - } else { - needComma = true; - } - serialize(k); - out.push(':'); - serialize(v); - } - } - out.push('}'); - } - break; - - case 'string': - // If the string contains no control characters, no quote - // characters, and no backslash characters, then we can - // simply slap some quotes around it. Otherwise we must - // also replace the offending characters with safe - // sequences. - if ((/["\\\x00-\x1f]/).test(value)) { //"])){ - out.push('"' + - value.replace((/[\x00-\x1f\\"]/g), //"]), - function (a) { - var c = m[a]; - if (c) { - return c; - } - c = a.charCodeAt(); - return '\\u00' + Math.floor(c / 16).toString(16) + - (c % 16).toString(16); - }) + '"'); - } else { - out.push('"' + value + '"'); - } - break; - - case 'number': - // JSON numbers must be finite. Encode non-finite numbers - // as null. - out.push(isFinite(value) ? String(value) : 'null'); - break; - - case 'boolean': - out.push(String(value)); - break; - - default: - out.push('null'); - } - // stack.pop(); - } - - var fakeRoot = [value]; - serialize(filter(fakeRoot, 0)); - return out.join(''); - }, - - unserialize: function(str, optFilter) { - - var result; - - function walk(value) { - var i,len,k,v; - - if (value && typeof value === 'object') { - if (value instanceof Array) { - len = value.length; - for (i = 0; i < len; i += 1) { - walk(value[i]); - v = optFilter(value, i); - if (v === undefined) { - delete value[i]; - } else { - value[i] = v; - } - } - } else { - for (k in value) { - walk(value[k]); - v = optFilter(value, k); - if (v === undefined) { - delete value[k]; - } else { - value[k] = v; - } - } - } - } - - } - - if ((/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/). - test(str. - replace((/\\./g), '@'). - replace((/"[^"\\\n\r]*"/g), ''))) { //"))) { - result = eval('(' + str + ')'); - if (optFilter) { - var fakeRoot = [result]; - walk(fakeRoot); - return fakeRoot[0]; - } else { - return result; - } - } - throw new SyntaxError('parseJSON'); - } - }; -})(); - -// reuse existing JSON implementation -if (window.JSON) { // "window" added by Adam - seems to break otherwise - for (var name in CustomJSON) - JSON[name] = CustomJSON[name]; -} else { - JSON = CustomJSON -} diff --git a/public/javascripts/prototype/prototype.js b/public/javascripts/prototype/prototype.js index 252dc91..8236fe0 100644 --- a/public/javascripts/prototype/prototype.js +++ b/public/javascripts/prototype/prototype.js @@ -170,31 +170,6 @@ var Class = (function() { } } - function toJSON(object) { - var type = typeof object; - switch (type) { - case 'undefined': - case 'function': - case 'unknown': return; - case 'boolean': return object.toString(); - } - - if (object === null) return 'null'; - if (object.toJSON) return object.toJSON(); - if (isElement(object)) return; - - var results = []; - for (var property in object) { - if (property !== '__annotation__') { // added by Adam to prevent infinite recursion - var value = toJSON(object[property]); - if (!isUndefined(value)) - results.push(property.toJSON() + ': ' + value); - } - } - - return '{' + results.join(', ') + '}'; - } - function toQueryString(object) { return $H(object).toQueryString(); } @@ -253,7 +228,6 @@ var Class = (function() { extend(Object, { extend: extend, inspect: inspect, - toJSON: toJSON, toQueryString: toQueryString, toHTML: toHTML, keys: keys, @@ -358,16 +332,6 @@ Object.extend(Function.prototype, (function() { })()); -Date.prototype.toJSON = function() { - return '"' + this.getUTCFullYear() + '-' + - (this.getUTCMonth() + 1).toPaddedString(2) + '-' + - this.getUTCDate().toPaddedString(2) + 'T' + - this.getUTCHours().toPaddedString(2) + ':' + - this.getUTCMinutes().toPaddedString(2) + ':' + - this.getUTCSeconds().toPaddedString(2) + 'Z"'; -}; - - RegExp.prototype.match = RegExp.prototype.test; RegExp.escape = function(str) { @@ -584,10 +548,6 @@ Object.extend(String.prototype, (function() { return "'" + escapedString.replace(/'/g, '\\\'') + "'"; } - function toJSON() { - return this.inspect(true); - } - function unfilterJSON(filter) { return this.replace(filter || Prototype.JSONFilter, '$1'); } @@ -654,7 +614,6 @@ Object.extend(String.prototype, (function() { underscore: underscore, dasherize: dasherize, inspect: inspect, - toJSON: toJSON, unfilterJSON: unfilterJSON, isJSON: isJSON, evalJSON: evalJSON, @@ -1043,15 +1002,6 @@ Array.from = $A; return '[' + this.map(Object.inspect).join(', ') + ']'; } - function toJSON() { - var results = []; - this.each(function(object) { - var value = Object.toJSON(object); - if (!Object.isUndefined(value)) results.push(value); - }); - return '[' + results.join(', ') + ']'; - } - function indexOf(item, i) { i || (i = 0); var length = this.length; @@ -1100,8 +1050,7 @@ Array.from = $A; clone: clone, toArray: clone, size: size, - inspect: inspect, - toJSON: toJSON + inspect: inspect }); var CONCAT_ARGUMENTS_BUGGY = (function() { @@ -1199,10 +1148,6 @@ var Hash = Class.create(Enumerable, (function() { }).join(', ') + '}>'; } - function toJSON() { - return Object.toJSON(this.toObject()); - } - function clone() { return new Hash(this); } @@ -1222,7 +1167,6 @@ var Hash = Class.create(Enumerable, (function() { update: update, toQueryString: toQueryString, inspect: inspect, - toJSON: toJSON, clone: clone }; })()); @@ -1247,10 +1191,6 @@ Object.extend(Number.prototype, (function() { return '0'.times(length - string.length) + string; } - function toJSON() { - return isFinite(this) ? this.toString() : 'null'; - } - function abs() { return Math.abs(this); } @@ -1272,7 +1212,6 @@ Object.extend(Number.prototype, (function() { succ: succ, times: times, toPaddedString: toPaddedString, - toJSON: toJSON, abs: abs, round: round, ceil: ceil, From 2695784b007af8f6e499fdbbfebac6e842003c98 Mon Sep 17 00:00:00 2001 From: Alex Ausch Date: Thu, 24 Oct 2013 18:38:27 -0400 Subject: [PATCH 13/13] fixed annoying ui bug --- public/javascripts/general_ui/wheel_menus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/javascripts/general_ui/wheel_menus.js b/public/javascripts/general_ui/wheel_menus.js index 212b028..3efd0ee 100644 --- a/public/javascripts/general_ui/wheel_menus.js +++ b/public/javascripts/general_ui/wheel_menus.js @@ -514,7 +514,7 @@ thisModule.addSlots(avocado.morphMixins.WorldMorph, function(add) { return commandMorph._cachedArgumentMorphLabels; }, {category: ['commands', 'feedback']}); - add.method('findArgumentMorphsAndShowLabels', function (argMorphLabels, partialCommand) { + add.method('findArgumentMorphsAndShowLabels', function (evt, argMorphLabels, partialCommand) { var context = partialCommand.command().contextOrDefault(); argMorphLabels.each(function(m, i) { var argHolder = partialCommand.argumentHolders()[i]; @@ -531,7 +531,7 @@ thisModule.addSlots(avocado.morphMixins.WorldMorph, function(add) { add.method('showWhatWillHappenIfThisCommandRuns', function (evt, commandMorph) { var pc = commandMorph._model.createPartialCommand(); - this.findArgumentMorphsAndShowLabels(this.argumentMorphLabelsFor(commandMorph), pc); + this.findArgumentMorphsAndShowLabels(evt, this.argumentMorphLabelsFor(commandMorph), pc); var world = avocado.ui.worldFor(evt); world.removeAllPartialCommandMorphs(); world.showPartialCommandMorph(world.morphFor(pc).setFillOpacity(0.5));