הבדלים בין גרסאות בדף "מדיה ויקי:BookmarkletsInit.js"
קפיצה לניווט
קפיצה לחיפוש
שורה 2: | שורה 2: | ||
'use strict'; | 'use strict'; | ||
− | var | + | console.log( 'closure' ); |
− | + | ||
+ | var stubparts, bookmarklets, bookmarletsWrong, | ||
+ | $bookmarkletsList = $( '#bookmarkletsList' ); | ||
+ | |||
+ | stubparts = [ | ||
+ | 'javascript:(function(){if(typeof(', | ||
+ | ")=='undefined'){var s=document.createElement('script');s.setAttribute('src','//chabadpedia.co.il/index.php?title= ", | ||
+ | "&action=raw&maxage=3600&ctype=text/javascript&dontcountme=s');document.getElementsByTagName('body')[0].appendChild(s);}else ", | ||
+ | "();})()" | ||
+ | ]; | ||
+ | |||
+ | bookmarklets = [ | ||
+ | { | ||
+ | func: 'wikiit', | ||
+ | sourcepage: 'MediaWiki:Bookmarklets/wikiit.js', | ||
+ | name: 'תבנית לחב"דפדיה', | ||
+ | description: 'יצירת תבנית קישור ממאמרים באתרים שימושיים: ' | ||
+ | } | ||
+ | ]; | ||
+ | |||
+ | $bookmarkletsList.empty(); | ||
+ | |||
+ | $( bookmarklets ).each( function( i, bookmarklet ) { | ||
+ | $bookmarkletsList.append( $( '<li>' ) | ||
+ | .text( bookmarklet.description ) | ||
+ | .append( $( '<a>', | ||
+ | { | ||
+ | 'href': stubparts[0] + bookmarklet.func + | ||
+ | stubparts[1] + bookmarklet.sourcepage + | ||
+ | stubparts[2] + bookmarklet.func + | ||
+ | stubparts[3], | ||
+ | 'click': bookmarletsWrong, | ||
+ | 'text': bookmarklet.name | ||
+ | } | ||
+ | ) ) | ||
+ | ); | ||
+ | } ); | ||
+ | |||
+ | bookmarletsWrong = function ( e ) { | ||
+ | e.preventDefault(); | ||
+ | alert( 'את הקישור יש לגרור לסרגל המועדפים, ולהפעיל באתרים המתאימים.' + | ||
+ | '\nקישור זה לא מיועד להפעלה מתוך חב"דפדיה. למידע נוסף קראו את ההוראות בדף.' | ||
+ | ); | ||
}; | }; | ||
− | |||
− | |||
} )(); | } )(); |
גרסה מ־18:42, 23 במרץ 2014
( function () {
'use strict';
console.log( 'closure' );
var stubparts, bookmarklets, bookmarletsWrong,
$bookmarkletsList = $( '#bookmarkletsList' );
stubparts = [
'javascript:(function(){if(typeof(',
")=='undefined'){var s=document.createElement('script');s.setAttribute('src','//chabadpedia.co.il/index.php?title= ",
"&action=raw&maxage=3600&ctype=text/javascript&dontcountme=s');document.getElementsByTagName('body')[0].appendChild(s);}else ",
"();})()"
];
bookmarklets = [
{
func: 'wikiit',
sourcepage: 'MediaWiki:Bookmarklets/wikiit.js',
name: 'תבנית לחב"דפדיה',
description: 'יצירת תבנית קישור ממאמרים באתרים שימושיים: '
}
];
$bookmarkletsList.empty();
$( bookmarklets ).each( function( i, bookmarklet ) {
$bookmarkletsList.append( $( '<li>' )
.text( bookmarklet.description )
.append( $( '<a>',
{
'href': stubparts[0] + bookmarklet.func +
stubparts[1] + bookmarklet.sourcepage +
stubparts[2] + bookmarklet.func +
stubparts[3],
'click': bookmarletsWrong,
'text': bookmarklet.name
}
) )
);
} );
bookmarletsWrong = function ( e ) {
e.preventDefault();
alert( 'את הקישור יש לגרור לסרגל המועדפים, ולהפעיל באתרים המתאימים.' +
'\nקישור זה לא מיועד להפעלה מתוך חב"דפדיה. למידע נוסף קראו את ההוראות בדף.'
);
};
} )();