User:Splarka/newwiki.js

// function showpreload { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; document.getElementById('ca-preload').firstChild.innerHTML = 'preloads';

var wname = document.createwiki.wpCreateWikiName.value; var wtitle = document.createwiki.wpCreateWikiTitle.value; var wdesc = document.createwiki.wpCreateWikiDesc.value; var waddtnl = document.createwiki.wpCreateWikiAddtnl.value; var wdate = ', '; var wfounder = document.createwiki.wpName.value; var wlang = document.createwiki.wpCreateWikiLang.value;

var pre1 = '' + wname +'\n'; pre1 += '' + wname +'\n'; pre1 += '\n'; pre1 += '\n[[Category:_]]\n'; pre1 = encodeURIComponent(pre1);

var pre2 = '#REDIRECT '+ wtitle +''; pre2 = encodeURIComponent(pre2);

var href1 = '/index.php?title=' + wtitle.replace(' ','_') + '&action=edit&preloadtext=' + pre1; var href2 = '/index.php?title=' + wname + '&action=edit&preloadtext=' + pre2; if(!document.getElementById('ca-description')) { addlilink(tabs, href1, 'description page', 'ca-description'); addlilink(tabs, href2, 'redirect', 'ca-redirect'); } else { document.getElementById('ca-description').href = href1; document.getElementById('ca-redirect').href = href2; } }

function preloadbutton { if(document.title.indexOf('Request a new wiki')!=0) return; var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tabs, '#', 'preloads >', 'ca-preload'); document.getElementById('ca-preload').onclick=showpreload; } addOnloadHook(preloadbutton)

function checkpreload { if(queryString('preloadtext')) { if(document.getElementById('wpTextbox1').value.length != 0) { alert('Unable to preload!\nThere are already ' + document.getElementById('wpTextbox1').value.length + ' bytes of text.\nThis is either due to the page already existing,\nor because you are returning to this page in your history.'); } else { document.getElementById('wpTextbox1').value = decodeURIComponent(queryString('preloadtext')); } } } addOnloadHook(checkpreload);

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; };

function addlilink(tabs, url, name, id) { var na = document.createElement('a'); na.href = url; na.id = id; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); tabs.appendChild(li); return li; } //