אונטערשייד צווישן ווערסיעס פון "באַניצער:תנא קמא/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/static/favicon/wikisource.ico';


         // Helper: Convert Hebrew numeral to integer
         // Helper: Convert Hebrew numeral to integer
שורה 78: שורה 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;
שורה 86: שורה 88:
             // Construct Sefaria URL
             // Construct Sefaria URL
             var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefariaNames.english) + '.' + perek + '.' + pasuk;
             var sefariaUrl = 'https://www.sefaria.org/' + encodeURIComponent(sefariaNames.english) + '.' + perek + '.' + pasuk;
            // Create and append the Sefaria icon
            var sefariaIcon = $('<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;">');
            $link.after(sefariaIcon);


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


             // Construct Wikisource URL (Hebrew names and numbers as-is)
             // Construct Wikisource URL (Hebrew names and numbers as-is)
שורה 110: שורה 96:
     'קטגוריה:' + encodeURIComponent(sefer + '_' + perekRaw + '_' + pasukRaw);
     'קטגוריה:' + encodeURIComponent(sefer + '_' + perekRaw + '_' + pasukRaw);


             // Create and append the Wikisource icon
             // Construct Wikisource URL (Hebrew names and numbers as-is)
            var wikiSourceIcon = $('<a>')
            var wikiSourceUrl = 'https://he.wikisource.org/wiki/' + 'קטגוריה:' + encodeURIComponent(sefer + '_' + perek + '_' + pasuk);
                .attr('href', wikiSourceUrl)
 
                .attr('target', '_blank')
                    // Create a button to toggle the visibility of the icons
                .attr('title', 'עפן אין ויקיטקסט')
                    var button = $('<button>')
                .html('<img src="https://he.wikisource.org/static/favicon/wikisource.ico" alt="Wikisource" style="width:12px; height:12px; vertical-align:middle; margin-left: 3px;">');
                        .text('Show Sources')
            $link.after(wikiSourceIcon);
                        .css({
                            'padding': '5px 10px',
                            'background': '#4CAF50',
                            'color': 'white',
                            'border': 'none',
                            'cursor': 'pointer',
                            'border-radius': '5px',
                            'margin-top': '5px'
                        });
 
                    // Create the icon container (hidden initially)
                    var iconContainer = $('<div>')
                        .addClass('icon-container')
                        .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
                    $link.after(button).after(iconContainer);
 
                    // 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
                    );
                }
            }
        });
    });
});
});