User:Jeblad/vector.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* testpage */
/*
$(document).ready(function (){
var uri = mw.util.wikiScript( 'index' )
+ '?' + $.param({
title: 'User:Jeblad/worker.js',
action: 'raw',
ctype: 'text/javascript',
smaxage: '21600',
maxage: '86400'
});
var worker = new Worker(uri);
worker.onmessage = function (event){
console.info("World:" + event.data);
};
worker.onerror = function (event){
console.log(event.filename + ' [' + event.lineno + ']: ' + event.message);
};
worker.postMessage("Is there anybody in there" );
});
*/
/*
(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'));
});
*/