אונטערשייד צווישן ווערסיעס פון "באַניצער:תנא קמא/tanachLinks.js"

פון המכלול
קפיצה לניווט קפיצה לחיפוש
אין תקציר עריכה
אין תקציר עריכה
שורה 5: שורה 5:
         var shituftaFavicon = 'https://shitufta.org.il/newGigLogo.svg';
         var shituftaFavicon = 'https://shitufta.org.il/newGigLogo.svg';


         // Find all links that use the תנ"ך template (Shitufta links)
         // Iterate over each Tanakh citation link
         $('a[href*="shitufta.org.il"]').each(function () {
         $('.tanach-citation').each(function () {
             var $link = $(this);
             var $link = $(this);
             var href = $link.attr('href');
             var sefer = $link.data('sefer');
            var perek = $link.data('perek');
            var pasuk = $link.data('pasuk');


             // Extract book and chapter from the Shitufta URL
             // Construct the Sefaria URL
             var match = href.match(/shitufta\.org\.il\/([^\/]+)\/([^\/]+)/);
             var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefer) + '.' + encodeURIComponent(perek) + '.' + encodeURIComponent(pasuk);
            if (match) {
                var book = decodeURIComponent(match[1]);
                var chapter = decodeURIComponent(match[2]);


                // Construct Sefaria URL
            // Create the Shitufta icon link
                var sefariaUrl = 'https://www.sefaria.org/' + book + '.' + chapter;
            var shituftaIcon = $('<a>')
                .attr('href', $link.attr('href'))
                .attr('target', '_blank')
                .attr('title', 'Go to Shitufta')
                .html('<img src="' + shituftaFavicon + '" alt="Shitufta" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');


                // Create the Shitufta icon link
            // Create the Sefaria icon link
                var shituftaIcon = $('<a>')
            var sefariaIcon = $('<a>')
                    .attr('href', href)
                .attr('href', sefariaUrl)
                    .attr('target', '_blank')
                .attr('target', '_blank')
                    .attr('title', 'Go to Shitufta')
                .attr('title', 'Go to Sefaria')
                    .html('<img src="' + shituftaFavicon + '" alt="Shitufta" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                .html('<img src="' + sefariaFavicon + '" alt="Sefaria" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');


                // Create the Sefaria icon link
            // Append icons next to the link
                var sefariaIcon = $('<a>')
            $link.after(shituftaIcon, sefariaIcon);
                    .attr('href', sefariaUrl)
                    .attr('target', '_blank')
                    .attr('title', 'Go to Sefaria')
                    .html('<img src="' + sefariaFavicon + '" alt="Sefaria" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
 
                // Append icons **next to** the link instead of replacing it
                $link.after(shituftaIcon, sefariaIcon);
            }
         });
         });
     });
     });
});
});

רעוויזיע פון 23:54, 3 אפריל 2025

mw.loader.using(['mediawiki.util', 'jquery'], function () {
    $(document).ready(function () {
        // Define favicon URLs
        var sefariaFavicon = 'https://www.sefaria.org/static/icons/favicon.ico';
        var shituftaFavicon = 'https://shitufta.org.il/newGigLogo.svg';

        // Iterate over each Tanakh citation link
        $('.tanach-citation').each(function () {
            var $link = $(this);
            var sefer = $link.data('sefer');
            var perek = $link.data('perek');
            var pasuk = $link.data('pasuk');

            // Construct the Sefaria URL
            var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefer) + '.' + encodeURIComponent(perek) + '.' + encodeURIComponent(pasuk);

            // Create the Shitufta icon link
            var shituftaIcon = $('<a>')
                .attr('href', $link.attr('href'))
                .attr('target', '_blank')
                .attr('title', 'Go to Shitufta')
                .html('<img src="' + shituftaFavicon + '" alt="Shitufta" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');

            // Create the Sefaria icon link
            var sefariaIcon = $('<a>')
                .attr('href', sefariaUrl)
                .attr('target', '_blank')
                .attr('title', 'Go to Sefaria')
                .html('<img src="' + sefariaFavicon + '" alt="Sefaria" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');

            // Append icons next to the link
            $link.after(shituftaIcon, sefariaIcon);
        });
    });
});