summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorAlex Xu <alex_y_xu@yahoo.ca>2013-06-20 22:37:35 -0400
committerAlex Xu <alex_y_xu@yahoo.ca>2013-06-21 13:23:45 -0400
commit337bdbbc21e4e091cb0d53a8266504a6506fec51 (patch)
treead0a685591d921abdf975f4286aa910758fd754f /www
parent81f028bb73e43bbe9c5252085ebb2f2d55290f7b (diff)
downloadhtml5ks-337bdbbc21e4e091cb0d53a8266504a6506fec51.tar.xz
html5ks-337bdbbc21e4e091cb0d53a8266504a6506fec51.zip
still working
Diffstat (limited to 'www')
-rw-r--r--www/index.html3
-rw-r--r--www/js/html5ks.js53
2 files changed, 41 insertions, 15 deletions
diff --git a/www/index.html b/www/index.html
index e58669c..91d6de4 100644
--- a/www/index.html
+++ b/www/index.html
@@ -20,12 +20,13 @@
#container {
width: 800px;
height: 600px;
+ position: absolute;
top: 50%;
margin-top: -300px;
left: 50%;
margin-left: -400px;
- position: absolute;
overflow: hidden;
+ cursor: url("dump/ui/mousecursor.png"), default;
}
@keyframes toright {
from {
diff --git a/www/js/html5ks.js b/www/js/html5ks.js
index 92eb3c8..09e94c0 100644
--- a/www/js/html5ks.js
+++ b/www/js/html5ks.js
@@ -11,7 +11,8 @@ window.html5ks = {
hdisabled: false,
settings: {
// ms per character
- autospeed: 20
+ autospeed: 20,
+ fade: 100
}
},
save: function () {
@@ -40,15 +41,35 @@ window.html5ks = {
scene_register: function (scene) {
this.persistent.seen_scenes.scene = true;
},
+ fading: function (audio, dir, fade) {
+ var fadeSet = html5ks.persistent.settings.fade,
+ step = fadeSet / (fade * 1000),
+ over = audio.volume + step * dir;
+ console.log(arguments);
+ if (over > 1) {
+ audio.volume = 1;
+ } else if (over < 0) {
+ audio.volume = 0;
+ } else {
+ audio.volume += step * dir;
+ setTimeout(function () {
+ html5ks.fading(audio, dir, fade);
+ }, fadeSet);
+ }
+ },
play: function (channel, name, fade) {
// TODO: fade
var deferred = when.defer(),
audio = this.elements.audio[channel];
audio.src = "/dump/" + (channel === "music" ? "bgm/" + this.music[name] + ".ogg" : this.sfx[name]);
audio.load();
+ if (fade) {
+ audio.volume = 0;
+ }
audio.play();
audio.addEventListener("playing", function () {
deferred.resolve(this);
+ html5ks.fading(audio, 1, fade);
}, false);
audio.addEventListener("error", function () {
deferred.reject(this.error);
@@ -56,10 +77,14 @@ window.html5ks = {
return deferred.promise;
},
stop: function (channel, fade) {
- var deferred = when.defer();
- // TODO: fade
- // TODO: event?
- this.elements.audio[channel].pause();
+ var deferred = when.defer(),
+ audio = this.elements.audio[channel],
+ fadeSet = html5ks.persistent.settings.fade;
+ if (fade) {
+ html5ks.fading(audio, -1, fade);
+ } else {
+ audio.pause();
+ }
deferred.resolve();
return deferred.promise;
},
@@ -97,11 +122,10 @@ window.html5ks = {
},
// NOT iscene
scene: function (type, name) {
- var deferred = when.defer();
+ var deferred = when.defer(),
+ nom = type;
if (name) {
- var nom = type + "_" + name;
- } else {
- var nom = type;
+ nom = type + "_" + name;
}
var bg = this.elements.img.bg;
var image = this.images[nom];
@@ -130,11 +154,12 @@ window.html5ks = {
},
scale: function () {
var height = document.documentElement.clientHeight,
- width = document.documentElement.clientWidth;
+ width = document.documentElement.clientWidth,
+ newScale = 1;
if (height / width <= 0.75) { // widescreen
- var newScale = height / 600;
+ newScale = height / 600;
} else {
- var newScale = width / 800;
+ newScale = width / 800;
}
this.elements.container.style.webkitTransform = "scale(" + newScale + ")";
this.elements.container.style.mozTransform = "scale(" + newScale + ")";
@@ -149,11 +174,11 @@ window.html5ks = {
this.next = function () {
deferred.resolve(text);
this.next = function () {};
- }
+ };
setTimeout(this.next, 1000 + this.persistent.settings.autospeed * text.length);
return deferred.promise;
};
- };
+ }
},
onload: function () {
this.load();