Content deleted Content added
→top: update |
fix instruction manual, work on explanatory notes |
||
Line 1:
: ''I'm using this page as a workspace. The talk page portion of it starts at [[#Discussions]], below.''
: '''''This script is operational'''''. ''''Quirk in wikEd: When results are copy and pasted into wikEd, the results are erroneously double spaced. Clicking on undo in wikEd reverts it to single spaced as initially intended. (
[[User:The Transhumanist/StripSearchSorted.js|StripSearchSorted.js]]:
= Script's workshop =
Line 12:
: ''This script is partially operational; it doesn't sort the results yet.''
[[User:The Transhumanist/
<nowiki>* [[</nowiki>[[John Wayne]]<nowiki>]]</nowiki></br>▼
<nowiki>* [[</nowiki>[[Clint Eastwood]]<nowiki>]]</nowiki></br>▼
<nowiki>* [[</nowiki>[[Brad Pitt]]<nowiki>]]</nowiki></br>
▲<nowiki>* [[</nowiki>[[Clint Eastwood]]<nowiki>]]</nowiki></br>
<nowiki>* [[</nowiki>[[Dwayne Johnson]]<nowiki>]]</nowiki></br>
▲<nowiki>* [[</nowiki>[[John Wayne]]<nowiki>]]</nowiki></br>
<nowiki>* [[</nowiki>[[Tom Cruise]]<nowiki>]]</nowiki></br>
Once installed, the menu item "SR sort" will appear in the side bar tools menu, specifying what action it is ready to perform (either "turn on" or "turn off").
To install, add this line to your vector.js page:
<syntaxhighlight lang="javascript">
importScript("User:The Transhumanist/
</syntaxhighlight>
== Explanatory notes (source code walk-through) ==
Line 57 ⟶ 55:
I didn't know what else to call these. I wanted the program to only work when intended, and only on intended pages (search result pages). So, I applied the [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals conditional, '''''if'''''].
==== Vector skin activation filter ====
I use the Vector skin, and haven't tested the script on any other skin, so the script basically says "''if'' the vector skin is in use, do what's between the curly brackets". (Which includes the entire rest of the program).
<syntaxhighlight lang="javascript">
// Only activate on Vector skin
if ( mw.config.get( 'skin' ) === 'vector' ) {
// The rest of the script goes here
}
</syntaxhighlight>
// Run this script only if " - Search results - Wikipedia" is in the page title▼
==== Page title activation filter ====
if (document.title.indexOf(" - Search results - Wikipedia") != -1) {▼
<syntaxhighlight lang="javascript">
// The rest of the script goes here
}
</syntaxhighlight>
=== Prep work ===
|