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

ק
הגהה
אין תקציר עריכה
ק (הגהה)
 
(26 מיטלסטע ווערסיעס פון 2 באַניצער נישט געוויזן.)
שורה 2: שורה 2:
     $(document).ready(function () {
     $(document).ready(function () {
         // Define favicon URLs
         // Define favicon URLs
         var sefariaFavicon = 'https://www.sefaria.org/static/icons/favicon.ico';
         var sefariaFavicon = 'https://www.sefaria.org/static/icons/library/favicon.svg';
         var alHaTorahFavicon = 'https://mg.alhatorah.org/favicon.ico';
         var alHaTorahFavicon = 'https://mg.alhatorah.org/favicon.ico';
        var wikiSourceFavicon = 'https://he.wikisource.org/static/favicon/wikisource.ico';
        // Helper: Convert Hebrew numeral to integer
        function hebrewNumeralToInt(hebrew) {
            const gematria = {
                'א': 1, 'ב': 2, 'ג': 3, 'ד': 4, 'ה': 5,
                'ו': 6, 'ז': 7, 'ח': 8, 'ט': 9,
                'י': 10, 'כ': 20, 'ל': 30, 'מ': 40, 'נ': 50,
                'ס': 60, 'ע': 70, 'פ': 80, 'צ': 90,
                'ק': 100, 'ר': 200, 'ש': 300, 'ת': 400
            };
            // Remove gershayim/geresh
            hebrew = hebrew.replace(/["״׳']/g, '');
            let total = 0;
            for (const letter of hebrew) {
                total += gematria[letter] || 0;
            }
            return total;
        }


         // Define the mapping between Hebrew book names and their English and AlHaTorah equivalents
         // Define the mapping between Hebrew book names and their English and AlHaTorah equivalents
שורה 33: שורה 54:
             'זכריה': { english: 'Zechariah', alHaTorah: 'Zekharyah' },
             'זכריה': { english: 'Zechariah', alHaTorah: 'Zekharyah' },
             'מלאכי': { english: 'Malachi', alHaTorah: 'Malakhi' },
             'מלאכי': { english: 'Malachi', alHaTorah: 'Malakhi' },
             'תהילים': { english: 'Psalms', alHaTorah: 'Tehillim' },
             'תהלים': { english: 'Psalms', alHaTorah: 'Tehillim' },
             'משלי': { english: 'Proverbs', alHaTorah: 'Mishlei' },
             'משלי': { english: 'Proverbs', alHaTorah: 'Mishlei' },
             'איוב': { english: 'Job', alHaTorah: 'Iyyov' },
             'איוב': { english: 'Job', alHaTorah: 'Iyyov' },
שורה 52: שורה 73:
             var $link = $(this);
             var $link = $(this);
             var sefer = $link.data('sefer');
             var sefer = $link.data('sefer');
             var perek = $link.data('perek');
             var perekRaw = $link.data('perek');
             var pasuk = $link.data('pasuk');
             var pasukRaw = $link.attr('data-pasuk');


             // Ensure the necessary data exists
             // Ensure the necessary data exists
             if (!sefer || !perek || !pasuk) return;
             if (!sefer || !perekRaw) return;
 
            var seferNames = bookNameMapping[sefer];
            if (!seferNames) return;
 
            var perek = hebrewNumeralToInt(perekRaw);
            var pasuk = (pasukRaw && pasukRaw.trim() !== '') ? hebrewNumeralToInt(pasukRaw) : null;


             // Construct Sefaria URL
             // Construct Sefaria URL
             var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefer) + '.' + encodeURIComponent(perek) + '.' + encodeURIComponent(pasuk);
             var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(seferNames.english) + '.' + perek;
            if (pasuk !== null) {
                sefariaUrl += '.' + pasuk;
            }
 
            // Construct AlHaTorah URL
            var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(seferNames.alHaTorah) + '/' + perek;
            if (pasuk !== null) {
                alHaTorahUrl += '.' + pasuk;
            }
 
            // Construct Wikisource URL
            var wikiSourceUrl = 'https://he.wikisource.org/wiki/' + encodeURIComponent(sefer + '_' + perekRaw);
            if (pasukRaw && pasukRaw.trim() !== '') {
                wikiSourceUrl += '_' + pasukRaw;
            }
 
            // Create container span for the icons
            var $container = $('<span class="tanach-icons" style="white-space: nowrap; margin-right: 4px;"></span>');


             // Create and append the Sefaria icon
             // Create and append the Sefaria icon
שורה 67: שורה 112:
                 .attr('title', 'עפן אין ספריא')
                 .attr('title', 'עפן אין ספריא')
                 .html('<img src="' + sefariaFavicon + '" alt="Sefaria" 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;">');
             $link.after(sefariaIcon);
             $container.append(sefariaIcon);
 
            // Create and append the AlHaTorah icon
            var alHaTorahIcon = $('<a>')
                .attr('href', alHaTorahUrl)
                .attr('target', '_blank')
                .attr('title', 'עפן אין על התורה')
                .html('<img src="' + alHaTorahFavicon + '" alt="AlHaTorah" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
            $container.append(alHaTorahIcon);


             // Map Hebrew book name to AlHaTorah's naming convention
             // Create and append the Wikisource icon
             var alHaTorahNames = bookNameMapping[sefer];
             var wikiSourceIcon = $('<a>')
            if (alHaTorahNames) {
                .attr('href', wikiSourceUrl)
                 // Construct AlHaTorah URL
                 .attr('target', '_blank')
                 var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(alHaTorahNames.alHaTorah) +
                 .attr('title', 'עפן אין ויקיטקסט')
                    '/' + encodeURIComponent(perek) +
                .html('<img src="' + wikiSourceFavicon + '" alt="Wikisource" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                    '.' + encodeURIComponent(pasuk);
            $container.append(wikiSourceIcon);


                // Create and append the AlHaTorah icon
            // Insert the container before the original link
                var alHaTorahIcon = $('<a>')
            $link.before($container);
                    .attr('href', alHaTorahUrl)
                    .attr('target', '_blank')
                    .attr('title', 'עפן אין על התורה')
                    .html('<img src="' + alHaTorahFavicon + '" alt="AlHaTorah" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                $link.after(alHaTorahIcon);
            }
         });
         });
     });
     });
});
});