Jump to content

User:Slakr/pagebar.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// add page bar
function add_pagebar() 
{ 
	var insertpoint = document.getElementById('contentSub');
	box = document.createElement('iframe');
	box.setAttribute('src', 'http://wikitools.annoyed.org/pagebar.php?article=' + mw.config.get('wgPageName'));
	box.setAttribute('width', '100%');
	box.setAttribute('height', 60);
	box.setAttribute('frameborder', 0);
        box.setAttribute('style', 'border-bottom: 1px dotted black; margin:0px; padding:0px;');
	insertpoint.parentNode.insertBefore(box, insertpoint);
}
$(add_pagebar);

function add_user_info() 
{ 
	var insertpoint = document.getElementById('contentSub');
 
	if ( mw.config.get('wgNamespaceNumber') == 3 ) {
 
		newDiv = document.createElement('div');
 
		thisBox = document.createElement('iframe');
		thisBox.setAttribute('src', 'http://wikitools.annoyed.org/le.php?user=' + mw.config.get('wgTitle') + '&quick=1');
		thisBox.setAttribute('width', '100%');
		thisBox.setAttribute('height', 75);
		thisBox.setAttribute('frameborder', 0);
                thisBox.setAttribute('style', 'border-bottom: 1px dotted black; padding:0px; margin:0px;');
 
		exLink = document.createElement('a');
		txtNode = document.createTextNode('toggle');
		uinfoState = 0;
		exLink.appendChild(txtNode);
		exLink.setAttribute('href', 'javascript:void();');
		exLink.addEventListener('click', function() {
			if (!uinfoState)
			{
				thisBox.style.height = '300px';
				uinfoState = 1;
			} else {
				thisBox.style.height = '75px';
				uinfoState = 0;
			}
		}, true);
 
		newDiv.appendChild(exLink);
		newDiv.appendChild(document.createElement('br'));
		newDiv.appendChild(thisBox);
 
		insertpoint.parentNode.insertBefore(newDiv, insertpoint);
 
	}
}
$(add_user_info);
 
// Top submit button
function add_top_submit() 
{ 
	var insertpoint = document.getElementById('wpTextbox1');
 
	if ( mw.config.get('wgNamespaceNumber') == 3 && ( QueryString.equals( 'action', 'edit' ) || QueryString.equals( 'action', 'submit' ) || QueryString.equals('action', 'editredlink') ) ) {
		newDiv = document.createElement('div');
		newDiv.setAttribute('align', 'right');
 
		btn = document.createElement('input');
		btn.setAttribute('name', 'wpSave');
		btn.setAttribute('type', 'submit');
		btn.setAttribute('value', 'Save page');
 
		newDiv.appendChild(btn);
		insertpoint.parentNode.insertBefore(newDiv, insertpoint);
	}
}
$(add_top_submit);