Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var addShit = function() {
- var list = document.getElementById("list");
- var input = document.getElementById("inputText");
- var li = document.createElement("li");
- li.appendChild(getTimestamp(input.value.toString()));
- input.value = "";
- list.appendChild(li);
- };
- var getTimestamp = function (text) {
- var d = new Date();
- var fd = {
- h: d.getHours().toString(),
- m: d.getMinutes().toString(),
- s: d.getSeconds().toString(),
- }
- for (var prop in fd) {
- if (fd[prop].length === 1) {
- fd[prop] = "0" + fd[prop];
- }
- }
- var prf = fd.h + ":" + fd.m + " - ";
- var p = document.createElement("p");
- p.innerHTML = prf + text;
- return p;
- };
- </script>
- <ul id=list>
- </ul>
- <button onclick="addShit()"> add </button>
- <input id=inputText onkeydown="if (event.keyCode == 13) {addShit();}" ></input>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement