Usuario:Robinsonsmay/monobook.js
Ir a la navegación
Ir a la búsqueda
Nota: Después de publicar, quizás necesite actualizar la caché de su navegador para ver los cambios.
- Firefox/Safari: Mantenga presionada la tecla Shift mientras pulsa el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
- Google Chrome: presione Ctrl+Shift+R (⌘+Shift+R en Mac)
- Internet Explorer/Edge: mantenga presionada Ctrl mientras pulsa Actualizar, o presione Ctrl+F5
- Opera: Presiona Ctrl+F5.
function ajaxPreviewInit(){
if ((wgNamespaceNumber % 2 == 0) && /\.(js|css)$/.test(wgTitle)) return
if (typeof ajaxPreviewKey != 'string') ajaxPreviewKey = 'p'
if (typeof ajaxDiffKey != 'string') ajaxDiffKey = 'v'
ajaxPreviewPos = window.ajaxPreviewPos || 'right'
if (ajaxPreviewPos != 'bottom'){
var tOld = document.getElementById('toolbar') || document.getElementById('wpTextbox1')
tOld.style.clear = 'none'
var d = document.createElement('div'); d.style.cssText = 'width:100%; clear:both'
tOld.parentNode.insertBefore(d, tOld)
var tNew = document.createElement('div'); tNew.style.cssText = 'float:'+ ajaxPreviewPos
tOld.parentNode.insertBefore(tNew, tOld)
}
addBtn(window.ajaxPreviewButton, 'wpPreview', ajaxPreviewKey)
addBtn(window.ajaxDiffButton, 'wpDiff', ajaxDiffKey)
function addBtn(name, id, akey){
var btnOld = document.getElementById(id)
if (!btnOld) return
//var
btn = document.createElement('input'); btn.type = 'button'
btn.onclick = ajaxPreviewClick; btn.id = id + 'Live'
if (!name){ //extract last word from standard buttons
name = btnOld.value.split(' '); name = name[name.length-1]
name = name.substring(0,1).toUpperCase() + name.substring(1)
}
btn.value = name; btn.title = btnOld.value + ' (Ajax)'
if (ajaxPreviewPos == 'bottom'){
btnOld.parentNode.insertBefore(btn, btnOld)
btn.value = btnOld.value
btnOld.value = '>'
}else{
btn.style.cssText = 'height:22px; padding:0 1px'
tNew.appendChild(btn)
}
if (akey){ //reassign acces key
if (btnOld.accessKey == akey){
btnOld.accessKey = ''
//btnOld.setAttribute('accesskey', '')
btnOld.title = btnOld.title.replace(tooltipAccessKeyRegexp, '')
}
//btn.setAttribute('accesskey', akey)
btn.accessKey = akey
btn.title += ' ['+tooltipAccessKeyPrefix+akey+']'
}
btn.value2 = btn.value
}
}
function ajaxPreviewClick(){ajaxPreviewRun(this)}
function ajaxPreviewRun(btn){
var wkPreview = document.getElementById('wikiPreview'), form = document.editform
var aj = sajax_init_object()
if (!wkPreview || !form || !aj) return
var oldHeight = wkPreview.offsetHeight
var el, htm, isDiff = (btn.id=='wpDiffLive')
wkPreview.style.opacity = '0.3'; wkPreview.style.color = 'gray'; document.body.style.cursor = 'wait'
if (el=document.getElementById('wikiDiff')) el.style.display = 'none'
if (el=document.getElementById('newarticletext')) el.style.display = 'none'
btn.style.width = Math.max(btn.scrollWidth, btn.offsetWidth) + 'px'; btn.value = '...'
//prepare
var txt = form.wpTextbox1.value, action = form.action
var boundary = '--------123xyz', data = ''
if (isDiff){
addData('wpDiff', ''); addData('wpStarttime'); addData('wpEdittime')
if (!window.ajaxPreview_CSS) ajaxPreview_CSS = importStylesheetURI('/skins-1.5/common/diff.css')
}else{
action += '&live'
if (form.wpSection && form.wpSection.value) txt += '\n<br /><references />'
}
addData('wpTextbox1', txt); addData('wpSection'); addData('wpSummary')
//send
aj.open('POST', action, true)
aj.setRequestHeader('Content-Type', 'multipart/form-data; boundary='+boundary)
aj.send(data + '--' + boundary)
aj.onreadystatechange = function(){
if (aj.readyState != 4) return
wkPreview.style.display = 'block'
if (isDiff){
var htm = aj.responseText
var p1 = htm.indexOf("<table class='diff'>" )
var p2 = htm.indexOf('</table>', p1)
htm = (p1!=-1 && p2!=-1) ? htm.substring(p1, p2+8) : 'Error'
}else{
htm = aj.responseText.replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"').replace(/&/g,'&').replace(/'/g,"'")
}
wkPreview.innerHTML = htm
btn.value = btn.value2
btn.blur()
if (el = wkPreview.getElementsByTagName('h2')[0]){
if (el.style.textAlign != 'right') el.innerHML += ' (Ajax)'
el.style.textAlign = 'right'
}
if (window.ajaxPreviewScrollTop && wkPreview.scrollIntoView) wkPreview.scrollIntoView()
else document.documentElement.scrollTop += wkPreview.offsetHeight - oldHeight
wkPreview.style.opacity = ''; wkPreview.style.color = ''; document.body.style.cursor = ''
if (!isDiff) ajaxPreviewFinish(wkPreview)
}
function addData(name, value){
if (!value) value = form[name] ? form[name].value : ''
data += '--' + boundary + '\nContent-Disposition: form-data; name="'+name+'"\n\n' + value + '\n'
}
}
function ajaxPreviewFinish(el){
sortables_init()
if (window.createCollapseButtons){//en.wp
createCollapseButtons()
createNavigationBarToggleButton()
}
if (window.ajaxPreviewExec) ajaxPreviewExec(el)
}
if (wgAction=='edit' || wgAction=='submit') addOnloadHook(ajaxPreviewInit)
//Fin de script
//On diff pages this script replaces ''(Difference between revisions)''with
//different tools for reverting the edit and warning the user that made the edit.
//For instructions see talk page.
// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
// Function from http://www.dustindiaz.com/getelementsbyclass/
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
var _temp_get_arr_1 = new Array();
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
_temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
_GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
function getMessage (where, user1, user2) {
var message = prompt ('Comentario:', '');
window.location = 'http://inciclopedia.wikia.com/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
addOnloadHook(function (){
if (location.href.match(/diff=/)) {
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
document.getElementById('contentSub').innerHTML = '[<font color="#008000"><a href="http://inciclopedia.wikia.com/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Revertir</a></font>] [<font color="#808000"><a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Revertir (resumen)</a></font>] [<font color="#FF0000"><a href="http://inciclopedia.wikia.com/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">Revertir (vandalismo)</a></font>]';
} else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = 'Revertidos los cambios de [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] a la última edición de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value = 'Revertidos los cambios de [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] a la última edición de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=1/)) {
document.getElementById('wpSummary').value = 'Revertidos los cambios de [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] identificados como vandalismo';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=2/)) {
document.getElementById('wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=1/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=2/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:blatantvandal}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=3/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test2}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=4/)) {
document.getElementById('wpSummary').value = 'Vandalism warning';
document.getElementById('wpTextbox1').value = '{{sub'+'st:test2a}} ~~'+'~~';
document.getElementById('editform').submit();
}
});