@woodyloody/

Html and JS Practice

HTML, CSS, JS

Html and JS Practice

fork
loading
Files
  • index.html
  • s.jpeg
  • script.js
  • style.css

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.29242167352553294","path":"index.html","file":{"path":"index.html","content":{"asEncoding":{"base64":"PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPHNjcmlwdD4KZnVuY3Rpb24gc2V0Q29va2llKGNuYW1lLGN2YWx1ZSxleGRheXMpIHsKICB2YXIgZCA9IG5ldyBEYXRlKCk7CiAgZC5zZXRUaW1lKGQuZ2V0VGltZSgpICsgKGV4ZGF5cyoyNCo2MCo2MCoxMDAwKSk7CiAgdmFyIGV4cGlyZXMgPSAiZXhwaXJlcz0iICsgZC50b0dNVFN0cmluZygpOwogIGRvY3VtZW50LmNvb2tpZSA9IGNuYW1lICsgIj0iICsgY3ZhbHVlICsgIjsiICsgZXhwaXJlcyArICI7cGF0aD0vIjsKfQoKZnVuY3Rpb24gZ2V0Q29va2llKGNuYW1lKSB7CiAgdmFyIG5hbWUgPSBjbmFtZSArICI9IjsKICB2YXIgZGVjb2RlZENvb2tpZSA9IGRlY29kZVVSSUNvbXBvbmVudChkb2N1bWVudC5jb29raWUpOwogIHZhciBjYSA9IGRlY29kZWRDb29raWUuc3BsaXQoJzsnKTsKICBmb3IodmFyIGkgPSAwOyBpIDwgY2EubGVuZ3RoOyBpKyspIHsKICAgIHZhciBjID0gY2FbaV07CiAgICB3aGlsZSAoYy5jaGFyQXQoMCkgPT0gJyAnKSB7CiAgICAgIGMgPSBjLnN1YnN0cmluZygxKTsKICAgIH0KICAgIGlmIChjLmluZGV4T2YobmFtZSkgPT0gMCkgewogICAgICByZXR1cm4gYy5zdWJzdHJpbmcobmFtZS5sZW5ndGgsIGMubGVuZ3RoKTsKICAgIH0KICB9CiAgcmV0dXJuICIiOwp9CgpmdW5jdGlvbiBjaGVja0Nvb2tpZSgpIHsKICB2YXIgdXNlcj1nZXRDb29raWUoInVzZXJuYW1lIik7CiAgaWYgKHVzZXIgIT0gIiIpIHsKICAgIGFsZXJ0KCJXZWxjb21lIGFnYWluICIgKyB1c2VyKTsKICB9IGVsc2UgewogICAgIHVzZXIgPSBwcm9tcHQoIlBsZWFzZSBlbnRlciB5b3VyIG5hbWU6IiwiIik7CiAgICAgaWYgKHVzZXIgIT0gIiIgJiYgdXNlciAhPSBudWxsKSB7CiAgICAgICBzZXRDb29raWUoInVzZXJuYW1lIiwgdXNlciwgMzApOwogICAgIH0KICB9Cn0KPC9zY3JpcHQ+CjwvaGVhZD4KCjxib2R5IG9ubG9hZD0iY2hlY2tDb29raWUoKSI+PC9ib2R5PgoKPC9odG1sPgoK"},"asBuffer":null},"loaded":true}}
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
<!DOCTYPE html>
<html>
<head>
<script>
function setCookie(cname,cvalue,exdays) {
  var d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  var expires = "expires=" + d.toGMTString();
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for(var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}

function checkCookie() {
  var user=getCookie("username");
  if (user != "") {
    alert("Welcome again " + user);
  } else {
     user = prompt("Please enter your name:","");
     if (user != "" && user != null) {
       setCookie("username", user, 30);
     }
  }
}
</script>
</head>

<body onload="checkCookie()"></body>

</html>

result
console