User:Thetrick/tfd helper/close.js

// /*********** TfD Helper - basic **********/ /* see User:Thetrick/tfd_helper     */ /* based on User:Jnothman/afd_helper */

importScript("User:Thetrick/tfd_helper/automodtfdh.js"); var tfdh_signature; var tfdh_advanced; var tfdh_multi;

/* this function runs at load */ function tfd_close_helper { if (tfdh_advanced == null) tfdh_advanced = false; if (tfdh_multi == null) tfdh_multi = false; if (tfdh_signature == null) tfdh_signature = ''+'~' /* add close links */ if (wgCanonicalNamespace == 'Project') { var title = wgTitle; if (title.match(new RegExp('eletion'))) { var anchors = document.getElementById('bodyContent').getElementsByTagName('a'); var url_re = new RegExp("title=Wikipedia:Templates_for_deletion\/Log\/([^&]+)\&action=edit\&section="); for (var i=0; i < anchors.length; i++) { /* this match is touchy because main page and individual logs display differently */ if ( !(anchors[i].href.match(url_re)) || (anchors[i].href.match(/section=1$/)) || (anchors[i].href.match(/section=T-1$/)) ) continue; var na = document.createElement('a'); na.href = "javascript:tfd_close('" + escape(anchors[i].href) + "')"; na.title = "Close this nomination"; na.innerHTML = " &bull; close"; anchors[i].parentNode.insertBefore(na, anchors[i].nextSibling); }       }    } } /* closing function - close a TfD nomination */ function tfd_close(edit_link) { var result = window.prompt("Enter the result (Keep, Delete, No consensus, Redirect, Merge, Already deleted, Already redirected):", ""); if (!result) return; var reason = window.prompt("Provide an rationale for the action:", ""); if (!reason) return; var edit_sum = window.prompt("Provide an edit summary for the action:", "Closing"); if (!edit_sum) return; //if window.open(edit_link + '&tfdaddbefore=' + escape("" + result + ""+ tfdh_signature + " " + "" + "~") + '&tfdsummary=' + escape(edit_sum), 'tfdv1'); }

/* run a register function */ $(tfd_close_helper); //bits of test code sit here //   var yes_no = window.prompt('Here is the url', amtfdh_make_url(here, here, here, here)); //   return; //