Skip to content

Instantly share code, notes, and snippets.

@DevotionGeo
Forked from codepo8/localstorage.js
Last active August 29, 2015 14:21
Show Gist options
  • Save DevotionGeo/a24ff248f9f137968e86 to your computer and use it in GitHub Desktop.
Save DevotionGeo/a24ff248f9f137968e86 to your computer and use it in GitHub Desktop.

Revisions

  1. @codepo8 codepo8 revised this gist Aug 26, 2010. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions localstorage.js
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,13 @@
    // test for localStorage support
    if(('localStorage' in window) && window['localStorage'] !== null){

    var f = document.getElementById('mainform');
    // test with PHP if the form was sent (the submit button has the name "sent")
    <?php if(isset($_POST['sent']))){?>

    // get the HTML of the form and cache it in the property "state"
    var f = document.getElementById('mainform');
    localStorage.setItem('state',f.innerHTML);
    }


    // if the form hasn't been sent...
    <?php }else{ ?>

  2. @codepo8 codepo8 revised this gist Aug 26, 2010. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion localstorage.js
    Original file line number Diff line number Diff line change
    @@ -20,4 +20,5 @@

    <?php } ?>

    }</script>
    }
    </script>
  3. @codepo8 codepo8 renamed this gist Aug 26, 2010. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @codepo8 codepo8 revised this gist Aug 26, 2010. 1 changed file with 22 additions and 12 deletions.
    34 changes: 22 additions & 12 deletions localstorage.php
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,23 @@
    <script>
    if(('localStorage' in window) && window['localStorage'] !== null){
    <?php if(isset($_POST['sent']))){?>
    var f = document.getElementById('mainform');
    localStorage.setItem('state',f.innerHTML);
    }
    <?php }else{ ?>
    if('state' in localStorage){
    f.innerHTML = localStorage.getItem('state');
    }
    <?php } ?>
    }
    </script>
    // test for localStorage support
    if(('localStorage' in window) && window['localStorage'] !== null){

    // test with PHP if the form was sent (the submit button has the name "sent")
    <?php if(isset($_POST['sent']))){?>

    // get the HTML of the form and cache it in the property "state"
    var f = document.getElementById('mainform');
    localStorage.setItem('state',f.innerHTML);
    }

    // if the form hasn't been sent...
    <?php }else{ ?>

    // check if a state property exists and write back the HTML cache
    if('state' in localStorage){
    f.innerHTML = localStorage.getItem('state');
    }

    <?php } ?>

    }</script>
  5. @codepo8 codepo8 revised this gist Aug 25, 2010. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions localstorage.php
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,5 @@
    f.innerHTML = localStorage.getItem('state');
    }
    <?php } ?>
    }
    </script>
  6. @codepo8 codepo8 revised this gist Aug 25, 2010. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions localstorage.php
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    <script>
    if(('localStorage' in window) && window['localStorage'] !== null){
    <?php if(isset($_POST['sent']))){?>
    var f = document.getElementById('mainform');
    if(this.localStorage){
    localStorage.setItem('state',f.innerHTML);
    localStorage.setItem('state',f.innerHTML);
    }
    <?php }else{ ?>
    if(this.localStorage && localStorage.getItem('state')){
    if('state' in localStorage){
    f.innerHTML = localStorage.getItem('state');
    }
    <?php } ?>
  7. @codepo8 codepo8 revised this gist Aug 25, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions localstorage.php
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    <script>
    <?php if(isset($_POST['sent']))){?>
    var f = document.getElementById('mainform');
    if(localStorage){
    if(this.localStorage){
    localStorage.setItem('state',f.innerHTML);
    }
    <?php }else{ ?>
    if(localStorage && localStorage.getItem('state')){
    if(this.localStorage && localStorage.getItem('state')){
    f.innerHTML = localStorage.getItem('state');
    }
    <?php } ?>
  8. @codepo8 codepo8 revised this gist Aug 25, 2010. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions localstorage.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,12 @@
    <script>
    <?php if(isset($_POST['sent']))){?>
    var f = document.getElementById('mainform');
    if(localStorage){
    localStorage.setItem('state',f.innerHTML);
    }
    <?php }else{ ?>
    if(localStorage && localStorage.getItem('state')){
    f.innerHTML = localStorage.getItem('state');
    }
    if(localStorage && localStorage.getItem('state')){
    f.innerHTML = localStorage.getItem('state');
    }
    <?php } ?>
    </script>
  9. @codepo8 codepo8 created this gist Aug 25, 2010.
    10 changes: 10 additions & 0 deletions localstorage.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <?php if(isset($_POST['sent']))){?>
    var f = document.getElementById('mainform');
    if(localStorage){
    localStorage.setItem('state',f.innerHTML);
    }
    <?php }else{ ?>
    if(localStorage && localStorage.getItem('state')){
    f.innerHTML = localStorage.getItem('state');
    }
    <?php } ?>