אונטערשייד צווישן ווערסיעס פון "באַניצער:תנא קמא/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';
        // 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
שורה 52: שורה 72:
             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.data('pasuk');


             // Ensure the necessary data exists
             // Ensure the necessary data exists
             if (!sefer || !perek || !pasuk) return;
             if (!sefer || !perekRaw || !pasukRaw) return;
 
            var sefariaNames = bookNameMapping[sefer];
            if (!sefariaNames) return;


// Lookup
            var perek = hebrewNumeralToInt(perekRaw);
var names = bookNameMapping[sefer];
            var pasuk = hebrewNumeralToInt(pasukRaw);
if (names) {
    // Sefaria URL using English name
    var sefariaUrl = 'https://www.sefaria.org/' +
        encodeURIComponent(names.english) + '.' +
        encodeURIComponent(perek) + '.' +
        encodeURIComponent(pasuk);


    // Add Sefaria icon
            // Construct Sefaria URL
    var sefariaIcon = $('<a>')
            var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefariaNames.english) + '.' + perek + '.' + pasuk;
        .attr('href', sefariaUrl)
        .attr('target', '_blank')
        .attr('title', 'עפן אין ספריא')
        .html('<img src="' + sefariaFavicon + '" alt="Sefaria" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
    $link.after(sefariaIcon);


    // AlHaTorah URL using alHaTorah name
            // Create and append the Sefaria icon
    var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' +
            var sefariaIcon = $('<a>')
        encodeURIComponent(names.alHaTorah) + '/' +
                .attr('href', sefariaUrl)
        encodeURIComponent(perek) + '.' +
                .attr('target', '_blank')
        encodeURIComponent(pasuk);
                .attr('title', 'עפן אין ספריא')
                .html('<img src="' + sefariaFavicon + '" alt="Sefaria" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
            $link.after(sefariaIcon);


    // Add AlHaTorah icon
            // Construct AlHaTorah URL
    var alHaTorahIcon = $('<a>')
            var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(sefariaNames.alHaTorah) + '/' + perek + '.' + pasuk;
        .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);
}


            // 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;">');
            $link.after(alHaTorahIcon);
         });
         });
     });
     });
});
});