summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-06-03 13:56:30 +0200
committerAndreas Gohr <andi@splitbrain.org>2011-06-03 13:56:30 +0200
commitd4be3f966cd03ceb295f319346c185ccf58da10a (patch)
treedb659cbd6e36006df37571cb2dd3e526d6f10f7a /lib
parente91ea5c1942bfc6533e12375b8140ce774c7d8ca (diff)
downloadrpg-d4be3f966cd03ceb295f319346c185ccf58da10a.tar.gz
rpg-d4be3f966cd03ceb295f319346c185ccf58da10a.tar.bz2
Deprecation marker for JavaScript functions
This adds a DEPRECATED() JavaScript function. This function will print a warning to the Browser's debug console if available (Chrome and Firefox with Firebug extension) when ever it is called. The DEPRECATED() function was also added to the $() function which should no longer be used and be replaced with JQuery calls. Other deprecated functions need to be identified and marked.
Diffstat (limited to 'lib')
-rw-r--r--lib/scripts/script.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/scripts/script.js b/lib/scripts/script.js
index a99735c99..20e475190 100644
--- a/lib/scripts/script.js
+++ b/lib/scripts/script.js
@@ -4,6 +4,32 @@ if ('function' === typeof jQuery && 'function' === typeof jQuery.noConflict) {
}
/**
+ * Mark a JavaScript function as deprecated
+ *
+ * This will print a warning to the JavaScript console (if available) in
+ * Firebug and Chrome and a stack trace (if available) to easily locate the
+ * problematic function call.
+ *
+ * @param msg optional message to print
+ */
+function DEPRECATED(msg){
+ if(!console) return;
+ if(!arguments.callee) return;
+
+ var func = arguments.callee.caller.name;
+ var line = 'DEPRECATED function call '+func+'(). '+msg;
+
+ if(console.warn){
+ console.warn(line);
+ }else{
+ console.log(line);
+ }
+
+ if(console.trace) console.trace();
+}
+
+
+/**
* Some of these scripts were taken from wikipedia.org and were modified for DokuWiki
*/
@@ -30,6 +56,8 @@ if (clientPC.indexOf('opera')!=-1) {
* @link http://prototype.conio.net/
*/
function $() {
+ DEPRECATED('Please use the JQuery() function instead.');
+
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {