1// if jQuery was loaded, let's make it noConflict here. 2if ('function' === typeof jQuery && 'function' === typeof jQuery.noConflict) { 3 jQuery.noConflict(); 4} 5 6/** 7 * Mark a JavaScript function as deprecated 8 * 9 * This will print a warning to the JavaScript console (if available) in 10 * Firebug and Chrome and a stack trace (if available) to easily locate the 11 * problematic function call. 12 * 13 * @param msg optional message to print 14 */ 15function DEPRECATED(msg){ 16 if(!window.console) return; 17 if(!msg) msg = ''; 18 19 var func; 20 if(arguments.callee) func = arguments.callee.caller.name; 21 if(func) func = ' '+func+'()'; 22 var line = 'DEPRECATED function call'+func+'. '+msg; 23 24 if(console.warn){ 25 console.warn(line); 26 }else{ 27 console.log(line); 28 } 29 30 if(console.trace) console.trace(); 31} 32 33/** 34 * Construct a wrapper function for deprecated function names 35 * 36 * This function returns a wrapper function which just calls DEPRECATED 37 * and the new function. 38 * 39 * @param func The new function 40 * @param context Optional; The context (`this`) of the call 41 */ 42function DEPRECATED_WRAP(func, context) { 43 return function () { 44 DEPRECATED(); 45 return func.apply(context || this, arguments); 46 } 47} 48 49/** 50 * Some of these scripts were taken from wikipedia.org and were modified for DokuWiki 51 */ 52 53/** 54 * Some browser detection 55 */ 56var clientPC = navigator.userAgent.toLowerCase(); // Get client info 57var is_macos = navigator.appVersion.indexOf('Mac') != -1; 58var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1) && 59 (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1)); 60var is_safari = ((clientPC.indexOf('applewebkit')!=-1) && (clientPC.indexOf('spoofer')==-1)); 61var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled )); 62if (clientPC.indexOf('opera')!=-1) { 63 var is_opera = true; 64 var is_opera_preseven = (window.opera && !document.childNodes); 65 var is_opera_seven = (window.opera && document.childNodes); 66} 67 68/** 69 * Handy shortcut to document.getElementById 70 * 71 * This function was taken from the prototype library 72 * 73 * @link http://prototype.conio.net/ 74 */ 75function $() { 76 DEPRECATED('Please use the JQuery() function instead.'); 77 78 var elements = new Array(); 79 80 for (var i = 0; i < arguments.length; i++) { 81 var element = arguments[i]; 82 if (typeof element == 'string') 83 element = document.getElementById(element); 84 85 if (arguments.length == 1) 86 return element; 87 88 elements.push(element); 89 } 90 91 return elements; 92} 93 94/** 95 * Simple function to check if a global var is defined 96 * 97 * @author Kae Verens 98 * @link http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-2835 99 */ 100function isset(varname){ 101 return(typeof(window[varname])!='undefined'); 102} 103 104/** 105 * Get the computed style of a node. 106 * 107 * @link https://acidmartin.wordpress.com/2008/08/26/style-get-any-css-property-value-of-an-object/ 108 * @link http://svn.dojotoolkit.org/src/dojo/trunk/_base/html.js 109 */ 110function gcs(node){ 111 if(node.currentStyle){ 112 return node.currentStyle; 113 }else{ 114 return node.ownerDocument.defaultView.getComputedStyle(node, null); 115 } 116} 117 118/** 119 * Escape special chars in JavaScript 120 * 121 * @author Andreas Gohr <andi@splitbrain.org> 122 */ 123function jsEscape(text){ 124 var re=new RegExp("\\\\","g"); 125 text=text.replace(re,"\\\\"); 126 re=new RegExp("'","g"); 127 text=text.replace(re,"\\'"); 128 re=new RegExp('"',"g"); 129 text=text.replace(re,'"'); 130 re=new RegExp("\\\\\\\\n","g"); 131 text=text.replace(re,"\\n"); 132 return text; 133} 134 135/** 136 * This function escapes some special chars 137 * @deprecated by above function 138 */ 139function escapeQuotes(text) { 140 var re=new RegExp("'","g"); 141 text=text.replace(re,"\\'"); 142 re=new RegExp('"',"g"); 143 text=text.replace(re,'"'); 144 re=new RegExp("\\n","g"); 145 text=text.replace(re,"\\n"); 146 return text; 147} 148 149/** 150 * Prints a animated gif to show the search is performed 151 * 152 * Because we need to modify the DOM here before the document is loaded 153 * and parsed completely we have to rely on document.write() 154 * 155 * @author Andreas Gohr <andi@splitbrain.org> 156 */ 157function showLoadBar(){ 158 159 document.write('<img src="'+DOKU_BASE+'lib/images/loading.gif" '+ 160 'width="150" height="12" alt="..." />'); 161 162 /* this does not work reliable in IE 163 obj = $(id); 164 165 if(obj){ 166 obj.innerHTML = '<img src="'+DOKU_BASE+'lib/images/loading.gif" '+ 167 'width="150" height="12" alt="..." />'; 168 obj.style.display="block"; 169 } 170 */ 171} 172 173/** 174 * Disables the animated gif to show the search is done 175 * 176 * @author Andreas Gohr <andi@splitbrain.org> 177 */ 178function hideLoadBar(id){ 179 obj = $(id); 180 if(obj) obj.style.display="none"; 181} 182 183/** 184 * Handler to close all open Popups 185 */ 186function closePopups(){ 187 jQuery('div.JSpopup').hide(); 188} 189 190 191