mirror of
https://github.com/sstent/node.git
synced 2026-01-25 22:52:07 +00:00
big update - restarted app including jquery
This commit is contained in:
@@ -97,24 +97,34 @@ console.log("Express server listening on port %d in %s mode", app.address().port
|
||||
var io = require('socket.io');
|
||||
io = io.listen(app);
|
||||
io.configure('development', function(){
|
||||
io.set("transports", ["xhr-polling"]);
|
||||
io.set("polling duration", 10);
|
||||
//io.set("transports", ["xhr-polling"]);
|
||||
io.set("transports", ["websocket"]);
|
||||
//io.set("polling duration", 20);
|
||||
//io.set("polling timeout", 20);
|
||||
//io.set("log level", 1);
|
||||
//io.set('heartbeat timeout', 5);
|
||||
//io.set('heartbeat interval', 5);
|
||||
});
|
||||
|
||||
io.sockets.on('connection', function(socket) {
|
||||
console.log('Client connected');
|
||||
|
||||
socket.on('data', function(data) {
|
||||
console.log("data" + JSON.stringify(data))
|
||||
//console.log("data" + JSON.stringify(data))
|
||||
testcollection.insert(data, function(err, result) {
|
||||
if (err) throw err;
|
||||
if (result) console.log('Added!' + result);
|
||||
if (result) console.log('Added!');
|
||||
testcollection.find().toArray(function(err, result) {
|
||||
if (err) throw err;
|
||||
//console.log('This Is What I Got ' +JSON.stringify(result));
|
||||
socket.emit('populate', result);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function emitdata(channel,data) {
|
||||
console.log('This Is What I should Emit ' +JSON.stringify(data));
|
||||
console.log('This Is What I should Emit');
|
||||
io.sockets.on('connection', function (socket) {
|
||||
console.log('This Is What I Emit ' +JSON.stringify(data));
|
||||
socket.emit(channel, data);
|
||||
|
||||
@@ -11,11 +11,16 @@
|
||||
div(id='Activity',style='display: none',)
|
||||
form#myForm
|
||||
input(type='submit', id='save', value='Save')
|
||||
input(type='button', id='cancel', value='Cancel')
|
||||
div(Class='ActivityBlock_T', style='display: none')
|
||||
input(type='button', class='AddNeut', value='Add note Field', data-field='note_area', data-area='note', data-limit='1')
|
||||
input(type='button', class='AddNeut', value='Add exercise Field', data-field='exercise_area', data-area='exercise', data-limit='1')
|
||||
input(type='button', class='RemNeut noterem', value='Remove note Field', data-field='note_area', data-area='note', data-limit='0', disabled='disabled')
|
||||
input(type='button', class='RemNeut exerciserem', value='Remove exercise Field', data-field='exercise_area', data-area='exercise', data-limit='0', disabled='disabled' )
|
||||
input(type='button', class='AddNeut', value='Add Note', data-field='note_area', data-area='note', data-limit='1')
|
||||
input(type='button', class='AddNeut', value='Add Exercise', data-field='exercise_area', data-area='exercise', data-limit='10')
|
||||
input(type='button', class='AddNeut', value='Add Run', data-field='run_area', data-area='run', data-limit='5')
|
||||
input(type='button', class='AddNeut', value='Add Bike', data-field='bike_area', data-area='bike', data-limit='5')
|
||||
input(type='button', class='RemNeut noterem', value='Remove Note', data-field='note_area', data-area='note', data-limit='0', disabled='disabled')
|
||||
input(type='button', class='RemNeut exerciserem', value='Remove Exercise', data-field='exercise_area', data-area='exercise', data-limit='0', disabled='disabled' )
|
||||
input(type='button', class='RemNeut runrem', value='Remove Run', data-field='exercise_area', data-area='exercise', data-limit='0', disabled='disabled' )
|
||||
input(type='button', class='RemNeut bikerem', value='Remove Bike', data-field='exercise_area', data-area='exercise', data-limit='0', disabled='disabled' )
|
||||
ul(class='activity')
|
||||
li(class='activity', style='display: none')
|
||||
label Activity
|
||||
@@ -32,6 +37,17 @@
|
||||
input(type='text', name='activity.exercise[i].sets', value='Sets', disabled='disabled', class='numericonly')
|
||||
input(type='text', name='activity.exercise[i].reps', value='Reps', disabled='disabled')
|
||||
input(type='text', name='activity.exercise[i].weight', value='Weight', disabled='disabled')
|
||||
ul(class='run')
|
||||
li(class='run_T', style='display: none')
|
||||
label Run
|
||||
input(type='text', name='activity.run[i].time', value='Time', disabled='disabled')
|
||||
input(type='text', name='activity.run[i].distance', value='Distance', disabled='disabled')
|
||||
input(type='text', name='activity.run[i].location', value='Location', disabled='disabled')
|
||||
ul(class='bike')
|
||||
li(class='bike_T', style='display: none')
|
||||
label Bike
|
||||
input(type='text', name='activity.bike[i].track', value='Track', disabled='disabled')
|
||||
input(type='text', name='activity.bike[i].time', value='Time', disabled='disabled', class='numericonly')
|
||||
|
||||
ul#employees
|
||||
|
||||
|
||||
@@ -13,22 +13,26 @@ html
|
||||
link(rel='stylesheet', href="stylesheets/smoothness/jquery-ui-1.8.20.custom.css")
|
||||
script#movieTemplate1(type="text/x-jsrender").
|
||||
<tr>
|
||||
<td colspan=3>{{:activity.name}}</td>
|
||||
<td>{{:_id}}</td>
|
||||
<td><p class=RowDelete id={{:_id}}>Delete</p></td>
|
||||
<td class=RowShow id={{:_id}} colspan=3>{{:activity.name}}</td>
|
||||
<td>{{:date}}</td>
|
||||
<td>
|
||||
{{if activity.note}}
|
||||
{{for activity.note}}
|
||||
<div>
|
||||
<em>{{:name}}</em>
|
||||
</div>
|
||||
{{/for}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
{{for activity.exercise}}
|
||||
{{if activity.exercise}}
|
||||
{{for activity.exercise}}
|
||||
<div>
|
||||
<em>{{:name}}</em><em>{{:sets}}</em><em>{{:reps}}</em><em>{{:weight}}</em>
|
||||
</div>
|
||||
{{/for}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -37,40 +41,12 @@ html
|
||||
script
|
||||
$(function() {
|
||||
//$( "#datepicker" ).datepicker();
|
||||
var socket = io.connect('http://localhost:3000');
|
||||
var socket = io.connect();
|
||||
|
||||
socket.on('populate', function(json) {
|
||||
console.log('#poulate recieved');
|
||||
var content = "";
|
||||
$('#employees').empty();
|
||||
//iterate activities
|
||||
// $.each (json, function (bb) {
|
||||
// var activity = json[bb].activity;
|
||||
// content += '<p>Activity - '+ bb + '</p>';
|
||||
// if (typeof activity.name !== 'undefined') {
|
||||
// content += '<p>Name - '+ activity.name + '</p>';
|
||||
// };
|
||||
// if (typeof activity.note !== 'undefined') {
|
||||
// $.each (activity.note, function (cc) {
|
||||
// content += '<p>Note - '+ cc + '</p>';
|
||||
// });
|
||||
// };
|
||||
// if (typeof activity.exercise !== 'undefined') {
|
||||
// $.each (activity.exercise, function (cc) {
|
||||
// content += '<p>Exercise '+ cc +' - name:' + activity.exercise[cc].name +'</p>';
|
||||
// content += '<p>Exercise '+ cc +' - sets:' + activity.exercise[cc].sets +'</p>';
|
||||
// content += '<p>Exercise '+ cc +' - reps:' + activity.exercise[cc].reps +'</p>';
|
||||
// content += '<p>Exercise '+ cc +' - weight:' + activity.exercise[cc].weight +'</p>';
|
||||
// });
|
||||
// };
|
||||
|
||||
// });
|
||||
// $(content).appendTo("#employees");
|
||||
// $.templates({
|
||||
// titleTemplate: "<tr><td colspan=3>{{:activity.name}}</td><td>{{:_id}}</td><td></td></tr>",
|
||||
// detailTemplate: "<tr><td>{{:name}}</td><td>Released: {{:releaseYear}}</td><td>director: {{:director}}</td></tr>"
|
||||
// });
|
||||
// content = $.render.titleTemplate( json );
|
||||
// $( "#employees" ).html( content );
|
||||
$( "#employees" ).html(
|
||||
$( "#movieTemplate1" ).render( json )
|
||||
);
|
||||
@@ -92,6 +68,7 @@ html
|
||||
$(newElem).find('ul.activity li').children('input').attr('disabled',false);
|
||||
$(newElem).find('ul.activity li').attr('style', 'display: block');
|
||||
$(newElem).find('input.datefield').datepicker()
|
||||
$(newElem).find('input.datefield').datepicker('setDate', new Date())
|
||||
$(newElem).appendTo('form#myForm');
|
||||
|
||||
});
|
||||
@@ -157,6 +134,12 @@ html
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#cancel').click(function() {
|
||||
$('.ActivityBlock').remove();
|
||||
$('#Activity').attr('style', 'display: none');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user