/[drupal]/contributions/modules/semantic_search/js/semantic_search.helpers.js
ViewVC logotype

Contents of /contributions/modules/semantic_search/js/semantic_search.helpers.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jun 5 06:37:06 2007 UTC (2 years, 5 months ago) by hendler
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
File MIME type: text/javascript
adding files from our SVN
1 /**
2 * eval wrapper for data
3 */
4 function decodeReturnArray(data){
5 try{
6 return eval(XPdecode(data));
7 } catch (e){ alert(e + ' \n\n\n' + data); }
8 }
9
10 /**
11 * fixes bug in IE6 and 7 with slow decodeURIComponent on large strings
12 *
13 * @param {Object} data
14 */
15 function XPdecode(data){
16 //broken?
17 return decodeURIComponent(data);
18
19 if ($.browser.msie) {
20 //fixes bug where decoding large strings over ~300k causes LONG delay in IE6
21 return decodeURIComponentJS(data);
22 }
23 else{
24 return decodeURIComponent(data);
25 }
26 }
27
28 /**
29 * decodes a string encoded in the semantic_search_rpc module
30 *
31 */
32 function decodeSEMANTIC_SEARCHHtml(string)
33 {
34 try{
35 return _semantic_search_stripslashes(XPdecode(string));
36 } catch (e){ alert(e + ' \n in decodeSEMANTIC_SEARCHHtml() \n\n' );
37 $('#header').append('<div>'+string+'</div>');
38 }
39 }
40
41 /**
42 * function to replace IE
43 *
44 * @param {Object} str
45 */
46 function decodeURIComponentJS(str){
47 var elm=/(%F[0-9A-F]%E[0-9A-F]%[A-B][0-9A-F]%[8-9A-B][0-9A-F])|(%E[0-9A-F]%[A-B][0-9A-F]%[8-9A-B][0-9A-F])|(%[C-D][0-9A-F]%[8-9A-B][0-9A-F])|(%[0-9A-F]{2})/g;
48 try{
49 return str.toString().replace(elm,decodeURIComponent);
50 } catch (e){
51 alert(e + 'decodeURIComponentJS() error');
52 }
53 }
54
55
56 /**
57 * from http://javascript.about.com/library/bladdslash.htm
58 *
59 */
60 function _semantic_search_stripslashes(str) {
61 str=str.replace(/\\'/g,'\'');
62 str=str.replace(/\\"/g,'"');
63 str=str.replace(/\\\\/g,'\\');
64 str=str.replace(/\\0/g,'\0');
65 return str;
66 }
67
68
69
70 ///////////////////////////////////////////////////////////////////////////////
71 /// testing functions
72 var starttime;
73
74
75
76
77 function nStart(){
78 starttime = getMicrotime();
79 }
80
81 /* only tests/assumes firefox and IE at the moment - windows? */
82 function nEnd(){
83 try{
84 var stime = starttime;
85 var endtime = getMicrotime();
86 var browser_type = '';
87 var plat = navigator.platform;
88
89 if ($.browser.msie ){
90 browser_type = ' IE ';
91 } else {
92 browser_type = ' FF ';
93 }
94
95 var result_text = '<tr><td>' +(endtime - stime) + '</td><td> ' + browser_type+ '</td><td> ' + plat + '</td><td> '+ rpc_uri + ' </td></tr>';
96
97 try{
98 if ($(".jsBench").size()>0){
99 $(".jsBench").html(result_text);
100 }
101 else{
102 $('body').prepend('<table class="jsBench"> '+result_text +'</table>');
103 }
104 } catch(e){
105 alert(e.message + '\n benchmark rendering issue');
106 }
107 }
108 catch(e){ alert(e.message + ' \n nEnd benchmark error');}
109 }
110
111 function getMicrotime(){
112 var tStamp = new Date();
113 return tStamp.getTime();
114 }

  ViewVC Help
Powered by ViewVC 1.1.2