--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Piano</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>json.validation.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.tizen.web.jslint.nature.JSLintBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.tizen.web.css.nature.CSSBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.tizen.web.project.builder.WebBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>usedLibraryType</key>
+ <value>WebUIFramework</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>json.validation.nature</nature>
+ <nature>org.tizen.web.jslint.nature.JSLintNature</nature>
+ <nature>org.tizen.web.css.nature.CSSNature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.tizen.web.project.builder.WebNature</nature>
+ </natures>
+</projectDescription>
<head>
<meta name="viewport" content="width=800, user-scalable=no">
<link rel="stylesheet" href="./css/style.css" />
- <script type="text/javascript" src="./js/jquery-1.6.4.min.js" defer="defer"></script>
- <script type="text/javascript" src="./js/jquery.mobile-1.0.min.js" defer="defer"></script>
- <script type="text/javascript" src="./js/main.js" defer="defer"></script>
+ <script src="/usr/share/tizen-web-ui-fw/latest/js/jquery.min.js"></script>
+ <script type="text/javascript" src="./js/main.js"></script>
</head>
<body ondragstart="return false" onselectstart="return false">
"use strict";
Piano.prototype = {
touchPianoKey: [],
+ lockIds: {},
audio: []
};
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');
});
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;
+ });
}
};
* @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]) {
this.audio[nrAudio].src = this.audio[nrAudio].name + ".wav";
}
this.audio[nrAudio].play();
+ if (callback instanceof Function) {
+ callback.call(this);
+ }
}
};