Created
October 21, 2014 05:04
-
-
Save aereal/53fc3ae5d0af91a542f6 to your computer and use it in GitHub Desktop.
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
function numerize(numeric) { | |
return Number(numeric.trim().replace(/,\s*/, '')); | |
} | |
function getNetTotal() { | |
var contents = document.getElementById('contents'); | |
var totalTable = contents.querySelector('table:last-child'); | |
var total = totalTable.querySelector('tr:last-child td:last-child').textContent; | |
return numerize(total); | |
} | |
function getTotalDeduction() { | |
var contents = document.getElementById('contents'); | |
var deductionTable = contents.querySelector('table:nth-child(3)'); | |
var total = deductionTable.querySelector('tr:last-child td:last-child').textContent; | |
return numerize(total); | |
} | |
function object2JSONDataURInize (object) { | |
var json = JSON.stringify(object); | |
var chunk = ''; | |
chunk += 'data:application/json,'; | |
chunk += json; | |
return chunk; | |
} | |
+function () { | |
var result = { | |
netTotal: getNetTotal(), | |
deductionTotal: getTotalDeduction(), | |
}; | |
var uri = object2JSONDataURInize(result); | |
window.open(uri); | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment