You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
405 lines
12 KiB
405 lines
12 KiB
14 years ago
|
/*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
14 years ago
|
|
||
|
function init(){
|
||
|
|
||
13 years ago
|
var tempHours;
|
||
|
var tempMinutes;
|
||
|
var tempSeconds;
|
||
14 years ago
|
|
||
13 years ago
|
if(window.sankore){
|
||
|
tempHours = window.sankore.preference("hours","00");
|
||
|
tempMinutes = window.sankore.preference("minutes","00");
|
||
|
tempSeconds = window.sankore.preference("seconds","00");
|
||
|
} else {
|
||
|
tempHours = "00";
|
||
|
tempMinutes = "00";
|
||
|
tempSeconds = "00";
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
var ubwidget = $("#ubwidget").ubwidget({
|
||
|
width:252,
|
||
|
height:89
|
||
|
});
|
||
14 years ago
|
|
||
14 years ago
|
var space = $("<div style='font-size:15px'>h</div>").ubwbutton({
|
||
|
w:17,
|
||
|
h:68
|
||
|
});
|
||
|
space.find(".ubw-button-body").css({
|
||
|
borderLeft:"none",
|
||
|
borderRight:"none"
|
||
|
});
|
||
|
var spaceb = $("<div style='font-size:15px'>m</div>").ubwbutton({
|
||
|
w:17,
|
||
|
h:68
|
||
|
});
|
||
|
spaceb.find(".ubw-button-body").css({
|
||
|
borderLeft:"none",
|
||
|
borderRight:"none"
|
||
|
});
|
||
|
spaceb.find(".ubw-button-canvas").unbind("mouseenter");
|
||
|
var spacec = $("<div style='font-size:15px'>s</div>").ubwbutton({
|
||
|
w:17,
|
||
|
h:68
|
||
|
});
|
||
|
spacec.find(".ubw-button-body").css({
|
||
|
borderLeft:"none",
|
||
|
borderRight:"none"
|
||
|
});
|
||
|
spacec.find(".ubw-button-canvas").unbind("mouseenter");
|
||
14 years ago
|
|
||
|
var hours = $("<div class='scroll' id='hours'>" + tempHours + "</div>").ubwbutton({
|
||
14 years ago
|
w:52,
|
||
|
h:68
|
||
|
}, {
|
||
|
bottom:1,
|
||
|
top:1,
|
||
|
right:0,
|
||
|
left:0
|
||
|
});
|
||
|
hours.find(".ubw-button-body").css({
|
||
|
borderRight:"none"
|
||
|
});
|
||
14 years ago
|
var minutes = $("<div class='scroll' id='minutes'>" + tempMinutes + "</div>").ubwbutton({
|
||
14 years ago
|
w:52,
|
||
|
h:68
|
||
|
}, {
|
||
|
bottom:1,
|
||
|
top:1,
|
||
|
right:0,
|
||
|
left:0
|
||
|
});
|
||
|
minutes.find(".ubw-button-body").css({
|
||
|
borderLeft:"none",
|
||
|
borderRight:"none"
|
||
|
});
|
||
14 years ago
|
var seconds = $("<div class='scroll' id='seconds'>" + tempSeconds + "</div>").ubwbutton({
|
||
14 years ago
|
w:52,
|
||
|
h:68
|
||
|
}, {
|
||
|
bottom:1,
|
||
|
top:1,
|
||
|
right:0,
|
||
|
left:0
|
||
|
});
|
||
14 years ago
|
|
||
14 years ago
|
seconds.find(".ubw-button-body").css({
|
||
|
borderLeft:"none",
|
||
|
borderRight:"none"
|
||
|
});
|
||
|
var pause = $("<div id='pausebutton'><img src='images/button_pause_invert.png'></div>")
|
||
|
pause.css({
|
||
|
marginLeft:8,
|
||
|
marginTop:3,
|
||
|
marginBottom:-2,
|
||
|
height:47
|
||
|
});
|
||
14 years ago
|
|
||
14 years ago
|
var reset = $("<div id='resetbutton'><img src='images/button_reset_invert.png'></div>")
|
||
|
.css({
|
||
|
marginLeft:8,
|
||
|
marginTop:1
|
||
|
})
|
||
|
.click(function(){
|
||
|
$("#hours").find(".ubw-button-content").text("00");
|
||
|
$("#minutes").find(".ubw-button-content").text("00");
|
||
|
$("#seconds").find(".ubw-button-content").text("00");
|
||
|
clearTimeout(currentTimer);
|
||
|
if(play){
|
||
|
$("#pausebutton").trigger("click");
|
||
|
}
|
||
|
});
|
||
14 years ago
|
|
||
14 years ago
|
if (window.widget) {
|
||
|
window.widget.onremove = function(){
|
||
|
if(play){
|
||
|
$("#pausebutton").trigger("click");
|
||
|
}
|
||
|
};
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
pause.toggle(
|
||
|
function(){
|
||
|
play = false;
|
||
|
clearTimeout(currentTimer);
|
||
|
$(this).find("img").attr("src", "images/button_play_invert.png");
|
||
|
},
|
||
|
function(){
|
||
|
if($("#hours").find(".ubw-button-content").text() != "00" ||
|
||
|
$("#minutes").find(".ubw-button-content").text() != "00" ||
|
||
|
$("#seconds").find(".ubw-button-content").text() != "00") {
|
||
|
|
||
|
play = true;
|
||
|
var timeInSeconds = parseInt($("#seconds").find(".ubw-button-content").text(), 10) +
|
||
|
parseInt($("#minutes").find(".ubw-button-content").text(), 10)*60 +
|
||
|
parseInt($("#hours").find(".ubw-button-content").text(), 10)*3600;
|
||
14 years ago
|
|
||
14 years ago
|
updateChronometerReverse(timeInSeconds);
|
||
14 years ago
|
|
||
14 years ago
|
$(this).find("img").attr("src", "images/button_pause_invert.png");
|
||
|
}
|
||
|
}
|
||
|
);/*.mouseenter(function(){
|
||
14 years ago
|
var o = $(this).find("img").attr("src");
|
||
|
$(this).find("img").attr("src", o.split(".")[0]+"xov.png");
|
||
|
}).mouseout(function(){
|
||
|
var o = $(this).find("img").attr("src");
|
||
|
$(this).find("img").attr("src", o.split("x")[0]+".png");
|
||
|
});*/
|
||
|
|
||
14 years ago
|
setTimeout(function(){
|
||
|
pause.trigger("click")
|
||
|
}, 200);
|
||
14 years ago
|
|
||
14 years ago
|
hours
|
||
|
.bind("mousedown", {
|
||
|
button:hours
|
||
|
}, timeButtonDownHandler)
|
||
|
.find(".ubw-button-arrowTop").bind("mousedown",{
|
||
|
button:hours
|
||
|
}, addbtn);
|
||
|
hours
|
||
|
.find(".ubw-button-arrowBottom").bind("mousedown",{
|
||
|
button:hours
|
||
|
}, rembtn);
|
||
|
minutes
|
||
|
.bind("mousedown", {
|
||
|
button:minutes
|
||
|
}, timeButtonDownHandler)
|
||
|
.find(".ubw-button-arrowTop").bind("mousedown",{
|
||
|
button:minutes
|
||
|
}, addbtn);
|
||
|
minutes
|
||
|
.find(".ubw-button-arrowBottom").bind("mousedown",{
|
||
|
button:minutes
|
||
|
}, rembtn);
|
||
|
seconds
|
||
|
.bind("mousedown", {
|
||
|
button:seconds
|
||
|
}, timeButtonDownHandler)
|
||
|
.find(".ubw-button-arrowTop").bind("mousedown",{
|
||
|
button:seconds
|
||
|
}, addbtn);
|
||
|
seconds
|
||
|
.find(".ubw-button-arrowBottom").bind("mousedown",{
|
||
|
button:seconds
|
||
|
}, rembtn);
|
||
14 years ago
|
|
||
14 years ago
|
$(document).mouseup(function(){
|
||
|
/*if(isScrolling){
|
||
14 years ago
|
$().unbind("mousemove");
|
||
|
activeTimeScroll.find(".ubw-button-canvas")
|
||
|
.bind("mouseleave", {button:activeTimeScroll}, buttonOutHandler)
|
||
|
.bind("mouseenter", {button:activeTimeScroll}, buttonOverHandler);
|
||
|
};*/
|
||
14 years ago
|
clearTimeout(incDecTime);
|
||
|
});
|
||
14 years ago
|
|
||
14 years ago
|
var btnsWrapper = $("<div></div>")
|
||
|
.css({
|
||
|
float:"left",
|
||
|
marginLeft:5,
|
||
|
marginTop:6
|
||
|
})
|
||
|
.append(pause)
|
||
|
.append(reset);
|
||
14 years ago
|
|
||
14 years ago
|
ubwidget
|
||
|
.append(hours)
|
||
|
.append(space.clone())
|
||
|
.append(minutes)
|
||
|
.append(spaceb)
|
||
|
.append(seconds)
|
||
|
.append(spacec)
|
||
|
.append(btnsWrapper);
|
||
14 years ago
|
|
||
14 years ago
|
clearTimeout(currentTimer);
|
||
14 years ago
|
|
||
14 years ago
|
var currentTimer = null;
|
||
|
var incDecTime = null;
|
||
|
var play = true;
|
||
|
var isScrolling = false;
|
||
|
var reverse = true;
|
||
|
var activeTimeScroll = null;
|
||
14 years ago
|
|
||
14 years ago
|
function addbtn(m){
|
||
14 years ago
|
|
||
14 years ago
|
var button = m.data.button;
|
||
|
var content = button.find(".ubw-button-content");
|
||
14 years ago
|
|
||
14 years ago
|
if(content.text().substr(0, 1) == "0"){
|
||
|
content.text(content.text().substr(1, content.text().length))
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
content.text(formatTime(parseInt(content.text())+1));
|
||
14 years ago
|
|
||
14 years ago
|
incDecTime = setTimeout(function(){
|
||
|
addbtn(m)
|
||
|
},150);
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
function rembtn(m){
|
||
14 years ago
|
|
||
14 years ago
|
var button = m.data.button;
|
||
|
var content = button.find(".ubw-button-content");
|
||
14 years ago
|
|
||
14 years ago
|
if(content.text().substr(0, 1) == "0"){
|
||
|
content.text(content.text().substr(1, content.text().length))
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
content.text(formatTime(parseInt(content.text())-1));
|
||
14 years ago
|
|
||
14 years ago
|
incDecTime = setTimeout(function(){
|
||
|
rembtn(m);
|
||
|
},150);
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
function timeButtonDownHandler(m){
|
||
13 years ago
|
var button = m.data.button;
|
||
|
var content = button.find(".ubw-button-content");
|
||
|
if(window.sankore){
|
||
|
var temp = button.attr("id");
|
||
|
switch(temp){
|
||
|
case "seconds":
|
||
|
window.sankore.setPreference("seconds", content.text());
|
||
|
break;
|
||
|
case "minutes":
|
||
|
window.sankore.setPreference("minutes", content.text());
|
||
|
break;
|
||
|
case "hours":
|
||
|
window.sankore.setPreference("hours", content.text());
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
14 years ago
|
/*var mouseStart = {
|
||
14 years ago
|
pageX:m.pageX,
|
||
|
pageY:m.pageY
|
||
14 years ago
|
};*/
|
||
14 years ago
|
var val = content.text();
|
||
|
isScrolling = true;
|
||
|
reverse = true;
|
||
|
activeTimeScroll = button;
|
||
|
if(play){
|
||
|
$("#pausebutton").trigger("click");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
/*button.find(".ubw-button-canvas")
|
||
14 years ago
|
.unbind("mouseenter")
|
||
|
.unbind("mouseleave");
|
||
|
|
||
|
$().bind("mousemove", function(e){
|
||
|
var value = {
|
||
|
x:mouseStart.pageX-e.pageX,
|
||
|
y:mouseStart.pageY-e.pageY
|
||
|
};
|
||
|
hvalue = Math.floor(value.y/10);
|
||
|
content.text(parseInt(val)+Math.floor(hvalue));
|
||
|
|
||
|
content.text(content.text()%60);
|
||
|
if(content.text() < 0)content.text(0);
|
||
|
});*/
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
14 years ago
|
function buttonOverHandler(e) {
|
||
|
var button = e.data.button;
|
||
|
var buttonbody = button.find(".ubw-button-body");
|
||
14 years ago
|
|
||
14 years ago
|
button.css({
|
||
|
zIndex:1
|
||
|
})
|
||
|
buttonbody.removeClass("ubw-button-out")
|
||
|
.addClass("ubw-button-over")
|
||
|
.css({
|
||
|
fontSize:"125%"
|
||
|
});
|
||
14 years ago
|
|
||
14 years ago
|
button.find(".ubw-button-canvas").find(".ubw-button-arrowTop").children("img").attr("src", "images/arrows_over/top.png");
|
||
|
button.find(".ubw-button-canvas").find(".ubw-button-arrowBottom").children("img").attr("src", "images/arrows_over/bottom.png");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
function buttonOutHandler(e){
|
||
|
var button = e.data.button;
|
||
|
var buttonbody = button.find(".ubw-button-body");
|
||
14 years ago
|
|
||
14 years ago
|
button.css({
|
||
|
zIndex:0
|
||
|
});
|
||
|
buttonbody.removeClass("ubw-button-over")
|
||
|
.addClass("ubw-button-out")
|
||
|
.css({
|
||
|
fontSize:"100%"
|
||
|
});
|
||
14 years ago
|
|
||
14 years ago
|
button.find(".ubw-button-canvas").find(".ubw-button-arrowTop").children("img").attr("src", "images/arrows_out/top.png");
|
||
|
button.find(".ubw-button-canvas").find(".ubw-button-arrowBottom").children("img").attr("src", "images/arrows_out/top.png");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
function updateChronometerReverse(seconds){
|
||
14 years ago
|
|
||
14 years ago
|
currentTimer = setTimeout(function(){
|
||
|
updateChronometerReverse(seconds-1)
|
||
|
}, 1000);
|
||
|
if (seconds < 6 && seconds > 0){
|
||
13 years ago
|
DHTMLSound(1);
|
||
14 years ago
|
}else if(seconds === 0){
|
||
13 years ago
|
DHTMLSound(2);
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
14 years ago
|
if(seconds < 1){
|
||
|
seconds = 0;
|
||
|
$("#pausebutton").trigger("click");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
var hoursValue = $("#hours").find(".ubw-button-content");
|
||
|
var minutesValue = $("#minutes").find(".ubw-button-content");
|
||
|
var secondsValue = $("#seconds").find(".ubw-button-content");
|
||
14 years ago
|
|
||
14 years ago
|
var currentSecond = String(seconds%60);
|
||
|
var currentMinute = String(Math.floor(seconds/60)%60);
|
||
|
var currentHour = String(Math.floor(seconds/3600));
|
||
14 years ago
|
|
||
14 years ago
|
hoursValue.text(formatTime(currentHour));
|
||
|
minutesValue.text(formatTime(currentMinute));
|
||
|
secondsValue.text(formatTime(currentSecond));
|
||
14 years ago
|
|
||
13 years ago
|
if(window.sankore){
|
||
|
window.sankore.setPreference("hours", hoursValue.text());
|
||
|
window.sankore.setPreference("minutes", minutesValue.text());
|
||
|
window.sankore.setPreference("seconds", secondsValue.text());
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
14 years ago
|
function formatTime(time){
|
||
14 years ago
|
|
||
14 years ago
|
document.title = time +", " + String(time).length;
|
||
14 years ago
|
|
||
14 years ago
|
if(time<0){
|
||
|
time = 59;
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
time = time%60;
|
||
14 years ago
|
|
||
14 years ago
|
String(time).length < 2 ? time = "0"+time : time = time;
|
||
14 years ago
|
|
||
14 years ago
|
return time;
|
||
|
}
|
||
14 years ago
|
|
||
13 years ago
|
function DHTMLSound(type) {
|
||
|
var ad = document.getElementById("audio" + type);
|
||
|
ad.play();
|
||
14 years ago
|
}
|
||
14 years ago
|
}
|