-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
260 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
/* global $, setTimeout */ | ||
|
||
"use strict"; // jshint ignore:line | ||
|
||
var Cheesto = | ||
{ | ||
firstgen: true, | ||
|
||
dashboardInit: function() { | ||
Cheesto.getStatuses(); | ||
}, | ||
|
||
getStatuses: function () { | ||
$.getJSON("api/i/cheesto/read", | ||
function (data) { | ||
if (data.errorcode == 5) { | ||
return; | ||
} | ||
|
||
Cheesto.generateView(data.data); | ||
|
||
if (Cheesto.firstgen) { | ||
setTimeout(Cheesto.getStatuses, 30000); | ||
} | ||
}); | ||
}, | ||
|
||
generateView: function (dataObj) { | ||
Cheesto.generateTable(dataObj); | ||
if (Cheesto.firstgen) { | ||
Cheesto.makeStatusSelect(dataObj); | ||
} | ||
return; | ||
}, | ||
|
||
|
||
makeStatusSelect: function (dataObj) { | ||
var statusSelect = $('<select/>').attr('id', 'status-select'); | ||
statusSelect.change(Cheesto.setStatus); | ||
|
||
statusSelect.append('<option value="-1">Set Status:</option>'); | ||
|
||
for (var key2 in dataObj.statusOptions) { | ||
var html = '<option value="' + dataObj.statusOptions[key2] + '">' + dataObj.statusOptions[key2] + '</option>'; | ||
statusSelect.append(html); | ||
} | ||
|
||
$('#status-select').replaceWith(statusSelect); | ||
Cheesto.firstgen = false; | ||
return; | ||
}, | ||
|
||
generateTable: function (dataObj) { | ||
var div = $('<div/>').attr('id', 'messages-cheesto-content'); | ||
var table = $('<table/>'); | ||
table.append('<thead><tr><td>Name</td><td>Status</td></tr></thead><tbody>'); | ||
|
||
for (var key in dataObj) { | ||
if (dataObj.hasOwnProperty(key)) { | ||
if (key !== "statusOptions") { | ||
var user = dataObj[key]; | ||
|
||
var html = '<tr><td>' + user.realname + '</td>'+ | ||
'<td class="status-cell" title="' + user.message + '
Return: ' + user.returntime + '">'+ | ||
user.status + '</td></tr>'; | ||
|
||
table.append(html); | ||
} | ||
} | ||
} | ||
|
||
table.append('</tbody>'); | ||
div.append(table); | ||
$('#messages-cheesto-content').replaceWith(div); | ||
|
||
$('td.status-cell').tooltip({ | ||
track: true, | ||
show: { | ||
effect: 'fade', | ||
delay: 50 | ||
} | ||
}); | ||
return; | ||
}, | ||
|
||
setStatus: function () { | ||
var newStatus = $("#status-select").val(); | ||
|
||
if (newStatus != 'Available') { | ||
// Status requires a return time and optional message | ||
$('#cheesto-status-form').dialog({ | ||
height: 440, | ||
width: 640, | ||
title: 'Ĉeesto Status', | ||
modal: true, | ||
open: function(evt, ui) { | ||
$('#cheesto-date-pick').datetimepicker({ | ||
timeFormat: "HH:mm", | ||
controlType: 'select', | ||
stepMinute: 10, | ||
}); | ||
}, | ||
show: { | ||
effect: 'fade', | ||
duration: 500 | ||
}, | ||
hide: { | ||
effect: 'fade', | ||
duration: 500 | ||
}, | ||
buttons: { | ||
'Save': function() { | ||
Cheesto.processStatus(newStatus); | ||
}, | ||
Cancel: function() { | ||
$(this).dialog('close'); | ||
$("#status-select").prop("selectedIndex", 0); | ||
} | ||
} | ||
}); | ||
} else { | ||
// Status is Available | ||
Cheesto.sendNewStatus(newStatus, '00:00:00', ''); | ||
} | ||
}, | ||
|
||
processStatus: function(status) { | ||
var message = $('#cheesto-message-text'); | ||
var returnTime = $('#cheesto-date-pick'); | ||
|
||
Cheesto.sendNewStatus(status, returnTime.val(), message.val()); | ||
$('#cheesto-status-form').dialog('close'); | ||
|
||
$("#status-select").prop("selectedIndex", 0); | ||
message.val(''); | ||
returnTime.val('Today'); | ||
}, | ||
|
||
sendNewStatus: function (stat, rt, message) { | ||
$.post('api/i/cheesto/update', {status: stat, returntime: rt, message: message}) | ||
.done(function() { Cheesto.getStatuses(); }); | ||
}, | ||
|
||
setDateTime: function(delta) { | ||
var currentdate = new Date(); | ||
|
||
var minutes = currentdate.getMinutes()+(delta % 60); | ||
var hours = currentdate.getHours()+((delta-(delta % 60))/60); | ||
|
||
if (minutes > 59) { | ||
minutes = minutes - 60; | ||
hours++; | ||
} | ||
|
||
var datetime = ('0' + (currentdate.getMonth()+1)).slice(-2) + '/' + | ||
('0' + currentdate.getDate()).slice(-2) + '/' + | ||
currentdate.getFullYear() + ' ' + | ||
('0' + hours).slice(-2) + ':' + | ||
('0' + minutes).slice(-2); | ||
|
||
$('#cheesto-date-pick').val(datetime); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* css for timepicker */ | ||
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; } | ||
.ui-timepicker-div dl { text-align: left; } | ||
.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; } | ||
.ui-timepicker-div dl dd { margin: 0 10px 10px 45%; } | ||
.ui-timepicker-div td { font-size: 90%; } | ||
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; } | ||
|
||
.ui-timepicker-rtl{ direction: rtl; } | ||
.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; } | ||
.ui-timepicker-rtl dl dt{ float: right; clear: right; } | ||
.ui-timepicker-rtl dl dd { margin: 0 45% 10px 10px; } | ||
|
||
div.ui-datepicker{ | ||
font-size:15px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters