-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtagpanel.js
50 lines (47 loc) · 1.31 KB
/
tagpanel.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
var tagname = document.getElementById('input-tag')
var submit = document.getElementById('tag-sub-btn')
submit.onclick = () =>
{
console.log(tagname.value);
var date = new Date()
console.log(date);
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
var hrs = today.getHours();
var mins = today.getMinutes();
var format="AM";
if(hrs>12)
{
hrs= hrs - 12;
format= "PM";
}
today = + dd + '-' + getMonths(mm) + '-' + yyyy;
today= today + " ( " + hrs + ':' + mins + ' ' + format + " )";
console.log(today);
var obj = Object();
obj.tagname = tagname.value;
obj.tagdate = today;
obj.tagflag = "1";
obj.tagcreator = document.getElementById('tagcreator').innerHTML;
console.log(obj);
var request = new XMLHttpRequest()
request.open('POST','/addtag')
request.setRequestHeader("Content-Type","application/json")
request.send(JSON.stringify(obj))
request.onload = function()
{
alert("added")
tagname.innerHTML = "";
}
}
function getMonths(monthno)
{
var month=["Jan","Feb","Mar","Apr","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
return month[monthno-1];
}
function opentaglist()
{
window.location = '/showtaglist'
}