From 4dcd04b01cd0b723b0fd23745a0eca51f5435b00 Mon Sep 17 00:00:00 2001 From: "ji.ji" Date: Wed, 26 Jun 2013 19:09:22 +0900 Subject: [PATCH] Updated Private -> RSA Change-Id: I94bad00c7a4682ebfbdccd42d442439ef1be6697 --- .project | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config.xml | 4 ++-- css/style.css | 2 +- index.html | 5 ++--- js/main.js | 32 ++++++++++++++++++++++++++------ 5 files changed, 88 insertions(+), 12 deletions(-) create mode 100755 .project diff --git a/.project b/.project new file mode 100755 index 0000000..49bdd3a --- /dev/null +++ b/.project @@ -0,0 +1,57 @@ + + + Piano + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + json.validation.builder + + + + + org.tizen.web.jslint.nature.JSLintBuilder + + + + + org.tizen.web.css.nature.CSSBuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.tizen.web.project.builder.WebBuilder + + + usedLibraryType + WebUIFramework + + + + + + json.validation.nature + org.tizen.web.jslint.nature.JSLintNature + org.tizen.web.css.nature.CSSNature + org.eclipse.wst.jsdt.core.jsNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.tizen.web.project.builder.WebNature + + diff --git a/config.xml b/config.xml index b961e8e..93fabd2 100755 --- a/config.xml +++ b/config.xml @@ -1,6 +1,6 @@ - - + + Piano diff --git a/css/style.css b/css/style.css index ff512bb..93d6cb9 100755 --- a/css/style.css +++ b/css/style.css @@ -34,7 +34,7 @@ body { height: 73.8%; background-size: 100%; background-position: top center; - position: absolute; + position: fixed; top: 0px; } diff --git a/index.html b/index.html index 4a99609..d77fe62 100755 --- a/index.html +++ b/index.html @@ -2,9 +2,8 @@ - - - + + diff --git a/js/main.js b/js/main.js index 99dc081..3d9b7ba 100644 --- a/js/main.js +++ b/js/main.js @@ -25,6 +25,7 @@ function Piano() { "use strict"; Piano.prototype = { touchPianoKey: [], + lockIds: {}, audio: [] }; @@ -40,6 +41,12 @@ function Piano() { tizen.application.getCurrentApplication().exit(); }); + document.addEventListener('tizenhwkey', function(e) { + if (e.keyName === "back") { + tizen.application.getCurrentApplication().exit(); + } + }); + $('#back').bind('touchend', function (event) { $(this).removeClass('active'); }); @@ -54,26 +61,36 @@ function Piano() { if (element) { if (this.touchPianoKey[touch.identifier] !== element.id) { $('#' + this.touchPianoKey[touch.identifier]).removeClass('pressed'); - this.playAudioByElement(element, touch.identifier); + this.playAudioByElement(element, touch.identifier, function () { + this.lockIds[element.id] = true; + }); } } } }; Piano.prototype.onPianoKeyTouchUp = function onPianoKeyTouchUp(data) { - var i, touchId, len; + var i, touchId, len, buttonId; for (i = 0, len = data.originalEvent.changedTouches.length; i < len; i += 1) { touchId = data.originalEvent.changedTouches[i].identifier; - $('#' + this.touchPianoKey[touchId]).removeClass('pressed'); + buttonId = this.touchPianoKey[touchId]; + setTimeout(function () { + (function (id) { + $('#' + id).removeClass('pressed'); + })(buttonId); + }, 100); this.touchPianoKey[touchId] = undefined; } }; Piano.prototype.audioInit = function audioInit() { - var i; + var i, self = this; for (i = 0; i <= 13; i += 1) { this.audio[i] = document.createElement('audio'); this.audio[i].name = i; + this.audio[i].addEventListener("playing", function(){ + self.lockIds["play" + this.name] = false; + }); } }; @@ -82,8 +99,8 @@ function Piano() { * @param {Object} element * @param {Number} touchId */ - Piano.prototype.playAudioByElement = function playAudioByElement(element, touchId) { - var nrAudio = parseInt(element.id.replace(/[a-zA-Z]*/, ''), 10); + Piano.prototype.playAudioByElement = function playAudioByElement(element, touchId, callback) { + var nrAudio = parseInt(element.id.substr(4), 10); $(element).addClass('pressed'); this.touchPianoKey[touchId] = element.id; if (this.audio[nrAudio]) { @@ -94,6 +111,9 @@ function Piano() { this.audio[nrAudio].src = this.audio[nrAudio].name + ".wav"; } this.audio[nrAudio].play(); + if (callback instanceof Function) { + callback.call(this); + } } }; -- 2.7.4