MediaWiki:Common.js: Difference between revisions

From Seven Sages of Rome
No edit summary
Tag: Reverted
No edit summary
 
(46 intermediate revisions by the same user not shown)
Line 1: Line 1:
function drilldownswitcher() {
function drilldownswitcher() {
     $('#drilldown-switch:contains("Show all filters")').length
     $('#drilldown-switch:contains("Show all filters")').length ? ($(".drilldown-filter-values:has(a)").css("display", "block"),
        ? ($(".drilldown-filter-values:has(a)").css("display", "block"),
             $(".drilldown-values-toggle").each(function () {
             $(".drilldown-values-toggle").each(function () {
                 $("img").each(function () {
                 $("img").each(function () {
Line 19: Line 18:
$(document).ready(function () {
$(document).ready(function () {
     $(".drilldown-results").css({ "-webkit-filter": "blur(0)", "-moz-filter": "blur(0)", "-o-filter": "blur(0)", "-ms-filter": "blur(0)", filter: "blur(0)" }), $(".drilldown-filter-values:has(a)").css("display", "none");
     $(".drilldown-results").css({ "-webkit-filter": "blur(0)", "-moz-filter": "blur(0)", "-o-filter": "blur(0)", "-ms-filter": "blur(0)", filter: "blur(0)" }), $(".drilldown-filter-values:has(a)").css("display", "none");
    $('<br /><h3 class="drilldown-pre-header">1. Selected Filters</h3>').insertBefore("#drilldown-applied-filters"),
    $('<h3 class="drilldown-pre-filters">2. Available Filters</h3>').insertBefore("#drilldown-applicable-filters"),
    $('<h3 class="drilldown-post-filters">3. Filtered Results</h3>').insertAfter("#drilldown-applicable-filters"),
    $('<html><div class="drilldown-btn-wrapper"><a class="btn primary-btn" href="javascript:;" onclick="drilldownswitcher()" id="drilldown-switch">Show all filters <i class="fa fa-plus"></i></a></div></html>').insertBefore("#drilldown-filters");
    $(".drilldown-values-toggle").each(function () {
    $("img").each(function () {
        $(this).attr("src", $(this).attr("src").replace("down-arrow.png", "right-arrow.png"));
    });
    });
    if( mw.storage.get( "wip-dismissed" ) === null || JSON.parse(mw.storage.get( "wip-dismissed" )) === false){
    $( ".wip-alert" ).fadeIn( "slow", function() {});
    }
   
    $( "#close-wip" ).on( "click", function() {
  mw.storage.set( "wip-dismissed", true );
  $( ".wip-alert" ).fadeOut( "slow", function() {});
    } );
})
})
$(document).ready(function () {
$(document).ready(function () {
     $("#drilldown-header").next().remove(),
     $('#copyButton').on('click', function () {
         $('<br /><h3 class="drilldown-pre-header">1. Selected Filters</h3>').insertBefore("#drilldown-header"),
         var targetPage = $("#targetPageInput").val().trim();
         $('<h3 class="drilldown-pre-filters">2. Available Filters</h3>').insertBefore(".drilldown-filters"),
         var embeddedStories = $("#embeddedStoryTemplates").text();
         $('<h3 class="drilldown-post-filters">3. Filtered Results</h3>').insertAfter(".drilldown-filters"),
 
         $(
         if (!targetPage) {
             '<htmL><div class="drilldown-btn-wrapper"><a class="btn primary-btn" href="javascript:;" onclick="drilldownswitcher()" id="drilldown-switch">Show all filters <i class="fa fa-plus"></i></a></div></html>'
            alert("Please select a target page.");
         ).insertBefore(".drilldown-filters");
            return;
})
        }
$(document).ready(function () {
 
    $(".drilldown-values-toggle").each(function () {
         if (!embeddedStories) {
         $("img").each(function () {
             alert("No EmbeddedStory templates found on the source page.");
             $(this).attr("src", $(this).attr("src").replace("down-arrow.png", "right-arrow.png"));
            return;
        }
 
        // Confirm action
         if (!confirm("Are you sure you want to copy the EmbeddedStory templates to " + targetPage + "?")) {
            return;
        }
 
        // Use MediaWiki API to append templates to the target page
        $.post(mw.util.wikiScript('api'), {
            action: 'edit',
            title: targetPage,
            appendtext: "\n" + embeddedStories,
            token: mw.user.tokens.get('csrfToken'),
            format: 'json'
         })
        .done(function (data) {
             if (data && data.edit && data.edit.result === 'Success') {
                alert("EmbeddedStory templates copied successfully to " + targetPage + "!");
            } else {
                alert("An error occurred: " + (data.error && data.error.info));
            }
        })
        .fail(function () {
            alert("An error occurred while trying to copy the EmbeddedStory templates.");
         });
         });
     });
     });
})
});

Latest revision as of 20:18, 13 November 2024

function drilldownswitcher() {
    $('#drilldown-switch:contains("Show all filters")').length ? ($(".drilldown-filter-values:has(a)").css("display", "block"),
            $(".drilldown-values-toggle").each(function () {
                $("img").each(function () {
                    $(this).attr("src", $(this).attr("src").replace("right-arrow.png", "down-arrow.png"));
                });
            }),
            (document.getElementById("drilldown-switch").innerHTML = 'Hide all filters <i class="fa fa-minus"></i>'))
        : $('#drilldown-switch:contains("Hide all filters")').length &&
        ($(".drilldown-filter-values:has(a)").css("display", "none"),
            $(".drilldown-values-toggle").each(function () {
                $("img").each(function () {
                    $(this).attr("src", $(this).attr("src").replace("down-arrow.png", "right-arrow.png"));
                });
            }),
            (document.getElementById("drilldown-switch").innerHTML = 'Show all filters <i class="fa fa-plus"></i>'));
}
$(document).ready(function () {
    $(".drilldown-results").css({ "-webkit-filter": "blur(0)", "-moz-filter": "blur(0)", "-o-filter": "blur(0)", "-ms-filter": "blur(0)", filter: "blur(0)" }), $(".drilldown-filter-values:has(a)").css("display", "none");
    $('<br /><h3 class="drilldown-pre-header">1. Selected Filters</h3>').insertBefore("#drilldown-applied-filters"),
    $('<h3 class="drilldown-pre-filters">2. Available Filters</h3>').insertBefore("#drilldown-applicable-filters"),
    $('<h3 class="drilldown-post-filters">3. Filtered Results</h3>').insertAfter("#drilldown-applicable-filters"),
    $('<html><div class="drilldown-btn-wrapper"><a class="btn primary-btn" href="javascript:;" onclick="drilldownswitcher()" id="drilldown-switch">Show all filters <i class="fa fa-plus"></i></a></div></html>').insertBefore("#drilldown-filters");
    $(".drilldown-values-toggle").each(function () {
    	$("img").each(function () {
        	$(this).attr("src", $(this).attr("src").replace("down-arrow.png", "right-arrow.png"));
    	});
    });

    if( mw.storage.get( "wip-dismissed" ) === null || JSON.parse(mw.storage.get( "wip-dismissed" )) === false){
    	$( ".wip-alert" ).fadeIn( "slow", function() {});
    }
    
    $( "#close-wip" ).on( "click", function() {
	  mw.storage.set( "wip-dismissed", true );
	  $( ".wip-alert" ).fadeOut( "slow", function() {});
    } );
})
$(document).ready(function () {
    $('#copyButton').on('click', function () {
        var targetPage = $("#targetPageInput").val().trim();
        var embeddedStories = $("#embeddedStoryTemplates").text();

        if (!targetPage) {
            alert("Please select a target page.");
            return;
        }

        if (!embeddedStories) {
            alert("No EmbeddedStory templates found on the source page.");
            return;
        }

        // Confirm action
        if (!confirm("Are you sure you want to copy the EmbeddedStory templates to " + targetPage + "?")) {
            return;
        }

        // Use MediaWiki API to append templates to the target page
        $.post(mw.util.wikiScript('api'), {
            action: 'edit',
            title: targetPage,
            appendtext: "\n" + embeddedStories,
            token: mw.user.tokens.get('csrfToken'),
            format: 'json'
        })
        .done(function (data) {
            if (data && data.edit && data.edit.result === 'Success') {
                alert("EmbeddedStory templates copied successfully to " + targetPage + "!");
            } else {
                alert("An error occurred: " + (data.error && data.error.info));
            }
        })
        .fail(function () {
            alert("An error occurred while trying to copy the EmbeddedStory templates.");
        });
    });
});