Skip to content
Browse files

start_time is local variable. update time change 300msec.

  • Loading branch information...
1 parent e269242 commit 2e3eb218c1b5efddc4cffe130a281dcd0be6802d @vestige committed Oct 7, 2012
Showing with 96 additions and 99 deletions.
  1. +3 −4 Resources/app.js
  2. +3 −3 build/iphone/build/build.log
  3. +88 −90 build/mobileweb/app.js
  4. +2 −2 build/mobileweb/titanium/filesystem.registry
View
7 Resources/app.js
@@ -102,21 +102,20 @@ function update () {
}
count.text = date_format(counting);
past_time = tmp_time;
- timer_id = setTimeout("update()", 100);
+ timer_id = setTimeout("update()", 300);
}
} else {
- timer_id = setTimeout("update()", 100);
+ timer_id = setTimeout("update()", 300);
}
};
-var start_time;
var past_time;
var counting;
var timer_id;
var pause = 0;
function timerClear(){
- start_time = new Date();
+ var start_time = new Date();
past_time = start_time;
if (spanSwitch.value) {
counting = 25 * 60;
View
6 build/iphone/build/build.log
@@ -5,7 +5,7 @@ reporting an issue to help us understand your environment, build settings
and aid in debugging. Please attach this log to any issue that you report.
================================================================================
-Starting build at 10/07/12 19:03
+Starting build at 10/07/12 21:15
Build details:
@@ -22,8 +22,8 @@ Script arguments:
/Users/vestige/Documents/Titanium_Studio_Workspace/Toteka
vst
Toteka
- iphone
- iphone
+ ipad
+ ipad
Building from: /Users/vestige/Library/Application Support/Titanium/mobilesdk/osx/2.1.2.GA/iphone
View
178 build/mobileweb/app.js
@@ -1,154 +1,152 @@
Titanium.UI.setBackgroundColor('#000');
var ground = Ti.UI.createWindow({
- layout: 'vertical'
+ layout: 'vertical'
});
var top = Ti.UI.createView({
- backgroundColor: '#333',
- height: '20%'
+ backgroundColor: '#333',
+ height: '20%'
});
var title = Ti.UI.createLabel({
- text: 'toteka timer',
- textAlign: 'center',
- color: '#ddd',
- font:{fontSize: '100%'},
+ text: 'toteka timer',
+ textAlign: 'center',
+ color: '#ddd',
+ font:{fontSize: '100%'},
})
var contents = Ti.UI.createView({
- backgroundColor: '#000',
- height: '70%',
- layout: 'vertical',
+ backgroundColor: '#000',
+ height: '70%',
+ layout: 'vertical',
});
var qa = Ti.UI.createLabel({
- text: '',
- color: 'white',
- font:{fontSize: '70%'},
+ text: '',
+ color: 'white',
+ font:{fontSize: '70%'},
});
var count = Ti.UI.createLabel({
- text: '00:00',
- color: '#444',
- top: 20,
- font:{fontSize: '250%'},
+ text: '00:00',
+ color: '#444',
+ top: 20,
+ font:{fontSize: '250%'},
});
var footer = Ti.UI.createView({
- backgroundColor: '#333',
- height: '10%'
+ backgroundColor: '#333',
+ height: '10%'
});
var toolview = Ti.UI.createView({
- backgroundColor: '#333',
- layout: 'horizontal',
- left: 20,
- top: 10
+ backgroundColor: '#333',
+ layout: 'horizontal',
+ left: 20,
+ top: 10
});
var start = Ti.UI.createButton({
- title: 'start',
- height: 42,
+ title: 'start',
+ height: 42,
});
var stop = Ti.UI.createButton({
- title: 'stop',
- left: 10,
- height: 42,
+ title: 'stop',
+ left: 10,
+ height: 42,
});
var clear = Ti.UI.createButton({
- title: 'clear',
- left: 10,
- height: 42,
+ title: 'clear',
+ left: 10,
+ height: 42,
});
var spanSwitch = Ti.UI.createSwitch({
- left: 10,
- value: true
+ left: 10,
+ value: true
});
function date_format(counting) {
- var min = parseInt(counting / 60);
- var sec = counting % 60;
- var disp_time = '';
+ var min = parseInt(counting / 60);
+ var sec = counting % 60;
+ var disp_time = '';
- if (min < 10) {
- disp_time += '0';
- }
- disp_time += min;
- disp_time += ':';
- if (sec < 10) {
- disp_time += '0';
- }
- disp_time += sec;
- return disp_time;
+ if (min < 10) {
+ disp_time += '0';
+ }
+ disp_time += min;
+ disp_time += ':';
+ if (sec < 10) {
+ disp_time += '0';
+ }
+ disp_time += sec;
+ return disp_time;
};
function update () {
- var tmp_time = new Date();
+ var tmp_time = new Date();
- if (tmp_time.getSeconds() != past_time.getSeconds()) {
- counting -= 1;
- if (counting < 0) {
- qa.text = 'Finish!';
- count.text = "88888888";
- stop.fireEvent('click');
- } else {
- if (counting == remain) {
- contents.backgroundColor = '#777';
- qa.text = 'Question?';
- }
- count.text = date_format(counting);
- past_time = tmp_time;
- timer_id = setTimeout("update()", 100);
- }
- } else {
- timer_id = setTimeout("update()", 100);
- }
+ if (tmp_time.getSeconds() != past_time.getSeconds()) {
+ counting -= 1;
+ if (counting < 0) {
+ qa.text = 'Finish!';
+ count.text = "88888888";
+ stop.fireEvent('click');
+ } else {
+ if (counting == remain) {
+ contents.backgroundColor = '#777';
+ qa.text = 'Question?';
+ }
+ count.text = date_format(counting);
+ past_time = tmp_time;
+ timer_id = setTimeout("update()", 300);
+ }
+ } else {
+ timer_id = setTimeout("update()", 300);
+ }
};
-var start_time;
var past_time;
var counting;
var timer_id;
var pause = 0;
function timerClear(){
- start_time = new Date();
- past_time = start_time;
- if (spanSwitch.value) {
- counting = 25 * 60;
- } else {
- counting = 15 * 60;
- }
- remain = 5 * 60;
- count.text = date_format(counting);
- qa.text = '';
- contents.backgroundColor = '#000';
- pause = 0;
+ var start_time = new Date();
+ past_time = start_time;
+ if (spanSwitch.value) {
+ counting = 25 * 60;
+ } else {
+ counting = 15 * 60;
+ }
+ remain = 5 * 60;
+ count.text = date_format(counting);
+ qa.text = '';
+ contents.backgroundColor = '#000';
+ pause = 0;
};
clear.addEventListener('click', function (){
- timerClear();
+ timerClear();
});
start.addEventListener('click', function () {
- if (pause === 0) {
- timerClear();
- } else {
- var tmp_time = new Date();
- past_time = tmp_time;
- }
- pause = 0;
- timer_id = setTimeout("update()", 300);
+ if (pause === 0) {
+ timerClear();
+ } else {
+ var tmp_time = new Date();
+ past_time = tmp_time;
+ }
+ pause = 0;
+ timer_id = setTimeout("update()", 300);
});
stop.addEventListener('click', function () {
- console.log("stop timer.");
- clearTimeout(timer_id);
- pause = 1;
+ clearTimeout(timer_id);
+ pause = 1;
});
top.add(title);
View
4 build/mobileweb/titanium/filesystem.registry
@@ -1,10 +1,10 @@
-ts 1349610812000
+ts 1349612354000
Default-Landscape.jpg 36232
Default-Portrait.jpg 28479
Default.jpg 17184
KS_nav_ui.png 1158
KS_nav_views.png 1074
-app.js 2843
+app.js 3166
appicon.png 19109
apple-touch-icon-114x114-precomposed.png 15820
apple-touch-icon-57x57-precomposed.png 6790

0 comments on commit 2e3eb21

Please sign in to comment.
Something went wrong with that request. Please try again.