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

ק
הגהה
אין תקציר עריכה
צייכן: צוריקגעשטעלט
ק (הגהה)
 
(14 מיטלסטע ווערסיעס פון 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';
         var wikiSourceFavicon = 'https://he.wikisource.org/static/favicon/wikisource.ico';
שורה 54: שורה 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' },
שורה 73: שורה 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;


            // Map Hebrew book name to Sefaria's naming convention
             var seferNames = bookNameMapping[sefer];
             var sefariaNames = bookNameMapping[sefer];
             if (!seferNames) return;
             if (sefariaNames) {
                // Construct Sefaria URL
                var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefariaNames.english) + '.' + encodeURIComponent(perek) + '.' + encodeURIComponent(pasuk);


                // Map Hebrew book name to AlHaTorah's naming convention
            var perek = hebrewNumeralToInt(perekRaw);
                var alHaTorahNames = bookNameMapping[sefer];
            var pasuk = (pasukRaw && pasukRaw.trim() !== '') ? hebrewNumeralToInt(pasukRaw) : null;
                if (alHaTorahNames) {
                    // Construct AlHaTorah URL
                    var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(alHaTorahNames.alHaTorah) +
                        '/' + encodeURIComponent(perek) +
                        '.' + encodeURIComponent(pasuk);


                    // Construct Wikisource URL (Hebrew names and numbers as-is)
            // Construct Sefaria URL
                    var wikiSourceUrl = 'https://he.wikisource.org/wiki/' +
            var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(seferNames.english) + '.' + perek;
                        'קטגוריה:' + encodeURIComponent(sefer + '_' + perek + '_' + pasuk);
            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 a button to toggle the visibility of the icons
            // Create container span for the icons
                    var button = $('<button>')
            var $container = $('<span class="tanach-icons" style="white-space: nowrap; margin-right: 4px;"></span>');
                        .text('Show Sources')
                        .css({
                            'padding': '5px 10px',
                            'background': '#4CAF50',
                            'color': 'white',
                            'border': 'none',
                            'cursor': 'pointer',
                            'border-radius': '5px',
                            'margin-top': '5px'
                        });


                    // Create the icon container (hidden initially)
            // Create and append the Sefaria icon
                    var iconContainer = $('<div>')
            var sefariaIcon = $('<a>')
                        .addClass('icon-container')
                .attr('href', sefariaUrl)
                        .css('display', 'none')
                .attr('target', '_blank')
                        .append(
                .attr('title', 'עפן אין ספריא')
                            $('<a>')
                .html('<img src="' + sefariaFavicon + '" alt="Sefaria" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                                .attr('href', sefariaUrl)
            $container.append(sefariaIcon);
                                .attr('target', '_blank')
                                .attr('title', 'עפן אין ספריא')
                                .html('<img src="' + sefariaFavicon + '" alt="Sefaria" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">'),
                            $('<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;">'),
                            $('<a>')
                                .attr('href', wikiSourceUrl)
                                .attr('target', '_blank')
                                .attr('title', 'עפן אין ויקיטקסט')
                                .html('<img src="' + wikiSourceFavicon + '" alt="Wikisource" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">')
                        );


                    // Add button and icon container after the link
            // Create and append the AlHaTorah icon
                    $link.after(button).after(iconContainer);
            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);


                    // Toggle the visibility of the icons when the button is clicked
            // Create and append the Wikisource icon
                    button.click(function () {
            var wikiSourceIcon = $('<a>')
                        iconContainer.toggle();
                .attr('href', wikiSourceUrl)
                    });
                .attr('target', '_blank')
                .attr('title', 'עפן אין ויקיטקסט')
                .html('<img src="' + wikiSourceFavicon + '" alt="Wikisource" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
            $container.append(wikiSourceIcon);


                    // Optionally, show the icons on hover
            // Insert the container before the original link
                    $link.hover(
            $link.before($container);
                        function () { iconContainer.show(); }, // Show icons on hover
                        function () { iconContainer.hide(); }  // Hide icons when not hovering
                    );
                }
            }
         });
         });
     });
     });
});
});