Misplaced Pages

User:Lupin/popups.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Lupin Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 16:04, 2 October 2011 view sourceMSGJ (talk | contribs)Autopatrolled, Administrators130,779 edits use protocol-relative URLs, per request← Previous edit Revision as of 17:28, 9 August 2015 view source Mr. Stradivarius (talk | contribs)Edit filter managers, Administrators59,191 edits add deprecation warning per protected edit request by User:TheDJNext edit →
Line 27: Line 27:
popups_importStylesheetURI(popStyleSheet); popups_importStylesheetURI(popStyleSheet);
popups_importScriptURI(popScript); popups_importScriptURI(popScript);

if ( typeof mw !== 'undefined' ) {
mw.loader.using('jquery.jStorage', function() {
var k = 'User:Lupin/popups.js',
t = 'Information: You are importing User:Lupin/popups.js' +
' into your common.js or <skin>.js!\n' +
'This script is unmaintained. Please remove this inclusion and enable the Navigation popups Gadget in the preferences of your account instead.',
x = $.jStorage.get( k );

if ( !x ) {
$.jStorage.set( k, 1 );
alert( t );
} else {
x++;
$.jStorage.set( k, x );
if ( x % 25 === 0 ) {
mw.notify( t );
}
}
});
}

Revision as of 17:28, 9 August 2015

var popScript     = '//en.wikipedia.org/search/?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-popups.js';
var popStyleSheet = '//en.wikipedia.org/search/?action=raw&ctype=text/css&title=MediaWiki:Gadget-navpop.css';
if ( window.localCSS ) { popStyleSheet = 'http://localhost:8080/js/navpop.css'; }

function popups_importScriptURI(url) {
	var s = document.createElement('script');
	s.setAttribute('src',url);
	s.setAttribute('type','text/javascript');
	document.getElementsByTagName('head').appendChild(s);
	return s;
}

function popups_importStylesheetURI(url) {
	return document.createStyleSheet ? document.createStyleSheet(url) : popups_appendCSS('@import "' + url + '";');
}

function popups_appendCSS(text) {
	var s = document.createElement('style');
	s.type = 'text/css';
	s.rel = 'stylesheet';
	if (s.styleSheet) s.styleSheet.cssText = text //IE
	else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
	document.getElementsByTagName('head').appendChild(s);
	return s;
}

popups_importStylesheetURI(popStyleSheet);
popups_importScriptURI(popScript);

if ( typeof mw !== 'undefined' ) {
mw.loader.using('jquery.jStorage', function() {
	var k = 'User:Lupin/popups.js',
		t = 'Information: You are importing User:Lupin/popups.js' +
			' into your common.js or <skin>.js!\n' +
			'This script is unmaintained. Please remove this inclusion and enable the Navigation popups Gadget in the preferences of your account instead.',
		x = $.jStorage.get( k );

	if ( !x ) {
		$.jStorage.set( k, 1 );
		alert( t );
	} else {
		x++;
		$.jStorage.set( k, x );
		if ( x % 25 === 0 ) {
			mw.notify( t );
		}
	}
});
}