-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
72 lines (70 loc) · 3.14 KB
/
script.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function f(){
const month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
let d = new Date();
document.getElementById("dat").innerHTML ="<span>"+ month[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear()+"</span>";
let a = d.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric',second:'2-digit', hour12: true });
document.getElementById("tme").innerHTML = "<span>" + a + "</span>";
}
setInterval(f,0);
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
function h(){
document.getElementById("frm").reset();
document.getElementById("dbx").style.visibility = "visible";
document.getElementById("dbx").style.opacity = "1";
}
function g(){
document.getElementById("dbx").style.visibility = "hidden";
document.getElementById("dbx").style.opacity = "0";
}
function formf(){
document.getElementById("dbx").style.visibility = "hidden";
document.getElementById("dbx").style.opacity = "0";
let fv = document.forms['f1']['tsk'].value;
let t = document.forms['f1']['tme'].value;
let b = `<div class="row" id = "nt">
<div class="col" id = "tt"><span>${t} | ${fv}</span></div>
<div class="col text-end " >
<button type="button" class="edt btn btn-info" >Edit</button>
<button type="button" class="delt btn btn-success">Delete</button>
<button type="button" class="mkd btn btn-success">Mark Done</button>
</div>
</div>`
document.getElementById("task").innerHTML+=b;
return false;
}
//jquery
$(document).ready(function(){
$(document).click(function(event){
if($(event.target).attr('class') === "delt btn btn-success"){
event.target.parentNode.parentNode.remove();
}else if($(event.target).attr('class') === "mkd btn btn-success"){
$(event.target.parentNode.parentNode).css("background-color", "lime");
event.target.innerHTML= "✔";
}else if($(event.target).attr('class') === "edt btn btn-info"){
//alert(event.target.parentNode.previousElementSibling.firstChild.tagName);
if(event.target.parentNode.previousElementSibling.firstChild.tagName === "SPAN"){
let aa = event.target.parentNode.previousElementSibling.firstChild.innerHTML;
let d = `<form name = "f2">
<textarea id = "updt" name = "uu">${aa}</textarea>
</form>`
event.target.parentNode.previousElementSibling.innerHTML = d;
event.target.innerHTML = "Done";
}else{
let v = document.forms['f2']['uu'].value;
let uv = `<span>${v} </span>`;
event.target.parentNode.previousElementSibling.innerHTML = uv;
event.target.innerHTML = "Edit";
}
}
});
});