forked from justaprogrammer/ObjectId.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Objectid.html
41 lines (40 loc) · 2.09 KB
/
Objectid.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ObjectId Test Page</title>
<script type="text/javascript" src="Objectid.js"></script>
<meta name="copyright" CONTENT="© 2011 Justin Dearing">
</head>
<body>
<form method="post" action="Objectid.html" onsubmit="return false;">
<p><label>Timestamp</label><input type="text" id="timeStamp" size="60" /></p>
<p><label>Machine</label><input type="text" id="machine" size="50" /></p>
<p><label>Pid</label><input type="text" id="pid" size="50" /></p>
<p><label>Increment</label><input type="text" id="increment" size="50" /></p>
<p><input type="button" value="Generate new Id" onclick="generateNewId()"/></p>
</form>
<span id="rawObject"></span>
<hr/>
<div id="copyrightNotice">Copyright 2011 <a href="mailto:[email protected]">Justin Dearing</a> Licensed under both the <a href="MIT.License.md">MIT License<a> and <a href="GPL-v2.License.md">GPL v2 License<a></div>
<script type="text/javascript">
function generateNewId() {
var objectId = new ObjectId();
document.getElementById("timeStamp").value = objectId.getDate();
document.getElementById("machine").value = objectId.machine;
document.getElementById("pid").value = objectId.pid;
document.getElementById("increment").value = objectId.increment;
if (typeof (JSON) == 'object' && typeof (JSON.stringify) == 'function') {
var txtNode = document.createTextNode('Raw: ');
var element = document.createElement('pre').appendChild(document.createTextNode(JSON.stringify(objectId)));
var rawObject = document.getElementById("rawObject");
while (rawObject.childNodes.length > 0) {
rawObject.removeChild(rawObject.childNodes[0]);
}
rawObject.appendChild(txtNode);
rawObject.appendChild(element);
}
}
</script>
</body>
</html>