1 /* getting random error messages with this... -- jordan
2 wait until query code is fixed
3 jQuery(document).ready(function() {
4 // ajax default settings
9 alert('Sorry, we ran into a technical problem (parse error). Please try again...');
10 } else if('timeout'==e) {
11 alert('Request timed out. Please try again...');
13 else if ( "status" in x ) {
15 alert('You are offline! Please check your network.');
16 }else if (404 == x.status){
17 alert('Sorry, we ran into a technical problem (404). Please try again...');
18 }else if(500 == x.status){
19 alert('Sorry, we ran into a technical problem (500). Please try again...');
23 alert('Sorry, we ran into a technical problem (unknown error). Please try again...');
30 function get_value(value) {
31 //if(typeof(jQuery(value).attr('value'))!="undefined"){
32 if (/<span value=['"].*['"]>.*<\/span>/i.test(value)) {
33 return jQuery(value).attr('value');
40 From: http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object
41 I want to note that the .clone() method in jQuery only clones DOM elements. In order to clone JavaScript objects, you would do:
44 var newObject = jQuery.extend({}, oldObject);
47 var newObject = jQuery.extend(true, {}, oldObject);
49 More information can be found in the jQuery documentation <http://docs.jquery.com/Utilities/jQuery.extend>
51 function clone_object(obj) {
52 return jQuery.extend(true, {}, obj);
55 /* https://gist.github.com/661855 */
60 $.subscribe = function( types, selector, data, fn) {
61 /* borrowed from jQuery */
62 if ( data == null && fn == null ) {
65 data = selector = undefined;
66 } else if ( fn == null ) {
67 if ( typeof selector === "string" ) {
68 // ( types, selector, fn )
72 // ( types, data, fn )
80 /* We use an indirection function that will clone the object passed in
81 * parameter to the subscribe callback
83 * FIXME currently we only clone query objects which are the only ones
84 * supported and editable, we might have the same issue with results but
85 * the page load time will be severely affected...
87 o.on.apply(o, [types, selector, data, function() {
88 for(i = 1; i < arguments.length; i++) {
89 if ( arguments[i].constructor.name == 'Query' )
90 arguments[i] = arguments[i].clone();
92 fn.apply(o, arguments);
96 $.unsubscribe = function() {
97 o.off.apply(o, arguments);
100 $.publish = function() {
101 o.trigger.apply(o, arguments);
107 function executeFunctionByName(functionName, context /*, args */) {
108 var args = Array.prototype.slice.call(arguments).splice(2);
109 var namespaces = functionName.split(".");
110 var func = namespaces.pop();
111 for(var i = 0; i < namespaces.length; i++) {
112 context = context[namespaces[i]];
114 return context[func].apply(this, args);