Team:TU-Delft/SynBioData

From 2013.igem.org

(Difference between revisions)
Line 4: Line 4:
{{:Team:TU-Delft/Templates/Logo}}
{{:Team:TU-Delft/Templates/Logo}}
 +
 +
<!DOCTYPE HTML>
<html>
<html>
-
<script>
+
<head>
-
var db = null;
+
<script type="text/javascript">
-
function html5_storage_support() {
+
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
-
  try {
+
var msg;
-
    return 'localStorage' in window && window['localStorage'] == null;
+
db.transaction(function (tx) {
-
  } catch (e) {
+
  tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
-
    return false;
+
  tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
-
  }
+
   tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
-
}
+
  msg = '<p>Log message created and row inserted.</p>';
-
//CHECK TO SEE IF THE BROWSER IS COMPATIBLE
+
  document.querySelector('#status').innerHTML = msg;
-
if (!html5_storage_support) {
+
});
-
  alert("This Might Be a Good Time to Upgrade Your Browser or Turn On Jeavascript");
+
-
} else {
+
-
 
+
-
//OPEN AND OR CREATE THE DATABASE ON THE USERS MACHINE
+
-
db = openDatabase("MyContacts", "1", "My Personal Contacts", 100000);
+
-
 
+
-
function storeMyContact(id) {
+
-
var fullname = document.getElementById('fullname').innerHTML;
+
-
var phone = document.getElementById('phone').innerHTML;
+
-
var email = document.getElementById('email').innerHTML;
+
-
localStorage.setItem('mcFull',fullname);
+
-
localStorage.setItem('mcPhone',phone);
+
-
localStorage.setItem('mcEmail',email);
+
-
}
+
-
   //GET STORED VALUES FROM KEYS TO DEFINE JAVASCRIPT VALUES OR DEFINE IF THEY DO NOT EXIST
+
-
  function getMyContact() {
+
-
    if ( localStorage.getItem('mcFull')) {
+
-
      var fullname = localStorage.getItem('mcFull');
+
-
      var phone = localStorage.getItem('mcPhone');
+
-
      var email = localStorage.getItem('mcEmail');
+
-
    }
+
-
    else {
+
-
      var fullname = 'Click And Enter A Name';
+
-
      var phone = 'Click And Enter A Phone Number';
+
-
      var email = 'Click And Enter An Email Address';
+
-
    }
+
-
    document.getElementById('fullname').innerHTML = fullname;
+
-
    document.getElementById('phone').innerHTML = phone;
+
-
    document.getElementById('email').innerHTML = email;
+
-
  }
+
-
  function clearLocal() {
+
db.transaction(function (tx) {
-
    clear: localStorage.clear();
+
  tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
-
    return false;
+
  var len = results.rows.length, i;
-
  }
+
  msg = "<p>Found rows: " + len + "</p>";
-
}
+
  document.querySelector('#status').innerHTML += msg;
-
</script>
+
  for (i = 0; i < len; i++){
-
<div id="myContacts">
+
    msg = "<p><b>" + results.rows.item(i).log + "</b></p>";
-
  <div>N: <span id="fullname" contenteditable="true" onkeyup="storeMyContact(this.id)"></span></div>
+
    document.querySelector('#status').innerHTML += msg;
-
  <div>P: <span id="phone" contenteditable="true" onkeyup="storeMyContact(this.id)"></span></div>
+
  }
-
  <div>E: <span id="email" contenteditable="true" onkeyup="storeMyContact(this.id)"></span></div>
+
}, null);
-
  <div><a onclick="clearLocal(); getMyContact();" href="javascript:void(0);">Clear All Of My Data</a></div>
+
});
-
</div>
+
-
<script>
+
-
  getMyContact();
+
</script>
</script>
 +
</head>
 +
<body>
 +
<div id="status" name="status">Status Message</div>
 +
</body>
</html>
</html>

Revision as of 08:58, 2 September 2013


<!DOCTYPE HTML>

Status Message