משתמש:מלא כל הארץ/common.js: הבדלים בין גרסאות בדף
מראה
מלא כל הארץ (שיחה | תרומות) ביטול גרסה 273447 של מלא כל הארץ (שיחה) לא עבד, כנראה התבלבלתי באתר |
מלא כל הארץ (שיחה | תרומות) אין תקציר עריכה |
||
| שורה 37: | שורה 37: | ||
//התראה על שינוי ערך בעת צפייה בו או עריכתו, נכתב ע"י אור: | //התראה על שינוי ערך בעת צפייה בו או עריכתו, נכתב ע"י אור: | ||
mw.loader.using( [ "mediawiki.api" ] ).then( function() { | mw.loader.using( [ "mediawiki.api" ] ).then( function() { | ||
function Alert(title, html) { | function Alert(title, html) { | ||
| שורה 86: | שורה 85: | ||
} | } | ||
}); | }); | ||
//עד כאן | //עד כאן | ||
גרסה מ־13:52, 10 בספטמבר 2017
importScript('משתמש:מלא כל הארץ/Redirect.js');
importUserScript(76, 52, 77, 67, 78, 13, 63, 98, 21, 29, 34, 39, 46, 61, 68, 71, 100, 102, 104, 105);
if (typeof window.orientation == 'undefined') {
importUserScript(95, 33, 8, 80, 48, 16, 41, 73, 91);
}
// [[Wikipedia:Tools/Navigation popups]]
mw.loader.load('https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript');
mw.loader.load('https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-navpop.css&action=raw&ctype=text/css', 'text/css');
// Wiki-Labels [[File:User:EpochFail/WikiLabels.js]] (workaround for [[phab:T35355]])
mw.loader.load('//https://meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-WikiLabels-loader.js&action=raw&ctype=text/javascript');
mw.loader.load('//https://he.wikipedia.org/w/index.php?title=Mediawiki:סקריפטים/92.js&action=raw&ctype=text/javascript');
window.translatelinks_target = 'he';
mw.loader.load('//https://he.wikipedia.org/w/index.php?title=Mediawiki:52סקריפטים/92.js&action=raw&ctype=text/javascript');
importScript('//https://he.wikipedia.org/w/index.php?title=משתמש:חיים_7/LiveClock.js&action=raw&ctype=text/javascript&dontcountme=s');
// הסקריפט מוסיף קישור "דף אקראי בקטגוריה" בדפי קטגוריה
// נכתב על ידי [[User:1Or]]
if ((mw.config.get('wgNamespaceNumber') == 14)){
var ShowRandomLink = $('<a>', {href: '//he.wikipedia.org/wiki/Special:RandomInCategory/' + mw.config.get( 'wgPageName' ), text: "דף אקראי בקטגוריה"});
if ($('#contentSub a').length) {
$('#contentSub a:last').after(ShowRandomLink).after(' | ');}
else {
$('#contentSub').append(ShowRandomLink);}
}
if ($("#catlinks a").length) {
$("#catlinks a").each(function(){
if (this.href.match(/\/wiki\/%D7%A7%D7%98%D7%92%D7%95%D7%A8%D7%99%D7%94/)) {
this.after(" ");
this.after($($('<a>', {href: '//he.wikipedia.org/wiki/Special:RandomInCategory/' + this.title, text: "(⚄)", title: "דף אקראי בקטגוריה"})["0"].outerHTML)["0"]);
this.after(" ");
}
});
}
//עד כאן
//התראה על שינוי ערך בעת צפייה בו או עריכתו, נכתב ע"י אור:
mw.loader.using( [ "mediawiki.api" ] ).then( function() {
function Alert(title, html) {
mw.loader.using( [ "jquery.ui.dialog" ] ).then( function() {
$("<div>").html(html).dialog({
title: title,
resizable: false,
modal: true,
buttons: {
"סגירה": function()
{
$( this ).dialog( "close" );
}
}
});
});
}
var lastEdit = "",
api = new mw.Api(),
apiParams = {
prop: 'revisions',
titles: mw.config.get("wgPageName"),
rvprop: 'ids|timestamp|user',
rvlimit: 1
};
function checkForNewRev() {
api.get( apiParams ).done(function(k){
if (k && k.query && k.query.pages) {
var currentRev = k.query.pages[mw.config.get('wgArticleId')].revisions["0"].revid;
if (lastEdit !== "" && lastEdit !== currentRev) {
if (window.location.search.match(/action\=edit/))
Alert("אזהרה", "הדף השתנה מאז שהתחלת לערוך אותו.<br /><a href='/wiki/%D7%9E%D7%99%D7%95%D7%97%D7%93:%D7%94%D7%91%D7%93%D7%9C/" + currentRev + "' target='_blank'>צפייה בשינוי החדש</a>");
else {
Alert("שימו לב", "הדף השתנה מאז שהתחלת לקרוא אותו.<br /><a href='/wiki/%D7%9E%D7%99%D7%95%D7%97%D7%93:%D7%94%D7%91%D7%93%D7%9C/" + currentRev + "' target='_blank'>צפייה בשינוי החדש</a>");
}
lastEdit = currentRev;
} else {
lastEdit = currentRev;
setTimeout(checkForNewRev, 10000);
}
}
});
}
if (~mw.config.get('wgNamespaceNumber')) {
checkForNewRev();
}
});
//עד כאן
//סקריפט 88 לחיוויים על שינויים ברשימת המעקב, נכתב ע"י קיפודנחש
mw.loader.using( ['mediawiki.api', 'mediawiki.user', 'mediawiki.util'] , function() {
const storageKeyName = 'watchlistwatcher-newestclicked';
var api = new mw.Api( { cache: false } ),
titles,
items,
newest = 0,
watchButton,
watchwButtonAnchor,
timer,
storage = window.localStorage;
function i18n( key ) {
switch ( mw.user.options.get( 'language' ) ) {
case 'he':
switch ( key ) {
case 'title' : return 'רשימת המעקב שלך';
}
break;
case 'en':
switch ( key ) {
case 'title': return 'Your watchlist';
}
break;
}
return key;
}
function updateStorageAndRefresh() {
storage.setItem( storageKeyName, newest ); // remember the click: only items newer than latest click will trigger coloring the bubble.
triggerQuery( 0 ); // initiate click, so when it returns we can color the icon accordingly
}
function showWatchlistDialog( e ) {
e.stopImmediatePropagation();
e.preventDefault();
updateStorageAndRefresh();
var $this = $( this ),
width60 = $( 'body' ).width() * 0.6,
height60 = $( 'body' ).height() * 0.6;
$.ajax( { url: mw.util.getUrl( 'Special:Watchlist' ) } )
.done( function( data ) {
mw.loader.using( 'jquery.ui.dialog' ).done ( function() {
var content = $( data ).find( '.mw-changeslist' ),
cl = '';
content
.parents()
.each( function() {
if ( $( this ).length )
cl += $this.attr( 'class' ) + ' ';
} );
$( '<div>' )
.addClass( 'mw-changeslist ' + cl )
.dialog( {
position: {
my: "center top",
at: "center bottom",
of: $this
},
width: width60,
height: height60,
close: function() { $( this ).remove(); }
} )
.css( { overflow: 'auto' } )
.append( content );
} );
} );
}
function announce() {
const new_id = 'pt-notifications-watchlist';
var count = titles.length;
if ( ! watchButton ) {
var url,
notif = $( '#pt-notifications-notice, #pt-notifications-alert' ).eq(-1);
if ( ! notif.length )
return;
watchButton = notif.clone()
.attr( { id: new_id } )
.insertAfter( notif );
watchwButtonAnchor = watchButton.find( 'a' )
.click( showWatchlistDialog )
.attr( { href: mw.util.getUrl( 'Special:Watchlist' ), title: i18n( 'title' ) } );
}
var lastClicked = parseInt( storage.getItem( storageKeyName ) ) || 0,
toColor = newest > lastClicked;
watchwButtonAnchor
.toggleClass( 'mw-echo-notifications-badge-unseen', toColor )
.toggleClass( 'mw-echo-notifications-badge-all-read', count === 0 )
.attr( { 'data-counter-text': count || '', 'data-counter-num': count } );
}
function calcParams() {
var
opts = {
/* watchlisthideown: we do not care about this one, since "unread" will never have own edits anyway */
watchlisthideanons: '!anon',
watchlisthidebots: '!bot',
watchlisthideliu: 'anon', /* this strangely named option means "hide regitered users", IOW, show anons */
watchlisthideminor: '!minor',
watchlisthidepatrolled: '!patrolled'
},
show = Object.keys( opts )
.filter( function( k ) {return mw.user.options.get( k ); } )
.map( function( k ) { return opts[k]; } )
.concat( 'unread' )
.join( '|' );
return {
list: 'watchlist',
wlprop: 'ids|user|title|timestamp|notificationtimestamp',
wlshow: show,
wltype: mw.user.options.get( 'watchlisthidecategorization' ) ? 'edit|new|log' : 'edit|new|log|categorize',
wllimit: 50
};
}
function triggerQuery( timeout ) {
clearTimeout( timer );
if ( typeof(timeout) != 'number')
timeout = 1000;
timer = setTimeout( queryAndUpdate, timeout );
}
function queryAndUpdate() {
api.get( calcParams() )
.done( function(data) {
var counts = {};
if ( data && data.query && data.query.watchlist ) {
items = data.query.watchlist;
items.forEach( function( item ) { counts[item.title] = ( counts[item.title] || 0 ) + 1; } );
newest = items.map( function( item ) { return new Date( item.timestamp ).getTime(); } ).sort().pop();
titles = Object.keys( counts );
announce();
triggerQuery( 60000 );
}
} ); // done
} // queryandupdate
//load css page. would do it locally, but javascript does not support multiline strings, and putting all the CSS locally is just too much.
mw.loader.load( '//he.wikipedia.org/w/index.php?title=מדיה_ויקי:סקריפטים/88.css&action=raw&ctype=text/css', 'text/css' );
queryAndUpdate();
$('#mw-watchlist-resetbutton').submit( triggerQuery );
$( 'body ').on( 'script-88-refresh', triggerQuery );
$( 'body ').on( 'script-88-pretend-clicked', updateStorageAndRefresh );
} );
//עד כאן 88
//MW:User:Remember the dot/Syntax highlighter
mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript');
syntaxHighlighterConfig = {
externalLinkColor: "#AFEEEE", //טורקיז חיוור עבור קישח"צ
wikilinkColor: "#87CEEB", //כחול שמיים עבור קישורים
headingColor: "#808080", //אפור עבור כותרות
boldOrItalicColor: "#C0C0C0", //כסף עבור הדגשה ואיטליקס
signatureColor: "#00FF00", //ירוק סיד עבור חתימה
templateColor: "#eeccee", //סגול בהיר כלשהו עבור תבניות
}
//עד כאן צביעת קוד מקור