User:SWFlash/monobook.js: Difference between revisions

From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump to search
No edit summary
No edit summary
 
(123 intermediate revisions by one other user not shown)
Line 1: Line 1:
// <nowiki>
function show(){
function show(){
shoe=['welcome','niwa','shroom','maintain','footer','p-Browse','p-community']
shoe=['welcome','niwa','shroom','maintain','footer','p-Browse','p-community']
for(i=0;i<shoe.length;i++){$(shoe[i]).style.display='table'}
for(i=0;i<shoe.length;i++){$(shoe[i]).style.display='table'}
$('announce').innerHTML=backup_announce
$('announce').style.padding='0px 2px'
$('ca-watch').parentNode.removeChild($('ca-watch'))}
$('ca-watch').parentNode.removeChild($('ca-watch'))}


function is_gif_image(i){return /^(?!data:).*\.gif/i.test(i.src)}
function is_gif_image(i){return /^(?!data:).*\.gif/i.test(i.src)}
function prefrz(i){
if($('file')){
if($('file').getElementsByTagName('img')[0]!=i){
freeze_gif(i)
}}else{
freeze_gif(i)
}}
function freeze_gif(i){
function freeze_gif(i){
c=document.createElement('canvas')
c=document.createElement('canvas')
Line 13: Line 20:
c.getContext('2d').drawImage(i,0,0,w,h)
c.getContext('2d').drawImage(i,0,0,w,h)
i.alt=i.src
i.alt=i.src
try{
i.src=c.toDataURL('image/gif')
i.src=c.toDataURL('image/gif')
i.setAttribute('onmouseover','gifanim_tmp=this.src;this.src=this.alt')
i.setAttribute('onmouseover','this.src=this.alt')
i.setAttribute('onmouseout','this.alt=this.src;this.src=gifanim_tmp')
i.setAttribute('onmouseout','freeze_gif(this)')
}catch(e){
for(var j=0,a;a=i.attributes[j];j++){
c.setAttribute(a.name,a.value)
}
c.setAttribute('onmouseover','unfree(this)')
i.parentNode.replaceChild(c,i)
}}
function unfree(x){
z=document.createElement('img')
z.width=x.width
z.height=x.height
for(var j=0,a;a=x.attributes[j];j++){
z.setAttribute(a.name,a.value)
}
z.setAttribute('onmouseover','')
z.scr=x.alt
x.parentNode.replaceChild(z,x)
}
}


Line 46: Line 71:


function imgfi(){
function imgfi(){
$('wpTextbox1').value=$('wpTextbox1').value.replace(/(?! )Image:/g,'File:')
wtx=$('wpTextbox1').value
$('wpTextbox1').value=$('wpTextbox1').value.replace(/  /g,' ')
 
wtx=wtx.replace(/(?! )Image:/ig,'File:')
wtx=wtx.replace(/      /g,' ')
wtx=wtx.replace(/      /g,' ')
wtx=wtx.replace(/    /g,' ')
wtx=wtx.replace(/    /g,' ')
wtx=wtx.replace(/  /g,' ')
wtx=wtx.replace(/  /g,' ')
wtx=wtx.replace(/&ndash;/g,'-')
wtx=wtx.replace(/&mdash;/g,'—')
wtx=wtx.replace(/<br \/>/g,'<br>')
wtx=wtx.replace(/<br clear="?all"?\s?\/?>/g,'{{br}}')
wtx=wtx.replace(/<br clear="?left"?\s?\/?>/g,'{{br|left}}')
wtx=wtx.replace(/<br clear="?right"?\s?\/?>/g,'{{br|right}}')
wtx=wtx.replace(/<nowiki>\'<\/nowiki>/g,'{{\'}}')
 
$('wpTextbox1').value=wtx
}
}


onload=function(){
/////////////////////////////////////////////////////////////
onload=function(){///////////////////////////////////////////
/////////////////////////////////////////////////////////////


mas=document.getElementsByTagName('a')
lgout=$('pt-logout').getElementsByTagName('a')[0]
for(i=0;i<mas.length;i++){
olgout=lgout.href
if(mas[i].href.indexOf('?')==-1){
lgout.href='javascript:if(confirm("Are you sure?")){location=olgout}'
mas[i].href+='?action=purge'
 
}else{
$('searchInput').setAttribute('class','searchInput')
if(mas[i].href.indexOf('action=')==-1){
$('searchBody').appendChild(ein=document.createElement('form'))
mas[i].href+='&action=purge'
ein.action='http://www.mariowiki.com/'
}}}
ein.innerHTML='<input type=hidden name=action value=edit><input type=text name=title class=searchInput id=searchInput2>'


if(unserc('action')=='edit'||unserc('action')=='submit'){
if(unserc('action')=='edit'||unserc('action')=='submit'){
Line 66: Line 109:
wf.value='Image to file'
wf.value='Image to file'
wf.setAttribute('onclick','imgfi()')
wf.setAttribute('onclick','imgfi()')
}
if(!$('filetoc')){
[].slice.apply(document.images).filter(is_gif_image).map(freeze_gif)
}
}


Line 78: Line 117:
}
}


document.title=document.title.replace(' — Super Mario Wiki','')
document.title=document.title.replace(/ — Super Mario Wiki$/,'')


editab=$('ca-edit')
editab=$('ca-edit')
Line 96: Line 135:
}}}}}}
}}}}}}


$('pt-mytalk').innerHTML+='<li class=spe><a href=/User:SWFlash/Sig?action=edit title="Ваша подпись">Подпись</a></li>'
$('pt-mytalk').innerHTML+='<li class=spe><a href=/User:SWFlash/Sig title="To-Do list">To-Do</a></li>'
$('pt-preferences').innerHTML+='<li class=spe><a href=/User:SWFlash/monobook.js?action=edit title=JavaScript>JS</a><li class=spe><a href=/User:SWFlash/monobook.css?action=edit title="Cascading Style Sheet">CSS</a></li></li>'
$('pt-preferences').innerHTML+='<li class=spe><a href=/User:SWFlash/monobook.js?action=edit title=JavaScript>JS</a><li class=spe><a href=/User:SWFlash/monobook.css?action=edit title="Cascading Style Sheet">CSS</a></li></li>'


Line 115: Line 154:
$('mw-searchButton').setAttribute('accesskey','f')
$('mw-searchButton').setAttribute('accesskey','f')


if(wgTitle=='Main Page'){
if(wgTitle=='Main Page'&&wgIsArticle){
$('ca-nstab-main').getElementsByTagName('a')[0].innerHTML='Заглавная'
$('ca-nstab-main').getElementsByTagName('a')[0].innerHTML='Заглавная'
}
}


if(wgPageName=='Main_Page'){
if(wgPageName=='Main_Page'&&wgIsArticle){
 
announce=$('announce')
if(announce){
backup_announce=announce.innerHTML
announce.innerHTML='<tr><td><span style=font-size:18pt>Super Mario Wiki</span><br><br>Ссылки: <a href=/Special:WebChat>Чат</a>, <a href=/Special:Watchlist>Список наблюдения</a>, <a href=/MarioWiki:Proposals#Talk_Page_Proposals>Предложения</a>, <a href=/User:SWFlash/monobook.js?action=edit>JS</a>, <a href=/User:SWFlash/monobook.css?action=edit>CSS</a>.</td></tr>'
announce.style.padding='15px'
}
 
proposal=document.getElementsByClassName('MainPageProposalBox')[0]
if(proposal){
proposal.innerHTML='<div style=float:right;font-size:8pt>[<a href=/index.php?title=Template:Proposal&action=edit>править</a>]</div>'+proposal.innerHTML
}


pds=document.getElementsByClassName('pds-links')[0]
pds=document.getElementsByClassName('pds-links')[0]
Line 143: Line 170:


$('searchInput').focus()
$('searchInput').focus()
}}
}
 
[].slice.apply(document.images).filter(is_gif_image).map(prefrz)
}
 
// </nowiki>

Latest revision as of 11:40, February 12, 2020

// <nowiki>

function show(){
shoe=['welcome','niwa','shroom','maintain','footer','p-Browse','p-community']
for(i=0;i<shoe.length;i++){$(shoe[i]).style.display='table'}
$('ca-watch').parentNode.removeChild($('ca-watch'))}

function is_gif_image(i){return /^(?!data:).*\.gif/i.test(i.src)}
function prefrz(i){
if($('file')){
if($('file').getElementsByTagName('img')[0]!=i){
freeze_gif(i)
}}else{
freeze_gif(i)
}}
function freeze_gif(i){
c=document.createElement('canvas')
w=c.width=i.width
h=c.height=i.height
c.getContext('2d').drawImage(i,0,0,w,h)
i.alt=i.src
try{
i.src=c.toDataURL('image/gif')
i.setAttribute('onmouseover','this.src=this.alt')
i.setAttribute('onmouseout','freeze_gif(this)')
}catch(e){
for(var j=0,a;a=i.attributes[j];j++){
c.setAttribute(a.name,a.value)
}
c.setAttribute('onmouseover','unfree(this)')
i.parentNode.replaceChild(c,i)
}}
function unfree(x){
z=document.createElement('img')
z.width=x.width
z.height=x.height
for(var j=0,a;a=x.attributes[j];j++){
z.setAttribute(a.name,a.value)
}
z.setAttribute('onmouseover','')
z.scr=x.alt
x.parentNode.replaceChild(z,x)
}

function $(a){return document.getElementById(a)}

function editer(){
editlead=$('firstHeading')
if(editlead){
editlead.innerHTML+='<div class=editsection>[<a href="/index.php?title='+escape(wgPageName)+'&action=edit&section=0">править</a>]</div>'
}}

function altload(){
if(!$('wpLicense').value){
alert('Вы должны выбрать лицензию!')
}else{
uplo.type='submit'
uplo.setAttribute('onclick','')
uplo.click()
}}

function unserc(val){
tmp=[];tmp2=[];get=[]
url=location.search
if(url){
tmp=url.substr(1).split('&')
for(i=0;i<tmp.length;i++){
tmp2=tmp[i].split('=')
get[tmp2[0]]=tmp2[1]}
return get[val]}}

function imgfi(){
wtx=$('wpTextbox1').value

wtx=wtx.replace(/(?! )Image:/ig,'File:')
wtx=wtx.replace(/       /g,' ')
wtx=wtx.replace(/      /g,' ')
wtx=wtx.replace(/     /g,' ')
wtx=wtx.replace(/    /g,' ')
wtx=wtx.replace(/   /g,' ')
wtx=wtx.replace(/  /g,' ')
wtx=wtx.replace(/&ndash;/g,'-')
wtx=wtx.replace(/&mdash;/g,'—')
wtx=wtx.replace(/<br \/>/g,'<br>')
wtx=wtx.replace(/<br clear="?all"?\s?\/?>/g,'{{br}}')
wtx=wtx.replace(/<br clear="?left"?\s?\/?>/g,'{{br|left}}')
wtx=wtx.replace(/<br clear="?right"?\s?\/?>/g,'{{br|right}}')
wtx=wtx.replace(/<nowiki>\'<\/nowiki>/g,'{{\'}}')

$('wpTextbox1').value=wtx
}

/////////////////////////////////////////////////////////////
onload=function(){///////////////////////////////////////////
/////////////////////////////////////////////////////////////

lgout=$('pt-logout').getElementsByTagName('a')[0]
olgout=lgout.href
lgout.href='javascript:if(confirm("Are you sure?")){location=olgout}'

$('searchInput').setAttribute('class','searchInput')
$('searchBody').appendChild(ein=document.createElement('form'))
ein.action='http://www.mariowiki.com/'
ein.innerHTML='<input type=hidden name=action value=edit><input type=text name=title class=searchInput id=searchInput2>'

if(unserc('action')=='edit'||unserc('action')=='submit'){
document.getElementsByClassName('editHelp')[0].parentNode.replaceChild(wf=document.createElement('input'),document.getElementsByClassName('editHelp')[0])
wf.type='button'
wf.value='Image to file'
wf.setAttribute('onclick','imgfi()')
}

if(wgPageName=='Special:Upload'&&unserc('wpForReUpload')!='1'){
uplo=document.getElementsByName('wpUpload')[0]
uplo.type='button'
uplo.setAttribute('onclick','altload()')
}

document.title=document.title.replace(/ — Super Mario Wiki$/,'')

editab=$('ca-edit')
editab=editab?editab.getElementsByTagName('a')[0].innerHTML:''
if(editab=='Править'){
if(wgIsArticle){
rig=wgRestrictionEdit
gir=wgUserGroups
if(rig.length==0){
editer()
}else{
for(i=0;i<rig.length;i++){
for(z=0;z<gir.length;z++){
if(rig[i]==gir[z]){
editer()
break
}}}}}}

$('pt-mytalk').innerHTML+='<li class=spe><a href=/User:SWFlash/Sig title="To-Do list">To-Do</a></li>'
$('pt-preferences').innerHTML+='<li class=spe><a href=/User:SWFlash/monobook.js?action=edit title=JavaScript>JS</a><li class=spe><a href=/User:SWFlash/monobook.css?action=edit title="Cascading Style Sheet">CSS</a></li></li>'

if($('bodyContent').innerHTML.indexOf('Очистить кеш этой страницы?')>0){
$('bodyContent').getElementsByTagName('form')[0].getElementsByTagName('input')[0].click()
}

if(wgPageName=='User:SWFlash/Sig'){
$('pt-mytalk').getElementsByClassName('spe')[0].getElementsByTagName('a')[0].style.fontWeight='bold'
}
if(wgPageName=='User:SWFlash/monobook.js'){
$('pt-preferences').getElementsByClassName('spe')[0].getElementsByTagName('a')[0].style.fontWeight='bold'
}
if(wgPageName=='User:SWFlash/monobook.css'){
$('pt-preferences').getElementsByClassName('spe')[1].getElementsByTagName('a')[0].style.fontWeight='bold'
}

$('mw-searchButton').setAttribute('accesskey','f')

if(wgTitle=='Main Page'&&wgIsArticle){
$('ca-nstab-main').getElementsByTagName('a')[0].innerHTML='Заглавная'
}

if(wgPageName=='Main_Page'&&wgIsArticle){

pds=document.getElementsByClassName('pds-links')[0]
if(pds){
location=pds.getElementsByTagName('a')[0].href
}

$('ca-watch').replaceChild(rst=document.createElement('a'),$('ca-watch').getElementsByTagName('a')[0])
rst.href='javascript:show()'
rst.appendChild(document.createTextNode('Восстановить'))

$('searchInput').focus()
}

[].slice.apply(document.images).filter(is_gif_image).map(prefrz)
}

// </nowiki>