2012-10-06 16:36:05 +00:00
|
|
|
(function(context,$) {
|
|
|
|
|
|
|
|
|
|
context.JK = context.JK || {};
|
|
|
|
|
context.JK.SessionScreen = function(app) {
|
2012-10-14 15:48:56 +00:00
|
|
|
var logger = context.JK.logger;
|
2012-10-06 16:36:05 +00:00
|
|
|
|
|
|
|
|
function afterShow(data) {
|
|
|
|
|
var sessionId = data.id;
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: "/api/sessions/" + sessionId
|
|
|
|
|
}).done(renderSession);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderSession(sessionData) {
|
|
|
|
|
$contents = $('#session-contents');
|
|
|
|
|
$contents.empty();
|
|
|
|
|
var template = $('#template-session-contents').html();
|
|
|
|
|
var contents = JK.fillTemplate(template, sessionData);
|
|
|
|
|
$contents.html(contents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteSession(evt) {
|
|
|
|
|
var sessionId = $(this).attr("action-id");
|
|
|
|
|
if (sessionId) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
url: "/api/sessions/" + sessionId
|
|
|
|
|
}).done(
|
|
|
|
|
function() { self.location="#/home"; }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function events() {
|
|
|
|
|
$('#session-contents').on("click", '[action="delete"]', deleteSession);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-14 15:48:56 +00:00
|
|
|
this.initialize = function() {
|
|
|
|
|
events();
|
|
|
|
|
screenBindings = {
|
|
|
|
|
'afterShow': afterShow
|
|
|
|
|
};
|
|
|
|
|
app.bindScreen('session', screenBindings);
|
2012-10-06 16:36:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(window,jQuery);
|