MediaWiki:Gadget-ContestHelper.js

/** * Provides a pop-up dialog box to allow for easy submission of revisions to one of Nookipedia's contests. * Created by Jake on Nookipedia (https://nookipedia.com/wiki/User:Jake) * Licensed under CC BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/) * (However, likely not applicable for use outside of Nookipedia) **/

// Check if revision eligible for contest submission if(mw.config.get('wgPostEdit') == 'saved'){ $.getJSON("/page/contest-api/?action=latest_revision", function(latest_revision){       if(mw.config.get('wgRevisionId') == latest_revision.revision_id){        	displayContestPrompt;        }    }); }

// Display prompt for eligible revision function displayContestPrompt{ mw.notify( $( 'Would you like to submit this edit to the currently running edit contest? Yes No Later ', { autoHideSeconds: 20 } ) ); $("#submit-button").click(submitRevision); $("#hide-button").click(hideRevision); }

// Handle callbacks function submitRevision{ var revision_data = {"revision_id":mw.config.get('wgRevisionId'), "hidden":0}; var data = $.post('/page/contest-api/?action=submit_revision', revision_data, function(data, textStatus){		if(data.status == 1){			mw.notify( 'Your edit has been submitted successfully!' );		}else{			alert('There was a problem when submitting your edit. Please try your submission again using the contest dashboard.');		}	}, "json"); }

function hideRevision{ var revision_data = {"revision_id":mw.config.get('wgRevisionId'), "hidden":1}; var data = $.post('/page/contest-api/?action=submit_revision', revision_data, function(data, textStatus){		if(data.status == 1){			mw.notify( 'Your edit has been hidden from this contest.' );		}else{			alert('There was a problem when hiding your edit. Please try hiding your submission again using the contest dashboard.');		}	}, "json"); }