Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Here's the object I'm trying to JSON.stringify
- var collection = function () {
- this.keys = [];
- this.events = [];
- var timer;
- var starttime;
- var stoptime;
- var key_definition = function () {
- return {
- id: -1,
- label: null,
- description: null,
- letter: null,
- position: -1,
- type: -1
- };
- }
- this.newkey = function(id0, label0, description0, letter0, position0, type0) {
- this.keys.push(key_definition());
- var key = this.keys[this.keys.length-1];
- key.id = id0;
- key.label = label0;
- key.description = description0;
- key.letter = letter0;
- key.position = position0;
- key.type = type0;
- }
- var event_definition = function() {
- //this.eventstream.push({event: this.element.buttondefinition,type: this.element.buttontype,state: this.element.buttonstate,time: ms_time});
- return {
- time: -1,
- buttonid: -1,
- state: -1 //0 off, 1 on
- };
- }
- this.newevent = function(time0, id0, state0) {
- console.log("newevent");
- this.events.push(event_definition());
- var event = this.events[this.events.length-1];
- event.time = time0;
- event.id = id0;
- event.state = state0;
- }
- };
- var cc = new collection();
- Here's the section where i try to stringify it:
- var str;
- str = "<body>";
- str += "<a href=selectkey.php?collectscreen=1><p>Reload</p></a>";
- str += "<a href=selectkey.php><p>Select Key File</p></a>";
- str += "<p>data</p><hr>\n";
- for (var i = 0; i < cc.events.length; i++) {
- str += cc.events[i].time + " " + cc.keys[cc.events[i].id].label + " " + cc.events[i].id + " " + cc.events[i].state + "<br>\n";
- }
- str += "<p><hr>";
- str += JSON.stringify(cc);
- str += "</body>";
- document.write(str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement