Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4353149b8f
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 128 lines (110 sloc) 4.575 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
<!DOCTYPE html>
<html manifest="timeloop.appcache">

  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Time Loops</title>
    <link rel="stylesheet" href="assets/jquery.mobile-1.0b3.min.css" >
    <script src="assets/jquery-1.6.3.min.js"></script>
    <script src="assets/jquery.mobile-1.0b3.min.js"></script>
    <script type="text/javascript" src="assets/jstorage.js"></script>
    <script type="text/javascript" src="assets/date.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
          // If the user was offline, and goes online, ask
          // the server for updates
          $(window).bind("online", remoteUpdate);
          // If the user is online, ask for updates now
          if(window.navigator.onLine) remoteUpdate();
          function remoteUpdate() {
            alert("Updated!");
          }
          showPreviousTasks();
          $('#flush-storage').click( function() {
            $.jStorage.flush();
            console.log('All records flushed!');
            });
          if (findCurrentTask()) {
            $('#task-start').hide();
            formatRunningTaskTitle(findCurrentTask());
          } else {
            $('#task-stop').hide();
          }

          if ($.jStorage.storageAvailable()) {

            $('#task-start').click( function() {
                $(this).hide();
                $('#task-stop').show();
                rightNow = new Date.now();
                formatRunningTaskTitle(rightNow);
                $.jStorage.set(rightNow.toISOString(), '');
                });
            $('#task-stop').click(function() {
                $(this).hide();
                $('#task-start').show();
                rightNow = new Date.now();
                $('#pageTitle').html('No current task');
                $.jStorage.set(findCurrentTask(), rightNow.toISOString());
                var li = $('.tasks li');
                li.fadeOut('fast', function() { li.remove(); });
                showPreviousTasks();
                remoteUpdate();
                });
          }
          function findCurrentTask() {
            var currentTask = false;
            index = $.jStorage.index();
            $.each(index, function(n, startTime) {
                startingDate = Date.parse(startTime);
                console.log(startTime, startingDate);

                endTime = $.jStorage.get(startTime);
                if (endTime == '') {
                currentTask = startTime;
                return false;
                }
                });
            return currentTask;
          }

          function formatRunningTaskTitle(timeStamp) {
            currentTime = timeStamp.toString('HH:mm');

            $('#pageTitle').html( 'Task running from <strong>' + currentTime + '</strong>.');
          }
          function showPreviousTasks() {
            index = $.jStorage.index();
            $.each(index, function(n, startTime) {

                endTime = $.jStorage.get(startTime);
                if (endTime != '') {
                console.log(startTime);
                $(".tasks").append('<li><strong>Start:</strong> ' + startTime.toString('HH:mm') + '. <strong>End:</strong> ' + endTime + '.</li>');
                }
                });
            $('ul').listview('refresh');
          }

      });

    </script>
</head>

<body>

  <!-- Start of first page: #one -->
  <div data-role="page" id="foo">

    <div data-role="header" class="ui-bar">
      <select name="select-choice-0" class="ui-btn-right" id="select-choice-1">
        <option value="en">English</option>
        <option value="ru">Russian</option>
        <option value="fin">Finland</option>
      </select>
    </div>
    <div data-role="content" id="one">
    <p><img src="assets/logo.png"></p>

      <h2 id="pageTitle">No current task</h2>

      <a href="#" id="task-start" class="" data-role="button" data-icon="arrow-r" data-inline="true" >Start task</a>
      <a href="#" id="task-stop" class="hidden" data-role="button" data-icon="check" data-inline="true" >Stop task</a>
      <p>Previous tasks:</p>
      <ul class="tasks" data-role="listview" data-inset="true">
      </ul>

    </div><!-- /content -->
    <div data-role="footer" class="ui-bar">
    <a href="#" id="flush-storage" data-role="button" data-icon="delete">Clear records</a>
    <a href="#" id="flush-storage" data-role="button" data-icon="refresh">Submit records</a>
    </div>

  </div><!-- /page one -->

</body>
</html>
Something went wrong with that request. Please try again.