User:Jeblad/vector.js

/* testpage */ /* (function{   var supported = ("websocket" in window) || ("MozWebSocket" in window);    if (supported) console.log("WebSockets are supported"); });

(function(exports){   exports.util.getCrawlFragment = function  {        var fragment = location.hash;        if (fragment) {            fragment = fragment.replace(/^#!\/?/, );        }        else {            fragment = mw.util.getParamValue('_escaped_fragment_');            if (fragment) {                fragment = fragment.replace(/^\/?/, );            }        }        return fragment;    };    exports.util.setCrawlFragment= function (hash) {        location.hash = '#!/' + hash;    }; })(mediaWiki);

mediaWiki.util.setCrawlFragment('foo'); console.log(mediaWiki.util.getCrawlFragment);

(function( $ ) {   // bla bla assert    if ( 0 && window.console !== undefined && $.isFunction( window.console.assert ) ) {        mw.assert = console.assert;    }    else {        mw.assert = function( bool, msg, obj ) {            if (!bool) {                var args = Array.prototype.slice.call( arguments );                var callerArgs = Array.prototype.slice.call( arguments.callee.caller.arguments );                var callerFunc = arguments.callee.caller.toString;                var callerName = callerFunc.substring(callerFunc.indexOf("function") + 8, callerFunc.indexOf("(")); callerName = callerName.replace(/^\s+/, ''); var i = callerName.length; while (callerName.charAt(--i) === ' '); callerName = callerName.slice(0, i + 1); if (!callerName) callerName = "anoynmous"; console.log(callerName + ' (' + callerArgs.join(', ') + ');'); console.log(callerFunc); var lineNumber = (new Error).lineNumber; console.log('lineNumber ' + lineNumber); for (var x in arguments.callee.caller) { console.log(x); }               console.dir(arguments.callee.caller); console.log(arguments.caller); console.log(arguments.caller.toString); console.log.apply( this, [ (msg === undefined ? 'Assertion failure' : msg), obj ] ); }       }    }    // affirm is opposite of assert })( jQuery );

$(function{   console.log('assert' + (console.assert ? 'found' : 'missing'));    mw.assert(false === true);    console.log('assert2' + (console.assert2 ? 'found' : 'missing')); });