summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2014-11-27 18:31:59 +0900
committerSean Whitton <spwhitton@spwhitton.name>2014-11-27 18:31:59 +0900
commit73aa705142af2eda2b88d52e82b19a84f5548f2d (patch)
tree93f7b89ccdc6c0e797525177a969d2a63a4364d5
parent1c5dcd53d386ae72f549dc942e784b85e6161842 (diff)
downloadschoolclock-73aa705142af2eda2b88d52e82b19a84f5548f2d.tar.gz
feature: backup information about classes to text area for copying and
pasting into a text document
-rw-r--r--index.html4
-rw-r--r--js/main.js35
2 files changed, 39 insertions, 0 deletions
diff --git a/index.html b/index.html
index b31a6c1..a737b00 100644
--- a/index.html
+++ b/index.html
@@ -102,8 +102,12 @@
<div class="col-md-2">
<br>
<p><a id="reset-clocks" class="btn btn-default">Reset all times</a></p>
+ <p><a id="backup-to-textarea" class="btn btn-default">Backup data</a></p>
</div>
</div>
+ <div class="row">
+ <div id="backup" class="col-md-6"></div>
+ </div>
</div> <!-- /container -->
<script src="js/vendor/jquery-1.11.1.min.js"></script>
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('<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();
});