diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2014-11-27 18:31:59 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2014-11-27 18:31:59 +0900 |
commit | 73aa705142af2eda2b88d52e82b19a84f5548f2d (patch) | |
tree | 93f7b89ccdc6c0e797525177a969d2a63a4364d5 /js | |
parent | 1c5dcd53d386ae72f549dc942e784b85e6161842 (diff) | |
download | schoolclock-73aa705142af2eda2b88d52e82b19a84f5548f2d.tar.gz |
feature: backup information about classes to text area for copying and
pasting into a text document
Diffstat (limited to 'js')
-rw-r--r-- | js/main.js | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -387,6 +387,41 @@ $(document).ready(function(){ updateClasses(); }); + $('#backup-to-textarea').button(); + $('#backup-to-textarea').click(function (){ + var text = ""; + var i = 0; + for (i = 0; i < classes.length; i++) + { + text = text + + 'Class: ' + + classes[i].grade + + '-' + + classes[i].clas + + "\t" + + 'Points: ' + + classes[i].points + + "\t" + + 'Time wasted this week so far (seconds): ' + + classes[i].time + + "\n"; + } + $('#backup').html('<textarea id="backup-textarea">' + text + "</textarea>"); + + // select all text in the textarea on click: http://stackoverflow.com/a/5797700 + $("#backup-textarea").focus(function() { + var $this = $(this); + $this.select(); + + // Work around Chrome's little problem + $this.mouseup(function() { + // Prevent further mouseup intervention + $this.unbind("mouseup"); + return false; + }); + }); + }); + updateClasses(); }); |