-
-
Save rickcnagy/11099867 to your computer and use it in GitHub Desktop.
Deletes a specific custom semester from all transcripts - DeleteSemesterFromTranscript.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DeleteSemesterFromTranscript.js.txt | |
// Rick Nagy | |
// 2014-04-19 | |
// | |
// run via js console | |
function init() { | |
stopAsap = false; | |
$(window).keypress(function(e) { | |
if (e.which === 3) { | |
stopAsap = true; | |
} | |
}); | |
openRecord($( ".dataTableContentRow" ).eq(getStart() - 1)); | |
} | |
function getStart() { | |
var startRow = prompt('Starting row?', '1'); | |
if (startRow === null) quit(); | |
return parseInt(startRow); | |
} | |
function nextRecord(row) { | |
openRecord(row.next()); | |
} | |
function openRecord(row) { | |
if (validRow(row)) { | |
row.children( ":last" ).click(); | |
afterLoad(interactWithRecord, row); | |
} else { | |
nextRecord(row); | |
} | |
} | |
function validRow(row) { | |
return true; | |
} | |
function interactWithRecord(row) { | |
var target = $( "td:contains(First Semester):contains(2012):contains(2013)" ); | |
if (target.length === 0) { | |
close(row); | |
} else { | |
target.eq(-2).click() | |
$( ".item:contains(Delete custom semester)" ).click() | |
afterLoad(saveAndClose, row); | |
} | |
} | |
function saveAndClose(row) { | |
$( "button:contains('Save & Close')" ).click(); | |
afterLoad(nextRecord, row); | |
} | |
function close(row) { | |
$( ".demotedButtonWidget:contains(Close)" ).click(); | |
afterLoad(nextRecord, row); | |
} | |
function quit() { | |
while ($( "*:contains('Close')" ).length > 0) { | |
$( "*:contains('Close'):last" ).click(); | |
} | |
throw new Error("Aborted JS"); | |
} | |
function afterLoad(callback, param) { | |
if (stopAsap) quit(); | |
else { | |
var loading = setInterval(function() { | |
if ($( "*[class^='load']:not('.ribbonSelectorWidget *'):visible" ).length === 0) { | |
clearInterval(loading); | |
callback(param); | |
} | |
}, 10, param); | |
} | |
} | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment