2 * This file is included in tophat_render.php
5 /* getting random error messages with this... -- jordan
6 wait until query code is fixed
7 jQuery(document).ready(function() {
8 // ajax default settings
12 if('parsererror'==e) {
13 alert('Sorry, we ran into a technical problem (parse error). Please try again...');
14 } else if('timeout'==e) {
15 alert('Request timed out. Please try again...');
17 else if ( "status" in x ) {
19 alert('You are offline! Please check your network.');
20 }else if (404 == x.status){
21 alert('Sorry, we ran into a technical problem (404). Please try again...');
22 }else if(500 == x.status){
23 alert('Sorry, we ran into a technical problem (500). Please try again...');
27 alert('Sorry, we ran into a technical problem (unknown error). Please try again...');
34 function get_value(value) {
35 //if(typeof(jQuery(value).attr('value'))!="undefined"){
36 if (/<span value=['"].*['"]>.*<\/span>/i.test(value)) {
37 return jQuery(value).attr('value');
44 From: http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object
45 I want to note that the .clone() method in jQuery only clones DOM elements. In order to clone JavaScript objects, you would do:
48 var newObject = jQuery.extend({}, oldObject);
51 var newObject = jQuery.extend(true, {}, oldObject);
53 More information can be found in the jQuery documentation <http://docs.jquery.com/Utilities/jQuery.extend>
55 function clone_object(obj) {
56 return jQuery.extend(true, {}, obj);
59 /* https://gist.github.com/661855 */
64 jQuery.subscribe = function( types, selector, data, fn) {
65 /* borrowed from jQuery */
66 if ( data == null && fn == null ) {
69 data = selector = undefined;
70 } else if ( fn == null ) {
71 if ( typeof selector === "string" ) {
72 // ( types, selector, fn )
76 // ( types, data, fn )
84 /* We use an indirection function that will clone the object passed in
85 * parameter to the subscribe callback
87 * FIXME currently we only clone query objects which are the only ones
88 * supported and editable, we might have the same issue with results but
89 * the page load time will be severely affected...
91 o.on.apply(o, [types, selector, data, function() {
92 for(i = 1; i < arguments.length; i++) {
93 if ( arguments[i].constructor.name == 'Query' )
94 arguments[i] = arguments[i].clone();
96 fn.apply(o, arguments);
100 jQuery.unsubscribe = function() {
101 o.off.apply(o, arguments);
104 jQuery.publish = function() {
105 o.trigger.apply(o, arguments);
111 function executeFunctionByName(functionName, context /*, args */) {
112 var args = Array.prototype.slice.call(arguments).splice(2);
113 var namespaces = functionName.split(".");
114 var func = namespaces.pop();
115 for(var i = 0; i < namespaces.length; i++) {
116 context = context[namespaces[i]];
118 return context[func].apply(this, args);