MediaWiki:Common.js
From ProofWiki
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Command-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Konqueror: Click Reload or press F5
- Opera: Clear the cache in Tools → Preferences
//<source lang="javascript"> /* Any JavaScript here will be loaded for all users on every page load. */ if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://proofwiki.org/w/images/toolbar/ref.png", "speedTip": "Insert reference tags", "tagOpen": "<ref>", "tagClose": "</ref>", "sampleText": ""}; /* mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://proofwiki.org/w/images/toolbar/proof.png", "speedTip": "Theorem/Proof Template", "tagOpen": "==Theorem==", "tagClose": "==Proof==", "sampleText": ""}; */ /*mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://proofwiki.org/w/images/toolbar/eqn.png", "speedTip": "Insert equation template for new row", "tagOpen": "{{equation |l=<math>", "tagClose": "</math> | r=<math></math>}}", "sampleText": ""}; */ } /* Process the collapsible subproof environments * * Description: Allow technical lemmata to have an included, but initially collapsed proof on the page itself. * * Author/Maintainer: [[Lord_Farin]] */ var hasClass = (function () { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; })(); function toggleSubproof( index ){ var Link = document.getElementById( "subprooflink" + index ); var Content = document.getElementById( "subproofcontent" + index); if(Content.style.display == 'none'){ Content.style.display = 'block'; Link.innerHTML = 'hide'; } else{ Content.style.display = 'none'; Link.innerHTML = 'show'; } } function processSubproofs(){ var Divs = document.getElementsByTagName( "div" ); var subproofCount = 1; for( var i = 0 ; i < Divs.length ; i++ ){ var Subproof = Divs[i]; /* Filter out the actual subproofs */ if( !hasClass( Divs[i], "subproof" ) ){ continue; } /* Extract the Header and Content divs, and the LinkHolder span. Abort if they aren't present */ var SubDivs = Subproof.getElementsByTagName( "div" ); var Header = null; var Content = null; for ( var j = 0; j < SubDivs.length ; j++ ){ if( !Header && hasClass( SubDivs[j], "subproofheader" )){ Header = SubDivs[j]; } if( !Content && hasClass( SubDivs[j], "subproofcontent" )){ Content = SubDivs[j]; } } if( !Header || !Content ){ continue; } var HeaderSpans = Header.getElementsByTagName( "span" ); var LinkHolder; for ( var j = 0; j < HeaderSpans.length ; j++ ){ if( hasClass( HeaderSpans[j], "linkholder" )){ LinkHolder = HeaderSpans[j]; break; } } if( !LinkHolder ){ continue; } /* Add a unique identifier to this particular subproof */ Subproof.setAttribute( "id", "subproof" + subproofCount); Header.setAttribute( "id", "subproofheader" + subproofCount); Content.setAttribute( "id", "subproofcontent" + subproofCount); LinkHolder.setAttribute( "id", "subprooflinkholder" + subproofCount); LinkHolder.innerHTML = '[<a id="subprooflink' + subproofCount + '" onclick="toggleSubproof('+subproofCount+')"></a>]'; /* Bring this subproof to its initial state */ Content.style.display = 'none'; document.getElementById( "subprooflink" + subproofCount).innerHTML = 'show'; subproofCount++; } } jQuery( processSubproofs ); /* Here ends the processing of collapsible sections */ //</source>