Skip to content

Instantly share code, notes, and snippets.

@aereal
Created October 21, 2014 05:04
Show Gist options
  • Save aereal/53fc3ae5d0af91a542f6 to your computer and use it in GitHub Desktop.
Save aereal/53fc3ae5d0af91a542f6 to your computer and use it in GitHub Desktop.
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