1// main proxy function 2// c=cfc id, m=cfc method, a=cfc arguments, scb=onsuccess callback, ecb=onerror callback, to=timeout, tocb=ontimeout callback 3function TS_AJX(c,m,a,scb,ecb,to,tocb) { 4 var url = '/?event=proxy.ts_json&c=' + c + '&m=' + m; 5 6 // intercept functions 7 var ts_scb = function(r) { 8 try { 9 if (typeof(scb)=="function") scb(r); 10 } catch(e) { 11 if (typeof(ecb)=="function") ecb(r,e.message,e.description); 12 } 13 }; 14 var ts_ecb = function(r) { 15 if (typeof(ecb)=="function") ecb(r); 16 }; 17 var ts_tcb = function(r) { 18 if (typeof(tocb)=="function") tocb(r); 19 else if (typeof(ecb)=="function") ecb(r); 20 }; 21 22 var data = TS_AJX_PrepareParams(a); 23 24 $.ajax({ 25 url: url, 26 timeout: to, 27 type: 'POST', 28 dataType: 'json', 29 data: data, 30 complete: function(xhr,s) { 31 try { 32 var r = TS_AJX_KeysToLowerCase(JSON.parse(xhr.responseText)); 33 if(r.success !== undefined) r.success = r.success.toString(); 34 } catch(e) { 35 var r = new Object(); 36 r.success = "false"; 37 r.errmsg = "Some error occured while parsing response."; 38 } 39 40 if (s == 'success') ts_scb(r); 41 else if (s == 'timeout') ts_tcb(r); 42 else ts_ecb(r); 43 } 44 }); 45} 46 47/* JQUERY AJAX SYNC SUPPORT */ 48// c=cfc id, m=cfc method, a=cfc arguments, scb=onsuccess callback, ecb=onerror callback, to=timeout, tocb=ontimeout callback 49function TS_AJX_SYNC(c,m,a,scb,ecb,to,tocb) { 50 var url = '/?event=proxy.ts_json&c=' + c + '&m=' + m; 51 52 // intercept functions 53 var ts_scb = function(r) { 54 try { 55 if (typeof(scb)=="function") scb(r); 56 } catch(e) { 57 if (typeof(ecb)=="function") ecb(r,e.message,e.description); 58 } 59 }; 60 var ts_ecb = function(r) { 61 if (typeof(ecb)=="function") ecb(r); 62 }; 63 var ts_tcb = function(r) { 64 if (typeof(tocb)=="function") tocb(r); 65 else if (typeof(ecb)=="function") ecb(r); 66 }; 67 68 var data = TS_AJX_PrepareParams(a); 69 70 $.ajax({ 71 url: url, 72 async: false, 73 cache: false, 74 timeout: to, 75 type: 'POST', 76 dataType: 'json', 77 data: data, 78 complete: function(xhr,s) { 79 try { 80 var r = TS_AJX_KeysToLowerCase(JSON.parse(xhr.responseText)); 81 if(r.success !== undefined) r.success = r.success.toString(); 82 } catch(e) { 83 var r = new Object(); 84 r.success = "false"; 85 r.errmsg = "Some error occured while parsing response."; 86 } 87 88 if (s == 'success') ts_scb(r); 89 else if (s == 'timeout') ts_tcb(r); 90 else ts_ecb(r); 91 } 92 }); 93} 94 95function TS_AJX_PrepareParams(obj) { 96 for(var i in obj) { 97 if (obj[i] === undefined || obj[i] === null) obj[i] = ''; 98 else if (obj[i] instanceof Array) { 99 obj[i + '~[]~'] = obj[i].join('^~~~^'); 100 delete obj[i]; 101 } 102 } 103 return obj; 104} 105 106function TS_AJX_KeysToLowerCase(obj) { 107 if (obj === null) return null; 108 else if(obj instanceof Array) { 109 for (var i in obj) { 110 obj[i] = TS_AJX_KeysToLowerCase(obj[i]); 111 } 112 } 113 if (!typeof(obj) === "object" || typeof(obj) === "string" || typeof(obj) === "number" || typeof(obj) === "boolean") { 114 return obj; 115 } 116 var keys = Object.keys(obj); 117 var n = keys.length; 118 var lowKey; 119 while (n--) { 120 var key = keys[n]; 121 if (key === (lowKey = key.toLowerCase())) 122 continue; 123 obj[lowKey] = TS_AJX_KeysToLowerCase(obj[key]); 124 delete obj[key]; 125 } 126 return obj; 127}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.