added pageresolver tests for tilde+startpage behaviour
[dokuwiki.git] / lib / scripts / compatibility.js
blob154aeadf7266fe31697c43b759c15c2c53a2a48b
1 /**
2  * Mark a JavaScript function as deprecated
3  *
4  * This will print a warning to the JavaScript console (if available) in
5  * Firebug and Chrome and a stack trace (if available) to easily locate the
6  * problematic function call.
7  *
8  * @param msg optional message to print
9  */
10 function DEPRECATED(msg){
11     if(!window.console) return;
12     if(!msg) msg = '';
14     var func;
15     if(arguments.callee) func = arguments.callee.caller.name;
16     if(func) func = ' '+func+'()';
17     var line = 'DEPRECATED function call'+func+'. '+msg;
19     if(console.warn){
20         console.warn(line);
21     }else{
22         console.log(line);
23     }
25     if(console.trace) console.trace();
28 /**
29  * Construct a wrapper function for deprecated function names
30  *
31  * This function returns a wrapper function which just calls DEPRECATED
32  * and the new function.
33  *
34  * @param func    The new function
35  * @param context Optional; The context (`this`) of the call
36  */
37 function DEPRECATED_WRAP(func, context) {
38     return function () {
39         DEPRECATED();
40         return func.apply(context || this, arguments);
41     };