Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1013955 // Test putting computer id in localStorage

HTML

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<div id="data"></div>
<script>
  function makeComputerID() {
    var text = "";
    var possible = "abcdefghijklmnopqrstuvwxyz";

    for (var i = 0; i < 12; i++)
      text += possible.charAt(Math.floor(Math.random() * possible.length));
    return text;
  }
  
  var id = localStorage.getItem('computer-id');
  $("#data").html("Computer ID: " + id);
  if (id == null || id.length != 12) {
    id = makeComputerID();
    localStorage.setItem('computer-id', id);
    $("#data").append("<br>ID set to: " + id);
  }
</script>

Author comment

Began life as a copy of #1013944

download  render html  show line numbers   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013955
Snippet name: Test putting computer id in localStorage
Eternal ID of this version: #1013955/6
Text MD5: 8c6438cd1a0338f940b9af0507a8fab6
Author: stefan
Category: javax / web
Type: HTML
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-03 16:47:01
Source code size: 607 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 311 / 202
Version history: 5 change(s)
Referenced in: [show references]