diff --git a/activities/Clock.activity/css/activity.css b/activities/Clock.activity/css/activity.css
index e3129783b..8b058f584 100644
--- a/activities/Clock.activity/css/activity.css
+++ b/activities/Clock.activity/css/activity.css
@@ -56,6 +56,10 @@ canvas {
background-image: url(../icons/write-date.svg);
}
+#main-toolbar #write-seconds-button {
+ background-image: url(../icons/write-seconds.svg);
+}
+
#main-toolbar #set-time-button {
background-image: url(../icons/set-time.svg);
}
diff --git a/activities/Clock.activity/icons/write-seconds.svg b/activities/Clock.activity/icons/write-seconds.svg
new file mode 100644
index 000000000..1196a657d
--- /dev/null
+++ b/activities/Clock.activity/icons/write-seconds.svg
@@ -0,0 +1,126 @@
+
+
diff --git a/activities/Clock.activity/index.html b/activities/Clock.activity/index.html
index c8c33c380..ffe6247c7 100644
--- a/activities/Clock.activity/index.html
+++ b/activities/Clock.activity/index.html
@@ -26,6 +26,7 @@
+
diff --git a/activities/Clock.activity/js/activity.js b/activities/Clock.activity/js/activity.js
index e78db6598..7440e3cfa 100644
--- a/activities/Clock.activity/js/activity.js
+++ b/activities/Clock.activity/js/activity.js
@@ -38,6 +38,13 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
}else{
document.getElementById("write-date-button").classList.remove("active");
}
+ if(data.writeSeconds){
+ document.getElementById("write-seconds-button").classList.add("active");
+ clock.changeWriteSeconds(true);
+ }else{
+ document.getElementById("write-seconds-button").classList.remove("active");
+ clock.changeWriteSeconds(false);
+ }
if(data.isSetTimeGame){
clock.setTimeGame = true;
@@ -115,6 +122,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
this.writeTime = false;
this.writeDate = false;
+ this.writeSeconds = true;
this.setTime = false;
this.setTimeGame = false;
this.isDrag = false;
@@ -187,6 +195,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
document.getElementById("nice-clock-button").title = l10n_s.get("NiceClock");
document.getElementById("write-time-button").title = l10n_s.get("WriteTime");
document.getElementById("write-date-button").title = l10n_s.get("WriteDate");
+ document.getElementById("write-seconds-button").title = l10n_s.get("WriteSeconds");
document.getElementById("set-time-button").title = l10n_s.get("SetTime");
document.getElementById("set-timeGame-button").title = l10n_s.get("SetTimeGame");
document.getElementById("text-time").innerHTML = l10n_s.get("WhatTime");
@@ -278,6 +287,16 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
this.drawBackground();
}
+ Clock.prototype.changeWriteSeconds = function (writeSeconds) {
+ this.writeSeconds = writeSeconds;
+
+ this.changeWriteTime(this.writeTime);
+ this.updateSizes();
+ var date = new Date();
+ this.displayDate(date);
+ this.drawBackground();
+ }
+
Clock.prototype.updateSizes = function () {
var toolbarElem = document.getElementById("main-toolbar");
var textContainerElem = document.getElementById("text-container");
@@ -345,8 +364,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
'' +
':{{ minutes }}' +
'' +
- ':{{ seconds }}' +
- '' +
+ (this.writeSeconds ? ':{{ seconds }}' : '') +
'' + txt +
''
;
@@ -485,7 +503,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
ctx.clearRect(this.margin, this.margin, this.radius * 2,
this.radius * 2);
- var handNames = ['hours', 'minutes', 'seconds'];
+ var handNames = this.writeSeconds ? ['hours', 'minutes', 'seconds'] : ['hours', 'minutes'];
for (var i = 0; i < handNames.length; i++) {
var name = handNames[i];
ctx.lineCap = 'round';
@@ -512,7 +530,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
ctx.clearRect(this.margin, this.margin, this.radius * 2,
this.radius * 2);
this.drawSmiley();
- var handNames = ['hours', 'minutes', 'seconds'];
+ var handNames = this.writeSeconds ? ['hours', 'minutes', 'seconds'] : ['hours', 'minutes'];
// tempPos is used to position circle on each hand in set time mode
var tempPos = [0.400,0.607,0.8125];
@@ -694,7 +712,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
if(this.timeToBeDisplayed['hours']==undefined){
this.timeToBeDisplayed['hours'] = Math.floor(Math.random() * 12) + 1;
this.timeToBeDisplayed['minutes'] = Math.floor(Math.random() * 60);
- this.timeToBeDisplayed['seconds'] = Math.floor(Math.random() * 60);
+ this.timeToBeDisplayed['seconds'] = this.writeSeconds ? Math.floor(Math.random() * 60) : 0;
}
var txt = "??";
this.displayTime(this.timeToBeDisplayed['hours'], this.timeToBeDisplayed['minutes'], this.timeToBeDisplayed['seconds'], txt);
@@ -761,6 +779,14 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
clock.changeWriteDate(active);
};
+ var writeSecondsButton = document.getElementById("write-seconds-button");
+ var that = this;
+ writeSecondsButton.onclick = function () {
+ this.classList.toggle('active');
+ var active = this.classList.contains('active');
+ clock.changeWriteSeconds(active);
+ };
+
var setTimeButton = document.getElementById("set-time-button");
setTimeButton.onclick = function () {
@@ -880,7 +906,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
clock.canvasY = canvasY;
if(clock.setTimeGame){
- var handNames = ['hours', 'minutes', 'seconds'];
+ var handNames = clock.writeSeconds ? ['hours', 'minutes', 'seconds'] : ['hours', 'minutes'];
var targetAngles = [];
targetAngles.push (Math.PI / 6 * (clock.timeToBeDisplayed['hours']%12) + Math.PI / 360 * clock.timeToBeDisplayed['minutes']);
@@ -889,7 +915,7 @@ define(["sugar-web/activity/activity","sugar-web/env","sugar-web/graphics/radiob
var ctr = 0;
- for(var i=0;i<3;i++){
+ for(var i=0;i