-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create better status bar API + Structure, add time to status bar
- Loading branch information
Showing
6 changed files
with
85 additions
and
10 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 |
---|---|---|
@@ -1,5 +1,34 @@ | ||
/* This file is licensed under the Affero General Public License. */ | ||
|
||
var bar = document.createElement('div'); | ||
bar.id = 'bar'; | ||
document.body.appendChild(bar); | ||
/*global $ */ | ||
|
||
(function() { | ||
// Add namespace | ||
var bar = window.bar = {}; | ||
|
||
// Add bar | ||
var barElement = document.createElement('div'); | ||
barElement.id = 'bar'; | ||
document.body.appendChild(barElement); | ||
|
||
// Add icon panel | ||
var barIcons = window.barIcons = document.createElement('div'); | ||
barIcons.id = 'barIcons'; | ||
barElement.appendChild(barIcons); | ||
|
||
bar.addItem = function(node) { | ||
$(barIcons).append(node); | ||
bar.updateWidth(); | ||
}; | ||
|
||
bar.removeItem = function(node) { | ||
barIcons.removeChild(node); | ||
bar.updateWidth(); | ||
}; | ||
|
||
bar.updateWidth = function() { | ||
window.barIconsWidth = barIcons.offsetWidth; | ||
}; | ||
|
||
bar.updateWidth(); | ||
})(window); |
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,33 @@ | ||
/* This file is licensed under the Affero General Public License. */ | ||
|
||
/*global deviceType */ | ||
|
||
(function() { | ||
// Don't show clock on mobile | ||
if(deviceType === 'mobile') { | ||
return; | ||
} | ||
|
||
// Create clock widget | ||
var clock = document.createElement('span'); | ||
clock.id = 'barClock'; | ||
updateTime(); | ||
|
||
// Add to bar | ||
window.bar.addItem(clock); | ||
|
||
// Prevent freeze | ||
var updateTimeout; | ||
|
||
function updateTime() { | ||
// Clear timeout | ||
clearTimeout(updateTimeout); | ||
|
||
// Get time | ||
var currentTime = new Date(); | ||
clock.textContent = currentTime.toLocaleTimeString(navigator.language, {hour: 'numeric', minute: 'numeric'}); | ||
|
||
// Keep up-to-date | ||
updateTimeout = setTimeout(updateTime, 60000 - (currentTime.getSeconds() * 1000) - currentTime.getMilliseconds()); | ||
} | ||
})(); |
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