move time into its own file and folder

This commit is contained in:
Jon Heller 2015-10-18 22:16:45 -04:00
parent 0dee9c0bd9
commit c2f9d0a06c
6 changed files with 118 additions and 24 deletions

View File

@ -24,11 +24,12 @@
<script src="js/jquery.js"></script> <script src="js/jquery.js"></script>
<script src="js/jquery.feedToJSON.js"></script> <script src="js/jquery.feedToJSON.js"></script>
<script src="js/ical_parser.js"></script> <script src="js/ical_parser.js"></script>
<script src="js/moment-with-langs.min.js"></script> <script src="js/moment-with-locales.min.js"></script>
<script src="js/config.js"></script> <script src="js/config.js"></script>
<script src="js/rrule.js"></script> <script src="js/rrule.js"></script>
<script src="js/compliments/compliments.js" type="text/javascript"></script> <script src="js/compliments/compliments.js" type="text/javascript"></script>
<script src="js/weather/weather.js" type="text/javascript"></script> <script src="js/weather/weather.js" type="text/javascript"></script>
<script src="js/time/time.js" type="text/javascript"></script>
<script src="js/main.js?nocache=<?php echo md5(microtime()) ?>"></script> <script src="js/main.js?nocache=<?php echo md5(microtime()) ?>"></script>
<!-- <script src="js/socket.io.min.js"></script> --> <!-- <script src="js/socket.io.min.js"></script> -->

View File

@ -1,5 +1,8 @@
var config = { var config = {
lang: 'en', lang: 'en',
time: {
timeFormat: 12
},
weather: { weather: {
//change weather params here: //change weather params here:
//units: metric or imperial //units: metric or imperial

View File

@ -34,7 +34,7 @@ jQuery(document).ready(function($) {
var lastCompliment; var lastCompliment;
var compliment; var compliment;
moment.lang(config.lang); moment.locale(config.lang);
//connect do Xbee monitor //connect do Xbee monitor
// var socket = io.connect('http://rpi-alarm.local:8082'); // var socket = io.connect('http://rpi-alarm.local:8082');
@ -64,19 +64,7 @@ jQuery(document).ready(function($) {
}, 3000); }, 3000);
})(); })();
(function updateTime() time.init();
{
var now = moment();
var date = now.format('LLLL').split(' ',4);
date = date[0] + ' ' + date[1] + ' ' + date[2] + ' ' + date[3];
$('.date').html(date);
$('.time').html(now.format('HH') + ':' + now.format('mm') + '<span class="sec">'+now.format('ss')+'</span>');
setTimeout(function() {
updateTime();
}, 1000);
})();
(function updateCalendarData() (function updateCalendarData()
{ {

File diff suppressed because one or more lines are too long

80
js/moment-with-locales.min.js vendored Normal file

File diff suppressed because one or more lines are too long

31
js/time/time.js Normal file
View File

@ -0,0 +1,31 @@
var time = {
timeFormat: config.time.timeFormat || 24,
dateLocation: '.date',
timeLocation: '.time',
updateInterval: 1000,
intervalId: null
};
time.updateTime = function () {
var _now = moment(),
_date = _now.format('dddd, LL');
$(this.dateLocation).html(_date);
$(this.timeLocation).html(_now.format(this._timeFormat+':mm[<span class="sec">]ss[</span>]'));
}
time.init = function () {
if (parseInt(time.timeFormat) === 12) {
time._timeFormat = 'hh'
} else {
time._timeFormat = 'HH';
}
this.intervalId = setInterval(function () {
this.updateTime();
}.bind(this), 1000);
}