diff --git a/app.js b/app.js index c326c61..3f9bf44 100644 --- a/app.js +++ b/app.js @@ -2,89 +2,63 @@ /** * Module dependencies. */ +var eresult; var fs = require('fs'); var path = require('path'); var mongo = require('mongodb'); +var async = require('async'); var BSON = mongo.BSONPure; var db = require('mongoskin').db('localhost:27017/test'); var testcollection = db.collection('testcollection'); var exercisecollection = db.collection('exercisecollection'); -var expressocollection = db.collection('expressocollection'); -var hrdatacollection = db.collection('hrdatacollection'); var util = require('util'); -var formidable = require('formidable'); -var xml2js = require('xml2js'); -var parser = new xml2js.Parser(); +//var parser = new xml2js.Parser(); var dateFormat = require('dateformat'); var app = require('http').createServer(function handler(request, response) { console.log('request starting...;' + request.url); - // switch(request.url) { - // case '/upload': - // var form = new formidable.IncomingForm(), - // files = [], - // fields = []; + switch(request.url) { + + case '/admin': + + //var filePath = '.' + request.url; + //if (filePath == './') + filePath = './admin.html'; - // var tempdirectory = "/tmp/"; + var extname = path.extname(filePath); + var contentType = 'text/html'; + switch (extname) { + case '.js': + contentType = 'text/javascript'; + break; + case '.css': + contentType = 'text/css'; + break; + } + path.exists(filePath, function(exists) { - // // //tempdirectory changes if the operating system is windows - // if(process.platform == "windows") - // { - // tempdirectory = "c:\\temp\\"; - // } - // form.uploaddir = tempdirectory; - - // //tempDirectory = "c:\\Temp\\"; - // //form.uploadDir = tempDirectory; - - // form.on('error', function(err) { - // response.writeHead(200, {'content-type': 'text/plain'}); - // response.end('error:\n\n'+util.inspect(err)); - // }); - // form.on('field', function(field, value) { - // console.log(field, value); - // fields.push([field, value]); - // }); - // form.on('file', function(field, file) { - // console.log(field, file); - // files.push([field, file]); - // }); - // form.on('end', function() { - // console.log('-> upload done'); - // response.writeHead(200, {'content-type': 'text/plain'}); - // response.write('received fields:\n\n '+util.inspect(fields)); - // response.write('\n\n'); - // response.write('received files:\n\n '+util.inspect(files)); - // }); - - // form.parse(request, function(err, fields, files) { - // console.log('-> uploaded -' + files.upload.path); - // fs.readFile(files.upload.path, function(err, data) { - // parser.parseString(data, function (err, result) { - // response.write('received file contents:\n\n '); - // response.end(JSON.stringify(result)); - // console.log('Done'); - - // //hrdatacollectionJSON.stringify(result) - // var data = JSON.stringify(result); - // var buf1 = new Buffer(12); - // var dataid = JSON.parse(data).Activities.Activity.Id; - // var datadate = Date.parse(dataid); - // //console.log('TCX ID' + JSON.parse(data).Activities.Activity.Id); - // console.log('TCX ID ' + datadate); - // var document_id = new BSON.ObjectID(datadate); - // console.log('inserted BSONID ' + document_id); - // hrdatacollection.update({_id:document_id}, data,{upsert:true} , function(err, result) { - // if (err) throw err; - // }); - - // }); - // }); - // }); - // break; - // default: + if (exists) { + fs.readFile(filePath, function(error, content) { + if (error) { + response.writeHead(500); + response.end(); + } + else { + response.writeHead(200, { 'Content-Type': contentType }); + response.end(content, 'utf-8'); + } + }); + } + else { + response.writeHead(404); + response.end(); + } + }); + break; + // default case + default: var filePath = '.' + request.url; if (filePath == './') filePath = './index.html'; @@ -118,7 +92,7 @@ var app = require('http').createServer(function handler(request, response) { response.end(); } }); - // } + } }).listen(3000); @@ -129,10 +103,10 @@ io.set("transports", ["websocket"]); }); io.sockets.on('connection', function(socket) { - console.log('Client connected'); + // console.log('Client connected'); socket.on('getactivites', function(data) { - console.log('getactivites'); + // console.log('getactivites'); testcollection.find().toArray(function(err, result) { if (err) throw err; socket.emit('populateactivities', result); @@ -140,18 +114,57 @@ io.sockets.on('connection', function(socket) { }); /////////////////////////////////////// socket.on('getactivitybyid', function(id) { - console.log('getactivitybyid'); + // console.log('getactivitybyid'); + testcollection.findById(id, function(err, result) { if (err) throw err; - socket.emit('populateactivitybyid', result); + //console.log('Activity result = ' + JSON.stringify(result)); + //var unpackedresult = JSON.parse(result); + eresult= result; + // var i; + for(i in result.Activities.Activity.Lap) { + //console.log('Activity parse result = ' + JSON.stringify(item.val1)); + console.log('above_i = ' + i); + /////////////// + getdoc(result.Activities.Activity.Lap[i].selection, i, function(docdata, iteration) { + console.log(docdata); + eresult.Activities.Activity.Lap[iteration].execisename = docdata.exercise.name + eresult.Activities.Activity.Lap[iteration].execiseclass = docdata.exercise.class + eresult.Activities.Activity.Lap[iteration].execisemuscledata = docdata.exercise.muscledata + + if (iteration == result.Activities.Activity.Lap.length-1) + { + // console.log('fnal round' + iteration); + socket.emit('populateactivitybyid', result); + } + + }); + + //////////////////// + console.log('below_i = ' + i); + //console.log('DATA = ' + JSON.stringify(callback)); + }; + + }); }); +function getdoc(docid, iteration, callback) { + exercisecollection.findById(docid, function(err, exresult) { + if (err) throw err; + + console.log('docid = ' + docid); + console.log('inside_i = ' + iteration); + callback(exresult, iteration); + }); + +} + //////////////////////// socket.on('addactivity', function(data, docid) { - console.log('addactivity' + docid); - console.log('add_activity_data' + JSON.stringify(data)); + // console.log('addactivity' + docid); + // console.log('add_activity_data' + JSON.stringify(data)); if (docid === null) { var document_id = new BSON.ObjectID(); } @@ -159,7 +172,7 @@ io.sockets.on('connection', function(socket) { var document_id = new BSON.ObjectID(docid); } //var document_id = new BSON.ObjectID(docid); - console.log('inserted BSONID' + document_id); + // console.log('inserted BSONID' + document_id); testcollection.update({_id:document_id}, data,{upsert:true} , function(err, result) { if (err) throw err; exercisecollection.find().toArray(function(err, result) { @@ -183,16 +196,17 @@ io.sockets.on('connection', function(socket) { }); /////////////////// socket.on('getexercises', function(data) { - console.log('emit exercises'); + // console.log('emit exercises'); exercisecollection.find().toArray(function(err, result) { if (err) throw err; socket.emit('populateexercises', result); }); }); +///////////////////// socket.on('updateexercises', function(data, docid) { - console.log('updateexecises' + JSON.stringify(data)); + // console.log('updateexecises' + JSON.stringify(data)); if (docid == 'undefined') { - console.log('edited updateexecises' + JSON.stringify(data)); + //console.log('edited updateexecises' + JSON.stringify(data)); exercisecollection.insert(data, function(err, result) { if (err) throw err; exercisecollection.find().toArray(function(err, result) { @@ -207,17 +221,44 @@ io.sockets.on('connection', function(socket) { if (err) throw err; exercisecollection.find().toArray(function(err, result) { if (err) throw err; - console.log('populateexercises'); + //console.log('populateexercises'); socket.emit('populateexercises', result); }); }); } }); - +//////////////////// + socket.on('getexercisebyid', function(id) { + // console.log('getexercisebyid'); + exercisecollection.findById(id, function(err, result) { + if (err) throw err; + socket.emit('populateexercisebyid', result); + }); + }); //////////////// + socket.on('delexercise', function(id) { + exercisecollection.removeById(id,function(err, reply){ + if (err) throw err; + exercisecollection.find().toArray(function(err, result) { + if (err) throw err; + socket.emit('populateexercises', result); + }); + }); + }); +////////////////// + /////////////////// + socket.on('getexerciselist', function(data) { + // console.log('emit exercises = ' + data); + exercisecollection.find({'exercise.class': data }).toArray(function(err, result) { + if (err) throw err; + //console.log('emited exercises = ' + JSON.stringify(result)); + socket.emit('populateexerciselist', data , result); + }); + }); +///////////////////// }); diff --git a/index.html b/index.html index 7f0a1cd..c9d9ed6 100644 --- a/index.html +++ b/index.html @@ -16,18 +16,15 @@ - - diff --git a/node_modules/xml2js/node_modules/sax/examples/test.xml b/node_modules/xml2js/node_modules/sax/examples/test.xml deleted file mode 100644 index 801292d..0000000 --- a/node_modules/xml2js/node_modules/sax/examples/test.xml +++ /dev/null @@ -1,1254 +0,0 @@ - - -]> - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - - Some Text - - - - - - - are ok in here. ]]> - - Pre-Text & Inlined text Post-text. -  - - \ No newline at end of file diff --git a/node_modules/xml2js/node_modules/sax/lib/sax.js b/node_modules/xml2js/node_modules/sax/lib/sax.js deleted file mode 100644 index abe58bb..0000000 --- a/node_modules/xml2js/node_modules/sax/lib/sax.js +++ /dev/null @@ -1,1016 +0,0 @@ -// wrapper for non-node envs -;(function (sax) { - -sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } -sax.SAXParser = SAXParser -sax.SAXStream = SAXStream -sax.createStream = createStream - -// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. -// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), -// since that's the earliest that a buffer overrun could occur. This way, checks are -// as rare as required, but as often as necessary to ensure never crossing this bound. -// Furthermore, buffers are only tested at most once per write(), so passing a very -// large string into write() might have undesirable effects, but this is manageable by -// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme -// edge case, result in creating at most one complete copy of the string passed in. -// Set to Infinity to have unlimited buffers. -sax.MAX_BUFFER_LENGTH = 64 * 1024 - -var buffers = [ - "comment", "sgmlDecl", "textNode", "tagName", "doctype", - "procInstName", "procInstBody", "entity", "attribName", - "attribValue", "cdata", "script" -] - -sax.EVENTS = // for discoverability. - [ "text" - , "processinginstruction" - , "sgmldeclaration" - , "doctype" - , "comment" - , "attribute" - , "opentag" - , "closetag" - , "opencdata" - , "cdata" - , "closecdata" - , "error" - , "end" - , "ready" - , "script" - , "opennamespace" - , "closenamespace" - ] - -function SAXParser (strict, opt) { - if (!(this instanceof SAXParser)) return new SAXParser(strict, opt) - - var parser = this - clearBuffers(parser) - parser.q = parser.c = "" - parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH - parser.opt = opt || {} - parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags; - parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase" - parser.tags = [] - parser.closed = parser.closedRoot = parser.sawRoot = false - parser.tag = parser.error = null - parser.strict = !!strict - parser.noscript = !!(strict || parser.opt.noscript) - parser.state = S.BEGIN - parser.ENTITIES = Object.create(sax.ENTITIES) - parser.attribList = [] - - // namespaces form a prototype chain. - // it always points at the current tag, - // which protos to its parent tag. - if (parser.opt.xmlns) parser.ns = Object.create(rootNS) - - // mostly just for error reporting - parser.trackPosition = parser.opt.position !== false - if (parser.trackPosition) { - parser.position = parser.line = parser.column = 0 - } - emit(parser, "onready") -} - -if (!Object.create) Object.create = function (o) { - function f () { this.__proto__ = o } - f.prototype = o - return new f -} - -if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) { - return o.__proto__ -} - -if (!Object.keys) Object.keys = function (o) { - var a = [] - for (var i in o) if (o.hasOwnProperty(i)) a.push(i) - return a -} - -function checkBufferLength (parser) { - var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10) - , maxActual = 0 - for (var i = 0, l = buffers.length; i < l; i ++) { - var len = parser[buffers[i]].length - if (len > maxAllowed) { - // Text/cdata nodes can get big, and since they're buffered, - // we can get here under normal conditions. - // Avoid issues by emitting the text node now, - // so at least it won't get any bigger. - switch (buffers[i]) { - case "textNode": - closeText(parser) - break - - case "cdata": - emitNode(parser, "oncdata", parser.cdata) - parser.cdata = "" - break - - case "script": - emitNode(parser, "onscript", parser.script) - parser.script = "" - break - - default: - error(parser, "Max buffer length exceeded: "+buffers[i]) - } - } - maxActual = Math.max(maxActual, len) - } - // schedule the next check for the earliest possible buffer overrun. - parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual) - + parser.position -} - -function clearBuffers (parser) { - for (var i = 0, l = buffers.length; i < l; i ++) { - parser[buffers[i]] = "" - } -} - -SAXParser.prototype = - { end: function () { end(this) } - , write: write - , resume: function () { this.error = null; return this } - , close: function () { return this.write(null) } - } - -try { - var Stream = require("stream").Stream -} catch (ex) { - var Stream = function () {} -} - - -var streamWraps = sax.EVENTS.filter(function (ev) { - return ev !== "error" && ev !== "end" -}) - -function createStream (strict, opt) { - return new SAXStream(strict, opt) -} - -function SAXStream (strict, opt) { - if (!(this instanceof SAXStream)) return new SAXStream(strict, opt) - - Stream.apply(this) - - this._parser = new SAXParser(strict, opt) - this.writable = true - this.readable = true - - - var me = this - - this._parser.onend = function () { - me.emit("end") - } - - this._parser.onerror = function (er) { - me.emit("error", er) - - // if didn't throw, then means error was handled. - // go ahead and clear error, so we can write again. - me._parser.error = null - } - - streamWraps.forEach(function (ev) { - Object.defineProperty(me, "on" + ev, { - get: function () { return me._parser["on" + ev] }, - set: function (h) { - if (!h) { - me.removeAllListeners(ev) - return me._parser["on"+ev] = h - } - me.on(ev, h) - }, - enumerable: true, - configurable: false - }) - }) -} - -SAXStream.prototype = Object.create(Stream.prototype, - { constructor: { value: SAXStream } }) - -SAXStream.prototype.write = function (data) { - this._parser.write(data.toString()) - this.emit("data", data) - return true -} - -SAXStream.prototype.end = function (chunk) { - if (chunk && chunk.length) this._parser.write(chunk.toString()) - this._parser.end() - return true -} - -SAXStream.prototype.on = function (ev, handler) { - var me = this - if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) { - me._parser["on"+ev] = function () { - var args = arguments.length === 1 ? [arguments[0]] - : Array.apply(null, arguments) - args.splice(0, 0, ev) - me.emit.apply(me, args) - } - } - - return Stream.prototype.on.call(me, ev, handler) -} - - - -// character classes and tokens -var whitespace = "\r\n\t " - // this really needs to be replaced with character classes. - // XML allows all manner of ridiculous numbers and digits. - , number = "0124356789" - , letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - // (Letter | "_" | ":") - , nameStart = letter+"_:" - , nameBody = nameStart+number+"-." - , quote = "'\"" - , entity = number+letter+"#" - , attribEnd = whitespace + ">" - , CDATA = "[CDATA[" - , DOCTYPE = "DOCTYPE" - , XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" - , XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/" - , rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE } - -// turn all the string character sets into character class objects. -whitespace = charClass(whitespace) -number = charClass(number) -letter = charClass(letter) -nameStart = charClass(nameStart) -nameBody = charClass(nameBody) -quote = charClass(quote) -entity = charClass(entity) -attribEnd = charClass(attribEnd) - -function charClass (str) { - return str.split("").reduce(function (s, c) { - s[c] = true - return s - }, {}) -} - -function is (charclass, c) { - return charclass[c] -} - -function not (charclass, c) { - return !charclass[c] -} - -var S = 0 -sax.STATE = -{ BEGIN : S++ -, TEXT : S++ // general stuff -, TEXT_ENTITY : S++ // & and such. -, OPEN_WAKA : S++ // < -, SGML_DECL : S++ // -, SCRIPT : S++ // " - , expect : - [ [ "opentag", { name: "xml", attributes: {} } ] - , [ "opentag", { name: "script", attributes: {} } ] - , [ "text", "hello world" ] - , [ "closetag", "script" ] - , [ "closetag", "xml" ] - ] - , strict : false - , opt : { lowercasetags: true, noscript: true } - } - ) - -require(__dirname).test - ( { xml : "" - , expect : - [ [ "opentag", { name: "xml", attributes: {} } ] - , [ "opentag", { name: "script", attributes: {} } ] - , [ "opencdata", undefined ] - , [ "cdata", "hello world" ] - , [ "closecdata", undefined ] - , [ "closetag", "script" ] - , [ "closetag", "xml" ] - ] - , strict : false - , opt : { lowercasetags: true, noscript: true } - } - ) - diff --git a/node_modules/xml2js/node_modules/sax/test/parser-position.js b/node_modules/xml2js/node_modules/sax/test/parser-position.js deleted file mode 100644 index e4a68b1..0000000 --- a/node_modules/xml2js/node_modules/sax/test/parser-position.js +++ /dev/null @@ -1,28 +0,0 @@ -var sax = require("../lib/sax"), - assert = require("assert") - -function testPosition(chunks, expectedEvents) { - var parser = sax.parser(); - expectedEvents.forEach(function(expectation) { - parser['on' + expectation[0]] = function() { - for (var prop in expectation[1]) { - assert.equal(parser[prop], expectation[1][prop]); - } - } - }); - chunks.forEach(function(chunk) { - parser.write(chunk); - }); -}; - -testPosition(['
abcdefgh
'], - [ ['opentag', { position: 5, startTagPosition: 1 }] - , ['text', { position: 19, startTagPosition: 14 }] - , ['closetag', { position: 19, startTagPosition: 14 }] - ]); - -testPosition(['
abcde','fgh
'], - [ ['opentag', { position: 5, startTagPosition: 1 }] - , ['text', { position: 19, startTagPosition: 14 }] - , ['closetag', { position: 19, startTagPosition: 14 }] - ]); diff --git a/node_modules/xml2js/node_modules/sax/test/script.js b/node_modules/xml2js/node_modules/sax/test/script.js deleted file mode 100644 index 464c051..0000000 --- a/node_modules/xml2js/node_modules/sax/test/script.js +++ /dev/null @@ -1,12 +0,0 @@ -require(__dirname).test({ - xml : "", - expect : [ - ["opentag", {"name": "HTML","attributes": {}}], - ["opentag", {"name": "HEAD","attributes": {}}], - ["opentag", {"name": "SCRIPT","attributes": {}}], - ["script", "if (1 < 0) { console.log('elo there'); }"], - ["closetag", "SCRIPT"], - ["closetag", "HEAD"], - ["closetag", "HTML"] - ] -}); diff --git a/node_modules/xml2js/node_modules/sax/test/self-closing-child-strict.js b/node_modules/xml2js/node_modules/sax/test/self-closing-child-strict.js deleted file mode 100644 index ce9c045..0000000 --- a/node_modules/xml2js/node_modules/sax/test/self-closing-child-strict.js +++ /dev/null @@ -1,40 +0,0 @@ - -require(__dirname).test({ - xml : - ""+ - "" + - "" + - "" + - "" + - "=(|)" + - "" + - "", - expect : [ - ["opentag", { - "name": "root", - "attributes": {} - }], - ["opentag", { - "name": "child", - "attributes": {} - }], - ["opentag", { - "name": "haha", - "attributes": {} - }], - ["closetag", "haha"], - ["closetag", "child"], - ["opentag", { - "name": "monkey", - "attributes": {} - }], - ["text", "=(|)"], - ["closetag", "monkey"], - ["closetag", "root"], - ["end"], - ["ready"] - ], - strict : true, - opt : {} -}); - diff --git a/node_modules/xml2js/node_modules/sax/test/self-closing-child.js b/node_modules/xml2js/node_modules/sax/test/self-closing-child.js deleted file mode 100644 index bc6b52b..0000000 --- a/node_modules/xml2js/node_modules/sax/test/self-closing-child.js +++ /dev/null @@ -1,40 +0,0 @@ - -require(__dirname).test({ - xml : - ""+ - "" + - "" + - "" + - "" + - "=(|)" + - "" + - "", - expect : [ - ["opentag", { - "name": "ROOT", - "attributes": {} - }], - ["opentag", { - "name": "CHILD", - "attributes": {} - }], - ["opentag", { - "name": "HAHA", - "attributes": {} - }], - ["closetag", "HAHA"], - ["closetag", "CHILD"], - ["opentag", { - "name": "MONKEY", - "attributes": {} - }], - ["text", "=(|)"], - ["closetag", "MONKEY"], - ["closetag", "ROOT"], - ["end"], - ["ready"] - ], - strict : false, - opt : {} -}); - diff --git a/node_modules/xml2js/node_modules/sax/test/self-closing-tag.js b/node_modules/xml2js/node_modules/sax/test/self-closing-tag.js deleted file mode 100644 index b2c5736..0000000 --- a/node_modules/xml2js/node_modules/sax/test/self-closing-tag.js +++ /dev/null @@ -1,25 +0,0 @@ - -require(__dirname).test({ - xml : - " "+ - " "+ - " "+ - " "+ - "=(|) "+ - ""+ - " ", - expect : [ - ["opentag", {name:"ROOT", attributes:{}}], - ["opentag", {name:"HAHA", attributes:{}}], - ["closetag", "HAHA"], - ["opentag", {name:"HAHA", attributes:{}}], - ["closetag", "HAHA"], - // ["opentag", {name:"HAHA", attributes:{}}], - // ["closetag", "HAHA"], - ["opentag", {name:"MONKEY", attributes:{}}], - ["text", "=(|)"], - ["closetag", "MONKEY"], - ["closetag", "ROOT"] - ], - opt : { trim : true } -}); \ No newline at end of file diff --git a/node_modules/xml2js/node_modules/sax/test/stray-ending.js b/node_modules/xml2js/node_modules/sax/test/stray-ending.js deleted file mode 100644 index 6b0aa7f..0000000 --- a/node_modules/xml2js/node_modules/sax/test/stray-ending.js +++ /dev/null @@ -1,17 +0,0 @@ -// stray ending tags should just be ignored in non-strict mode. -// https://github.com/isaacs/sax-js/issues/32 -require(__dirname).test - ( { xml : - "" - , expect : - [ [ "opentag", { name: "A", attributes: {} } ] - , [ "opentag", { name: "B", attributes: {} } ] - , [ "text", "" ] - , [ "closetag", "B" ] - , [ "closetag", "A" ] - ] - , strict : false - , opt : {} - } - ) - diff --git a/node_modules/xml2js/node_modules/sax/test/trailing-non-whitespace.js b/node_modules/xml2js/node_modules/sax/test/trailing-non-whitespace.js deleted file mode 100644 index 3e1fb2e..0000000 --- a/node_modules/xml2js/node_modules/sax/test/trailing-non-whitespace.js +++ /dev/null @@ -1,17 +0,0 @@ - -require(__dirname).test({ - xml : "Welcome, to monkey land", - expect : [ - ["opentag", { - "name": "SPAN", - "attributes": {} - }], - ["text", "Welcome,"], - ["closetag", "SPAN"], - ["text", " to monkey land"], - ["end"], - ["ready"] - ], - strict : false, - opt : {} -}); diff --git a/node_modules/xml2js/node_modules/sax/test/unquoted.js b/node_modules/xml2js/node_modules/sax/test/unquoted.js deleted file mode 100644 index dbeb638..0000000 --- a/node_modules/xml2js/node_modules/sax/test/unquoted.js +++ /dev/null @@ -1,17 +0,0 @@ -// unquoted attributes should be ok in non-strict mode -// https://github.com/isaacs/sax-js/issues/31 -require(__dirname).test - ( { xml : - "" - , expect : - [ [ "attribute", { name: "CLASS", value: "test" } ] - , [ "attribute", { name: "HELLO", value: "world" } ] - , [ "opentag", { name: "SPAN", - attributes: { CLASS: "test", HELLO: "world" } } ] - , [ "closetag", "SPAN" ] - ] - , strict : false - , opt : {} - } - ) - diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-issue-41.js b/node_modules/xml2js/node_modules/sax/test/xmlns-issue-41.js deleted file mode 100644 index 596d82b..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-issue-41.js +++ /dev/null @@ -1,67 +0,0 @@ -var t = require(__dirname) - - , xmls = // should be the same both ways. - [ "" - , "" ] - - , ex1 = - [ [ "opennamespace" - , { prefix: "a" - , uri: "http://ATTRIBUTE" - } - ] - , [ "attribute" - , { name: "xmlns:a" - , value: "http://ATTRIBUTE" - , prefix: "xmlns" - , local: "a" - , uri: "http://www.w3.org/2000/xmlns/" - } - ] - , [ "attribute" - , { name: "a:attr" - , local: "attr" - , prefix: "a" - , uri: "http://ATTRIBUTE" - , value: "value" - } - ] - , [ "opentag" - , { name: "parent" - , uri: "" - , prefix: "" - , local: "parent" - , attributes: - { "a:attr": - { name: "a:attr" - , local: "attr" - , prefix: "a" - , uri: "http://ATTRIBUTE" - , value: "value" - } - , "xmlns:a": - { name: "xmlns:a" - , local: "a" - , prefix: "xmlns" - , uri: "http://www.w3.org/2000/xmlns/" - , value: "http://ATTRIBUTE" - } - } - , ns: {"a": "http://ATTRIBUTE"} - } - ] - , ["closetag", "parent"] - , ["closenamespace", { prefix: "a", uri: "http://ATTRIBUTE" }] - ] - - // swap the order of elements 2 and 1 - , ex2 = [ex1[0], ex1[2], ex1[1]].concat(ex1.slice(3)) - , expected = [ex1, ex2] - -xmls.forEach(function (x, i) { - t.test({ xml: x - , expect: expected[i] - , strict: true - , opt: { xmlns: true } - }) -}) diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-rebinding.js b/node_modules/xml2js/node_modules/sax/test/xmlns-rebinding.js deleted file mode 100644 index f464876..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-rebinding.js +++ /dev/null @@ -1,59 +0,0 @@ - -require(__dirname).test - ( { xml : - ""+ - ""+ - ""+ - ""+ - ""+ - "" - - , expect : - [ [ "opennamespace", { prefix: "x", uri: "x1" } ] - , [ "opennamespace", { prefix: "y", uri: "y1" } ] - , [ "attribute", { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ] - , [ "attribute", { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" } ] - , [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ] - , [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ] - , [ "opentag", { name: "root", uri: "", prefix: "", local: "root", - attributes: { "xmlns:x": { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } - , "xmlns:y": { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" } - , "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } - , "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } }, - ns: { x: 'x1', y: 'y1' } } ] - - , [ "opennamespace", { prefix: "x", uri: "x2" } ] - , [ "attribute", { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ] - , [ "opentag", { name: "rebind", uri: "", prefix: "", local: "rebind", - attributes: { "xmlns:x": { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } }, - ns: { x: 'x2' } } ] - - , [ "attribute", { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } ] - , [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ] - , [ "opentag", { name: "check", uri: "", prefix: "", local: "check", - attributes: { "x:a": { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } - , "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } }, - ns: { x: 'x2' } } ] - - , [ "closetag", "check" ] - - , [ "closetag", "rebind" ] - , [ "closenamespace", { prefix: "x", uri: "x2" } ] - - , [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ] - , [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ] - , [ "opentag", { name: "check", uri: "", prefix: "", local: "check", - attributes: { "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } - , "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } }, - ns: { x: 'x1', y: 'y1' } } ] - , [ "closetag", "check" ] - - , [ "closetag", "root" ] - , [ "closenamespace", { prefix: "x", uri: "x1" } ] - , [ "closenamespace", { prefix: "y", uri: "y1" } ] - ] - , strict : true - , opt : { xmlns: true } - } - ) - diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-strict.js b/node_modules/xml2js/node_modules/sax/test/xmlns-strict.js deleted file mode 100644 index 9c7258d..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-strict.js +++ /dev/null @@ -1,71 +0,0 @@ - -require(__dirname).test - ( { xml : - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "" - - , expect : - [ [ "opentag", { name: "root", prefix: "", local: "root", uri: "", - attributes: {}, ns: {} } ] - - , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ] - , [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "", - attributes: { "attr": { name: "attr", value: "normal", uri: "", prefix: "", local: "attr", uri: "" } }, - ns: {} } ] - , [ "closetag", "plain" ] - - , [ "opennamespace", { prefix: "", uri: "uri:default" } ] - - , [ "attribute", { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } ] - , [ "opentag", { name: "ns1", prefix: "", local: "ns1", uri: "uri:default", - attributes: { "xmlns": { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } }, - ns: { "": "uri:default" } } ] - - , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ] - , [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "uri:default", ns: { '': 'uri:default' }, - attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } } } ] - , [ "closetag", "plain" ] - - , [ "closetag", "ns1" ] - - , [ "closenamespace", { prefix: "", uri: "uri:default" } ] - - , [ "opennamespace", { prefix: "a", uri: "uri:nsa" } ] - - , [ "attribute", { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } ] - - , [ "opentag", { name: "ns2", prefix: "", local: "ns2", uri: "", - attributes: { "xmlns:a": { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } }, - ns: { a: "uri:nsa" } } ] - - , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ] - , [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "", - attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } }, - ns: { a: 'uri:nsa' } } ] - , [ "closetag", "plain" ] - - , [ "attribute", { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } ] - , [ "opentag", { name: "a:ns", prefix: "a", local: "ns", uri: "uri:nsa", - attributes: { "a:attr": { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } }, - ns: { a: 'uri:nsa' } } ] - , [ "closetag", "a:ns" ] - - , [ "closetag", "ns2" ] - - , [ "closenamespace", { prefix: "a", uri: "uri:nsa" } ] - - , [ "closetag", "root" ] - ] - , strict : true - , opt : { xmlns: true } - } - ) - diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-unbound.js b/node_modules/xml2js/node_modules/sax/test/xmlns-unbound.js deleted file mode 100644 index 2944b87..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-unbound.js +++ /dev/null @@ -1,15 +0,0 @@ - -require(__dirname).test( - { strict : true - , opt : { xmlns: true } - , expect : - [ ["error", "Unbound namespace prefix: \"unbound\"\nLine: 0\nColumn: 28\nChar: >"] - - , [ "attribute", { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } ] - , [ "opentag", { name: "root", uri: "", prefix: "", local: "root", - attributes: { "unbound:attr": { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } }, - ns: {} } ] - , [ "closetag", "root" ] - ] - } -).write("") diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-ns.js b/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-ns.js deleted file mode 100644 index 3eab96d..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-ns.js +++ /dev/null @@ -1,30 +0,0 @@ -var xmlns_attr = -{ - name: "xmlns", value: "http://foo", prefix: "xmlns", - local: "", uri : "http://www.w3.org/2000/xmlns/" -}; - -var attr_attr = -{ - name: "attr", value: "bar", prefix: "", - local : "attr", uri : "" -}; - - -require(__dirname).test - ( { xml : - "" - , expect : - [ [ "opennamespace", { prefix: "", uri: "http://foo" } ] - , [ "attribute", xmlns_attr ] - , [ "attribute", attr_attr ] - , [ "opentag", { name: "elm", prefix: "", local: "elm", uri : "http://foo", - ns : { "" : "http://foo" }, - attributes: { xmlns: xmlns_attr, attr: attr_attr } } ] - , [ "closetag", "elm" ] - , [ "closenamespace", { prefix: "", uri: "http://foo"} ] - ] - , strict : true - , opt : {xmlns: true} - } - ) diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js b/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js deleted file mode 100644 index 16da771..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js +++ /dev/null @@ -1,35 +0,0 @@ -require(__dirname).test( - { xml : "" - , expect : - [ [ "attribute" - , { name: "xml:lang" - , local: "lang" - , prefix: "xml" - , uri: "http://www.w3.org/XML/1998/namespace" - , value: "en" - } - ] - , [ "opentag" - , { name: "root" - , uri: "" - , prefix: "" - , local: "root" - , attributes: - { "xml:lang": - { name: "xml:lang" - , local: "lang" - , prefix: "xml" - , uri: "http://www.w3.org/XML/1998/namespace" - , value: "en" - } - } - , ns: {} - } - ] - , ["closetag", "root"] - ] - , strict : true - , opt : { xmlns: true } - } -) - diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix.js b/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix.js deleted file mode 100644 index 9a1ce1b..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix.js +++ /dev/null @@ -1,20 +0,0 @@ -require(__dirname).test( - { xml : "" - , expect : - [ - [ "opentag" - , { name: "xml:root" - , uri: "http://www.w3.org/XML/1998/namespace" - , prefix: "xml" - , local: "root" - , attributes: {} - , ns: {} - } - ] - , ["closetag", "xml:root"] - ] - , strict : true - , opt : { xmlns: true } - } -) - diff --git a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-redefine.js b/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-redefine.js deleted file mode 100644 index 1eba9c7..0000000 --- a/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-redefine.js +++ /dev/null @@ -1,40 +0,0 @@ -require(__dirname).test( - { xml : "" - , expect : - [ ["error" - , "xml: prefix must be bound to http://www.w3.org/XML/1998/namespace\n" - + "Actual: ERROR\n" - + "Line: 0\nColumn: 27\nChar: '" - ] - , [ "attribute" - , { name: "xmlns:xml" - , local: "xml" - , prefix: "xmlns" - , uri: "http://www.w3.org/2000/xmlns/" - , value: "ERROR" - } - ] - , [ "opentag" - , { name: "xml:root" - , uri: "http://www.w3.org/XML/1998/namespace" - , prefix: "xml" - , local: "root" - , attributes: - { "xmlns:xml": - { name: "xmlns:xml" - , local: "xml" - , prefix: "xmlns" - , uri: "http://www.w3.org/2000/xmlns/" - , value: "ERROR" - } - } - , ns: {} - } - ] - , ["closetag", "xml:root"] - ] - , strict : true - , opt : { xmlns: true } - } -) - diff --git a/node_modules/xml2js/package.json b/node_modules/xml2js/package.json index bea52a7..71dc864 100644 --- a/node_modules/xml2js/package.json +++ b/node_modules/xml2js/package.json @@ -90,8 +90,5 @@ "readme": "node-xml2js\n===========\n\nEver had the urge to parse XML? And wanted to access the data in some sane,\neasy way? Don't want to compile a C parser, for whatever reason? Then xml2js is\nwhat you're looking for!\n\nDescription\n===========\n\nSimple XML to JavaScript object converter. Uses\n[sax-js](https://github.com/isaacs/sax-js/).\n\nNote: If you're looking for a full DOM parser, you probably want\n[JSDom](https://github.com/tmpvar/jsdom).\n\nInstallation\n============\n\nSimplest way to install `xml2js` is to use [npm](http://npmjs.org), just `npm\ninstall xml2js` which will download xml2js and all dependencies.\n\nUsage\n=====\n\nThis will have to do, unless you're looking for some fancy extensive\ndocumentation. If you're looking for every single option and usage, see the\nunit tests.\n\nSimple as pie usage\n-------------------\n\nThe simplest way to use it, is to use the optional callback interface added in\n0.1.11. That's right, if you have been using xml-simple or a home-grown\nwrapper, this is for you:\n\n```javascript\nvar fs = require('fs'),\n xml2js = require('xml2js');\n\nvar parser = new xml2js.Parser();\nfs.readFile(__dirname + '/foo.xml', function(err, data) {\n parser.parseString(data, function (err, result) {\n console.dir(result);\n console.log('Done');\n });\n});\n```\n\nLook ma, no event listeners! Alternatively you can still use the traditional\n`addListener` variant:\n\n```javascript\nvar fs = require('fs'),\n xml2js = require('xml2js');\n\nvar parser = new xml2js.Parser();\nparser.addListener('end', function(result) {\n console.dir(result);\n console.log('Done.');\n});\nfs.readFile(__dirname + '/foo.xml', function(err, data) {\n parser.parseString(data);\n});\n```\n\nYou can also use xml2js from\n[CoffeeScript](http://jashkenas.github.com/coffee-script/), further reducing\nthe clutter:\n\n```coffeescript\nfs = require 'fs',\nxml2js = require 'xml2js'\n\nparser = new xml2js.Parser()\nfs.readFile __dirname + '/foo.xml', (err, data) ->\n parser.parseString data, (err, result) ->\n console.dir result\n console.log 'Done.'\n```\n\nSo you wanna some JSON?\n-----------------------\n\nJust wrap the `result` object in a call to `JSON.stringify` like this\n`JSON.stringify(result)`. You get a string containing the JSON representation\nof the parsed object that you can feed to JSON-hungry consumers.\n\nDisplaying results\n------------------\n\nYou might wonder why, using `console.dir` or `console.log` the output at some\nlevel is only `[Object]`. Don't worry, this is not because xml2js got lazy.\nThat's because Node uses `util.inspect` to convert the object into strings and\nthat function stops after `depth=2` which is a bit low for most XML.\n\nTo display the whole deal, you can use `console.log(util.inspect(result, false,\nnull))`, which displays the whole result.\n\nSo much for that, but what if you use\n[eyes](https://github.com/cloudhead/eyes.js) for nice colored output and it\ntruncates the output with `…`? Don't fear, there's also a solution for that,\nyou just need to increase the `maxLength` limit by creating a custom inspector\n`var inspect = require('eyes').inspector({maxLength: false})` and then you can\neasily `inspect(result)`.\n\nOptions\n=======\n\nApart from the default settings, there is a number of options that can be\nspecified for the parser. Options are specified by ``new Parser({optionName:\nvalue})``. Possible options are:\n\n * `attrkey` (default: `$`): Prefix that is used to access the attributes.\n Version 0.1 default was `@`.\n * `charkey` (default: `_`): Prefix that is used to access the character\n content. Version 0.1 default was `#`.\n * `explicitCharkey` (default: `false`)\n * `trim` (default: `false`): Trim the whitespace at the beginning and end of\n text nodes.\n * `normalizeTags` (default: `false`): Normalize all tag names to lowercase.\n * `normalize` (default: `false`): Trim whitespaces inside text nodes.\n * `explicitRoot` (default: `true`): Set this if you want to get the root\n node in the resulting object.\n * `emptyTag` (default: `undefined`): what will the value of empty nodes be.\n Default is `{}`.\n * `explicitArray` (default: `true`): Always put child nodes in an array if\n true; otherwise an array is created only if there is more than one.\n * `ignoreAttrs` (default: `false`): Ignore all XML attributes and only create\n text nodes.\n * `mergeAttrs` (default: `false`): Merge attributes and child elements as\n properties of the parent, instead of keying attributes off a child\n attribute object. This option is ignored if `ignoreAttrs` is `false`.\n * `validator` (default `null`): You can specify a callable that validates\n the resulting structure somehow, however you want. See unit tests\n for an example.\n * `xmlns` (default `false`): Give each element a field usually called '$ns'\n (the first character is the same as attrkey) that contains its local name\n and namespace URI.\n\nUpdating to new version\n=======================\n\nVersion 0.2 changed the default parsing settings, but version 0.1.14 introduced\nthe default settings for version 0.2, so these settings can be tried before the\nmigration.\n\n```javascript\nvar xml2js = require('xml2js');\nvar parser = new xml2js.Parser(xml2js.defaults[\"0.2\"]);\n```\n\nTo get the 0.1 defaults in version 0.2 you can just use\n`xml2js.defaults[\"0.1\"]` in the same place. This provides you with enough time\nto migrate to the saner way of parsing in xml2js 0.2. We try to make the\nmigration as simple and gentle as possible, but some breakage cannot be\navoided.\n\nSo, what exactly did change and why? In 0.2 we changed some defaults to parse\nthe XML in a more universal and sane way. So we disabled `normalize` and `trim`\nso xml2js does not cut out any text content. You can reenable this at will of\ncourse. A more important change is that we return the root tag in the resulting\nJavaScript structure via the `explicitRoot` setting, so you need to access the\nfirst element. This is useful for anybody who wants to know what the root node\nis and preserves more information. The last major change was to enable\n`explicitArray`, so everytime it is possible that one might embed more than one\nsub-tag into a tag, xml2js >= 0.2 returns an array even if the array just\nincludes one element. This is useful when dealing with APIs that return\nvariable amounts of subtags.\n\nRunning tests, development\n==========================\n\nThe development requirements are handled by npm, you just need to install\nthem. We also have a number of unit tests, they can be run using `zap`\ndirectly from the project root.\n", "readmeFilename": "README.md", "_id": "xml2js@0.2.2", - "dist": { - "shasum": "5279de6517fdfa12f7e1fd643a92cbd520255921" - }, "_from": "xml2js" } diff --git a/package.json b/package.json index 90127bb..4f9431c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ , "private": true , "dependencies": { "formidable": ">= 0.0.1" - , "mongoskin": ">= 0.0.1" + , "mongodb": ">= 0.0.1" , "socket.io": ">= 0.0.1" , "dateformat": ">= 0.0.1" , "request": "2.11.4" diff --git a/static/javascripts/script.js b/static/javascripts/script.js index 3e49f46..ebb139a 100644 --- a/static/javascripts/script.js +++ b/static/javascripts/script.js @@ -1,351 +1,249 @@ - $(document).ready(function() { - var socket = io.connect(); - exercise_autocompletedata = "unset"; - bike_autocompletedata = "unset"; - - socket.emit('getactivites', 'please'); - socket.emit('getexercises', 'please'); - // socket.emit('getexpresso', 'please'); - - - socket.on('populateactivities', function(json) { - console.log('#poulate recieved'); - var content = ""; - $(".workoutdata").hide(); - $('#ActivityList').empty(); - $( "#ActivityList" ).html( - $( "#movieTemplate1" ).render( json ) - ); - $(".ui-accordion-content").css("display", "block"); - // $("#ActivityList").accordion('destroy').accordion({ - // header: 'h3', - // active: false, - // collapsible: true - // }); +$(document).ready(function() { + //makes buttons buttons + $("button").button(); - }); - //poulate activity by id - socket.on('populateactivitybyid', function(json) { - //set document id - $('span.ActivityID').attr('docid',json._id); - //poulate name - $('input[name="Activities.Activity.name"]').attr('value', json.Activities.Activity.name) - //poulate date - $('input[name="Activities.Activity.date"]').attr('value', json.Activities.Activity.date) - // Activities.Activity.date - // for each lap - if ("Lap" in json.Activities.Activity) { - var array = json.Activities.Activity.Lap; - $.each(array, function(index, value) { - ////if cardio - if ("cardio" in value) { - //get exercise muscledata - var lapmuscledata = exercise_autocompletedata[value.cardio.selection].muscledata.value; - AddPopulatedLap("Cardio", value.cardio.name, value.cardio.time, value.cardio.distance, "", "" , "", lapmuscledata) + +// $("#ExerciseEditor").dialog({ autoOpen: false }); +// $( "#ExerciseEditor" ).dialog( "option", "minHeight", 330 ); +// $( "#ExerciseEditor" ).dialog( "option", "minWidth", 630 ); +// $( "#ExerciseEditor" ).dialog({ buttons: [ +// { +// text: "Close/Cancel", +// click: function() { $(this).dialog("close"); } +// } +// ] +// }); - }; - ////if exercise - if ("exercise" in value) { - //get exercise muscledata - console.log("selction = " + value.exercise.selection); - var lapmuscledata = exercise_autocompletedata[value.exercise.selection].muscledata.value; - AddPopulatedLap("Exercise", value.exercise.name, "", "", value.exercise.sets, value.exercise.reps , value.exercise.weight , lapmuscledata) - }; - }); - - }; - $('#savecopy').attr('style', 'display: block'); - ///refresh tabvle - $('#sortable').trigger('sortupdate'); - - //switch to tab - $( "#tabs" ).tabs( "select" , 1 ) - - }); +// $("button#openexercises").click(function() { +// socket.emit('getexercises', 'please'); +// $("#ExerciseEditor").dialog("open"); +// }); - function AddPopulatedLap(type, name, time, distance, sets, reps, weight, muscledata) { - console.log('type= ' + type); - console.log('muscledata= ' + muscledata); - var newElem = $('.new-lap').clone(true).attr('style', 'display: block'); - $(newElem).removeClass('new-lap'); - $(newElem).appendTo('#sortable'); - $(newElem).children('.laptype').val(type).trigger('change'); - $(newElem).children('input').attr('disabled',false); - $(newElem).find('.lapname').attr('value', name); - $(newElem).find('.lapdistance').attr('value', distance); - $(newElem).find('.laptime').attr('value', time); - $(newElem).find('.sets').attr('value', sets); - $(newElem).find('.reps').attr('value', reps); - $(newElem).find('.weight').attr('value', weight); - $(newElem).find('.muscledata').attr('value', muscledata); - $(newElem).sortable( "refresh" ); - }; - - //var addtype = $(this).attr('value'); - //var newElem = $('.new-' + addtype).clone(true).attr('style', 'display: block'); - //$(newElem).removeClass("new-" + addtype); - //$(newElem).children('input').attr('disabled',false); - //$(newElem).appendTo('#sortable'); - //$(newElem).sortable( "refresh" ); - //$('#sortable').trigger('sortupdate'); +// $("#Activity").dialog({ autoOpen: false }); +// $( "#Activity" ).dialog( "option", "minHeight", 330 ); +// $( "#Activity" ).dialog( "option", "minWidth", 730 ); +// $( "#Activity" ).dialog({ buttons: [ +// { +// text: "Close/Cancel", +// click: function() { $(this).dialog("close"); } +// } +// ] +// }); - ////populate exercise sortable - socket.on('populateexercises', function(json) { - //console.log('#exercises recieved' + JSON.stringify(json, null, ' ')); - var content = ""; - $('ul#sortableexercises li').remove(); - $('span.ExerciseID').attr('docid',json[0]._id); - //$( "ul#sortableexercises" ).append('
  • ') - ///// for loop - var array = json[0].exercise; - exercise_autocompletedata = array; - $('#sortable').trigger('sortupdate'); - $.each(array, function(index, value) { - $( "ul#sortableexercises" ).append('
  • delete
  • '); - $('#sortableexercises').trigger('sortupdate'); - }); - - ////populate expresso sortable - // socket.on('populateexpresso', function(json) { - // //console.log('#tracks recieved' + JSON.stringify(json, null, ' ')); - // var content = ""; - // $('ul#sortableexpresso li').remove(); - // $('span.ExpressoID').attr('docid',json[0]._id); - // var barray = json[0].track.name; - // bike_autocompletedata = barray; - // $('#sortable').trigger('sortupdate'); - // $.each(barray, function(index, value) { - // $( "ul#sortableexpresso" ).append('
  • ') - // }); - // }); - - }); - - // //THe TABs stuff - // $( "#tabs" ).tabs(); - // $( "#tabs" ).tabs('select' , 0); - //sets buttons to be jquery buttons - $("button").button(); - //sets datepickers - $( "#datepicker" ).datepicker(); +// $("button#openactivities").click(function() { +// // +// $("#Activity").dialog("open"); +// }); - $( "#tabs" ).bind( "tabsselect", function(event, ui) { - if (ui.index == 0) { - console.log('send stuff ' + ui.index ); - socket.emit('getactivites', 'please'); - }; - if (ui.index == 2) { - console.log('send stuff ' + ui.index ); - socket.emit('getexercises', 'please'); - }; - }); - - $('#ActivityList').delegate('a.activitydelete', 'click', function() { - socket.emit('delactivity', $(this).attr('title')); - return false; - }); - $('#ActivityList').delegate('a.activityedit', 'click', function() { - socket.emit('getactivitybyid', $(this).attr('title')); - return false; - }); - - //THe Sortable Stuff - $("#sortable").sortable({ - placeholder: "ui-state-highlight", - revert: true, - stop: function(event, ui) { - $('#sortable').trigger('sortupdate') - }, + //makes datepickers + $( "#datepicker" ).datepicker(); + $('#Activity').find('input.datepicker').datepicker(); + $('#Activity').find('input.datepicker').datepicker('setDate', new Date()); - }); - - $("#sortable").bind('sortupdate', function(event, ui) { - - - $('#sortable li').each(function(){ - var itemindex= $(this).index() - $(this).children('label.uiindex').html('Exercise '+ itemindex ); - $(this).find('input').each(function(){ - var newname = $(this).attr('name').replace(/\[[0-9]*\]/,'[' + itemindex + ']'); - $(this).attr("name",newname); - }); - - - $(this).find('input.exertags').autocomplete({source: exercise_autocompletedata}); - }); - }); - - $("#sortableexercises").sortable({ - placeholder: "ui-state-highlight", - revert: true, - }); - - $("#sortableexercises").bind('sortupdate', function(event, ui) { - $('#sortableexercises li').each(function(){ - var itemindex= $(this).index() - $(this).find('input, select').each(function(){ - var newname = $(this).attr('name').replace(/\[[0-9]*\]/,'[' + itemindex + ']'); - console.log('newname' + newname ); - $(this).attr("name",newname); - }); - }); - }); - - - $('ul').on('click', '.delete',function() { - $(this).closest('li').remove(); - $('#sortable').trigger('sortupdate') - // $('#sortableexercises').trigger('sortupdate') - }); - - ///All the Buttons - $("button").button(); + var socket = io.connect(); + exercise_autocompletedata = "unset"; + bike_autocompletedata = "unset"; + + //get intial data + socket.emit('getactivites', 'please'); + socket.emit('getexercises', 'please'); + socket.emit('getexerciselist', 'cardio'); + socket.emit('getexerciselist', 'weights'); - //adds selectable element - $("button").click(function() { - var addtype = $(this).attr('value'); - var newElem = $('.new-' + addtype).clone(true).attr('style', 'display: block'); - $(newElem).removeClass("new-" + addtype); - $(newElem).children('input').attr('disabled',false); - $(newElem).appendTo('#sortable'); - $(newElem).sortable( "refresh" ); + socket.on('populateactivities', function(json) { + console.log('#poulate recieved'); + var content = ""; + $(".workoutdata").hide(); + $('#ActivityList').empty(); + $( "#ActivityList" ).html( + $( "#movieTemplate1" ).render( json ) + ); + $(".ui-accordion-content").css("display", "block"); + // $("#ActivityList").accordion('destroy').accordion({ + // header: 'h3', + // active: false, + // collapsible: true + // }); + }); + //poulate activity by id + socket.on('populateactivitybyid', function(json) { + // clear it first + $('ul#sortable li').remove('.removable'); + $('span.ActivityID').removeAttr('docid'); + $('#Activity').find('input').attr('value',''); + $('#Activity').find('input.datepicker').datepicker(); + $('#Activity').find('input.datepicker').datepicker('setDate', new Date()); + + //set document id + $('span.ActivityID').attr('docid',json._id); + //poulate name + // $('input[name="Activities.Activity.name"]').attr('value', json.Activities.Activity.name) + //poulate date + $('input[name="Activities.Activity.date"]').attr('value', json.Activities.Activity.date) + // Activities.Activity.date + // for each lap + if ("Lap" in json.Activities.Activity) { + var array = json.Activities.Activity.Lap; + $.each(array, function(index, value) { + ////if cardio + if (value.class == "Cardio" ) { + //get exercise muscledata + var lapmuscledata = "123123"; + AddPopulatedLap("Cardio", value.name, value.time, value.distance, "", "" , "", lapmuscledata) + }; + ////if exercise + if (value.class == "Exercise" ) { + //get exercise muscledata + console.log("selction = " + value.selection); + var lapmuscledata = "123123"; + AddPopulatedLap("Exercise", value.name, "", "", value.sets, value.reps , value.weight , lapmuscledata) + }; + }); + }; + ///refresh table + $('#sortable').trigger('sortupdate'); + + }); - $('#sortable').trigger('sortupdate'); - //$('#sortableexercises').trigger('sortupdate'); + function AddPopulatedLap(type, name, time, distance, sets, reps, weight, muscledata) { + console.log('type= ' + type); + console.log('muscledata= ' + muscledata); + var newElem = $('.new-lap').clone(true).attr('style', 'display: block'); + $(newElem).removeClass('new-lap'); + $(newElem).appendTo('#sortable'); + $(newElem).children('.laptype').val(type).trigger('change'); + $(newElem).children('input').attr('disabled',false); + $(newElem).find('.lapname').attr('value', name); + $(newElem).find('.lapdistance').attr('value', distance); + $(newElem).find('.laptime').attr('value', time); + $(newElem).find('.sets').attr('value', sets); + $(newElem).find('.reps').attr('value', reps); + $(newElem).find('.weight').attr('value', weight); + $(newElem).find('.muscledata').attr('value', muscledata); + $(newElem).sortable( "refresh" ); + }; + + socket.on('populateexerciselist', function(data, result) { + if ("cardio" == data) { + //create cardiodropdownlist + $( ".ExerciseDropDownCardio" ).remove('option'); + $.each(result, function(index, array) { + $( ".ExerciseDropDownCardio" ).append(''); + }) + }; + if ("weights" == data) { + $( ".ExerciseDropDownWeights" ).remove('option'); + $.each(result, function(index, array) { + $( ".ExerciseDropDownWeights" ).append(''); + }) + }; + + }); + + + //THe Sortable Stuff + $("#sortable").sortable({ + placeholder: "ui-state-highlight", + revert: true, + stop: function(event, ui) { + $('#sortable').trigger('sortupdate') + }, + + }); + + $("#sortable").bind('sortupdate', function(event, ui) { + $('#sortable li').each(function(){ + var itemindex= $(this).index() + $(this).children('label.uiindex').html('Exercise '+ itemindex ); + $(this).find('input, select').each(function(){ + var newname = $(this).attr('name').replace(/\[[0-9]*\]/,'[' + itemindex + ']'); + $(this).attr("name",newname); }); + $(this).find('input.exertags').autocomplete({source: exercise_autocompletedata}); + }); + }); - $("button.AddExercise").click(function() { - $( "ul#sortableexercises" ).append('
  • delete
  • ') - $('#sortableexercises').trigger('sortupdate'); - }); - $("button.AddExpresso").click(function() { - $( "ul#sortableexpresso" ).append('
  • ') - }); + $('#ActivityList').delegate('a.activitydelete', 'click', function() { + socket.emit('delactivity', $(this).attr('title')); + return false; + }); - $('#Activity').find('input.datepicker').datepicker(); - $('#Activity').find('input.datepicker').datepicker('setDate', new Date()); - - - - $('#save').click(function() { - var docid =$(this).closest('span').attr('docid'); - var selector= "#myForm" - var formDataAll = $(selector).toObject({mode: 'all'}); - socket.emit('addactivity', formDataAll[0], docid); - //console.log('All ', JSON.stringify(formDataAll[0], null, ' ')); - $('ul#sortable li').remove('.removable'); - $('#Activity').find('input').attr('value',''); - $('span.ActivityID').removeAttr('docid'); - $('#savecopy').attr('style', 'display: none'); - $( "#tabs" ).tabs( "select" , 0 ) - $('#Activity').find('input.datepicker').datepicker(); - $('#Activity').find('input.datepicker').datepicker('setDate', new Date()); - socket.emit('getactivites', 'please'); - socket.emit('getexercises', 'please'); - return false; + $('#ActivityList').delegate('a.activityedit', 'click', function() { + socket.emit('getactivitybyid', $(this).attr('title')); + $("#Activity").dialog("open"); + return false; + }); - }); - - $('#savecopy').click(function() { - var selector= "#myForm" - var formDataAll = $(selector).toObject({mode: 'all'}); - socket.emit('addactivity', formDataAll[0]); - //console.log('All ', JSON.stringify(formDataAll[0], null, ' ')); + + // $('ul').on('click', '.delete',function() { + // $(this).closest('li').remove(); + // $('#sortable').trigger('sortupdate') + // }); + + //adds selectable element + $("button").click(function() { + var addtype = $(this).attr('value'); + var newElem = $('.new-' + addtype).clone(true).attr('style', 'display: block'); + $(newElem).removeClass("new-" + addtype); + $(newElem).children('input').attr('disabled',false); + $(newElem).appendTo('#sortable'); + $(newElem).sortable( "refresh" ); + $('#sortable').trigger('sortupdate'); + }); + + + + $('#save').click(function() { + var docid =$(this).closest('span').attr('docid'); + var selector= "#myForm" + var formDataAll = $(selector).toObject({mode: 'all'}); + socket.emit('addactivity', formDataAll[0], docid); + $('ul#sortable li').remove('.removable'); + $('#Activity').find('input').attr('value',''); + $('span.ActivityID').removeAttr('docid'); + $('#Activity').find('input.datepicker').datepicker(); + $('#Activity').find('input.datepicker').datepicker('setDate', new Date()); + socket.emit('getactivites', 'please'); + socket.emit('getexercises', 'please'); + return false; + + }); + + + $('#cancelform').click(function() { $('ul#sortable li').remove('.removable'); - $('#Activity').find('input').attr('value',''); $('span.ActivityID').removeAttr('docid'); - $('#savecopy').attr('style', 'display: none'); - $( "#tabs" ).tabs( "select" , 0 ) + $('#Activity').find('input').attr('value',''); $('#Activity').find('input.datepicker').datepicker(); $('#Activity').find('input.datepicker').datepicker('setDate', new Date()); return false; - }); + socket.emit('getactivites', 'please'); + socket.emit('getexercises', 'please'); + }); + + + $('ul').on('change', '.laptype',function() { + console.log ('value= ' + $(this).val() ); + var currentselect; + switch($(this).val()) { + case "Cardio": + $(this).siblings('span').html('delete'); + + socket.emit('getexerciselist', 'cardio'); + + break; + case "Exercise": + $(this).siblings('span').html(' delete'); + socket.emit('getexerciselist', 'weights'); + break; + }; + $('#sortable').trigger('sortupdate') + }); - $('#saveexercises').click(function() { - var docid =$(this).closest('span').attr('docid'); - var selector= "#ExerciseForm" - var formDataAll = $(selector).toObject({mode: 'all'}); - socket.emit('updateexercises', formDataAll[0], docid); - - //console.log('All ', JSON.stringify(formDataAll, null, ' ')); - // to prevent the page from changing - $('ul#sortableexercises li').remove(); - $( "#tabs" ).tabs( "select" , 0 ) - socket.emit('getactivites', 'please'); - socket.emit('getexercises', 'please'); - return false; - }); - - $('#saveexpresso').click(function() { - var docid =$(this).closest('span').attr('docid'); - var selector= "#ExpressoForm" - var formDataAll = $(selector).toObject({mode: 'all'}); - socket.emit('updateexpresso', formDataAll[0], docid); - - console.log('All ', JSON.stringify(formDataAll, null, ' ')); - // to prevent the page from changing - $('ul#sortableexpresso li').remove(); - $( "#tabs" ).tabs( "select" , 0 ) - return false; - }); +//document closing +}); - - $('#cancelform').click(function() { - $('ul#sortable li').remove('.removable'); - $('span.ActivityID').removeAttr('docid'); - $('#Activity').find('input').attr('value',''); - $('#Activity').find('input.datepicker').datepicker(); - $('#Activity').find('input.datepicker').datepicker('setDate', new Date()); - return false; - socket.emit('getactivites', 'please'); - socket.emit('getexercises', 'please'); - }); - - $('#my-text-link').click(function() { // bind click event to link - $tabs.tabs('select', 2); // switch to third tab - return false; - }); - - - $('ul').on('change', '.laptype',function() { - console.log ('value= ' + $(this).val() ); - var currentselect; - switch($(this).val()) { - case "Cardio": - $(this).siblings('span').html('delete'); - $(exercise_autocompletedata).each(function(index) - { - var option = $('