Jump to content

User:Barak a/global.js

From Meta, a Wikimedia project coordination wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Note: After publishing, 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 (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
window.translatelinks_target = 'he';
mw.loader.load('//he.wikipedia.org/w/index.php?title=Mediawiki:סקריפטים/92.js&action=raw&ctype=text/javascript');
mw.hook( 'convenientDiscussions.pageReady' ).add( function ( cd ) {
	cd.comments.forEach( function ( comment ) {
		comment.$menu.appendTo( comment.$header );
	} );
} );
mw.loader.load('//he.wikipedia.org/w/index.php?title=MediaWiki:סקריפטים/88.js&action=raw&ctype=text/javascript');
mw.loader.load('https://commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions.js&action=raw&ctype=text/javascript');
$(function() {
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Watchlist' &&
		window.location.hostname !== 'he.wikipedia.org') {
	$('.mw-changeslist-line-not-watched ').hide();
	$('.mw-changeslist-line-watched span.mw-title').before( // Thanks to חיים 7
			$('<a>', {text: '♦', title: 'סמן עריכה כנצפתה', href: '#nw'})
				.css({marginLeft: '0.3em', marginRight: '0.1em', color: '#990066'})
				.click(function() {
					var $this = $(this);
					$.getJSON($this.siblings('span.mw-title').find('a:first').attr('href'));
					$this.closest('.mw-changeslist-line-watched').removeClass('.mw-changeslist-line-watched')
						.addClass('mw-changeslist-line-not-watched').hide();
					$this.remove();
				}
			)
		);
	mw.loader.using('mediawiki.util').done( function() { 
		$( mw.util.addPortletLink('p-cactions', '#', 'גלה עריכות שהוסתרו') )
		    .click(function() {
					$('.mw-changeslist-line-not-watched ').show();
					$('.mw-changeslist-line-watched ').show();
		    } );
	} );
	mw.loader.using('mediawiki.util').done( function() { 
		$( mw.util.addPortletLink('p-cactions', '#', 'הסתר עריכות שנקראו') )
		    .click(function() {
					$('.mw-changeslist-line-not-watched ').hide();
		    } );
	} );
}
});

mw.loader.using( 'mediawiki.util' ).done( function () {
	mw.util.addCSS( '\
		.cd-comment-menu { display:inline-block; margin:0 0 0 1em; font-size:inherit; }\
		.sitedir-rtl .cd-comment-menu { margin:0 1em 0 0; }\
		' );
} );

mw.hook( 'convenientDiscussions.pageReady' ).add( function ( cd ) {
	cd.comments.forEach( function ( comment ) {
		comment.$menu.appendTo( comment.$header );
	} );
} );

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript' );
//Gadget-WikidataTab.js
if ($.inArray(mw.config.get('wgNamespaceNumber'), [0, 4, 10, 12, 14, 100]) + 1)
$(function($) {
        var translate = {
                'he': {
                        notfound: "לא נמצאה כותרת ויקינתונים",
                        nolabel: "(אין תווית)",
                        nodescription: "(אין תיאור)"
                },
                'en': {
                        notfound: "Wikidata item not found",
                        nolabel: "(No label)",
                        nodescription: "(no description given)"
                }
        },
        pagename = mw.config.get('wgPageName').replace(/_/g, " ");
 
        $.ajax({
                url: '//www.wikidata.org/w/api.php',
                data: {
                        'format': 'json',
                        'action': 'wbgetentities',
                        'sites': mw.config.get('wgDBname'),
                        'titles': pagename,
                        'props': 'info|labels|descriptions|aliases',
                        'languages': mw.config.get('wgPageContentLanguage')
                },
                dataType: 'jsonp',
                success: function(data) {
                        var d = $("<li>");
                        $("#p-views ul").append(d);
                        if (data.success) {
                                var lang = mw.config.get('wgPageContentLanguage'),
                                        m = translate[lang] || translate.he;
                                for (var i in data.entities) {
                                        if (i == -1) {
                                                d.append(
                                                        $("<span>")
                                                        .append(
                                                                $("<a>")
                                                                .attr("href", "//www.wikidata.org/wiki/Special:CreateItem?setlang=he&label=" + pagename + "&site=hewiki&page=" + pagename)
                                                                .attr("title", m.notfound)
                                                                .append(
                                                                        $("<img>")
                                                                        .attr("src", "//upload.wikimedia.org/wikipedia/commons/e/e8/Wikidata-favicon.png")
                                                                        .attr("style", "margin-bottom: 5px; opacity:0.3; filter:alpha(opacity=30);")
                                                                )
                                                        )
                                                );
                                        } else {
                                                var item = data.entities[i],
                                                        i = 0,
                                                        aliases = [];
                                                try {
                                                        for (; i < item.aliases[lang].length; i++) {
                                                                aliases.push(item.aliases[lang][i].value);
                                                        }
                                                } catch (e) { }
                                                d.append(
                                                        $("<span>")
                                                        .append(
                                                                $("<a>")
                                                                .attr("href", "//www.wikidata.org/wiki/" + item.title)
                                                                .attr("title", ((item.labels && item.labels[lang]) ? item.labels[lang].value : m.nolabel) + " (" + item.title + "):" + ((item.descriptions && item.descriptions[lang]) ? item.descriptions[lang].value : m.nodescription))
                                                                .append(
                                                                        $("<img>")
                                                                        .attr("src", "//upload.wikimedia.org/wikipedia/commons/e/e8/Wikidata-favicon.png")
                                                                        .attr("style", "margin-bottom: 5px;")
                                                                )
                                                        )
                                                );
                                        } // else
                                } // for
                        } // if success
                } // succeess function
        }); // ajax
}); // ready

// based on http://en.wikipedia.org/wiki/User:Fran Rogers/dimorphism.js
// and on http://en.wikipedia.org/wiki/User:Splarka/sysopdectector.js

function UserinfoJsFormatQty(qty, singular, plural) {
    return String(qty).replace(/\d{1,3}(?=(\d{3})+(?!\d))/g, "$&,") + "\u00a0" + (qty == 1 ? singular : plural);
}