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

קיין רעדאגירונג באמערקונג
אין תקציר עריכה
צייכן: אַנולירונג
אין תקציר עריכה
שורה 79: שורה 79:
             if (!sefer || !perekRaw || !pasukRaw) return;
             if (!sefer || !perekRaw || !pasukRaw) return;


            // Map Hebrew book name to Sefaria's naming convention
             var sefariaNames = bookNameMapping[sefer];
             var sefariaNames = bookNameMapping[sefer];
             if (!sefariaNames) return;
             if (!sefariaNames) return;
שורה 89: שורה 88:
             var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefariaNames.english) + '.' + perek + '.' + pasuk;
             var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefariaNames.english) + '.' + perek + '.' + pasuk;


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


                    // Construct Wikisource URL (Hebrew names and numbers as-is)
            // Construct AlHaTorah URL
                    var wikiSourceUrl = 'https://he.wikisource.org/wiki/' +
            var alHaTorahUrl = 'https://mg.alhatorah.org/Full/' + encodeURIComponent(sefariaNames.alHaTorah) + '/' + perek + '.' + pasuk;
                        'קטגוריה:' + encodeURIComponent(sefer + '_' + perek + '_' + pasuk);


                    // Create a button to toggle the visibility of the icons
            // Create and append the AlHaTorah icon
                    var button = $('<button>')
            var alHaTorahIcon = $('<a>')
                        .text('Show Sources')
                .attr('href', alHaTorahUrl)
                        .css({
                .attr('target', '_blank')
                            'padding': '5px 10px',
                .attr('title', 'עפן אין על התורה')
                            'background': '#4CAF50',
                .html('<img src="' + alHaTorahFavicon + '" alt="AlHaTorah" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                            'color': 'white',
            $link.after(alHaTorahIcon);
                            'border': 'none',
                            'cursor': 'pointer',
                            'border-radius': '5px',
                            'margin-top': '5px'
                        });


                    // Create the icon container (hidden initially)
            // Construct Wikisource URL (Hebrew names and numbers as-is)
                    var iconContainer = $('<div>')
            var wikiSourceUrl = 'https://he.wikisource.org/wiki/' +
                        .addClass('icon-container')
    'קטגוריה:' + encodeURIComponent(sefer + '_' + perekRaw + '_' + pasukRaw);
                        .css('display', 'none')
                        .append(
                            $('<a>')
                                .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;">'),
                            $('<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 Wikisource icon
                    $link.after(button).after(iconContainer);
            var wikiSourceIcon = $('<a>')
                .attr('href', wikiSourceUrl)
                .attr('target', '_blank')
                .attr('title', 'עפן אין ויקיטקסט')
                .html('<img src="' + wikiSourceFavicon + '" alt="AlHaTorah" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
            $link.after(wikiSourceIcon);


                    // Toggle the visibility of the icons when the button is clicked
                    button.click(function () {
                        iconContainer.toggle();
                    });
                    // Optionally, show the icons on hover
                    $link.hover(
                        function () { iconContainer.show(); }, // Show icons on hover
                        function () { iconContainer.hide(); }  // Hide icons when not hovering
                    );
                }
            }
         });
         });
     });
     });
});
});