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

ק
הגהה
אין תקציר עריכה
ק (הגהה)
 
(27 מיטלסטע ווערסיעס פון 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';


         // Define the mapping between Sefaria and AlHaTorah book names
        // 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
         const bookNameMapping = {
         const bookNameMapping = {
             'Genesis': 'Bereshit',
             'בראשית': { english: 'Genesis', alHaTorah: 'Bereshit' },
             'Exodus': 'Shemot',
             'שמות': { english: 'Exodus', alHaTorah: 'Shemot' },
             'Leviticus': 'Vayikra',
             'ויקרא': { english: 'Leviticus', alHaTorah: 'Vayikra' },
             'Numbers': 'Bemidbar',
             'במדבר': { english: 'Numbers', alHaTorah: 'Bemidbar' },
             'Deuteronomy': 'Devarim',
             'דברים': { english: 'Deuteronomy', alHaTorah: 'Devarim' },
             'Joshua': 'Yehoshua',
             'יהושע': { english: 'Joshua', alHaTorah: 'Yehoshua' },
             'Judges': 'Shofetim',
             'שופטים': { english: 'Judges', alHaTorah: 'Shofetim' },
             'Samuel I': 'Shemuel I',
             'שמואל א': { english: 'I_Samuel', alHaTorah: 'Shemuel_I' },
             'Samuel II': 'Shemuel II',
             'שמואל ב': { english: 'II_Samuel', alHaTorah: 'Shemuel_II' },
             'Kings I': 'Melakhim I',
             'מלכים א': { english: 'I_Kings', alHaTorah: 'Melakhim_I' },
             'Kings II': 'Melakhim II',
             'מלכים ב': { english: 'II_Kings', alHaTorah: 'Melakhim_II' },
             'Isaiah': 'Yeshayahu',
             'ישעיהו': { english: 'Isaiah', alHaTorah: 'Yeshayahu' },
             'Jeremiah': 'Yirmeyahu',
             'ירמיהו': { english: 'Jeremiah', alHaTorah: 'Yirmeyahu' },
             'Ezekiel': 'Yechezkel',
             'יחזקאל': { english: 'Ezekiel', alHaTorah: 'Yechezkel' },
             'Hosea': 'Hoshea',
             'הושע': { english: 'Hosea', alHaTorah: 'Hoshea' },
             'Joel': 'Yoel',
             'יואל': { english: 'Joel', alHaTorah: 'Yoel' },
             'Amos': 'Amos',
             'עמוס': { english: 'Amos', alHaTorah: 'Amos' },
             'Obadiah': 'Ovadyah',
             'עובדיה': { english: 'Obadiah', alHaTorah: 'Ovadyah' },
             'Jonah': 'Yonah',
             'יונה': { english: 'Jonah', alHaTorah: 'Yonah' },
             'Micah': 'Mikhah',
             'מיכה': { english: 'Micah', alHaTorah: 'Mikhah' },
             'Nahum': 'Nachum',
             'נחום': { english: 'Nahum', alHaTorah: 'Nachum' },
             'Habakkuk': 'Chavakkuk',
             'חבקוק': { english: 'Habakkuk', alHaTorah: 'Chavakkuk' },
             'Zephaniah': 'Zephanyah',
             'צפניה': { english: 'Zephaniah', alHaTorah: 'Zephanyah' },
             'Haggai': 'Chaggai',
             'חגי': { english: 'Haggai', alHaTorah: 'Chaggai' },
             'Zechariah': 'Zekharyah',
             'זכריה': { english: 'Zechariah', alHaTorah: 'Zekharyah' },
             'Malachi': 'Malakhi',
             'מלאכי': { english: 'Malachi', alHaTorah: 'Malakhi' },
             'Psalms': 'Tehillim',
             'תהלים': { english: 'Psalms', alHaTorah: 'Tehillim' },
             'Proverbs': 'Mishlei',
             'משלי': { english: 'Proverbs', alHaTorah: 'Mishlei' },
             'Job': 'Iyyov',
             'איוב': { english: 'Job', alHaTorah: 'Iyyov' },
             'Song of Songs': 'Shir HaShirim',
             'שיר השירים': { english: 'Song_of_Songs', alHaTorah: 'Shir_HaShirim' },
             'Ruth': 'Rut',
             'רות': { english: 'Ruth', alHaTorah: 'Rut' },
             'Lamentations': 'Eikhah',
             'איכה': { english: 'Lamentations', alHaTorah: 'Eikhah' },
             'Ecclesiastes': 'Kohelet',
             'קהלת': { english: 'Ecclesiastes', alHaTorah: 'Kohelet' },
             'Esther': 'Esther',
             'אסתר': { english: 'Esther', alHaTorah: 'Esther' },
             'Daniel': 'Daniel',
             'דניאל': { english: 'Daniel', alHaTorah: 'Daniel' },
             'Ezra': 'Ezra',
             'עזרא': { english: 'Ezra', alHaTorah: 'Ezra' },
             'Nehemiah': 'Nechemyah',
             'נחמיה': { english: 'Nehemiah', alHaTorah: 'Nechemyah' },
             'Chronicles I': 'Divrei HaYamim I',
             'דברי הימים א': { english: 'I_Chronicles', alHaTorah: 'Divrei HaYamim_I' },
             'Chronicles II': 'Divrei HaYamim II'
             'דברי הימים ב': { english: 'II_Chronicles', alHaTorah: 'Divrei HaYamim_II' }
         };
         };


שורה 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 Sefaria book name to AlHaTorah's naming convention
             // Create and append the Wikisource icon
             var alHaTorahSefer = bookNameMapping[sefer];
             var wikiSourceIcon = $('<a>')
            if (alHaTorahSefer) {
                .attr('href', wikiSourceUrl)
                 // Construct AlHaTorah URL
                 .attr('target', '_blank')
                 var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(alHaTorahSefer) +
                 .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);
            }
         });
         });
     });
     });
});
});