Wikinews:Javascript

From Wikinews, the free news source you can write!

(Redirected from Wikinews:WiktLookup)
Jump to:navigation, search

The purpose of this page is to document the JavaScript used on Wikinews (right now it is more of an overview than documentation, but hopefully it is useful to someone). See also Wikinews:Skins. For information on enabling custom JavaScript for yourself, see meta:Help:User style.

If you discover a bug in the local javascript, or one of the gadgets, please report it at the bottom of this page.

Contents

[edit] Gadgets

Gadgets are optional functionality you can enable in your preferences.

[edit] Hide fundraiser

Only available during fundraisers, hides the fundraiser notice.

[edit] Navagation popups

Copied from Wikipedia, so probably out of date. See Wikipedia:Tools/Navigation popups. Provides quick overviews of articles as you hover over text. See File:Popup-preview.png for an example.

[edit] HotCat

Stolen from commons. Allows easy insertion/removal of categories. Modified for Wikinews so that it doesn't remove date categories, or tag categories (published, developing, archived, etc).

[edit] WikEd

Stolen from Wikipedia. Adds syntax highlighting, and better editing toolbar. This directly loads the script from Wikipedia, so it should always be up to date. See w:User:Cacycle/wikEd for more details.

[edit] ReadyAlert

Adds to the sitenotice a list of articles currently needing to be reviewed, as well as a list of articles that are published but need to be re-flagged. Also includes how long the article has been waiting to be reviewed/flagged.

[edit] talkSeperate

Add a yellow border around different levels of indentation to make it easier to tell who is talking. Stolen from french Wikinews.

[edit] CommentWatch

If you add a page to your watchlist, also add the associated comment (opinion) page to your watchlist as well.

[edit] Wiktionary lookup gadget (Hover box variety)

[edit] FAQ

javascript:(function%20()%20%7Bvar%20src%20=%20document.createElement('script');src.type%20=%20'text/javascript';src.src%20=%20'http://en.wikinews.org/w/index.php?title=MediaWiki:WiktionaryLookup-external-bookmarklet.js&action=raw&ctype=text/javascript&scrver=1';document.getElementsByTagName('head')%5B0%5D.appendChild(src);%7D)();void%200

[edit] Introduction

Screenshot of a definition given with the Look Up tool from the French Wiktionary

In short, double click a word, get its definition.

This gadget allows you to double click on a word, and a box will be overlaid showing the definition of that word. This gadget works, by detecting what is highlighted when you double-click on the page (double-clicking a word automatically highlights it). The gadget than looks up the word, using the following url http://en.wiktionary.org/w/api.php?action=parse&prop=text&format=xml&xslt=MediaWiki:extractFirst.xsl&page=Word (replacing word with the name of the word. It than displays that page in an overlay (absolutely positioned iframe for those familiar with html) on the current page. To close the overlay just click anywhere outside it. (preferably to the left or right of it. there is a little space directly under the overlay box which won't close [this is because it is actually a transparent part of the box, used to accomadate large definitions]).

A couple of notes

[edit] How to install

[edit] On mediawiki wiki
importScriptURI('http://en.wikinews.org/w/index.php?title=MediaWiki:Gadget-dictionaryLookupHover.js&action=raw&ctype=text/javascript');
[edit] On an arbitrary website (aka your blog)

Add the folowing somewhere into the html (preferably in the <head>, but should work anywhere:

<script src='http://en.wikinews.org/w/index.php?title=MediaWiki%3AWiktionaryLookup-external.js&action=raw&ctype=text/javascript' type='text/javascript'></script>

Note if for some reason you don't want to hot link hot-linking is highly recomended though), contact me (user:Bawolff) and i'll tell you how to set that up.

The script uses the lang attribute on the <html> element to determine the language of your website. You can also override this by setting a global js variable wgContentLanguage. For example: var wgContentLanguage = 'fr';. Theres some other options that can customize the script, but i havn't documented them yet (don't worry, they are not really useful).

[edit] Configuration options

This script has a number of configuration options. to configure add the following to somewhere where js is loaded (could be loaded before or after the script). For example on a wiki, if you wanted to configure for the entire site, it could be at mediawiki:Common.js . If its just for you, special:mypage/monobook.js (or special:mypage/vector.js if you use vector, etc for other skins). If its a blog, where ever you can execute js (for example, insert it between a <script> and </script> tags.

The following parameters are supported (prefix with wiktLookup.)

For example, to use a count of 3 defintions, the bold showWord, a slightly wider box, add the following js:

if (!window.wiktLookup) wiktLookup = {};
wiktLookup.count = 3;
wiktLookup.showWord = 'bold';
wiktLookup.width = 220;

If you are on a wiki, you would either add it to special:mypage/monobook.js (replacing monobook with the skin you use) if you just want it for you, or mediawiki:Common.js if you want the options. If you are using an external website, such as blog, you would suround it with <script> tags, and insert it into the html source of your website.

If you are using this from a blog (not a wiki), you can also use the global variable wgContentLanguage to overide the assumed content language of your blog (it defaults to the lang attribute of the html element) This is used to figure out what language the word you clicked on is in. The global variable wgUserLanguage controls what language it is assumed the user speaks (aka what language to present the definition in).

[edit] Always enabled

[edit] mediawiki:Common.js

[edit] Rss Feeds

[edit] Dynamic Navigation

A script for the collapsible boxes you know and love. It was stolen from some other project a long time, and was modified so that there is an option to make the open boxes close if another one is opened (only one open at a time). This script is rather ugly, and could be much improved.

[edit] Tabber

script to create tab boxes. Created by by Patrick Fitzgerald, and released under an open source MIT license (go open source). Was modified slightly to suit our purposes. Creates tab boxes.

[edit] IRC box

Creates an IRC login box anytime you put <div id="cgiircbox"></div> on a page. Logs you into the wikizine cgi:irc web interface. Used to be used on WN:IRC, not anymore. Still on WN:V

[edit] Custom edit buttons

Adds a button to the edit toolbar for Linking to Wikipedia, and for creating redirects.

[edit] Comment crap

[edit] Ticker

Shows a list of items, one at a time. If you're using an old computer, and don't want to waste cpu cycles, it can be disabled via a gadget, or by doing var disable_ticker2=true;.

Note: Historically we used a different ticker system - mediawiki:Ticker.js. It is no longer loaded by the english wikinews js, but some other languages use it.

[edit] Edit tools (MediaWiki:Edittools.js)

Add a drop down menu to the insert markup box that comes after the editbox.

[edit] per page customization


Common.css/Main Page Common.css/Main Page Lite Common.css/Portal:Australia
Common.css/Portal:Canada Common.css/Portal:United Kingdom Common.css/User:Bawolff/Sandbox/MessedRocker based main page redesign
Common.css/User:Bawolff/sandbox/alt citations Common.css/User:Bawolff/sandbox/horizInfobox Common.css/User:Bawolff/sandbox/leads
Common.css/User:Bawolff/sandbox/leads/fixed width 1280x1024 Common.css/User:Bawolff/sandbox/powerFlag Common.css/User:Bawolff/sandbox/ticker
Common.css/User:Brian McNeil Common.css/User:Dendodge
Common.css/User:Rayboy8 Common.css/User:Rayboy8/Articles Common.css/User:Rayboy8/Articles 101 to 200
Common.css/User:Rayboy8/Articles 1 to 100 Common.css/User:Rayboy8/Main page Common.css/User:ShakataGaNai/Main Page
Common.css/User:TheFearow Common.css/User:Tristan Thomas Common.css/User talk:Brian McNeil
Common.css/User talk:Rayboy8 Common.css/Wikinews:CommonsTicker Common.css/Wikinews:Newsroom
Common.css/Wikinews:Reusing Wikinews content Common.css/Wikinews:Water cooler Common.css/Wikinews:Water cooler/miscellaneous/Archive/monobook.css
Common.css/Wikinews:World News Quiz Common.css/Wikinews:Writing contest 2010 Common.css/test


Common.js/Category:Review Common.js/Main Page Common.js/Special:Contributions
Common.js/Special:MovePage Common.js/Template:Social bookmarks Common.js/User:BarkingFish
Common.js/User:Bawolff/idea Common.js/User:Bawolff/sandbox/MainPageHeader collapse Common.js/User:Bawolff/sandbox/Wiktionary query
Common.js/User:Bawolff/sandbox/alt citations Common.js/User:Bawolff/sandbox/catStats Common.js/User:Bawolff/sandbox/horizInfobox
Common.js/User:Bawolff/sandbox/leads Common.js/User:Bawolff/sandbox/leads/1024
Common.js/User:Bawolff/sandbox/powerFlag Common.js/User:Bawolff/sandbox/resizeEditbox Common.js/User:Bawolff/sandbox/tabs
Common.js/User:Bawolff/sandbox/ticker Common.js/User:Bawolff/sandbox/utcclockthingy Common.js/User:Brianmc/sandbox
Common.js/User:Doldrums/Main page Common.js/Wikinews:Make lead Common.js/Wikinews:Newsroom
Common.js/Wikinews:Syndication

[edit] Social networking stuff

For use with template:Social bookmarks.

[edit] Custom Editintros

[edit] from wikipedia

We append &editintro=Template:Editintro_from_wikipedia to all the editlinks on any page, when the user has a referrer starting with http://en.wikipedia.org . This puts {{Editintro from wikipedia}} above the edit box.

[edit] not current

Any article that has a publish date (in {{date}}, or more accurately the date category that the date template adds) over 48 hours ago, is in category published, and not in category archived, has &editintro=template:Editintro_notcurrent to the end of all edit urls (unless they already have an edit intro). This makes {{Editintro notcurrent}} go on top of the edit box

Note if there is a conflict between not current, and from wikipedia, not current wins. This was a completely arbitrary decesion, it could be switched, or we could have another template when both apply if people would prefer that.

[edit] {{develop}} → {{review}}

Recognizes a span with a specific id (develop_to_review_link), that contains a link to edit the current page, and replaces it with a button that magically replaces {{Develop}} with {{review}}. Note you can change the text inside the link to change the text in the button, but do not change the link or the span, or add whitespace between the span and the link.

[edit] mediawiki:Monobook.js

Monobook only JavaScript

[edit] Alt stylesheets

[edit] Main Page stuff

Hides the title if skin is monobook, and page is main page (This should possibly be moved to css).

[edit] Mediawiki:Modern.js

[edit] Other Stuff

[edit] user:Bawolff/mwapilib.js/user:Bawolff/mwapilib2.js

Called by some of the per-page js, and some js in my (Bawolff's) userspace. Aims to make using the mediawiki api easier to use. Some docs at user:Bawolff/mwapilib

[edit] jQuery

[edit] Bugs

Please use this area to report bugs and/or feature requests (for gadgets or the core js. If its a gadget maintained on wikinews you can alternatively report it to the maintainer of that gadget)

Navigation
Wikinews
Regions
Toolbox