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

פון המכלול
קפיצה לניווט קפיצה לחיפוש
אין תקציר עריכה
אין תקציר עריכה
צייכן: צוריקגעשטעלט
שורה 4: שורה 4:
         var sefariaFavicon = 'https://www.sefaria.org/static/icons/favicon.ico';
         var sefariaFavicon = 'https://www.sefaria.org/static/icons/favicon.ico';
         var alHaTorahFavicon = 'https://mg.alhatorah.org/favicon.ico';
         var alHaTorahFavicon = 'https://mg.alhatorah.org/favicon.ico';
        var wikisourceFavicon = 'https://he.wikisource.org/favicon.ico';


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


שורה 65: שורה 66:
                 .attr('href', sefariaUrl)
                 .attr('href', sefariaUrl)
                 .attr('target', '_blank')
                 .attr('target', '_blank')
                 .attr('title', 'עפן אין ספריא')
                 .attr('title', 'View on Sefaria')
                 .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);
             $link.after(sefariaIcon);


             // Map Hebrew book name to AlHaTorah's naming convention
             // Map Sefaria book name to AlHaTorah's naming convention
             var alHaTorahNames = bookNameMapping[sefer];
             var alHaTorahSefer = bookNameMapping[sefer];
             if (alHaTorahNames) {
             if (alHaTorahSefer) {
                 // Construct AlHaTorah URL
                 // Construct AlHaTorah URL
                 var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(alHaTorahNames.alHaTorah) +
                 var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(alHaTorahSefer) +
                     '/' + encodeURIComponent(perek) +
                     '/' + encodeURIComponent(perek) +
                     '.' + encodeURIComponent(pasuk);
                     '.' + encodeURIComponent(pasuk);
שורה 81: שורה 82:
                     .attr('href', alHaTorahUrl)
                     .attr('href', alHaTorahUrl)
                     .attr('target', '_blank')
                     .attr('target', '_blank')
                     .attr('title', 'עפן אין על התורה')
                     .attr('title', 'View on AlHaTorah')
                     .html('<img src="' + alHaTorahFavicon + '" alt="AlHaTorah" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                     .html('<img src="' + alHaTorahFavicon + '" alt="AlHaTorah" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                 $link.after(alHaTorahIcon);
                 $link.after(alHaTorahIcon);
            }
            // Map Sefaria book name to Wikisource's naming convention
            var wikisourceSefer = bookNameMapping[sefer];
            if (wikisourceSefer) {
                // Construct Wikisource URL
                var wikisourceUrl = 'https://he.wikisource.org/wiki/' + encodeURIComponent(wikisourceSefer) +
                    '_' + encodeURIComponent(perek) +
                    ':' + encodeURIComponent(pasuk);
                // Create and append the Wikisource icon
                var wikisourceIcon = $('<a>')
                    .attr('href', wikisourceUrl)
                    .attr('target', '_blank')
                    .attr('title', 'View on Wikisource')
                    .html('<img src="' + wikisourceFavicon + '" alt="Wikisource" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                $link.after(wikisourceIcon);
             }
             }
         });
         });
     });
     });
});
});

רעוויזיע פון 02:51, 4 אפריל 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 alHaTorahFavicon = 'https://mg.alhatorah.org/favicon.ico';
        var wikisourceFavicon = 'https://he.wikisource.org/favicon.ico';

        // Define the mapping between Sefaria and AlHaTorah book names
        const bookNameMapping = {
            'Genesis': 'בראשית',
            'Exodus': 'שמות',
            'Leviticus': 'ויקרא',
            'Numbers': 'במדבר',
            'Deuteronomy': 'דברים',
            'Joshua': 'יהושע',
            'Judges': 'שופטים',
            'Samuel I': 'שמואל א',
            'Samuel II': 'שמואל ב',
            'Kings I': 'מלכים א',
            'Kings II': 'מלכים ב',
            'Isaiah': 'ישעיהו',
            'Jeremiah': 'ירמיהו',
            'Ezekiel': 'יחזקאל',
            'Hosea': 'הושע',
            'Joel': 'יואל',
            'Amos': 'עמוס',
            'Obadiah': 'עובדיה',
            'Jonah': 'יונה',
            'Micah': 'מיכה',
            'Nahum': 'נחום',
            'Habakkuk': 'חבקוק',
            'Zephaniah': 'צפניה',
            'Haggai': 'חגי',
            'Zechariah': 'זכריה',
            'Malachi': 'מלאכי',
            'Psalms': 'תהילים',
            'Proverbs': 'משלי',
            'Job': 'איוב',
            'Song of Songs': 'שיר השירים',
            'Ruth': 'רות',
            'Lamentations': 'איכה',
            'Ecclesiastes': 'קהלת',
            'Esther': 'אסתר',
            'Daniel': 'דניאל',
            'Ezra': 'עזרא',
            'Nehemiah': 'נחמיה',
            'Chronicles I': 'דברי הימים א',
            'Chronicles II': 'דברי הימים ב'
        };

        // 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');

            // Ensure the necessary data exists
            if (!sefer || !perek || !pasuk) return;

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

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

            // Map Sefaria book name to AlHaTorah's naming convention
            var alHaTorahSefer = bookNameMapping[sefer];
            if (alHaTorahSefer) {
                // Construct AlHaTorah URL
                var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(alHaTorahSefer) +
                    '/' + encodeURIComponent(perek) +
                    '.' + encodeURIComponent(pasuk);

                // Create and append the AlHaTorah icon
                var alHaTorahIcon = $('<a>')
                    .attr('href', alHaTorahUrl)
                    .attr('target', '_blank')
                    .attr('title', 'View on AlHaTorah')
                    .html('<img src="' + alHaTorahFavicon + '" alt="AlHaTorah" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                $link.after(alHaTorahIcon);
            }

            // Map Sefaria book name to Wikisource's naming convention
            var wikisourceSefer = bookNameMapping[sefer];
            if (wikisourceSefer) {
                // Construct Wikisource URL
                var wikisourceUrl = 'https://he.wikisource.org/wiki/' + encodeURIComponent(wikisourceSefer) +
                    '_' + encodeURIComponent(perek) +
                    ':' + encodeURIComponent(pasuk);

                // Create and append the Wikisource icon
                var wikisourceIcon = $('<a>')
                    .attr('href', wikisourceUrl)
                    .attr('target', '_blank')
                    .attr('title', 'View on Wikisource')
                    .html('<img src="' + wikisourceFavicon + '" alt="Wikisource" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                $link.after(wikisourceIcon);
            }
        });
    });
});