הבדלים בין גרסאות בדף "מדיה ויקי:BookmarkletsInit.js"

מתוך חב"דפדיה, אנציקלופדיה חב"דית חופשית
קפיצה לניווט קפיצה לחיפוש
(ניסיון העתקה מויקיפדיה: https://he.wikipedia.org/wiki/%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:BookmarkletsInit.js)
שורה 1: שורה 1:
( function () {
+
function create_bookmarklets() {
'use strict';
+
    var stubparts = [
 
+
"javascript:(function(){if(typeof(",  
var stubparts, bookmarklets, bookmarkletsWrong,
+
")=='undefined'){var s=document.createElement('script');s.setAttribute('src','//chabadpedia.co.il/index.php?title= ",
$bookmarkletsList = $( '#bookmarkletsList' );
+
"&action=raw&maxage=3600&ctype=text/javascript&dontcountme=s');document.getElementsByTagName('body')[0].appendChild(s);}else ",
 
 
stubparts = [
 
"javascript:(function(){if(typeof(",
 
")=='undefined'){var s=document.createElement('script');s.setAttribute('src','http://chabadpedia.co.il/index.php?title= ",
 
"&action=raw&maxage=3600&ctype=text/javascript&dontcountme=s');document.getElementsByTagName('head')[0].appendChild(s);}else ",
 
 
"();})()"
 
"();})()"
 
];
 
];
 
+
var bookmarklets = [
bookmarklets = [
+
{func: 'wikiit', sourcepage: 'Mediawiki:Common.js/externalsmaker.js' , name: 'תבנית לחב"דפדיה', description: 'יצירת תבנית קישור מכתבות באתרים חב"דיים (חב"ד אינפו, חב"ד בישראל ועוד): '},
{
+
{func: 'coords', sourcepage: 'Mediawiki:Common.js/coords.js', name: 'תבנית coord', description: 'יצירת תבנית coord ממפה של גוגל או עמוד ענן (ראו הוראות למטה): '}
func: 'wikiit',
 
sourcepage: 'MediaWiki:Common.js/externalsmaker.js',
 
name: 'תבנית לחב"דפדיה',
 
description: ' '
 
}
 
 
];
 
];
 
+
var $ol = $("#bmList ol:first");
bookmarkletsWrong = function ( e ) {
+
$ol.contents().remove();
 +
$(bookmarklets).each(function(idx, item){
 +
$("<li>").text(item.description)
 +
.append(
 +
$("<a>",
 +
{
 +
"href": stubparts[0] + item.func + stubparts[1]+ item.sourcepage + stubparts[2] + item.func + stubparts[3],
 +
"click": bookmarlets_wrong,
 +
"text" : item.name
 +
}
 +
)
 +
).appendTo($ol)
 +
});
 +
 +
function bookmarlets_wrong(e)
 +
{
 
e.preventDefault();
 
e.preventDefault();
alert( 'את הקישור יש לגרור לסרגל המועדפים, ולהפעיל באתרים המתאימים.' +
+
alert('את הקישור יש לגרור לסרגל המועדפים, ולהפעיל באתרים הנתמכים.\nקישור זה לא מיועד להפעלה מתוך חב"דפדיה. למידע נוסף קראו את ההוראות בדף.');
'\nקישור זה לא מיועד להפעלה מתוך חב"דפדיה. למידע נוסף קראו את ההוראות בדף.'
+
}
);
+
};
+
};
 
 
$bookmarkletsList.empty();
 
 
 
$( bookmarklets ).each( function( i, bookmarklet ) {
 
var $link, $item;
 
 
 
$link = $( '<a>' )
 
.prop( 'href', stubparts[0] + bookmarklet.func +
 
stubparts[1] + bookmarklet.sourcepage +
 
stubparts[2] + bookmarklet.func +
 
stubparts[3] )
 
.click( bookmarkletsWrong )
 
.text( bookmarklet.name );
 
 
 
$item = $( '<li>' )
 
.text( bookmarklet.description )
 
.append( $link );
 
  
$bookmarkletsList.append( $item );
+
$(create_bookmarklets);
} );
 
} )();
 

גרסה מ־15:45, 8 בפברואר 2022

function create_bookmarklets() {
    var 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 ",
		"();})()"
	];
	var bookmarklets = [
{func: 'wikiit', sourcepage: 'Mediawiki:Common.js/externalsmaker.js'  , name: 'תבנית לחב"דפדיה', description: 'יצירת תבנית קישור מכתבות באתרים חב"דיים (חב"ד אינפו, חב"ד בישראל ועוד): '},
		{func: 'coords', sourcepage: 'Mediawiki:Common.js/coords.js', name: 'תבנית coord', description: 'יצירת תבנית coord ממפה של גוגל או עמוד ענן (ראו הוראות למטה): '}
	];
	var $ol = $("#bmList ol:first");
	$ol.contents().remove();
	$(bookmarklets).each(function(idx, item){
		$("<li>").text(item.description)
		.append(
			$("<a>",
				{
				"href": stubparts[0] + item.func + stubparts[1]+ item.sourcepage + stubparts[2] + item.func + stubparts[3],
				"click": bookmarlets_wrong,
				"text" : item.name
				}
			)
		).appendTo($ol)
	});
	
	function bookmarlets_wrong(e)
	{
		e.preventDefault();
		alert('את הקישור יש לגרור לסרגל המועדפים, ולהפעיל באתרים הנתמכים.\nקישור זה לא מיועד להפעלה מתוך חב"דפדיה. למידע נוסף קראו את ההוראות בדף.');
	}
	
};

$(create_bookmarklets);