Last active
February 15, 2022 12:13
-
-
Save cyrusn/8c55ff107fc95d31d420340a7b939ddf to your computer and use it in GitHub Desktop.
bookmarklet to sort school journal by classcode
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
javascript:(function(){ | |
let tables = document.getElementsByTagName("table"); | |
for (let table of tables) { | |
let stores = []; | |
const rows = table.tBodies[0].children; | |
for (let row of rows) { | |
const rowValue = row.children[0].innerText; | |
const matches = rowValue.match( | |
/^ +(\S+) +(\S+) +(\S+|\d\S\s{2}\S+) +(\d{1,2}\/\d{1,2}) .+(\d{2}-\d{2}) +(\d{2}:\d{2})$/, | |
); | |
if (matches) { | |
const attendance = matches[4].split("/"); | |
if (attendance[0] !== attendance[1]) | |
row.style.cssText += "background-color: #f2dede;"; | |
const classcode = matches[3]; | |
stores.push([classcode, row]); | |
} | |
} | |
stores.sort(function (x, y) { | |
return x[0].localeCompare(y[0]); | |
}); | |
for (var i = 0, len = stores.length; i < len; i++) { | |
table.appendChild(stores[i][1]); | |
} | |
stores = null; | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment