Skip to content

Instantly share code, notes, and snippets.

@wolph
Last active July 19, 2016 09:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wolph/6a6f1887dd1318684901 to your computer and use it in GitHub Desktop.
Due to either incompetence or unwillingness of computer futures it seems impossible to add worksheet hours in a normal way, this script makes it easier by making the hours pasteable. Just paste them as 1 line per day and start time + end time split by space. Note, it only supports 1 start/stop time per day currently.
// ==UserScript==
// @name Computer Futures Worksheet Filler
// @namespace http://wol.ph/
// @version 1.1
// @description
// @match https://worksheets.computerfutures.com/index.php?dir=timesheet*
// @match http://worksheets.computerfutures.com/index.php?dir=timesheet*
// @copyright 2015, Wolph
// @run-at document-end
// ==/UserScript==
var text = $('<textarea id="text">');
var parent = $('div#cwsUnderTopBar');
parent.append(text);
console.log(parent);
function get(id){
id = id.replace(/([\[\]])/g, '\\$1');
console.log('looking for %s', id);
return $(id);
}
function update(e){
console.log(e);
var lines = $('textarea#text').val().split('\n');
var i = lines.length;
while(i--){
var times = lines[i].split('\t');
get('#tsGrid[' + i + '][0][from]').val(times[0]);
get('#tsGrid[' + i + '][0][to]').val(times[1]);
}
}
text.bind('keyup', update);
text.bind('paste', function(e){
setTimeout(update);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment