-
-
Save titaniumbones/34594a187f191addd517fae12942550a to your computer and use it in GitHub Desktop.
does some munging on the versionista UI to simplify click-through process
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
/ How far back to go, in milliseconds (7 days = 604800000 ms). | |
var threshold = new Date() - 604800000; | |
$('#siteView tbody tr').filter(function () { | |
// Only add click handlers on the links to pages that have previous versions and that have changed recently. | |
return parseInt($('td:eq(6)', this).text()) > 1 && new Date($('td:eq(8)', this).text()) >= threshold; | |
}).find('td:eq(3)').css('background-color', '#ff0').end().each(function () { | |
// Change the behavior of the link in the "URL" column. | |
var a = $('a:eq(1)', this); | |
a.click(function (event) { | |
// Stop the original link from opening. | |
event.preventDefault(); | |
// Download the page at the original link. | |
var url = 'https://versionista.com' + a.attr('href'); | |
$.get(url, function (data) { | |
// The timestamps and version IDs are stored in the HTML. | |
var timestamp_regex = /"fst":"(\d+)"/g; | |
var version_regex = /"cid":"(\d+)"/g; | |
var timestamps = []; | |
while ((match = timestamp_regex.exec(data)) !== null) { | |
timestamps.push(parseInt(match[1]) * 1000); | |
} | |
var versions = []; | |
while ((match = version_regex.exec(data)) !== null) { | |
versions.push(match[1]); | |
} | |
var compare_to_version = '0'; | |
timestamps.slice(1).forEach(function (timestamp, i) { | |
if (timestamp >= threshold) { | |
compare_to_version = versions[i + 1]; | |
} | |
}); | |
window.open(url + versions[0] + ':' + compare_to_version + '/', '_blank').focus(); | |
}) | |
}); | |
}); |
For reference, the spreadsheet that people are filling in has the columns: Index,Who found this,Date/Time,Agency,Page Name,URL,Page View URL,Comparison URL,Description of Change,Similar Changes,IA Corroboration,PageFreeze Corroboration,Marks as Example of Significant Change,Mark as example of Exemplary Change
Consider adding code to add a button to the comparison page that would fill in (Who found this
would need to be configured by a bookmarklet generator): Who found this,Date/Time,Agency,Page Name,URL,Page View URL,Comparison URL
Note: Development is now at https://github.com/edgi-govdata-archiving/version-tracking-ui
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@titaniumbones Missing
/
at start of first line :)