From 73aa705142af2eda2b88d52e82b19a84f5548f2d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 27 Nov 2014 18:31:59 +0900 Subject: feature: backup information about classes to text area for copying and pasting into a text document --- index.html | 4 ++++ js/main.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/index.html b/index.html index b31a6c1..a737b00 100644 --- a/index.html +++ b/index.html @@ -102,8 +102,12 @@

Reset all times

+

Backup data

+
+
+
diff --git a/js/main.js b/js/main.js index 19de8f3..a898f98 100644 --- a/js/main.js +++ b/js/main.js @@ -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('"); + + // 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(); }); -- cgit v1.2.3