Closed OscarGodson closed 13 years ago
This should be working now. I added the the date/time insert as an inline script in new-session.html, but there may be a more elegant way to handle it.
It's missing some things ;)
app()
(example below)? The /templates directory is supposed to just be raw HTML. We'll want to reuse this, so we should move it. I.e. we change the front end presentation, make a mobile version, etc.N
sessions (i think 3, see the example session link above and look for Thursday)var sessionCount
you'll want to make an API call to get sessions for the current agenda. (i added an id
param to the example code below that you'd use). In main.js
you'd do something like (youll probably have to mod it a bit depending on the API response):app().api({action:'get',type:'agenda','id':dataStore('active-agenda')},function(json){
var sessionCount = json[x].sessions.length;
});
Here's an example method:
app = function(){ //...
//...the other methods here
nextSession: function(id){
// Set up the date and time for the first session
var nextWednesday = nextSession();
// Scour the HTML for any h3 tags, used to determine our session times
var sessionCount = $('h3.session').length; //replace with API call
switch(sessionCount){
case 0: sessionTime = '09:30'; break;
case 1: sessionTime = '14:00'; break;
default: sessionTime = '9:30'; //Not sure what this should be yet
}
// Write it to the input as a default value
return nextWednesday.getMonth()+1 + '-' + nextWednesday.getDate() + '-' + nextWednesday.getFullYear()+ ' ' + sessionTime;
}
//...the other methods here
});
You'd use it like:
var theNextSession = app().nextSession(dataStore('active-agenda'));
$('input[name=date]').val(theNextSession);
Fixed in accordance with the anti 'codin' drrty' statute.
We need to put that in our code style docs. Have a section called "Codin' Dirty"
When creating a new session, the date and time should be guessed.