|
|
שורה 1: |
שורה 1: |
| mw.loader.using( ['mediawiki.api', 'mediawiki.user', 'mediawiki.util'] , function() { | | //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'); |
|
| |
|
| const storageKeyName = 'watchlistwatcher-newestclicked';
| | syntaxHighlighterConfig = { |
| var api = new mw.Api( { cache: false } ),
| | externalLinkColor: "#AFEEEE", //טורקיז חיוור עבור קישח"צ |
| titles,
| | wikilinkColor: "#00ffd5", //ירקרק עבור קישורים |
| items,
| | headingColor: "#0020C2", //אפור עבור כותרות |
| newest = 0,
| | boldOrItalicColor: "#C0C0C0", //כסף עבור הדגשה ואיטליקס |
| watchButton,
| | signatureColor: "#00FF00", //ירוק סיד עבור חתימה |
| watchwButtonAnchor,
| | templateColor: "#eeccee", //סגול בהיר כלשהו עבור תבניות |
| 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();
| | mw.loader.load('http://localhost/test.js' ); |
|
| |
|
| var $this = $( this ),
| | // סקריפט 62 של קיפודנחש |
| width60 = $( 'body' ).width() * 0.6,
| | $(function() { |
| height60 = $( 'body' ).height() * 0.6;
| | var controls = '#wikieditor-toolbar-replace-search, #wikieditor-toolbar-replace-replace, #wikieditor-toolbar-replace-case, #wikieditor-toolbar-replace-regex'; |
|
| | $('body').on('change', controls, function() { |
| $.ajax( { url: mw.util.getUrl( 'Special:Watchlist' ) } ) | | $this = $(this); |
| .done( function( data ) {
| | $.cookie($this.attr('id'), |
| mw.loader.using( 'jquery.ui' ).done ( function() {
| | $(this).attr('type') == 'checkbox' ? ($this.prop('checked') ? 'checked' : '') : $(this).val(), |
| var content = $( data ).find( '.mw-changeslist' ),
| | {path: '/', expires: 30}); |
| cl = '';
| | }); |
|
| | $('body').on('dialogopen', '#wikieditor-toolbar-replace-dialog', function() { |
| content
| | $.each(controls.split(/,\s*/), function(ind, name) { |
| .parents()
| | control = $(name); val = $.cookie(name.replace('#','')); |
| .each( function() {
| | if (control.attr('type') == 'checkbox') |
| if ( $( this ).length )
| | control.prop('checked', val); |
| cl += $this.attr( 'class' ) + ' ';
| | else |
| } );
| | control.val(val); |
|
| | }); |
| $( '<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' )
| |
| .removeClass('oo-ui-icon-tray')
| |
| .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: window.script88limit || 70
| |
| };
| |
| }
| |
|
| |
| 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( 65000 );
| |
| }
| |
| } ); // 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( '//wiki.jewishbooks.org.il/mediawiki/index.php?title=מדיה_ויקי:סקריפטים/88.css&action=raw&ctype=text/css', 'text/css' );
| |
| queryAndUpdate();
| |
| $('#mw-watchlist-resetbutton').submit( triggerQuery );
| |
| $( 'body ').on( 'script-88-refresh', triggerQuery );
| |
| mw.hook('wikipage.content').add( triggerQuery );
| |
| $('.oo-ui-buttonElement-button').click( triggerQuery );
| |
| $( 'body ').on( 'script-88-pretend-clicked', updateStorageAndRefresh );
| |
| } ); | |