Initial commit
4
demo/filebrowser-durandal-widget/.bowerrc
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"directory" : "lib",
|
||||
"json" : "bower.json"
|
||||
}
|
||||
2
demo/filebrowser-durandal-widget/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
lib
|
||||
.codenvy
|
||||
7
demo/filebrowser-durandal-widget/MIT-LICENCE.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2015 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
19
demo/filebrowser-durandal-widget/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Durandal Filebrowser widget
|
||||
|
||||
## What's this widget ?
|
||||
|
||||
This [Durandal](http://durandaljs.com/) widget allows to display a folder tree and add some actions to manipulate this items :
|
||||
* A clic on a file or folder selects it
|
||||
* A double-clic opens / closes a folder
|
||||
* A double-clic displays the file content in the editor
|
||||
* A right-clic opens a context menu with different options :
|
||||
* Rename the item
|
||||
* Copy the selected item(s)
|
||||
* Paste the selected item(s)
|
||||
* Create an item (in a folder)
|
||||
* Delete an item (and its components)
|
||||
|
||||
|
||||
#Licence
|
||||
|
||||
Source code is under [MIT Licence](http://opensource.org/licenses/mit-license.php)
|
||||
44
demo/filebrowser-durandal-widget/app/main.js
Normal file
@@ -0,0 +1,44 @@
|
||||
requirejs.config({
|
||||
paths: {
|
||||
'text' : '../lib/requirejs-text/text',
|
||||
'durandal' : '../lib/durandal/js',
|
||||
'plugins' : '../lib/durandal/js/plugins',
|
||||
'transitions' : '../lib/durandal/js/transitions',
|
||||
'knockout' : '../lib/knockout.js/knockout',
|
||||
'knockout.mapping' : '../lib/bower-knockout-mapping/dist/knockout.mapping.min',
|
||||
'knockout.validation' : '../lib/knockout-validation/dist/knockout.validation.min',
|
||||
'jquery' : '../lib/jquery/jquery.min',
|
||||
'perfect.scrollbar' : '../lib/perfect-scrollbar/js/perfect-scrollbar.jquery',
|
||||
'highlightjs' : '../lib/highlightjs/highlight.pack'
|
||||
},
|
||||
shim: {
|
||||
'knockout.mapping': {
|
||||
deps: ['knockout'],
|
||||
exports: 'knockout.mapping'
|
||||
},
|
||||
'knockout.validation': {
|
||||
deps: ['knockout'],
|
||||
exports: 'knockout.validation'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
define(['durandal/system', 'durandal/app'], function (system, app) {
|
||||
system.debug(true);
|
||||
|
||||
app.title = 'File browser Durandal Widget';
|
||||
|
||||
app.configurePlugins({
|
||||
router : true,
|
||||
dialog : true,
|
||||
widget : {
|
||||
kinds: [
|
||||
'filebrowser'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
app.start().then(function() {
|
||||
app.setRoot('shell');
|
||||
});
|
||||
});
|
||||
34
demo/filebrowser-durandal-widget/app/shell.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="row-fluid">
|
||||
<aside class="col-sm-2 col-md-2">
|
||||
<div data-bind="widget: {kind:'filebrowser'}"></div>
|
||||
</aside>
|
||||
|
||||
<main class="col-sm-10 col-md-6" id="main">
|
||||
<pre data-bind="visible: content">
|
||||
<code data-bind="attr: {css: type}, text: content" id="editor"></code>
|
||||
</pre>
|
||||
<span class="text-center" data-bind="visible: !content()">Open file to view it.</span>
|
||||
</main>
|
||||
|
||||
<aside class="col-sd-12 col-md-4" id="helpPane">
|
||||
<h2>Welcome to the filebrowser Durandal widget demo</h2>
|
||||
<p>
|
||||
This <a href="http://durandaljs.com/" target="_blank">Durandal</a> widget allows to display a folder tree and add some actions to manipulate this items.
|
||||
<ul>
|
||||
<li>A clic on a file or folder selects it.
|
||||
<li>A double-clic opens / closes a folder</li>
|
||||
<li>A double-clic displays the file content in the editor</li>
|
||||
<li>
|
||||
A right-clic opens a context menu with different options :
|
||||
<ul>
|
||||
<li>Rename the item</li>
|
||||
<li>Copy the selected item(s)</li>
|
||||
<li>Paste the selected item(s)</li>
|
||||
<li>Create an item (in a folder)</li>
|
||||
<li>Delete an item (and its components)</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</aside>
|
||||
</div>
|
||||
26
demo/filebrowser-durandal-widget/app/shell.js
Normal file
@@ -0,0 +1,26 @@
|
||||
define(['durandal/app', 'knockout', 'highlightjs'], function (app, ko) {
|
||||
var type = ko.observable(),
|
||||
content = ko.observable();
|
||||
|
||||
var sub = app.on('filebrowser:open_file').then(function(message) {
|
||||
type(message.type);
|
||||
if( message.type === "json" ) {
|
||||
content(ko.utils.stringifyJson(message.content));
|
||||
} else {
|
||||
content(message.content);
|
||||
}
|
||||
hljs.highlightBlock($('#editor')[0]);
|
||||
}, this);
|
||||
|
||||
|
||||
return {
|
||||
attached: function () {
|
||||
hljs.configure({
|
||||
tabReplace: ' '
|
||||
});
|
||||
hljs.initHighlighting();
|
||||
},
|
||||
type: type,
|
||||
content: content
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" data-bind="click: close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">New item</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form data-bind="submit: ok" class="form-horizontal">
|
||||
<div class="row form-group">
|
||||
<label class="col-sm-2">Type</label>
|
||||
<div class="col-sm-10">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="typeItem" id="typeItemFile" value="file" data-bind="checked: typeItem"> File
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="typeItem" id="typeItemFolder" value="folder" data-bind="checked: typeItem"> Folder
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<label for="nameInput" class="col-sm-2 control-label">Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input data-bind="value: input, valueUpdate: 'afterkeydown'" name="nameInput" class="form-control autofocus"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" data-bind="click: ok, visible: isValid">Create</button>
|
||||
<button class="btn btn-default" data-bind="click: close">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
define(['plugins/dialog', 'knockout', 'knockout.validation'], function (dialog, ko, ko_validation) {
|
||||
|
||||
ko.validation = ko_validation;
|
||||
|
||||
var NewItemModal = function() {
|
||||
var self = this;
|
||||
self.input = ko.observable('').extend({
|
||||
required: true,
|
||||
pattern: {
|
||||
message : 'The name must not contain a \'/\'',
|
||||
params : '^[^/]+$'
|
||||
}
|
||||
});
|
||||
self.typeItem = ko.observable('file');
|
||||
self.form = ko.validatedObservable( {input: self.input} );
|
||||
self.isValid = ko.computed(function() {
|
||||
return self.form.isValid();
|
||||
});
|
||||
};
|
||||
|
||||
NewItemModal.prototype.ok = function() {
|
||||
dialog.close(this, { name: this.input(), type: this.typeItem()});
|
||||
};
|
||||
|
||||
NewItemModal.prototype.close = function() {
|
||||
dialog.close(this);
|
||||
};
|
||||
|
||||
NewItemModal.show = function(defaultValue){
|
||||
return dialog.show(new NewItemModal(defaultValue));
|
||||
};
|
||||
|
||||
return NewItemModal;
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" data-bind="click: close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Rename</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form data-bind="submit: ok" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="renameInput">New name</label>
|
||||
<input data-bind="value: input, valueUpdate: 'afterkeydown'" name="renameInput" class="form-control autofocus"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" data-bind="click: ok, visible: isValid">Ok</button>
|
||||
<button class="btn btn-default" data-bind="click: close">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
define(['plugins/dialog', 'knockout', , 'knockout.validation'], function (dialog, ko, ko_validation) {
|
||||
|
||||
ko.validation = ko_validation;
|
||||
|
||||
var RenameModal = function(defaultValue) {
|
||||
var self = this;
|
||||
self.previousName = defaultValue;
|
||||
self.input = ko.observable(defaultValue).extend({
|
||||
required: true,
|
||||
pattern: {
|
||||
message : 'The name must not contain a \'/\'',
|
||||
params : '^[^/]+$'
|
||||
}
|
||||
});
|
||||
self.form = ko.validatedObservable( {input: self.input} );
|
||||
self.isValid = ko.computed(function() {
|
||||
return self.form.isValid() && self.input() != self.previousName;
|
||||
});
|
||||
};
|
||||
|
||||
RenameModal.prototype.ok = function() {
|
||||
dialog.close(this, this.input());
|
||||
};
|
||||
|
||||
RenameModal.prototype.close = function() {
|
||||
dialog.close(this);
|
||||
};
|
||||
|
||||
RenameModal.show = function(defaultValue){
|
||||
return dialog.show(new RenameModal(defaultValue));
|
||||
};
|
||||
|
||||
return RenameModal;
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
<div id="filebrowser">
|
||||
<!-- ko if: folder() -->
|
||||
<!-- ko let: { loopRoot: $data } -->
|
||||
<ul data-bind="template: { name: 'tree-template', foreach: folder().children() }" class="tree-file"></ul>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
|
||||
<script id="tree-template" type="text/html">
|
||||
<!-- ko if: $data.type() === "folder" -->
|
||||
<li class="folder">
|
||||
<span data-bind="event: { contextmenu: loopRoot.openContextMenu, dblclick: loopRoot.open, click: loopRoot.select }">
|
||||
<i class="fa fa-folder-o" data-bind="attr: {id: 'icon_folder_' + $data.uuid()}"></i>
|
||||
<!-- ko text: $data.name --><!-- /ko -->
|
||||
</span>
|
||||
<input type="checkbox" data-bind="attr: {id: $data.uuid}" />
|
||||
<ul data-bind="template: { name: 'tree-template', foreach: $data.children }"></ul>
|
||||
</li>
|
||||
<!-- /ko -->
|
||||
<!--ko if: $data.type() !== "folder"-->
|
||||
<li data-bind="attr: {'data-id': $data.uuid, 'data-filetype': $data.type()},
|
||||
event: { contextmenu: loopRoot.openContextMenu, dblclick: loopRoot.open, click: loopRoot.select }"
|
||||
class="file">
|
||||
<!--ko ifnot: $data.type -->
|
||||
<i data-bind="attr: {class: 'fa fa-file-o'}"></i>
|
||||
<!-- /ko -->
|
||||
<!--ko if: $data.type -->
|
||||
<i data-bind="attr: {class: 'fa fa-file-' + $data.type() + '-o', title: $data.type()}"></i>
|
||||
<!-- /ko -->
|
||||
<span data-bind="text: $data.name, attr: {'data-extra': $data.extra ? $data.extra : ''}"></span>
|
||||
</li>
|
||||
<!-- /ko -->
|
||||
</script>
|
||||
|
||||
<!-- Context menu -->
|
||||
<div id="fileBrowserContextMenu" class="dropdown open" data-bind="visible: showContextMenu" tabindex="1">
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="contextMenu">
|
||||
<li data-bind="visible: hasSelectedFolder()" >
|
||||
<a role="menuitem" tabindex="-1" href="#" data-bind="click: newItem">New ...</a>
|
||||
</li>
|
||||
<li>
|
||||
<a role="menuitem" tabindex="-1" href="#" data-bind="click: openRenamePopup">Rename</a>
|
||||
</li>
|
||||
<li>
|
||||
<a role="menuitem" tabindex="-1" href="#" data-bind="click: copy">Copy</a>
|
||||
</li>
|
||||
<li data-bind="css: { 'disabled': !hasCopied()}, visible: hasSelectedFolder()">
|
||||
<a role="menuitem" tabindex="-1" href="#" data-bind="click: paste">Paste</a>
|
||||
</li>
|
||||
<li>
|
||||
<a role="menuitem" tabindex="-1" href="#" data-bind="click: openDeletePopup">Delete</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- End of Context menu -->
|
||||
</div>
|
||||
@@ -0,0 +1,147 @@
|
||||
define(['durandal/app', 'durandal/composition', 'plugins/http',
|
||||
'jquery', 'knockout', 'knockout.mapping',
|
||||
'perfect.scrollbar',
|
||||
'./renameModal', './newItemModal'],
|
||||
function(app, composition,http, $, ko, ko_mapping, perfectScrollbar, RenameModal, NewItemModal) {
|
||||
|
||||
ko.mapping = ko_mapping;
|
||||
|
||||
ko.bindingHandlers['let'] = {
|
||||
'init': function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
||||
// Make a modified binding context, with extra properties, and apply it to descendant elements
|
||||
var innerContext = bindingContext.extend(valueAccessor());
|
||||
ko.applyBindingsToDescendants(innerContext, element);
|
||||
|
||||
return { controlsDescendantBindings: true };
|
||||
}
|
||||
};
|
||||
ko.virtualElements.allowedBindings['let'] = true;
|
||||
|
||||
var ctor = function() {},
|
||||
selected = ko.observable(),
|
||||
showContextMenu = ko.observable(),
|
||||
copied = ko.observable(undefined),
|
||||
folder = ko.observable(ko.mapping.fromJS({children: []})),
|
||||
scrollable = $('#filebrowser');
|
||||
|
||||
ctor.prototype.attached = function() {
|
||||
showContextMenu(false);
|
||||
$('#filebrowser').perfectScrollbar();
|
||||
};
|
||||
|
||||
ctor.prototype.activate = function(settings) {
|
||||
this.settings = settings;
|
||||
this.selected = selected;
|
||||
this.folder = folder;
|
||||
this.showContextMenu = showContextMenu;
|
||||
this.hasSelectedFolder = ko.computed(function() {
|
||||
return selected() != undefined && selected().type === 'folder';
|
||||
});
|
||||
this.hasCopied = ko.computed( function() {
|
||||
return copied() !== undefined;
|
||||
});
|
||||
};
|
||||
|
||||
ctor.prototype.open = function(object,event) {
|
||||
console.log('Opening', object);
|
||||
if( object.type() === 'folder' ) {
|
||||
var id = object.uuid(),
|
||||
checkbox = $('input[type=checkbox][id=' + id + ']');
|
||||
|
||||
checkbox.prop('checked', !checkbox.prop('checked'));
|
||||
$('#icon_folder_' + id).toggleClass('fa-folder-o').toggleClass('fa-folder-open-o');
|
||||
|
||||
$('#filebrowser').perfectScrollbar('update');
|
||||
} else {
|
||||
var type = object.extra();
|
||||
http.get(object.path()).then(function(response) {
|
||||
app.trigger('filebrowser:open_file', {
|
||||
type: type,
|
||||
content: response
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
ctor.prototype.select = function(object, event) {
|
||||
$('li > span.select').removeClass('select');
|
||||
$(event.target).toggleClass('select');
|
||||
selected( ko.mapping.fromJS(object) );
|
||||
};
|
||||
|
||||
/** Context Menu **/
|
||||
|
||||
ctor.prototype.openContextMenu = function(object, event) {
|
||||
// Position du menu, calculer la pos pour eviter sortie du viewport
|
||||
var posX = event.pageX,
|
||||
posY = event.pageY,
|
||||
windowWidth = $(window).width(),
|
||||
windowHeight = $(window).height(),
|
||||
contextMenu = $('#fileBrowserContextMenu'),
|
||||
menuWidth = contextMenu.width(),
|
||||
menuHeight = contextMenu.height();
|
||||
|
||||
posX = Math.min(posX, windowWidth - menuWidth - 15);
|
||||
posY = Math.min(posY, windowHeight - menuHeight - 10);
|
||||
|
||||
// affichage
|
||||
contextMenu.css({
|
||||
left : posX + 'px',
|
||||
top : posY + 'px'
|
||||
});
|
||||
|
||||
|
||||
showContextMenu(true);
|
||||
};
|
||||
|
||||
ctor.prototype.openRenamePopup = function(ctor, event) {
|
||||
RenameModal.show(ctor.selected().name()).then(function(response) {
|
||||
if( response !== undefined ) {
|
||||
ctor.selected().name(response);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ctor.prototype.openDeletePopup = function(ctor, event) {
|
||||
app.showMessage(
|
||||
'Are you sure you want to delete this ' +
|
||||
(ctor.selected().is_folder ? ' folder and all its content' : 'file') + '?',
|
||||
'Delete ' + ctor.selected().name(), [ { text: "Yes", value: "yes" }, { text: "No", value: "no" }]).then( function( dialogResult ) {
|
||||
if( dialogResult === 'yes' ) {
|
||||
console.log('Deleting', ctor.selected().name());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ctor.prototype.copy = function(ctor, event) {
|
||||
console.log('Copied', ctor.selected().name());
|
||||
copied( ctor.selected() );
|
||||
};
|
||||
|
||||
ctor.prototype.paste = function(ctor, event) {
|
||||
if( copied() !== undefined ) {
|
||||
console.log('Paste', copied().name(), 'into', ctor.selected().name());
|
||||
copied( undefined );
|
||||
}
|
||||
};
|
||||
|
||||
ctor.prototype.newItem = function(ctor, event) {
|
||||
NewItemModal.show().then(function(response) {
|
||||
if( response !== undefined ) {
|
||||
console.log('New item : ' + response.type + ' - ' + response.name );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on('click', function() {
|
||||
showContextMenu(false);
|
||||
});
|
||||
/** End of Context Menu */
|
||||
|
||||
http.get('/data/filesystem.json').then(function(response) {
|
||||
folder(ko.mapping.fromJS(response));
|
||||
$('#filebrowser').perfectScrollbar('update');
|
||||
});
|
||||
|
||||
return ctor;
|
||||
});
|
||||
15
demo/filebrowser-durandal-widget/bower.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "filebrowser-durandal-widget",
|
||||
"version": "0.0.1-SNAPSHOT",
|
||||
"dependencies" : {
|
||||
"durandal" : "~2.1.0",
|
||||
"knockout-validation" : "~2.0.2",
|
||||
"bower-knockout-mapping" : "~2.5.0",
|
||||
"perfect-scrollbar" : "~0.6.0",
|
||||
"bootstrap" : "~3.3.4",
|
||||
"fontawesome" : "~4.3.0",
|
||||
"less.js" : "~2.4.0",
|
||||
"lesshat" : "~3.0.2",
|
||||
"highlightjs" : "~8.4.0"
|
||||
}
|
||||
}
|
||||
154
demo/filebrowser-durandal-widget/data/filesystem.json
Normal file
@@ -0,0 +1,154 @@
|
||||
{
|
||||
"uuid":"workspace",
|
||||
"name":"workspace",
|
||||
"type":"folder",
|
||||
"children":[
|
||||
{
|
||||
"uuid":"app",
|
||||
"name":"app",
|
||||
"type":"folder",
|
||||
"children":[
|
||||
{
|
||||
"uuid":"widgets",
|
||||
"name":"widgets",
|
||||
"type":"folder",
|
||||
"children":[
|
||||
{
|
||||
"uuid":"filebrowser",
|
||||
"name":"filebrowser",
|
||||
"type":"folder",
|
||||
"children": [
|
||||
{
|
||||
"name":"newItemModal.html",
|
||||
"uuid":"newItemModalhtml",
|
||||
"type":"code",
|
||||
"extra":"html",
|
||||
"path": "/app/widgets/filebrowser/newItemModal.html"
|
||||
},
|
||||
{
|
||||
"name":"newItemModal.js",
|
||||
"uuid":"newItemModaljs",
|
||||
"type":"code",
|
||||
"extra":"javascript",
|
||||
"path": "/app/widgets/filebrowser/newItemModal.js"
|
||||
},
|
||||
{
|
||||
"name":"renameModal.html",
|
||||
"uuid":"renameModalhtml",
|
||||
"type":"code",
|
||||
"extra":"html",
|
||||
"path": "/app/widgets/filebrowser/renameModal.html"
|
||||
},
|
||||
{
|
||||
"name":"renameModal.js",
|
||||
"uuid":"renameModaljs",
|
||||
"type":"code",
|
||||
"extra":"javascript",
|
||||
"path": "/app/widgets/filebrowser/renameModal.js"
|
||||
},
|
||||
{
|
||||
"name":"view.html",
|
||||
"uuid":"viewhtml",
|
||||
"type":"code",
|
||||
"extra":"html",
|
||||
"path": "/app/widgets/filebrowser/view.html"
|
||||
},
|
||||
{
|
||||
"name":"viewmodel.js",
|
||||
"uuid":"viewmodeljs",
|
||||
"type":"code",
|
||||
"extra":"javascript",
|
||||
"path": "/app/widgets/filebrowser/viewmodel.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"main.js",
|
||||
"uuid":"mainjs",
|
||||
"type":"code",
|
||||
"extra":"javascript",
|
||||
"path": "/app/main.js"
|
||||
},
|
||||
{
|
||||
"name":"shell.html",
|
||||
"uuid":"shellhtml",
|
||||
"type":"code",
|
||||
"extra":"html",
|
||||
"path": "/app/shell.html"
|
||||
},
|
||||
{
|
||||
"name":"shell.js",
|
||||
"uuid":"shelljs",
|
||||
"type":"code",
|
||||
"extra":"javascript",
|
||||
"path": "/app/shell.js"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid":"data",
|
||||
"name":"data",
|
||||
"type":"folder",
|
||||
"children":[
|
||||
{
|
||||
"name":"filesystem.json",
|
||||
"uuid":"filesystemjson",
|
||||
"type":"code",
|
||||
"extra":"json",
|
||||
"path": "/data/filesystem.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "style",
|
||||
"name": "style",
|
||||
"type": "folder",
|
||||
"children": [
|
||||
{
|
||||
"name": "filebrowser.less",
|
||||
"uuid": "filebrowserless",
|
||||
"type": "code",
|
||||
"extra": "less",
|
||||
"path": "/style/filebrowser.less"
|
||||
},
|
||||
{
|
||||
"name": "global.less",
|
||||
"uuid": "globalless",
|
||||
"type": "code",
|
||||
"extra": "less",
|
||||
"path": "/style/global.less"
|
||||
},
|
||||
{
|
||||
"name": "starterkit.css",
|
||||
"uuid": "starterkitcss",
|
||||
"type": "code",
|
||||
"extra": "less",
|
||||
"path": "/style/starterkit.css"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "bowerrc",
|
||||
"name": ".bowerrc",
|
||||
"type": "code",
|
||||
"extra": "json",
|
||||
"path": "/.bowerrc"
|
||||
},
|
||||
{
|
||||
"uuid": "bowerjson",
|
||||
"name": "bower.json",
|
||||
"type": "code",
|
||||
"extra": "json",
|
||||
"path": "/bower.json"
|
||||
},
|
||||
{
|
||||
"uuid": "indexhtml",
|
||||
"name": "index.html",
|
||||
"type": "code",
|
||||
"extra": "html",
|
||||
"path": "/index.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
45
demo/filebrowser-durandal-widget/index.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.css"/>
|
||||
<link rel="stylesheet" href="lib/fontawesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="lib/durandal/css/durandal.css"/>
|
||||
<link rel="stylesheet" href="lib/perfect-scrollbar/css/perfect-scrollbar.css" />
|
||||
<link rel="stylesheet" href="lib/highlightjs/styles/github.css" />
|
||||
<link rel="stylesheet" href="style/starterkit.css" />
|
||||
<link rel="stylesheet/less" href="style/global.less" />
|
||||
<link rel="stylesheet/less" href="style/filebrowser.less" />
|
||||
|
||||
<script>
|
||||
less = {
|
||||
env: "development"
|
||||
};
|
||||
</script>
|
||||
<script src="lib/less.js/dist/less.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="#">Filebrowser Durandal Widget</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="applicationHost">
|
||||
<div class="splash">
|
||||
<h1 class="message">Filebrowser Durandal widget</h1>
|
||||
<i class="fa fa-spinner fa-2x fa-spin active"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="navbar navbar-default navbar-fixed-bottom">
|
||||
<div class="container">
|
||||
Footer
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<script src="lib/requirejs/require.js" data-main="app/main"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
56
demo/filebrowser-durandal-widget/style/filebrowser.less
Normal file
@@ -0,0 +1,56 @@
|
||||
@import "../lib/lesshat/build/lesshat.less";
|
||||
|
||||
#filebrowser {
|
||||
max-height: 500px;
|
||||
|
||||
position: relative;
|
||||
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.folder {
|
||||
|
||||
& > label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
& input[type=checkbox] {
|
||||
opacity: 0;
|
||||
|
||||
& + ul > li {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:checked + ul > li {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ul {
|
||||
&.tree-file {
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
};
|
||||
|
||||
.folder > span,
|
||||
.file > span {
|
||||
|
||||
.user-select(none);
|
||||
|
||||
&.select {
|
||||
font-weight: bold;
|
||||
}
|
||||
};
|
||||
|
||||
#fileBrowserContextMenu {
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.validationMessage {
|
||||
color: red;
|
||||
}
|
||||
9
demo/filebrowser-durandal-widget/style/global.less
Normal file
@@ -0,0 +1,9 @@
|
||||
body {
|
||||
padding-bottom: 100px;
|
||||
}
|
||||
|
||||
#editor {
|
||||
position: relative;
|
||||
|
||||
overflow: hidden;
|
||||
}
|
||||
52
demo/filebrowser-durandal-widget/style/starterkit.css
Normal file
@@ -0,0 +1,52 @@
|
||||
/*!
|
||||
* Durandal 2.1.0 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved.
|
||||
* Available via the MIT license.
|
||||
* see: http://durandaljs.com or https://github.com/BlueSpire/Durandal for details
|
||||
*/
|
||||
|
||||
.splash {
|
||||
text-align: center;
|
||||
margin: 10% 0 0 0;
|
||||
}
|
||||
|
||||
.splash .message {
|
||||
font-size: 3em;
|
||||
line-height: 1.5em;
|
||||
-webkit-text-shadow: rgba(0, 0, 0, 0.5) 0 0 15px;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 0 0 15px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.splash .fa-spinner {
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
font-size: 3em;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.page-host {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 50px;
|
||||
bottom: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
section {
|
||||
margin: 0 20px;
|
||||
}
|
||||
|
||||
.navbar-nav li.loader {
|
||||
margin: 12px 6px 0 6px;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.navbar-nav li.loader.active {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.pictureDetail {
|
||||
max-width: 425px;
|
||||
}
|
||||
7
demo/pacman/MIT-LICENCE.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
31
demo/pacman/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
gq-pacman is a jQuery implementation of the famous Namco's Pacman.
|
||||
|
||||
|
||||
How to :
|
||||
--------
|
||||
|
||||
Use your keyboard arrows to move Pacman to eat all energizer to complete the level.
|
||||
Ghosts become frightened when Pacman eats a big energizer. Eat them !!!
|
||||
|
||||
Beware of ghost who haunt the maze !!! Each one has his own personality :
|
||||
* Blinky tracks Pacman as his shadow.
|
||||
* Pinky perfoms ambushes to Pacman.
|
||||
* Inky is the least predictable.
|
||||
* Clyde pretends ignorance and is one who lags behind.
|
||||
|
||||
A live demo is avalaible [here](http://www.pavnay.fr/gq-pacman/)
|
||||
|
||||
Credits :
|
||||
---------
|
||||
|
||||
* Graphics : Fabrice Ecaille aka Febbweiss
|
||||
* Code : Fabrice Ecaille aka Febbweiss
|
||||
* Algorithm : Based on the ["Pacman Dossier"](http://home.comcast.net/~jpittman2/pacman/pacmandossier.html)
|
||||
* Tools : [gameQuery](http://gamequeryjs.com/)
|
||||
* Sounds : [Sound FX Center](http://soundfxcenter.com/sound_effect/search.php?sfx=Pacman)
|
||||
|
||||
Licences :
|
||||
----------
|
||||
|
||||
Source code is under [MIT Licence](http://opensource.org/licenses/mit-license.php)
|
||||
Sprite is under [CC BY-SA 3.0](http://creativecommons.org/licenses/by-sa/3.0/legalcode)
|
||||
12
demo/pacman/css/hack/csshover3.htc
Normal file
@@ -0,0 +1,12 @@
|
||||
<public:attach event="ondocumentready" onevent="CSSHover()" />
|
||||
<script>
|
||||
/**
|
||||
* Whatever:hover - V3.11
|
||||
* http://www.xs4all.nl/~peterned/
|
||||
*
|
||||
* Copyright (c) 2009 Peter Nederlof
|
||||
* Licensed under the LGPL license
|
||||
* http://creativecommons.org/licenses/LGPL/2.1
|
||||
*/
|
||||
window.CSSHover=(function(){var m=/(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active|focus))/i;var n=/(.*?)\:(hover|active|focus)/i;var o=/[^:]+:([a-z\-]+).*/i;var p=/(\.([a-z0-9_\-]+):[a-z]+)|(:[a-z]+)/gi;var q=/\.([a-z0-9_\-]*on(hover|active|focus))/i;var s=/msie (5|6|7)/i;var t=/backcompat/i;var u={index:0,list:['text-kashida','text-kashida-space','text-justify'],get:function(){return this.list[(this.index++)%this.list.length]}};var v=function(c){return c.replace(/-(.)/mg,function(a,b){return b.toUpperCase()})};var w={elements:[],callbacks:{},init:function(){if(!s.test(navigator.userAgent)&&!t.test(window.document.compatMode)){return}var a=window.document.styleSheets,l=a.length;for(var i=0;i<l;i++){this.parseStylesheet(a[i])}},parseStylesheet:function(a){if(a.imports){try{var b=a.imports;var l=b.length;for(var i=0;i<l;i++){this.parseStylesheet(a.imports[i])}}catch(securityException){}}try{var c=a.rules;var r=c.length;for(var j=0;j<r;j++){this.parseCSSRule(c[j],a)}}catch(someException){}},parseCSSRule:function(a,b){var c=a.selectorText;if(m.test(c)){var d=a.style.cssText;var e=n.exec(c)[1];var f=c.replace(o,'on$1');var g=c.replace(p,'.$2'+f);var h=q.exec(g)[1];var i=e+h;if(!this.callbacks[i]){var j=u.get();var k=v(j);b.addRule(e,j+':expression(CSSHover(this, "'+f+'", "'+h+'", "'+k+'"))');this.callbacks[i]=true}b.addRule(g,d)}},patch:function(a,b,c,d){try{var f=a.parentNode.currentStyle[d];a.style[d]=f}catch(e){a.runtimeStyle[d]=''}if(!a.csshover){a.csshover=[]}if(!a.csshover[c]){a.csshover[c]=true;var g=new CSSHoverElement(a,b,c);this.elements.push(g)}return b},unload:function(){try{var l=this.elements.length;for(var i=0;i<l;i++){this.elements[i].unload()}this.elements=[];this.callbacks={}}catch(e){}}};var x={onhover:{activator:'onmouseenter',deactivator:'onmouseleave'},onactive:{activator:'onmousedown',deactivator:'onmouseup'},onfocus:{activator:'onfocus',deactivator:'onblur'}};function CSSHoverElement(a,b,c){this.node=a;this.type=b;var d=new RegExp('(^|\\s)'+c+'(\\s|$)','g');this.activator=function(){a.className+=' '+c};this.deactivator=function(){a.className=a.className.replace(d,' ')};a.attachEvent(x[b].activator,this.activator);a.attachEvent(x[b].deactivator,this.deactivator)}CSSHoverElement.prototype={unload:function(){this.node.detachEvent(x[this.type].activator,this.activator);this.node.detachEvent(x[this.type].deactivator,this.deactivator);this.activator=null;this.deactivator=null;this.node=null;this.type=null}};window.attachEvent('onbeforeunload',function(){w.unload()});return function(a,b,c,d){if(a){return w.patch(a,b,c,d)}else{w.init()}}})();
|
||||
</script>
|
||||
267
demo/pacman/css/pacman.css
Normal file
@@ -0,0 +1,267 @@
|
||||
#playgroundContainer {
|
||||
width: 448px;
|
||||
height: 512px;
|
||||
background-color: black;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.actor {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
position: relative;
|
||||
margin-top: -16px;
|
||||
margin-left: -16px;
|
||||
}
|
||||
|
||||
/** TILES **/
|
||||
|
||||
.tile {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
float: left;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.corner1 {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -0px -0px;
|
||||
}
|
||||
|
||||
.corner2 {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -16px -0px;
|
||||
}
|
||||
|
||||
.corner3 {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -32px 0px;
|
||||
}
|
||||
|
||||
.corner4 {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -48px 0px;
|
||||
}
|
||||
|
||||
.horizontalMidUp {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -96px -0px;
|
||||
}
|
||||
|
||||
.horizontalMidDown {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -112px -0px;
|
||||
}
|
||||
|
||||
.verticalMidLeft {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -64px -0px;
|
||||
}
|
||||
|
||||
.verticalMidRight {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -80px -0px;
|
||||
}
|
||||
|
||||
.squareCornerTopLeft {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -128px -0px;
|
||||
}
|
||||
|
||||
.squareCornerTopRight {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -144px -0px;
|
||||
}
|
||||
|
||||
.squareCornerBottomLeft {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -160px -0px;
|
||||
}
|
||||
|
||||
.squareCornerBottomRight {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -176px -0px;
|
||||
}
|
||||
|
||||
.gate {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -192px -0px;
|
||||
}
|
||||
|
||||
.dot {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -0px;
|
||||
}
|
||||
|
||||
.bigDot {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -16px;
|
||||
}
|
||||
|
||||
.ghost {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.blinky {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -160px -48px;
|
||||
}
|
||||
.pinky {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -160px -80px;
|
||||
}
|
||||
.inky {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -160px -112px;
|
||||
}
|
||||
.clyde {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -160px -144px;
|
||||
}
|
||||
|
||||
.cherries {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -32px;
|
||||
}
|
||||
|
||||
.strawberry {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -48px;
|
||||
}
|
||||
|
||||
.peach {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -64px;
|
||||
}
|
||||
|
||||
.apple {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -80px;
|
||||
}
|
||||
|
||||
.grapes {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -96px;
|
||||
}
|
||||
|
||||
.galaxian {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -112px;
|
||||
}
|
||||
|
||||
.bell {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -128px;
|
||||
}
|
||||
|
||||
.key {
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: -208px -144px;
|
||||
}
|
||||
|
||||
.description {
|
||||
padding-left: 40px;
|
||||
line-height: 3em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
/** HUD **/
|
||||
|
||||
#message {
|
||||
position : absolute;
|
||||
left : 50%;
|
||||
top : 50%;
|
||||
}
|
||||
|
||||
#level {
|
||||
position : relative;
|
||||
top: -10px;
|
||||
left: 5px;
|
||||
}
|
||||
|
||||
#levelNumber {
|
||||
position : relative;
|
||||
top: -14px;
|
||||
float: left;
|
||||
margin-left: 100px;
|
||||
}
|
||||
|
||||
#lives {
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
#scoreMessage {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.life {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
float: left;
|
||||
background-image: url('../img/sprite.png');
|
||||
background-position: 0px -16px;
|
||||
}
|
||||
|
||||
/** SCOREBOARD**/
|
||||
|
||||
.clock {
|
||||
background : transparent url("../img/font.png") no-repeat top left;
|
||||
height:32px;
|
||||
width:32px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
.clock.red {
|
||||
background : transparent url("../img/font-red.png") no-repeat top left;
|
||||
}
|
||||
|
||||
.clock.yellow {
|
||||
background : transparent url("../img/font-yellow.png") no-repeat top left;
|
||||
}
|
||||
|
||||
.clock.small {
|
||||
position: relative;
|
||||
top: 45%;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.n0 {
|
||||
background-position : 0px 0px;
|
||||
}
|
||||
.n1 {
|
||||
background-position : -32px 0px;
|
||||
}
|
||||
.n2 {
|
||||
background-position : -64px 0px;
|
||||
}
|
||||
.n3 {
|
||||
background-position : -96px 0px;
|
||||
}
|
||||
.n4 {
|
||||
background-position : -128px 0px;
|
||||
}
|
||||
.n5 {
|
||||
background-position : -160px 0px;
|
||||
}
|
||||
.n6 {
|
||||
background-position : -192px 0px;
|
||||
}
|
||||
.n7 {
|
||||
background-position : -224px 0px;
|
||||
}
|
||||
.n8 {
|
||||
background-position : -256px 0px;
|
||||
}
|
||||
.n9 {
|
||||
background-position : -288px 0px;
|
||||
}
|
||||
|
||||
.hiddenDot {
|
||||
visibility: hidden;
|
||||
}
|
||||
BIN
demo/pacman/img/banner.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
demo/pacman/img/font-red.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
demo/pacman/img/font-yellow.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
demo/pacman/img/font.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
demo/pacman/img/sprite.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
44
demo/pacman/index.html
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pacman</title>
|
||||
<!--[if IE]>
|
||||
<style type="text/css" media="screen">
|
||||
body {
|
||||
behavior: url("css/hack/csshover3.htc");
|
||||
}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<script src="lib/jquery-1.8.3.min.js" type="text/javascript" ></script>
|
||||
<script src="lib/jquery-ui-1.8.23.custom.min.js" type="text/javascript" ></script>
|
||||
<script src="lib/soundmanager2.min.js" type="text/javascript"></script>
|
||||
<script src="lib/gamequery-0.7.0.js" type="text/javascript" ></script>
|
||||
<script src="lib/gamequery-soundwrapper-soundmanager.js" type="text/javascript"></script>
|
||||
<script src="js/utils.js" type="text/javascript"></script>
|
||||
<script src="js/scoreboard.js" type="text/javascript" ></script>
|
||||
<script src="js/pacman-data.js" type="text/javascript" ></script>
|
||||
<script src="js/pacman-ui.js" type="text/javascript" ></script>
|
||||
<script src="js/pacman-core.js" type="text/javascript" ></script>
|
||||
<link href="css/pacman.css" type="text/css" rel="stylesheet" media="screen, projection" />
|
||||
|
||||
<link href="../../extra/css/extra.css" type="text/css" rel="stylesheet" media="screen, projection" />
|
||||
<script src="../../extra/js/pacman.js" type="text/javascript" ></script>
|
||||
</head>
|
||||
<div>
|
||||
<div id="playgroundContainer">
|
||||
<div id="playground"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="text-align: center;margin-top: 00px;">
|
||||
<button id="startBtn" class="push--skeuo">Start</button>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
GUI.drawText( $("#ranking"), 'Howto');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1009
demo/pacman/js/pacman-core.js
Normal file
13
demo/pacman/js/pacman-data.js
Normal file
255
demo/pacman/js/pacman-ui.js
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
var SOUND_ACTIVATED = false;
|
||||
|
||||
var WIDTH_TILE_COUNT = 28;
|
||||
var HEIGHT_TILE_COUNT = 34;
|
||||
var TILE_SIZE = 16;
|
||||
var HALF_TILE_SIZE = 8;
|
||||
var ACTOR_SIZE = 32;
|
||||
var PLAYGROUND_WIDTH = WIDTH_TILE_COUNT * TILE_SIZE;
|
||||
var PLAYGROUND_HEIGHT = HEIGHT_TILE_COUNT * TILE_SIZE;
|
||||
var ACTOR_SPEED = 4;
|
||||
var LOOP_COUNT_REFRESH = 66;
|
||||
var loopCount = 0;
|
||||
var REFRESH_RATE = 15;
|
||||
//1: up, 2: left, 3:down, 4: right
|
||||
var UP = 1;
|
||||
var LEFT = 2;
|
||||
var DOWN = 3;
|
||||
var RIGHT = 4;
|
||||
|
||||
var BONUS_TILE = 77;
|
||||
|
||||
var eatenBonus = new Array();
|
||||
|
||||
var INFINITY = 9999999999;
|
||||
|
||||
$(function(){
|
||||
|
||||
//Playground Sprites
|
||||
$("#playground").playground({height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH, keyTracker: true});
|
||||
|
||||
$.playground({refreshRate: 60}).addGroup("background", {posx: 0, posy: 0, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
|
||||
.end()
|
||||
.addGroup("dots", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
|
||||
.end()
|
||||
.addGroup("actors", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
|
||||
.end()
|
||||
.addGroup( "hud", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
|
||||
.end();
|
||||
|
||||
var hud = $("#hud");
|
||||
hud.append("<div id='scoreboard' class='scoreboard'><div class='subScoreboard'></div></div>");
|
||||
hud.append("<div id='lives' ><div id='life3' class='life'></div><div id='life2' class='life'></div><div id='life1' class='life'></div></div>");
|
||||
hud.append("<div id='scoreMessage'></div>");
|
||||
hud.append("<div id='message'></div>'");
|
||||
hud.append("<div id='level'></div>'");
|
||||
hud.append("<div id='levelNumber'></div>'");
|
||||
|
||||
GUI.updateLevel( "Level" );
|
||||
|
||||
var background = $("#background");
|
||||
var dotsGroup = $("#dots");
|
||||
var maze = Game.maze.structure;
|
||||
|
||||
for( var i = 0; i < maze.length; i++ ) {
|
||||
var clazz = "";
|
||||
switch( maze[i]) {
|
||||
case -2:
|
||||
clazz = "bigDot";
|
||||
Game.dots[i] = "bigDot";
|
||||
break;
|
||||
case -1:
|
||||
clazz = "dot";
|
||||
Game.dots[i] = "dot";
|
||||
break;
|
||||
case 1:
|
||||
clazz = "corner1";
|
||||
break;
|
||||
case 2:
|
||||
clazz = "corner2";
|
||||
break;
|
||||
case 3:
|
||||
clazz = "corner3";
|
||||
break;
|
||||
case 4:
|
||||
clazz = "corner4";
|
||||
break;
|
||||
case 5:
|
||||
clazz = "squareCornerTopLeft";
|
||||
break;
|
||||
case 6:
|
||||
clazz = "squareCornerTopRight";
|
||||
break;
|
||||
case 7:
|
||||
clazz = "squareCornerBottomLeft";
|
||||
break;
|
||||
case 8:
|
||||
clazz = "squareCornerBottomRight";
|
||||
break;
|
||||
case 9:
|
||||
clazz = "horizontalMidDown";
|
||||
break;
|
||||
case 10:
|
||||
clazz = "verticalMidLeft";
|
||||
break;
|
||||
case 11:
|
||||
clazz = "verticalMidRight";
|
||||
break;
|
||||
case 12:
|
||||
clazz = "gate";
|
||||
break;
|
||||
}
|
||||
background.append('<div id="'+ i + '" class="tile ' + clazz +'"></div>');
|
||||
|
||||
if(i % 28 == 27 ) {
|
||||
background.append('<div class="clear"></div>');
|
||||
}
|
||||
}
|
||||
|
||||
// this is the function that control most of the game logic
|
||||
$.playground().registerCallback(function(){
|
||||
if(jQuery.gameQuery.keyTracker[37]){ //this is left! (a)
|
||||
Game.hero.left();
|
||||
}
|
||||
if(jQuery.gameQuery.keyTracker[38]){ //this is up! (w)
|
||||
Game.hero.up();
|
||||
}
|
||||
if(jQuery.gameQuery.keyTracker[39]){ //this is right! (d)
|
||||
Game.hero.right();
|
||||
}
|
||||
if(jQuery.gameQuery.keyTracker[40]){ //this is down! (s)
|
||||
Game.hero.down();
|
||||
}
|
||||
|
||||
$.each(Game.actors, function(index, actor ) {
|
||||
actor.move();
|
||||
});
|
||||
|
||||
for( var i = Math.max(0, eatenBonus.length - 6), j = 0; i < eatenBonus.length; i++, j++) {
|
||||
$("#" +( BONUS_TILE + j)).removeClass().addClass("tile").addClass( eatenBonus[i] );
|
||||
}
|
||||
|
||||
}, REFRESH_RATE);
|
||||
|
||||
Sound.init(function(){
|
||||
$.playground().startGame( function() {
|
||||
// Game.init();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var Sound = {
|
||||
soundList : [],
|
||||
|
||||
init : function(callback) {
|
||||
if( SOUND_ACTIVATED ) {
|
||||
soundManager.setup({
|
||||
url: 'swf/'
|
||||
});
|
||||
|
||||
Sound.soundList = {
|
||||
opening : new $.gameQuery.SoundWrapper('sound/opening.mp3', false),
|
||||
waka : new $.gameQuery.SoundWrapper('sound/wakawaka.mp3', false),
|
||||
fruit : new $.gameQuery.SoundWrapper('sound/eatingfruit.mp3', false),
|
||||
ghost : new $.gameQuery.SoundWrapper('sound/eatingghost.mp3', false),
|
||||
dies : new $.gameQuery.SoundWrapper('sound/dies.mp3', false)
|
||||
};
|
||||
soundManager.onready( callback );
|
||||
} else
|
||||
callback();
|
||||
},
|
||||
|
||||
play: function( sound ) {
|
||||
if( SOUND_ACTIVATED )
|
||||
Sound.soundList[sound].play();
|
||||
},
|
||||
|
||||
stop: function( sound ) {
|
||||
if( SOUND_ACTIVATED )
|
||||
Sound.soundList[sound].stop();
|
||||
},
|
||||
}
|
||||
|
||||
var GUI = {
|
||||
updateMessage : function( message ) {
|
||||
GUI.drawText( $("#message"), message, true );
|
||||
},
|
||||
|
||||
updateScoreMessage : function( message ) {
|
||||
GUI.drawText( $("#scoreMessage"), message, false, "red" );
|
||||
},
|
||||
|
||||
updateLevel : function( message ) {
|
||||
GUI.drawText( $("#level"), message, false );
|
||||
},
|
||||
|
||||
updateLevelNumber: function( message ) {
|
||||
GUI.drawText( $("#levelNumber"), message + "", false, "", true );
|
||||
},
|
||||
|
||||
drawText : function( divHTML, message, center, customClazz, forceSmall) {
|
||||
var html = "";
|
||||
var clazz = "clock";
|
||||
var letterSize = 32;
|
||||
if( typeof customClazz !== "undefined" ) {
|
||||
clazz = " clock " + customClazz;
|
||||
}
|
||||
|
||||
|
||||
var count = 0;
|
||||
var width = 0;
|
||||
var height = 0;
|
||||
for( var i = 0; i < message.length; i++ ) {
|
||||
var letter = message[i];
|
||||
var iLetter = (message.charCodeAt(i) - 97);
|
||||
if( letter == " " ) {
|
||||
html += "<div class='blank'></div>";
|
||||
width += 16;
|
||||
count++;
|
||||
} else if( letter.charCodeAt(0) > 47 && letter.charCodeAt(0) < 58 ) {
|
||||
var letterSize = 32;
|
||||
if( forceSmall ) {
|
||||
letterSize = 16;
|
||||
}
|
||||
html += "<div class='" + clazz + (forceSmall ? "small" : "") + "' style='top: -50%;background-position: -" + ( parseInt( letter ) * letterSize) + "px -" + (forceSmall > -1 ? 128 : 0) +"px'></div>";
|
||||
count++;
|
||||
} else if( ( letter.charCodeAt(0) >= 'a'.charCodeAt(0) && letter.charCodeAt(0) <= 'z'.charCodeAt(0)) ) {
|
||||
if( height < 16 )
|
||||
height = 16;
|
||||
width += 16;
|
||||
var lineSize = 20;
|
||||
var x = (iLetter % lineSize) * 16;
|
||||
var y = Math.floor(iLetter / lineSize) * 16 + 144;
|
||||
html += "<div class='" + clazz + " small' style='background-position: -" + x + "px -" + y + "px'></div>";
|
||||
count++;
|
||||
} else if( letter.charCodeAt(0) >= 'A'.charCodeAt(0) && letter.charCodeAt(0) <= 'Z'.charCodeAt(0)) {
|
||||
iLetter = letter.charCodeAt(0) - 'A'.charCodeAt(0);
|
||||
if( height < 32 )
|
||||
height = 32;
|
||||
width += 32;
|
||||
var lineSize = 10;
|
||||
var x = (iLetter % lineSize) * 32;
|
||||
var y = Math.floor(iLetter / lineSize) * 32 + 32;
|
||||
html += "<div class='" + clazz + "' style='background-position: -" + x + "px -" + y + "px'></div>";
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
divHTML.empty();
|
||||
divHTML.css( "width", width + "px");
|
||||
divHTML.css( "height", height + "px");
|
||||
if( center )
|
||||
divHTML.css( "margin-left", "-" + (message.length * letterSize / 2) + "px");
|
||||
divHTML.append( html );
|
||||
}
|
||||
}
|
||||
54
demo/pacman/js/scoreboard.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var SCOREBOARD = {
|
||||
score: 0,
|
||||
scoreLength: 6,
|
||||
|
||||
init: function(size) {
|
||||
if( typeof size !== "undefined" )
|
||||
SCOREBOARD.scoreLength = size;
|
||||
SCOREBOARD.score = 0;
|
||||
SCOREBOARD.set_score( 0 );
|
||||
},
|
||||
|
||||
add: function(addToScore, div) {
|
||||
SCOREBOARD.set_score( SCOREBOARD.score + addToScore, div);
|
||||
},
|
||||
|
||||
set_score: function( score, div ) {
|
||||
var currentScore = "";
|
||||
var imageScore = "";
|
||||
|
||||
SCOREBOARD.score = score;
|
||||
currentScore = SCOREBOARD.pad();
|
||||
|
||||
for(i = 0; i < String(currentScore).length; i++) {
|
||||
imageScore += "<div class='clock n"+ String(currentScore)[i]+"'></div>";
|
||||
}
|
||||
|
||||
if( typeof div === "undefined" )
|
||||
div = $(".subScoreboard");
|
||||
div.empty();
|
||||
div.append( imageScore );
|
||||
},
|
||||
|
||||
pad: function() {
|
||||
var str = '' + SCOREBOARD.score;
|
||||
while (str.length < SCOREBOARD.scoreLength) {
|
||||
str = '0' + str;
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
callback: function() {
|
||||
console.log( "SCOREBOARD.callback" );
|
||||
}
|
||||
};
|
||||
55
demo/pacman/js/utils.js
Normal file
@@ -0,0 +1,55 @@
|
||||
function heriter(destination, source) {
|
||||
function initClassIfNecessary(obj) {
|
||||
if( typeof obj["_super"] == "undefined" ) {
|
||||
obj["_super"] = function() {
|
||||
var methodName = arguments[0];
|
||||
var parameters = arguments[1];
|
||||
this["__parent_methods"][methodName].apply(this, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
if( typeof obj["__parent_methods"] == "undefined" ) {
|
||||
obj["__parent_methods"] = {}
|
||||
}
|
||||
}
|
||||
|
||||
for (var element in source) {
|
||||
if( typeof destination[element] != "undefined" ) {
|
||||
initClassIfNecessary(destination);
|
||||
destination["__parent_methods"][element] = source[element];
|
||||
} else {
|
||||
destination[element] = source[element];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** PausableTimer **/
|
||||
|
||||
function PausableTimer(func, millisec) {
|
||||
this.func = func;
|
||||
this.stTime = new Date().valueOf();
|
||||
this.timeout = setTimeout(func, millisec);
|
||||
this.timeLeft = millisec;
|
||||
}
|
||||
|
||||
PausableTimer.prototype.stop = function() {
|
||||
clearTimeout(this.timeout);
|
||||
};
|
||||
|
||||
PausableTimer.prototype.pause = function() {
|
||||
clearTimeout(this.timeout);
|
||||
var timeRan = new Date().valueOf()-this.stTime;
|
||||
this.timeLeft -= timeRan;
|
||||
};
|
||||
|
||||
PausableTimer.prototype.resume = function() {
|
||||
this.timeout = setTimeout(this.func, this.timeLeft);
|
||||
this.stTime = new Date().valueOf();
|
||||
};
|
||||
|
||||
//Usage:
|
||||
//var myTimer = new PausableTimer(function(){alert("It works!");}, 2000);
|
||||
//myTimer.pause();
|
||||
//myTimer.unpause();
|
||||
|
||||
1738
demo/pacman/lib/gamequery-0.7.0.js
Normal file
80
demo/pacman/lib/gamequery-soundwrapper-soundmanager.js
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* gameQuery rev. $Revision$
|
||||
*
|
||||
* Copyright (c) 2008 Selim Arsever (gamequery.onaluf.org)
|
||||
* licensed under the MIT (MIT-LICENSE.txt)
|
||||
*/
|
||||
|
||||
/**
|
||||
* To use this wrapper you will need:
|
||||
* 1) Include SoundManager2.js before this script
|
||||
* 2) Give SoundManager2 the position of the swf ie. : soundManager.url = './path/to/swf'
|
||||
* 3) Optionally deactivate the debug mode from SoundManager2
|
||||
*/
|
||||
|
||||
// this allows use of the convenient $ notation in a plugin
|
||||
(function($) {
|
||||
soundManager.url = './'
|
||||
// Here is a bogus soundWrapper written as an example
|
||||
$.extend($.gameQuery, {
|
||||
SoundWrapper: function(url, loop) {
|
||||
|
||||
// start loading the sound. Should turn this.ready to true once done.
|
||||
this.load = function(){
|
||||
try{
|
||||
this.sound = soundManager.createSound({
|
||||
id: this.id,
|
||||
url: url,
|
||||
autoplay: false,
|
||||
autoLoad: true
|
||||
});
|
||||
} catch (err) {
|
||||
// if something failed we generate a fake sound object
|
||||
this.sound = {readyState: 3, play: function(){}};
|
||||
}
|
||||
};
|
||||
|
||||
// plays the sound if this.ready == true
|
||||
this.play = function(){
|
||||
if(loop){
|
||||
this.sound.play({
|
||||
onfinish: function() {
|
||||
this.play();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.sound.play();
|
||||
}
|
||||
};
|
||||
|
||||
// pauses the sound if it is playing
|
||||
this.pause = function(){
|
||||
this.sound.pause();
|
||||
};
|
||||
|
||||
// stops the sound if it is playing, rewind (even if paused)
|
||||
this.stop = function(){
|
||||
this.sound.stop();
|
||||
};
|
||||
|
||||
// mutes the sound without stopping it
|
||||
this.muted = function(mute){
|
||||
if(mute){
|
||||
this.sound.mute()
|
||||
} else {
|
||||
this.sound.unmute();
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if the sound is ready to be played
|
||||
this.ready = function(){
|
||||
return this.sound.readyState==3
|
||||
};
|
||||
|
||||
// add the sound to the manager
|
||||
this.id = 'sound_'+$.gameQuery.resourceManager.sounds.length;
|
||||
$.gameQuery.resourceManager.addSound(this);
|
||||
|
||||
return true;
|
||||
}});
|
||||
})(jQuery);
|
||||
2
demo/pacman/lib/jquery-1.8.3.min.js
vendored
Normal file
125
demo/pacman/lib/jquery-ui-1.8.23.custom.min.js
vendored
Normal file
106
demo/pacman/lib/soundmanager2.min.js
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/** @license
|
||||
|
||||
|
||||
SoundManager 2: JavaScript Sound for the Web
|
||||
----------------------------------------------
|
||||
http://schillmania.com/projects/soundmanager2/
|
||||
|
||||
Copyright (c) 2007, Scott Schiller. All rights reserved.
|
||||
Code provided under the BSD License:
|
||||
http://schillmania.com/projects/soundmanager2/license.txt
|
||||
|
||||
V2.97a.20130101
|
||||
*/
|
||||
(function(j,g){function aa(aa,pa){function ba(a){return c.preferFlash&&z&&!c.ignoreFlash&&c.flash[a]!==g&&c.flash[a]}function q(a){return function(d){var e=this._s;!e||!e._a?(e&&e.id?c._wD(e.id+": Ignoring "+d.type):c._wD(pb+"Ignoring "+d.type),d=null):d=a.call(this,d);return d}}this.setupOptions={url:aa||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1E3,
|
||||
wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0,html5Test:/^(probably|maybe)$/i,preferFlash:!0,noSWFCache:!1};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,
|
||||
useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},wav:{type:['audio/wav; codecs="1"',
|
||||
"audio/wav","audio/wave","audio/x-wav"],required:!1}};this.movieID="sm2-container";this.id=pa||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20130101";this.altURL=this.movieURL=this.version=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:!1,peakData:!1,waveformData:!1,
|
||||
eqData:!1,movieStar:!1};this.sandbox={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local+internet access)"},description:null,noRemote:null,noLocal:null};this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=!1;var Pa,c=this,Qa=null,i=null,pb="HTML5::",A,s=navigator.userAgent,R=j.location.href.toString(),
|
||||
h=document,qa,Ra,ra,l,C=[],sa=!0,x,S=!1,T=!1,n=!1,r=!1,ca=!1,k,qb=0,U,v,ta,K,ua,I,L,M,Sa,va,da,F,ea,wa,N,xa,V,fa,ga,O,Ta,ya,Ua=["log","info","warn","error"],Va,za,Wa,W=null,Aa=null,p,Ba,P,Xa,ha,ia,Q,t,X=!1,Ca=!1,Ya,Za,$a,ja=0,Y=null,ka,J=[],B=null,ab,la,Z,G,Da,Ea,bb,u,cb=Array.prototype.slice,D=!1,Fa,z,Ga,db,E,eb,Ha,ma=s.match(/(ipad|iphone|ipod)/i),fb=s.match(/android/i),H=s.match(/msie/i),rb=s.match(/webkit/i),Ia=s.match(/safari/i)&&!s.match(/chrome/i),Ja=s.match(/opera/i),Ka=s.match(/(mobile|pre\/|xoom)/i)||
|
||||
ma||fb,La=!R.match(/usehtml5audio/i)&&!R.match(/sm2\-ignorebadua/i)&&Ia&&!s.match(/silk/i)&&s.match(/OS X 10_6_([3-7])/i),gb=j.console!==g&&console.log!==g,Ma=h.hasFocus!==g?h.hasFocus():null,na=Ia&&(h.hasFocus===g||!h.hasFocus()),hb=!na,ib=/(mp3|mp4|mpa|m4a|m4b)/i,$=h.location?h.location.protocol.match(/http/i):null,jb=!$?"http://":"",kb=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,lb="mpeg4 aac flv mov mp4 m4v f4v m4a m4b mp4v 3gp 3g2".split(" "),sb=RegExp("\\.("+
|
||||
lb.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!$;var Na;try{Na=Audio!==g&&(Ja&&opera!==g&&10>opera.version()?new Audio(null):new Audio).canPlayType!==g}catch(ub){Na=!1}this.hasHTML5=Na;this.setup=function(a){var d=!c.url;a!==g&&(n&&B&&c.ok()&&(a.flashVersion!==g||a.url!==g||a.html5Test!==g))&&Q(p("setupLate"));ta(a);d&&(V&&a.url!==g)&&c.beginDelayedInit();!V&&(a.url!==g&&"complete"===h.readyState)&&setTimeout(N,1);return c};this.supported=
|
||||
this.ok=function(){return B?n&&!r:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return A(c)||h[c]||j[c]};this.createSound=function(a,d){function e(){f=ha(f);c.sounds[f.id]=new Pa(f);c.soundIDs.push(f.id);return c.sounds[f.id]}var b,f;b=null;b="soundManager.createSound(): "+p(!n?"notReady":"notOK");if(!n||!c.ok())return Q(b),!1;d!==g&&(a={id:a,url:d});f=v(a);f.url=ka(f.url);f.id.toString().charAt(0).match(/^[0-9]$/)&&c._wD("soundManager.createSound(): "+p("badID",f.id),2);c._wD("soundManager.createSound(): "+
|
||||
f.id+" ("+f.url+")",1);if(t(f.id,!0))return c._wD("soundManager.createSound(): "+f.id+" exists",1),c.sounds[f.id];la(f)?(b=e(),c._wD(f.id+": Using HTML5"),b._setup_html5(f)):(8<l&&(null===f.isMovieStar&&(f.isMovieStar=!(!f.serverURL&&!(f.type&&f.type.match(kb)||f.url.match(sb)))),f.isMovieStar&&(c._wD("soundManager.createSound(): using MovieStar handling"),1<f.loops&&k("noNSLoop"))),f=ia(f,"soundManager.createSound(): "),b=e(),8===l?i._createSound(f.id,f.loops||1,f.usePolicyFile):(i._createSound(f.id,
|
||||
f.url,f.usePeakData,f.useWaveformData,f.useEQData,f.isMovieStar,f.isMovieStar?f.bufferTime:!1,f.loops||1,f.serverURL,f.duration||null,f.autoPlay,!0,f.autoLoad,f.usePolicyFile),f.serverURL||(b.connected=!0,f.onconnect&&f.onconnect.apply(b))),!f.serverURL&&(f.autoLoad||f.autoPlay)&&b.load(f));!f.serverURL&&f.autoPlay&&b.play();return b};this.destroySound=function(a,d){if(!t(a))return!1;var e=c.sounds[a],b;e._iO={};e.stop();e.unload();for(b=0;b<c.soundIDs.length;b++)if(c.soundIDs[b]===a){c.soundIDs.splice(b,
|
||||
1);break}d||e.destruct(!0);delete c.sounds[a];return!0};this.load=function(a,d){return!t(a)?!1:c.sounds[a].load(d)};this.unload=function(a){return!t(a)?!1:c.sounds[a].unload()};this.onposition=this.onPosition=function(a,d,e,b){return!t(a)?!1:c.sounds[a].onposition(d,e,b)};this.clearOnPosition=function(a,d,e){return!t(a)?!1:c.sounds[a].clearOnPosition(d,e)};this.start=this.play=function(a,d){var e=!1;return!n||!c.ok()?(Q("soundManager.play(): "+p(!n?"notReady":"notOK")),e):!t(a)?(d instanceof Object||
|
||||
(d={url:d}),d&&d.url&&(c._wD('soundManager.play(): attempting to create "'+a+'"',1),d.id=a,e=c.createSound(d).play()),e):c.sounds[a].play(d)};this.setPosition=function(a,d){return!t(a)?!1:c.sounds[a].setPosition(d)};this.stop=function(a){if(!t(a))return!1;c._wD("soundManager.stop("+a+")",1);return c.sounds[a].stop()};this.stopAll=function(){var a;c._wD("soundManager.stopAll()",1);for(a in c.sounds)c.sounds.hasOwnProperty(a)&&c.sounds[a].stop()};this.pause=function(a){return!t(a)?!1:c.sounds[a].pause()};
|
||||
this.pauseAll=function(){var a;for(a=c.soundIDs.length-1;0<=a;a--)c.sounds[c.soundIDs[a]].pause()};this.resume=function(a){return!t(a)?!1:c.sounds[a].resume()};this.resumeAll=function(){var a;for(a=c.soundIDs.length-1;0<=a;a--)c.sounds[c.soundIDs[a]].resume()};this.togglePause=function(a){return!t(a)?!1:c.sounds[a].togglePause()};this.setPan=function(a,d){return!t(a)?!1:c.sounds[a].setPan(d)};this.setVolume=function(a,d){return!t(a)?!1:c.sounds[a].setVolume(d)};this.mute=function(a){var d=0;a instanceof
|
||||
String&&(a=null);if(a){if(!t(a))return!1;c._wD('soundManager.mute(): Muting "'+a+'"');return c.sounds[a].mute()}c._wD("soundManager.mute(): Muting all sounds");for(d=c.soundIDs.length-1;0<=d;d--)c.sounds[c.soundIDs[d]].mute();return c.muted=!0};this.muteAll=function(){c.mute()};this.unmute=function(a){a instanceof String&&(a=null);if(a){if(!t(a))return!1;c._wD('soundManager.unmute(): Unmuting "'+a+'"');return c.sounds[a].unmute()}c._wD("soundManager.unmute(): Unmuting all sounds");for(a=c.soundIDs.length-
|
||||
1;0<=a;a--)c.sounds[c.soundIDs[a]].unmute();c.muted=!1;return!0};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(a){return!t(a)?!1:c.sounds[a].toggleMute()};this.getMemoryUse=function(){var c=0;i&&8!==l&&(c=parseInt(i._getMemoryUse(),10));return c};this.disable=function(a){var d;a===g&&(a=!1);if(r)return!1;r=!0;k("shutdown",1);for(d=c.soundIDs.length-1;0<=d;d--)Va(c.sounds[c.soundIDs[d]]);U(a);u.remove(j,"load",L);return!0};this.canPlayMIME=function(a){var d;c.hasHTML5&&(d=Z({type:a}));
|
||||
!d&&B&&(d=a&&c.ok()?!!(8<l&&a.match(kb)||a.match(c.mimePattern)):null);return d};this.canPlayURL=function(a){var d;c.hasHTML5&&(d=Z({url:a}));!d&&B&&(d=a&&c.ok()?!!a.match(c.filePattern):null);return d};this.canPlayLink=function(a){return a.type!==g&&a.type&&c.canPlayMIME(a.type)?!0:c.canPlayURL(a.href)};this.getSoundById=function(a,d){if(!a)throw Error("soundManager.getSoundById(): sID is null/_undefined");var e=c.sounds[a];!e&&!d&&c._wD('"'+a+'" is an invalid sound ID.',2);return e};this.onready=
|
||||
function(a,d){if("function"===typeof a)n&&c._wD(p("queue","onready")),d||(d=j),ua("onready",a,d),I();else throw p("needFunction","onready");return!0};this.ontimeout=function(a,d){if("function"===typeof a)n&&c._wD(p("queue","ontimeout")),d||(d=j),ua("ontimeout",a,d),I({type:"ontimeout"});else throw p("needFunction","ontimeout");return!0};this._writeDebug=function(a,d){var e,b;if(!c.debugMode)return!1;if(gb&&c.useConsole){if(d&&"object"===typeof d)console.log(a,d);else if(Ua[d]!==g)console[Ua[d]](a);
|
||||
else console.log(a);if(c.consoleOnly)return!0}e=A("soundmanager-debug");if(!e)return!1;b=h.createElement("div");0===++qb%2&&(b.className="sm2-alt");d=d===g?0:parseInt(d,10);b.appendChild(h.createTextNode(a));d&&(2<=d&&(b.style.fontWeight="bold"),3===d&&(b.style.color="#ff3333"));e.insertBefore(b,e.firstChild);return!0};-1!==R.indexOf("sm2-debug=alert")&&(this._writeDebug=function(c){j.alert(c)});this._wD=this._writeDebug;this._debug=function(){var a,d;k("currentObj",1);a=0;for(d=c.soundIDs.length;a<
|
||||
d;a++)c.sounds[c.soundIDs[a]]._debug()};this.reboot=function(a,d){c.soundIDs.length&&c._wD("Destroying "+c.soundIDs.length+" SMSound objects...");var e,b,f;for(e=c.soundIDs.length-1;0<=e;e--)c.sounds[c.soundIDs[e]].destruct();if(i)try{H&&(Aa=i.innerHTML),W=i.parentNode.removeChild(i),k("flRemoved")}catch(g){k("badRemove",2)}Aa=W=B=i=null;c.enabled=V=n=X=Ca=S=T=r=D=c.swfLoaded=!1;c.soundIDs=[];c.sounds={};if(a)C=[];else for(e in C)if(C.hasOwnProperty(e)){b=0;for(f=C[e].length;b<f;b++)C[e][b].fired=
|
||||
!1}d||c._wD("soundManager: Rebooting...");c.html5={usingFlash:null};c.flash={};c.html5Only=!1;c.ignoreFlash=!1;j.setTimeout(function(){wa();d||c.beginDelayedInit()},20);return c};this.reset=function(){k("reset");return c.reboot(!0,!0)};this.getMoviePercent=function(){return i&&"PercentLoaded"in i?i.PercentLoaded():null};this.beginDelayedInit=function(){ca=!0;N();setTimeout(function(){if(Ca)return!1;ga();ea();return Ca=!0},20);M()};this.destruct=function(){c._wD("soundManager.destruct()");c.disable(!0)};
|
||||
Pa=function(a){var d,e,b=this,f,j,mb,m,h,n,q=!1,y=[],s=0,Oa,u,r=null;e=d=null;this.sID=this.id=a.id;this.url=a.url;this._iO=this.instanceOptions=this.options=v(a);this.pan=this.options.pan;this.volume=this.options.volume;this.isHTML5=!1;this._a=null;this.id3={};this._debug=function(){c._wD(b.id+": Merged options:",b.options)};this.load=function(a){var d=null;a!==g?b._iO=v(a,b.options):(a=b.options,b._iO=a,r&&r!==b.url&&(k("manURL"),b._iO.url=b.url,b.url=null));b._iO.url||(b._iO.url=b.url);b._iO.url=
|
||||
ka(b._iO.url);a=b.instanceOptions=b._iO;c._wD(b.id+": load ("+a.url+")");if(a.url===b.url&&0!==b.readyState&&2!==b.readyState)return k("onURL",1),3===b.readyState&&a.onload&&a.onload.apply(b,[!!b.duration]),b;b.loaded=!1;b.readyState=1;b.playState=0;b.id3={};if(la(a))d=b._setup_html5(a),d._called_load?c._wD(b.id+": Ignoring request to load again"):(b._html5_canplay=!1,b.url!==a.url&&(c._wD(k("manURL")+": "+a.url),b._a.src=a.url,b.setPosition(0)),b._a.autobuffer="auto",b._a.preload="auto",b._a._called_load=
|
||||
!0,a.autoPlay&&b.play());else try{b.isHTML5=!1,b._iO=ia(ha(a)),a=b._iO,8===l?i._load(b.id,a.url,a.stream,a.autoPlay,a.usePolicyFile):i._load(b.id,a.url,!!a.stream,!!a.autoPlay,a.loops||1,!!a.autoLoad,a.usePolicyFile)}catch(e){k("smError",2),x("onload",!1),O({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:!0})}b.url=a.url;return b};this.unload=function(){0!==b.readyState&&(c._wD(b.id+": unload()"),b.isHTML5?(m(),b._a&&(b._a.pause(),Da(b._a,"about:blank"),r="about:blank")):8===l?i._unload(b.id,"about:blank"):
|
||||
i._unload(b.id),f());return b};this.destruct=function(a){c._wD(b.id+": Destruct");b.isHTML5?(m(),b._a&&(b._a.pause(),Da(b._a),D||mb(),b._a._s=null,b._a=null)):(b._iO.onfailure=null,i._destroySound(b.id));a||c.destroySound(b.id,!0)};this.start=this.play=function(a,d){var e,f,w=!0,w=null;e=b.id+": play(): ";d=d===g?!0:d;a||(a={});b.url&&(b._iO.url=b.url);b._iO=v(b._iO,b.options);b._iO=v(a,b._iO);b._iO.url=ka(b._iO.url);b.instanceOptions=b._iO;if(b._iO.serverURL&&!b.connected)return b.getAutoPlay()||
|
||||
(c._wD(e+" Netstream not connected yet - setting autoPlay"),b.setAutoPlay(!0)),b;la(b._iO)&&(b._setup_html5(b._iO),h());1===b.playState&&!b.paused&&((f=b._iO.multiShot)?c._wD(e+"Already playing (multi-shot)",1):(c._wD(e+"Already playing (one-shot)",1),w=b));if(null!==w)return w;a.url&&a.url!==b.url&&b.load(b._iO);b.loaded?c._wD(e):0===b.readyState?(c._wD(e+"Attempting to load"),b.isHTML5||(b._iO.autoPlay=!0),b.load(b._iO),b.instanceOptions=b._iO):2===b.readyState?(c._wD(e+"Could not load - exiting",
|
||||
2),w=b):c._wD(e+"Loading - attempting to play...");if(null!==w)return w;!b.isHTML5&&(9===l&&0<b.position&&b.position===b.duration)&&(c._wD(e+"Sound at end, resetting to position:0"),a.position=0);if(b.paused&&0<=b.position&&(!b._iO.serverURL||0<b.position))c._wD(e+"Resuming from paused state",1),b.resume();else{b._iO=v(a,b._iO);if(null!==b._iO.from&&null!==b._iO.to&&0===b.instanceCount&&0===b.playState&&!b._iO.serverURL){f=function(){b._iO=v(a,b._iO);b.play(b._iO)};if(b.isHTML5&&!b._html5_canplay)c._wD(e+
|
||||
"Beginning load for from/to case"),b.load({oncanplay:f}),w=!1;else if(!b.isHTML5&&!b.loaded&&(!b.readyState||2!==b.readyState))c._wD(e+"Preloading for from/to case"),b.load({onload:f}),w=!1;if(null!==w)return w;b._iO=u()}c._wD(e+"Starting to play");(!b.instanceCount||b._iO.multiShotEvents||!b.isHTML5&&8<l&&!b.getAutoPlay())&&b.instanceCount++;b._iO.onposition&&0===b.playState&&n(b);b.playState=1;b.paused=!1;b.position=b._iO.position!==g&&!isNaN(b._iO.position)?b._iO.position:0;b.isHTML5||(b._iO=ia(ha(b._iO)));
|
||||
b._iO.onplay&&d&&(b._iO.onplay.apply(b),q=!0);b.setVolume(b._iO.volume,!0);b.setPan(b._iO.pan,!0);b.isHTML5?(h(),e=b._setup_html5(),b.setPosition(b._iO.position),e.play()):(w=i._start(b.id,b._iO.loops||1,9===l?b._iO.position:b._iO.position/1E3,b._iO.multiShot),9===l&&!w&&(c._wD(e+"No sound hardware, or 32-sound ceiling hit"),b._iO.onplayerror&&b._iO.onplayerror.apply(b)))}return b};this.stop=function(a){var d=b._iO;1===b.playState&&(c._wD(b.id+": stop()"),b._onbufferchange(0),b._resetOnPosition(0),
|
||||
b.paused=!1,b.isHTML5||(b.playState=0),Oa(),d.to&&b.clearOnPosition(d.to),b.isHTML5?b._a&&(a=b.position,b.setPosition(0),b.position=a,b._a.pause(),b.playState=0,b._onTimer(),m()):(i._stop(b.id,a),d.serverURL&&b.unload()),b.instanceCount=0,b._iO={},d.onstop&&d.onstop.apply(b));return b};this.setAutoPlay=function(a){c._wD(b.id+": Autoplay turned "+(a?"on":"off"));b._iO.autoPlay=a;b.isHTML5||(i._setAutoPlay(b.id,a),a&&(!b.instanceCount&&1===b.readyState)&&(b.instanceCount++,c._wD(b.id+": Incremented instance count to "+
|
||||
b.instanceCount)))};this.getAutoPlay=function(){return b._iO.autoPlay};this.setPosition=function(a){a===g&&(a=0);var d=b.isHTML5?Math.max(a,0):Math.min(b.duration||b._iO.duration,Math.max(a,0));b.position=d;a=b.position/1E3;b._resetOnPosition(b.position);b._iO.position=d;if(b.isHTML5){if(b._a)if(b._html5_canplay){if(b._a.currentTime!==a){c._wD(b.id+": setPosition("+a+")");try{b._a.currentTime=a,(0===b.playState||b.paused)&&b._a.pause()}catch(e){c._wD(b.id+": setPosition("+a+") failed: "+e.message,
|
||||
2)}}}else c._wD(b.id+": setPosition("+a+"): Cannot seek yet, sound not ready")}else a=9===l?b.position:a,b.readyState&&2!==b.readyState&&i._setPosition(b.id,a,b.paused||!b.playState,b._iO.multiShot);b.isHTML5&&b.paused&&b._onTimer(!0);return b};this.pause=function(a){if(b.paused||0===b.playState&&1!==b.readyState)return b;c._wD(b.id+": pause()");b.paused=!0;b.isHTML5?(b._setup_html5().pause(),m()):(a||a===g)&&i._pause(b.id,b._iO.multiShot);b._iO.onpause&&b._iO.onpause.apply(b);return b};this.resume=
|
||||
function(){var a=b._iO;if(!b.paused)return b;c._wD(b.id+": resume()");b.paused=!1;b.playState=1;b.isHTML5?(b._setup_html5().play(),h()):(a.isMovieStar&&!a.serverURL&&b.setPosition(b.position),i._pause(b.id,a.multiShot));!q&&a.onplay?(a.onplay.apply(b),q=!0):a.onresume&&a.onresume.apply(b);return b};this.togglePause=function(){c._wD(b.id+": togglePause()");if(0===b.playState)return b.play({position:9===l&&!b.isHTML5?b.position:b.position/1E3}),b;b.paused?b.resume():b.pause();return b};this.setPan=
|
||||
function(a,c){a===g&&(a=0);c===g&&(c=!1);b.isHTML5||i._setPan(b.id,a);b._iO.pan=a;c||(b.pan=a,b.options.pan=a);return b};this.setVolume=function(a,d){a===g&&(a=100);d===g&&(d=!1);b.isHTML5?b._a&&(b._a.volume=Math.max(0,Math.min(1,a/100))):i._setVolume(b.id,c.muted&&!b.muted||b.muted?0:a);b._iO.volume=a;d||(b.volume=a,b.options.volume=a);return b};this.mute=function(){b.muted=!0;b.isHTML5?b._a&&(b._a.muted=!0):i._setVolume(b.id,0);return b};this.unmute=function(){b.muted=!1;var a=b._iO.volume!==g;
|
||||
b.isHTML5?b._a&&(b._a.muted=!1):i._setVolume(b.id,a?b._iO.volume:b.options.volume);return b};this.toggleMute=function(){return b.muted?b.unmute():b.mute()};this.onposition=this.onPosition=function(a,c,d){y.push({position:parseInt(a,10),method:c,scope:d!==g?d:b,fired:!1});return b};this.clearOnPosition=function(b,a){var c,b=parseInt(b,10);if(isNaN(b))return!1;for(c=0;c<y.length;c++)if(b===y[c].position&&(!a||a===y[c].method))y[c].fired&&s--,y.splice(c,1)};this._processOnPosition=function(){var a,c;
|
||||
a=y.length;if(!a||!b.playState||s>=a)return!1;for(a-=1;0<=a;a--)c=y[a],!c.fired&&b.position>=c.position&&(c.fired=!0,s++,c.method.apply(c.scope,[c.position]));return!0};this._resetOnPosition=function(b){var a,c;a=y.length;if(!a)return!1;for(a-=1;0<=a;a--)c=y[a],c.fired&&b<=c.position&&(c.fired=!1,s--);return!0};u=function(){var a=b._iO,d=a.from,e=a.to,f,g;g=function(){c._wD(b.id+': "To" time of '+e+" reached.");b.clearOnPosition(e,g);b.stop()};f=function(){c._wD(b.id+': Playing "from" '+d);if(null!==
|
||||
e&&!isNaN(e))b.onPosition(e,g)};null!==d&&!isNaN(d)&&(a.position=d,a.multiShot=!1,f());return a};n=function(){var a,c=b._iO.onposition;if(c)for(a in c)if(c.hasOwnProperty(a))b.onPosition(parseInt(a,10),c[a])};Oa=function(){var a,c=b._iO.onposition;if(c)for(a in c)c.hasOwnProperty(a)&&b.clearOnPosition(parseInt(a,10))};h=function(){b.isHTML5&&Ya(b)};m=function(){b.isHTML5&&Za(b)};f=function(a){a||(y=[],s=0);q=!1;b._hasTimer=null;b._a=null;b._html5_canplay=!1;b.bytesLoaded=null;b.bytesTotal=null;b.duration=
|
||||
b._iO&&b._iO.duration?b._iO.duration:null;b.durationEstimate=null;b.buffered=[];b.eqData=[];b.eqData.left=[];b.eqData.right=[];b.failures=0;b.isBuffering=!1;b.instanceOptions={};b.instanceCount=0;b.loaded=!1;b.metadata={};b.readyState=0;b.muted=!1;b.paused=!1;b.peakData={left:0,right:0};b.waveformData={left:[],right:[]};b.playState=0;b.position=null;b.id3={}};f();this._onTimer=function(a){var c,f=!1,g={};if(b._hasTimer||a){if(b._a&&(a||(0<b.playState||1===b.readyState)&&!b.paused))c=b._get_html5_duration(),
|
||||
c!==d&&(d=c,b.duration=c,f=!0),b.durationEstimate=b.duration,c=1E3*b._a.currentTime||0,c!==e&&(e=c,f=!0),(f||a)&&b._whileplaying(c,g,g,g,g);return f}};this._get_html5_duration=function(){var a=b._iO;return(a=b._a&&b._a.duration?1E3*b._a.duration:a&&a.duration?a.duration:null)&&!isNaN(a)&&Infinity!==a?a:null};this._apply_loop=function(b,a){!b.loop&&1<a&&c._wD("Note: Native HTML5 looping is infinite.",1);b.loop=1<a?"loop":""};this._setup_html5=function(a){var a=v(b._iO,a),c=decodeURI,d=D?Qa:b._a,e=
|
||||
c(a.url),g;D?e===Fa&&(g=!0):e===r&&(g=!0);if(d){if(d._s)if(D)d._s&&(d._s.playState&&!g)&&d._s.stop();else if(!D&&e===c(r))return b._apply_loop(d,a.loops),d;g||(f(!1),d.src=a.url,Fa=r=b.url=a.url,d._called_load=!1)}else b._a=a.autoLoad||a.autoPlay?new Audio(a.url):Ja&&10>opera.version()?new Audio(null):new Audio,d=b._a,d._called_load=!1,D&&(Qa=d);b.isHTML5=!0;b._a=d;d._s=b;j();b._apply_loop(d,a.loops);a.autoLoad||a.autoPlay?b.load():(d.autobuffer=!1,d.preload="auto");return d};j=function(){if(b._a._added_events)return!1;
|
||||
var a;b._a._added_events=!0;for(a in E)E.hasOwnProperty(a)&&b._a&&b._a.addEventListener(a,E[a],!1);return!0};mb=function(){var a;c._wD(b.id+": Removing event listeners");b._a._added_events=!1;for(a in E)E.hasOwnProperty(a)&&b._a&&b._a.removeEventListener(a,E[a],!1)};this._onload=function(a){var d=!!a||!b.isHTML5&&8===l&&b.duration,a=b.id+": ";c._wD(a+(d?"onload()":"Failed to load? - "+b.url),d?1:2);!d&&!b.isHTML5&&(!0===c.sandbox.noRemote&&c._wD(a+p("noNet"),1),!0===c.sandbox.noLocal&&c._wD(a+p("noLocal"),
|
||||
1));b.loaded=d;b.readyState=d?3:2;b._onbufferchange(0);b._iO.onload&&b._iO.onload.apply(b,[d]);return!0};this._onbufferchange=function(a){if(0===b.playState||a&&b.isBuffering||!a&&!b.isBuffering)return!1;b.isBuffering=1===a;b._iO.onbufferchange&&(c._wD(b.id+": Buffer state change: "+a),b._iO.onbufferchange.apply(b));return!0};this._onsuspend=function(){b._iO.onsuspend&&(c._wD(b.id+": Playback suspended"),b._iO.onsuspend.apply(b));return!0};this._onfailure=function(a,d,e){b.failures++;c._wD(b.id+": Failures = "+
|
||||
b.failures);if(b._iO.onfailure&&1===b.failures)b._iO.onfailure(b,a,d,e);else c._wD(b.id+": Ignoring failure")};this._onfinish=function(){var a=b._iO.onfinish;b._onbufferchange(0);b._resetOnPosition(0);if(b.instanceCount&&(b.instanceCount--,b.instanceCount||(Oa(),b.playState=0,b.paused=!1,b.instanceCount=0,b.instanceOptions={},b._iO={},m(),b.isHTML5&&(b.position=0)),(!b.instanceCount||b._iO.multiShotEvents)&&a))c._wD(b.id+": onfinish()"),a.apply(b)};this._whileloading=function(a,c,d,e){var f=b._iO;
|
||||
b.bytesLoaded=a;b.bytesTotal=c;b.duration=Math.floor(d);b.bufferLength=e;b.durationEstimate=!b.isHTML5&&!f.isMovieStar?f.duration?b.duration>f.duration?b.duration:f.duration:parseInt(b.bytesTotal/b.bytesLoaded*b.duration,10):b.duration;b.isHTML5||(b.buffered=[{start:0,end:b.duration}]);(3!==b.readyState||b.isHTML5)&&f.whileloading&&f.whileloading.apply(b)};this._whileplaying=function(a,c,d,e,f){var m=b._iO;if(isNaN(a)||null===a)return!1;b.position=Math.max(0,a);b._processOnPosition();!b.isHTML5&&
|
||||
8<l&&(m.usePeakData&&(c!==g&&c)&&(b.peakData={left:c.leftPeak,right:c.rightPeak}),m.useWaveformData&&(d!==g&&d)&&(b.waveformData={left:d.split(","),right:e.split(",")}),m.useEQData&&(f!==g&&f&&f.leftEQ)&&(a=f.leftEQ.split(","),b.eqData=a,b.eqData.left=a,f.rightEQ!==g&&f.rightEQ&&(b.eqData.right=f.rightEQ.split(","))));1===b.playState&&(!b.isHTML5&&(8===l&&!b.position&&b.isBuffering)&&b._onbufferchange(0),m.whileplaying&&m.whileplaying.apply(b));return!0};this._oncaptiondata=function(a){c._wD(b.id+
|
||||
": Caption data received.");b.captiondata=a;b._iO.oncaptiondata&&b._iO.oncaptiondata.apply(b,[a])};this._onmetadata=function(a,d){c._wD(b.id+": Metadata received.");var e={},f,g;f=0;for(g=a.length;f<g;f++)e[a[f]]=d[f];b.metadata=e;b._iO.onmetadata&&b._iO.onmetadata.apply(b)};this._onid3=function(a,d){c._wD(b.id+": ID3 data received.");var e=[],f,g;f=0;for(g=a.length;f<g;f++)e[a[f]]=d[f];b.id3=v(b.id3,e);b._iO.onid3&&b._iO.onid3.apply(b)};this._onconnect=function(a){a=1===a;c._wD(b.id+": "+(a?"Connected.":
|
||||
"Failed to connect? - "+b.url),a?1:2);if(b.connected=a)b.failures=0,t(b.id)&&(b.getAutoPlay()?b.play(g,b.getAutoPlay()):b._iO.autoLoad&&b.load()),b._iO.onconnect&&b._iO.onconnect.apply(b,[a])};this._ondataerror=function(a){0<b.playState&&(c._wD(b.id+": Data error: "+a),b._iO.ondataerror&&b._iO.ondataerror.apply(b))};this._debug()};fa=function(){return h.body||h._docElement||h.getElementsByTagName("div")[0]};A=function(a){return h.getElementById(a)};v=function(a,d){var e=a||{},b,f;b=d===g?c.defaultOptions:
|
||||
d;for(f in b)b.hasOwnProperty(f)&&e[f]===g&&(e[f]="object"!==typeof b[f]||null===b[f]?b[f]:v(e[f],b[f]));return e};K={onready:1,ontimeout:1,defaultOptions:1,flash9Options:1,movieStarOptions:1};ta=function(a,d){var e,b=!0,f=d!==g,h=c.setupOptions;if(a===g){b=[];for(e in h)h.hasOwnProperty(e)&&b.push(e);for(e in K)K.hasOwnProperty(e)&&("object"===typeof c[e]?b.push(e+": {...}"):c[e]instanceof Function?b.push(e+": function() {...}"):b.push(e));c._wD(p("setup",b.join(", ")));return!1}for(e in a)if(a.hasOwnProperty(e))if("object"!==
|
||||
typeof a[e]||null===a[e]||a[e]instanceof Array||a[e]instanceof RegExp)f&&K[d]!==g?c[d][e]=a[e]:h[e]!==g?(c.setupOptions[e]=a[e],c[e]=a[e]):K[e]===g?(Q(p(c[e]===g?"setupUndef":"setupError",e),2),b=!1):c[e]instanceof Function?c[e].apply(c,a[e]instanceof Array?a[e]:[a[e]]):c[e]=a[e];else if(K[e]===g)Q(p(c[e]===g?"setupUndef":"setupError",e),2),b=!1;else return ta(a[e],e);return b};var nb=function(a){var a=cb.call(a),c=a.length;oa?(a[1]="on"+a[1],3<c&&a.pop()):3===c&&a.push(!1);return a},ob=function(a,
|
||||
c){var e=a.shift(),b=[tb[c]];if(oa)e[b](a[0],a[1]);else e[b].apply(e,a)},oa=j.attachEvent,tb={add:oa?"attachEvent":"addEventListener",remove:oa?"detachEvent":"removeEventListener"};u={add:function(){ob(nb(arguments),"add")},remove:function(){ob(nb(arguments),"remove")}};E={abort:q(function(){c._wD(this._s.id+": abort")}),canplay:q(function(){var a=this._s,d;if(a._html5_canplay)return!0;a._html5_canplay=!0;c._wD(a.id+": canplay");a._onbufferchange(0);d=a._iO.position!==g&&!isNaN(a._iO.position)?a._iO.position/
|
||||
1E3:null;if(a.position&&this.currentTime!==d){c._wD(a.id+": canplay: Setting position to "+d);try{this.currentTime=d}catch(e){c._wD(a.id+": canplay: Setting position of "+d+" failed: "+e.message,2)}}a._iO._oncanplay&&a._iO._oncanplay()}),canplaythrough:q(function(){var a=this._s;a.loaded||(a._onbufferchange(0),a._whileloading(a.bytesLoaded,a.bytesTotal,a._get_html5_duration()),a._onload(!0))}),ended:q(function(){var a=this._s;c._wD(a.id+": ended");a._onfinish()}),error:q(function(){c._wD(this._s.id+
|
||||
": HTML5 error, code "+this.error.code);this._s._onload(!1)}),loadeddata:q(function(){var a=this._s;c._wD(a.id+": loadeddata");!a._loaded&&!Ia&&(a.duration=a._get_html5_duration())}),loadedmetadata:q(function(){c._wD(this._s.id+": loadedmetadata")}),loadstart:q(function(){c._wD(this._s.id+": loadstart");this._s._onbufferchange(1)}),play:q(function(){c._wD(this._s.id+": play()");this._s._onbufferchange(0)}),playing:q(function(){c._wD(this._s.id+": playing");this._s._onbufferchange(0)}),progress:q(function(a){var d=
|
||||
this._s,e,b,f;e=0;var g="progress"===a.type,h=a.target.buffered,m=a.loaded||0,j=a.total||1;d.buffered=[];if(h&&h.length){e=0;for(b=h.length;e<b;e++)d.buffered.push({start:1E3*h.start(e),end:1E3*h.end(e)});e=1E3*(h.end(0)-h.start(0));m=e/(1E3*a.target.duration);if(g&&1<h.length){f=[];b=h.length;for(e=0;e<b;e++)f.push(1E3*a.target.buffered.start(e)+"-"+1E3*a.target.buffered.end(e));c._wD(this._s.id+": progress, timeRanges: "+f.join(", "))}g&&!isNaN(m)&&c._wD(this._s.id+": progress, "+Math.floor(100*
|
||||
m)+"% loaded")}isNaN(m)||(d._onbufferchange(0),d._whileloading(m,j,d._get_html5_duration()),m&&(j&&m===j)&&E.canplaythrough.call(this,a))}),ratechange:q(function(){c._wD(this._s.id+": ratechange")}),suspend:q(function(a){var d=this._s;c._wD(this._s.id+": suspend");E.progress.call(this,a);d._onsuspend()}),stalled:q(function(){c._wD(this._s.id+": stalled")}),timeupdate:q(function(){this._s._onTimer()}),waiting:q(function(){var a=this._s;c._wD(this._s.id+": waiting");a._onbufferchange(1)})};la=function(a){return a.serverURL||
|
||||
a.type&&ba(a.type)?!1:a.type?Z({type:a.type}):Z({url:a.url})||c.html5Only};Da=function(a,c){a&&(a.src=c,a._called_load=!1);D&&(Fa=null)};Z=function(a){if(!c.useHTML5Audio||!c.hasHTML5)return!1;var d=a.url||null,a=a.type||null,e=c.audioFormats,b;if(a&&c.html5[a]!==g)return c.html5[a]&&!ba(a);if(!G){G=[];for(b in e)e.hasOwnProperty(b)&&(G.push(b),e[b].related&&(G=G.concat(e[b].related)));G=RegExp("\\.("+G.join("|")+")(\\?.*)?$","i")}b=d?d.toLowerCase().match(G):null;!b||!b.length?a&&(d=a.indexOf(";"),
|
||||
b=(-1!==d?a.substr(0,d):a).substr(6)):b=b[1];b&&c.html5[b]!==g?d=c.html5[b]&&!ba(b):(a="audio/"+b,d=c.html5.canPlayType({type:a}),d=(c.html5[b]=d)&&c.html5[a]&&!ba(a));return d};bb=function(){function a(a){var b,e,f=b=!1;if(!d||"function"!==typeof d.canPlayType)return b;if(a instanceof Array){b=0;for(e=a.length;b<e;b++)if(c.html5[a[b]]||d.canPlayType(a[b]).match(c.html5Test))f=!0,c.html5[a[b]]=!0,c.flash[a[b]]=!!a[b].match(ib);b=f}else a=d&&"function"===typeof d.canPlayType?d.canPlayType(a):!1,b=
|
||||
!(!a||!a.match(c.html5Test));return b}if(!c.useHTML5Audio||!c.hasHTML5)return!1;var d=Audio!==g?Ja&&10>opera.version()?new Audio(null):new Audio:null,e,b,f={},h;h=c.audioFormats;for(e in h)if(h.hasOwnProperty(e)&&(b="audio/"+e,f[e]=a(h[e].type),f[b]=f[e],e.match(ib)?(c.flash[e]=!0,c.flash[b]=!0):(c.flash[e]=!1,c.flash[b]=!1),h[e]&&h[e].related))for(b=h[e].related.length-1;0<=b;b--)f["audio/"+h[e].related[b]]=f[e],c.html5[h[e].related[b]]=f[e],c.flash[h[e].related[b]]=f[e];f.canPlayType=d?a:null;c.html5=
|
||||
v(c.html5,f);return!0};F={notReady:"Unavailable - wait until onready() has fired.",notOK:"Audio support is not available.",domError:"soundManagerexception caught while appending SWF to DOM.",spcWmode:"Removing wmode, preventing known SWF loading issue(s)",swf404:"soundManager: Verify that %s is a valid path.",tryDebug:"Try soundManager.debugFlash = true for more security details (output goes to SWF.)",checkSWF:"See SWF output for more debug info.",localFail:"soundManager: Non-HTTP page ("+h.location.protocol+
|
||||
" URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/",waitFocus:"soundManager: Special case: Waiting for SWF to load with window focus...",waitForever:"soundManager: Waiting indefinitely for Flash (will recover if unblocked)...",waitSWF:"soundManager: Waiting for 100% SWF load...",needFunction:"soundManager: Function object expected for %s",
|
||||
badID:'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',currentObj:"soundManager: _debug(): Current sound objects",waitOnload:"soundManager: Waiting for window.onload()",docLoaded:"soundManager: Document already loaded",onload:"soundManager: initComplete(): calling soundManager.onload()",onloadOK:"soundManager.onload() complete",didInit:"soundManager: init(): Already called?",secNote:"Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html",
|
||||
badRemove:"soundManager: Failed to remove Flash node.",shutdown:"soundManager.disable(): Shutting down",queue:"soundManager: Queueing %s handler",smError:"SMSound.load(): Exception: JS-Flash communication failed, or JS error.",fbTimeout:"No flash response, applying .swf_timedout CSS...",fbLoaded:"Flash loaded",flRemoved:"soundManager: Flash movie removed.",fbHandler:"soundManager: flashBlockHandler()",manURL:"SMSound.load(): Using manually-assigned URL",onURL:"soundManager.load(): current URL already assigned.",
|
||||
badFV:'soundManager.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',as2loop:"Note: Setting stream:false so looping can work (flash 8 limitation)",noNSLoop:"Note: Looping not implemented for MovieStar formats",needfl9:"Note: Switching to flash 9, required for MP4 formats.",mfTimeout:"Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case",needFlash:"soundManager: Fatal error: Flash is needed to play some required formats, but is not available.",gotFocus:"soundManager: Got window focus.",
|
||||
policy:"Enabling usePolicyFile for data access",setup:"soundManager.setup(): allowed parameters: %s",setupError:'soundManager.setup(): "%s" cannot be assigned with this method.',setupUndef:'soundManager.setup(): Could not find option "%s"',setupLate:"soundManager.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().",noURL:"soundManager: Flash URL required. Call soundManager.setup({url:...}) to get started.",sm2Loaded:"SoundManager 2: Ready.",reset:"soundManager.reset(): Removing event callbacks",
|
||||
mobileUA:"Mobile UA detected, preferring HTML5 by default.",globalHTML5:"Using singleton HTML5 Audio() pattern for this device."};p=function(){var a=cb.call(arguments),c=a.shift(),c=F&&F[c]?F[c]:"",e,b;if(c&&a&&a.length){e=0;for(b=a.length;e<b;e++)c=c.replace("%s",a[e])}return c};ha=function(a){8===l&&(1<a.loops&&a.stream)&&(k("as2loop"),a.stream=!1);return a};ia=function(a,d){if(a&&!a.usePolicyFile&&(a.onid3||a.usePeakData||a.useWaveformData||a.useEQData))c._wD((d||"")+p("policy")),a.usePolicyFile=
|
||||
!0;return a};Q=function(a){console!==g&&console.warn!==g?console.warn(a):c._wD(a)};qa=function(){return!1};Va=function(a){for(var c in a)a.hasOwnProperty(c)&&"function"===typeof a[c]&&(a[c]=qa)};za=function(a){a===g&&(a=!1);(r||a)&&c.disable(a)};Wa=function(a){var d=null;if(a)if(a.match(/\.swf(\?.*)?$/i)){if(d=a.substr(a.toLowerCase().lastIndexOf(".swf?")+4))return a}else a.lastIndexOf("/")!==a.length-1&&(a+="/");a=(a&&-1!==a.lastIndexOf("/")?a.substr(0,a.lastIndexOf("/")+1):"./")+c.movieURL;c.noSWFCache&&
|
||||
(a+="?ts="+(new Date).getTime());return a};va=function(){l=parseInt(c.flashVersion,10);8!==l&&9!==l&&(c._wD(p("badFV",l,8)),c.flashVersion=l=8);var a=c.debugMode||c.debugFlash?"_debug.swf":".swf";c.useHTML5Audio&&(!c.html5Only&&c.audioFormats.mp4.required&&9>l)&&(c._wD(p("needfl9")),c.flashVersion=l=9);c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===l?" (AS3/Flash 9)":" (AS2/Flash 8)");8<l?(c.defaultOptions=v(c.defaultOptions,c.flash9Options),c.features.buffering=!0,c.defaultOptions=
|
||||
v(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+lb.join("|")+")(\\?.*)?$","i"),c.features.movieStar=!0):c.features.movieStar=!1;c.filePattern=c.filePatterns[8!==l?"flash9":"flash8"];c.movieURL=(8===l?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",a);c.features.peakData=c.features.waveformData=c.features.eqData=8<l};Ta=function(a,c){if(!i)return!1;i._setPolling(a,c)};ya=function(){c.debugURLParam.test(R)&&(c.debugMode=!0);if(A(c.debugID))return!1;var a,
|
||||
d,e,b;if(c.debugMode&&!A(c.debugID)&&(!gb||!c.useConsole||!c.consoleOnly)){a=h.createElement("div");a.id=c.debugID+"-toggle";d={position:"fixed",bottom:"0px",right:"0px",width:"1.2em",height:"1.2em",lineHeight:"1.2em",margin:"2px",textAlign:"center",border:"1px solid #999",cursor:"pointer",background:"#fff",color:"#333",zIndex:10001};a.appendChild(h.createTextNode("-"));a.onclick=Xa;a.title="Toggle SM2 debug console";s.match(/msie 6/i)&&(a.style.position="absolute",a.style.cursor="hand");for(b in d)d.hasOwnProperty(b)&&
|
||||
(a.style[b]=d[b]);d=h.createElement("div");d.id=c.debugID;d.style.display=c.debugMode?"block":"none";if(c.debugMode&&!A(a.id)){try{e=fa(),e.appendChild(a)}catch(f){throw Error(p("domError")+" \n"+f.toString());}e.appendChild(d)}}};t=this.getSoundById;k=function(a,d){return!a?"":c._wD(p(a),d)};Xa=function(){var a=A(c.debugID),d=A(c.debugID+"-toggle");if(!a)return!1;sa?(d.innerHTML="+",a.style.display="none"):(d.innerHTML="-",a.style.display="block");sa=!sa};x=function(a,c,e){if(j.sm2Debugger!==g)try{sm2Debugger.handleEvent(a,
|
||||
c,e)}catch(b){}return!0};P=function(){var a=[];c.debugMode&&a.push("sm2_debug");c.debugFlash&&a.push("flash_debug");c.useHighPerformance&&a.push("high_performance");return a.join(" ")};Ba=function(){var a=p("fbHandler"),d=c.getMoviePercent(),e={type:"FLASHBLOCK"};if(c.html5Only)return!1;c.ok()?(c.didFlashBlock&&c._wD(a+": Unblocked"),c.oMC&&(c.oMC.className=[P(),"movieContainer","swf_loaded"+(c.didFlashBlock?" swf_unblocked":"")].join(" "))):(B&&(c.oMC.className=P()+" movieContainer "+(null===d?"swf_timedout":
|
||||
"swf_error"),c._wD(a+": "+p("fbTimeout")+(d?" ("+p("fbLoaded")+")":""))),c.didFlashBlock=!0,I({type:"ontimeout",ignoreInit:!0,error:e}),O(e))};ua=function(a,c,e){C[a]===g&&(C[a]=[]);C[a].push({method:c,scope:e||null,fired:!1})};I=function(a){a||(a={type:c.ok()?"onready":"ontimeout"});if(!n&&a&&!a.ignoreInit||"ontimeout"===a.type&&(c.ok()||r&&!a.ignoreInit))return!1;var d={success:a&&a.ignoreInit?c.ok():!r},e=a&&a.type?C[a.type]||[]:[],b=[],f,d=[d],g=B&&!c.ok();a.error&&(d[0].error=a.error);a=0;for(f=
|
||||
e.length;a<f;a++)!0!==e[a].fired&&b.push(e[a]);if(b.length){a=0;for(f=b.length;a<f;a++)b[a].scope?b[a].method.apply(b[a].scope,d):b[a].method.apply(this,d),g||(b[a].fired=!0)}return!0};L=function(){j.setTimeout(function(){c.useFlashBlock&&Ba();I();"function"===typeof c.onload&&(k("onload",1),c.onload.apply(j),k("onloadOK",1));c.waitForWindowLoad&&u.add(j,"load",L)},1)};Ga=function(){if(z!==g)return z;var a=!1,c=navigator,e=c.plugins,b,f=j.ActiveXObject;if(e&&e.length)(c=c.mimeTypes)&&(c["application/x-shockwave-flash"]&&
|
||||
c["application/x-shockwave-flash"].enabledPlugin&&c["application/x-shockwave-flash"].enabledPlugin.description)&&(a=!0);else if(f!==g&&!s.match(/MSAppHost/i)){try{b=new f("ShockwaveFlash.ShockwaveFlash")}catch(h){}a=!!b}return z=a};ab=function(){var a,d,e=c.audioFormats;if(ma&&s.match(/os (1|2|3_0|3_1)/i))c.hasHTML5=!1,c.html5Only=!0,c.oMC&&(c.oMC.style.display="none");else if(c.useHTML5Audio){if(!c.html5||!c.html5.canPlayType)c._wD("SoundManager: No HTML5 Audio() support detected."),c.hasHTML5=!1;
|
||||
La&&c._wD("soundManager: Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - "+(!z?" would use flash fallback for MP3/MP4, but none detected.":"will use flash fallback for MP3/MP4, if available"),1)}if(c.useHTML5Audio&&c.hasHTML5)for(d in e)if(e.hasOwnProperty(d)&&(e[d].required&&!c.html5.canPlayType(e[d].type)||c.preferFlash&&(c.flash[d]||c.flash[e[d].type])))a=!0;c.ignoreFlash&&(a=!1);c.html5Only=c.hasHTML5&&c.useHTML5Audio&&!a;return!c.html5Only};
|
||||
ka=function(a){var d,e,b=0;if(a instanceof Array){d=0;for(e=a.length;d<e;d++)if(a[d]instanceof Object){if(c.canPlayMIME(a[d].type)){b=d;break}}else if(c.canPlayURL(a[d])){b=d;break}a[b].url&&(a[b]=a[b].url);a=a[b]}return a};Ya=function(a){a._hasTimer||(a._hasTimer=!0,!Ka&&c.html5PollingInterval&&(null===Y&&0===ja&&(Y=j.setInterval($a,c.html5PollingInterval)),ja++))};Za=function(a){a._hasTimer&&(a._hasTimer=!1,!Ka&&c.html5PollingInterval&&ja--)};$a=function(){var a;if(null!==Y&&!ja)return j.clearInterval(Y),
|
||||
Y=null,!1;for(a=c.soundIDs.length-1;0<=a;a--)c.sounds[c.soundIDs[a]].isHTML5&&c.sounds[c.soundIDs[a]]._hasTimer&&c.sounds[c.soundIDs[a]]._onTimer()};O=function(a){a=a!==g?a:{};"function"===typeof c.onerror&&c.onerror.apply(j,[{type:a.type!==g?a.type:null}]);a.fatal!==g&&a.fatal&&c.disable()};db=function(){if(!La||!Ga())return!1;var a=c.audioFormats,d,e;for(e in a)if(a.hasOwnProperty(e)&&("mp3"===e||"mp4"===e))if(c._wD("soundManager: Using flash fallback for "+e+" format"),c.html5[e]=!1,a[e]&&a[e].related)for(d=
|
||||
a[e].related.length-1;0<=d;d--)c.html5[a[e].related[d]]=!1};this._setSandboxType=function(a){var d=c.sandbox;d.type=a;d.description=d.types[d.types[a]!==g?a:"unknown"];"localWithFile"===d.type?(d.noRemote=!0,d.noLocal=!1,k("secNote",2)):"localWithNetwork"===d.type?(d.noRemote=!1,d.noLocal=!0):"localTrusted"===d.type&&(d.noRemote=!1,d.noLocal=!1)};this._externalInterfaceOK=function(a,d){if(c.swfLoaded)return!1;var e;x("swf",!0);x("flashtojs",!0);c.swfLoaded=!0;na=!1;La&&db();if(!d||d.replace(/\+dev/i,
|
||||
"")!==c.versionNumber.replace(/\+dev/i,""))return e='soundManager: Fatal: JavaScript file build "'+c.versionNumber+'" does not match Flash SWF build "'+d+'" at '+c.url+". Ensure both are up-to-date.",setTimeout(function(){throw Error(e);},0),!1;setTimeout(ra,H?100:1)};ga=function(a,d){function e(){var a=[],b,d=[];b="SoundManager "+c.version+(!c.html5Only&&c.useHTML5Audio?c.hasHTML5?" + HTML5 audio":", no HTML5 audio support":"");c.html5Only?c.html5PollingInterval&&a.push("html5PollingInterval ("+
|
||||
c.html5PollingInterval+"ms)"):(c.preferFlash&&a.push("preferFlash"),c.useHighPerformance&&a.push("useHighPerformance"),c.flashPollingInterval&&a.push("flashPollingInterval ("+c.flashPollingInterval+"ms)"),c.html5PollingInterval&&a.push("html5PollingInterval ("+c.html5PollingInterval+"ms)"),c.wmode&&a.push("wmode ("+c.wmode+")"),c.debugFlash&&a.push("debugFlash"),c.useFlashBlock&&a.push("flashBlock"));a.length&&(d=d.concat([a.join(" + ")]));c._wD(b+(d.length?" + "+d.join(", "):""),1);eb()}function b(a,
|
||||
b){return'<param name="'+a+'" value="'+b+'" />'}if(S&&T)return!1;if(c.html5Only)return va(),e(),c.oMC=A(c.movieID),ra(),T=S=!0,!1;var f=d||c.url,j=c.altURL||f,i=fa(),m=P(),l=null,l=h.getElementsByTagName("html")[0],k,q,n,l=l&&l.dir&&l.dir.match(/rtl/i),a=a===g?c.id:a;va();c.url=Wa($?f:j);d=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(null!==c.wmode&&(s.match(/msie 8/i)||!H&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))J.push(F.spcWmode),c.wmode=null;i=
|
||||
{name:a,id:a,src:d,quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:jb+"www.macromedia.com/go/getflashplayer",title:"JS/Flash audio component (SoundManager 2)",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};c.debugFlash&&(i.FlashVars="debug=1");c.wmode||delete i.wmode;if(H)f=h.createElement("div"),q=['<object id="'+a+'" data="'+d+'" type="'+i.type+'" title="'+i.title+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+jb+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">',
|
||||
b("movie",d),b("AllowScriptAccess",c.allowScriptAccess),b("quality",i.quality),c.wmode?b("wmode",c.wmode):"",b("bgcolor",c.bgColor),b("hasPriority","true"),c.debugFlash?b("FlashVars",i.FlashVars):"","</object>"].join("");else for(k in f=h.createElement("embed"),i)i.hasOwnProperty(k)&&f.setAttribute(k,i[k]);ya();m=P();if(i=fa())if(c.oMC=A(c.movieID)||h.createElement("div"),c.oMC.id)n=c.oMC.className,c.oMC.className=(n?n+" ":"movieContainer")+(m?" "+m:""),c.oMC.appendChild(f),H&&(k=c.oMC.appendChild(h.createElement("div")),
|
||||
k.className="sm2-object-box",k.innerHTML=q),T=!0;else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+m;k=m=null;c.useFlashBlock||(c.useHighPerformance?m={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"}:(m={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},l&&(m.left=Math.abs(parseInt(m.left,10))+"px")));rb&&(c.oMC.style.zIndex=1E4);if(!c.debugFlash)for(n in m)m.hasOwnProperty(n)&&(c.oMC.style[n]=m[n]);try{H||c.oMC.appendChild(f),
|
||||
i.appendChild(c.oMC),H&&(k=c.oMC.appendChild(h.createElement("div")),k.className="sm2-object-box",k.innerHTML=q),T=!0}catch(r){throw Error(p("domError")+" \n"+r.toString());}}S=!0;e();return!0};ea=function(){if(c.html5Only)return ga(),!1;if(i)return!1;if(!c.url)return k("noURL"),!1;i=c.getMovie(c.id);i||(W?(H?c.oMC.innerHTML=Aa:c.oMC.appendChild(W),W=null,S=!0):ga(c.id,c.url),i=c.getMovie(c.id));"function"===typeof c.oninitmovie&&setTimeout(c.oninitmovie,1);Ha();return!0};M=function(){setTimeout(Sa,
|
||||
1E3)};Sa=function(){var a,d=!1;if(!c.url||X)return!1;X=!0;u.remove(j,"load",M);if(na&&!Ma)return k("waitFocus"),!1;n||(a=c.getMoviePercent(),0<a&&100>a&&(d=!0));setTimeout(function(){a=c.getMoviePercent();if(d)return X=!1,c._wD(p("waitSWF")),j.setTimeout(M,1),!1;n||(c._wD("soundManager: No Flash response within expected time. Likely causes: "+(0===a?"SWF load failed, ":"")+"Flash blocked or JS-Flash security error."+(c.debugFlash?" "+p("checkSWF"):""),2),!$&&a&&(k("localFail",2),c.debugFlash||k("tryDebug",
|
||||
2)),0===a&&c._wD(p("swf404",c.url),1),x("flashtojs",!1,": Timed out"+$?" (Check flash security or flash blockers)":" (No plugin/missing SWF?)"));!n&&hb&&(null===a?c.useFlashBlock||0===c.flashLoadTimeout?(c.useFlashBlock&&Ba(),k("waitForever")):(k("waitForever"),I({type:"ontimeout",ignoreInit:!0})):0===c.flashLoadTimeout?k("waitForever"):za(!0))},c.flashLoadTimeout)};da=function(){if(Ma||!na)return u.remove(j,"focus",da),!0;Ma=hb=!0;k("gotFocus");X=!1;M();u.remove(j,"focus",da);return!0};Ha=function(){J.length&&
|
||||
(c._wD("SoundManager 2: "+J.join(" "),1),J=[])};eb=function(){Ha();var a,d=[];if(c.useHTML5Audio&&c.hasHTML5){for(a in c.audioFormats)c.audioFormats.hasOwnProperty(a)&&d.push(a+" = "+c.html5[a]+(!c.html5[a]&&z&&c.flash[a]?" (using flash)":c.preferFlash&&c.flash[a]&&z?" (preferring flash)":!c.html5[a]?" ("+(c.audioFormats[a].required?"required, ":"")+"and no flash support)":""));c._wD("SoundManager 2 HTML5 support: "+d.join(", "),1)}};U=function(a){if(n)return!1;if(c.html5Only)return k("sm2Loaded"),
|
||||
n=!0,L(),x("onload",!0),!0;var d=!0,e;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())n=!0,r&&(e={type:!z&&B?"NO_FLASH":"INIT_TIMEOUT"});c._wD("SoundManager 2 "+(r?"failed to load":"loaded")+" ("+(r?"Flash security/load error":"OK")+")",r?2:1);r||a?(c.useFlashBlock&&c.oMC&&(c.oMC.className=P()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error")),I({type:"ontimeout",error:e,ignoreInit:!0}),x("onload",!1),O(e),d=!1):x("onload",!0);r||(c.waitForWindowLoad&&!ca?(k("waitOnload"),
|
||||
u.add(j,"load",L)):(c.waitForWindowLoad&&ca&&k("docLoaded"),L()));return d};Ra=function(){var a,d=c.setupOptions;for(a in d)d.hasOwnProperty(a)&&(c[a]===g?c[a]=d[a]:c[a]!==d[a]&&(c.setupOptions[a]=c[a]))};ra=function(){if(n)return k("didInit"),!1;if(c.html5Only)return n||(u.remove(j,"load",c.beginDelayedInit),c.enabled=!0,U()),!0;ea();try{i._externalInterfaceTest(!1),Ta(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||i._disableDebug(),c.enabled=!0,x("jstoflash",!0),c.html5Only||
|
||||
u.add(j,"unload",qa)}catch(a){return c._wD("js/flash exception: "+a.toString()),x("jstoflash",!1),O({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),za(!0),U(),!1}U();u.remove(j,"load",c.beginDelayedInit);return!0};N=function(){if(V)return!1;V=!0;Ra();ya();var a=null,a=null,d=j.console!==g&&"function"===typeof console.log,e=R.toLowerCase();-1!==e.indexOf("sm2-usehtml5audio=")&&(a="1"===e.charAt(e.indexOf("sm2-usehtml5audio=")+18),d&&console.log((a?"Enabling ":"Disabling ")+"useHTML5Audio via URL parameter"),
|
||||
c.setup({useHTML5Audio:a}));-1!==e.indexOf("sm2-preferflash=")&&(a="1"===e.charAt(e.indexOf("sm2-preferflash=")+16),d&&console.log((a?"Enabling ":"Disabling ")+"preferFlash via URL parameter"),c.setup({preferFlash:a}));!z&&c.hasHTML5&&(c._wD("SoundManager: No Flash detected"+(!c.useHTML5Audio?", enabling HTML5.":". Trying HTML5-only mode."),1),c.setup({useHTML5Audio:!0,preferFlash:!1}));bb();c.html5.usingFlash=ab();B=c.html5.usingFlash;!z&&B&&(J.push(F.needFlash),c.setup({flashLoadTimeout:1}));h.removeEventListener&&
|
||||
h.removeEventListener("DOMContentLoaded",N,!1);ea();return!0};Ea=function(){"complete"===h.readyState&&(N(),h.detachEvent("onreadystatechange",Ea));return!0};xa=function(){ca=!0;u.remove(j,"load",xa)};wa=function(){if(Ka&&((!c.setupOptions.useHTML5Audio||c.setupOptions.preferFlash)&&J.push(F.mobileUA),c.setupOptions.useHTML5Audio=!0,c.setupOptions.preferFlash=!1,ma||fb&&!s.match(/android\s2\.3/i)))J.push(F.globalHTML5),ma&&(c.ignoreFlash=!0),D=!0};wa();Ga();u.add(j,"focus",da);u.add(j,"load",M);u.add(j,
|
||||
"load",xa);h.addEventListener?h.addEventListener("DOMContentLoaded",N,!1):h.attachEvent?h.attachEvent("onreadystatechange",Ea):(x("onload",!1),O({type:"NO_DOM2_EVENTS",fatal:!0}))}var pa=null;if(void 0===j.SM2_DEFER||!SM2_DEFER)pa=new aa;j.SoundManager=aa;j.soundManager=pa})(window);
|
||||
BIN
demo/pacman/sound/dies.mp3
Normal file
BIN
demo/pacman/sound/eatingfruit.mp3
Normal file
BIN
demo/pacman/sound/eatingghost.mp3
Normal file
BIN
demo/pacman/sound/opening.mp3
Normal file
BIN
demo/pacman/sound/siren.mp3
Normal file
BIN
demo/pacman/sound/wakawaka.mp3
Normal file
BIN
demo/pacman/swf/soundmanager2.swf
Normal file
BIN
demo/pacman/swf/soundmanager2_debug.swf
Normal file
BIN
demo/pacman/swf/soundmanager2_flash9.swf
Normal file
BIN
demo/pacman/swf/soundmanager2_flash9_debug.swf
Normal file
7
demo/pyramid/MIT-LICENCE.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
23
demo/pyramid/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
Pyramid is a jQuery implementation of the famous Pyramid solitaire game card.
|
||||
|
||||
|
||||
How to :
|
||||
--------
|
||||
|
||||
The goal is to remove all Pyramid's cards.
|
||||
To remove a card, it must be associated with an other one and their sum must be equals to 13.
|
||||
Each card has is numeric value and Kings' value is 13 (no need to be associated with an other card), Queens' value is 12 and Jake' value is 11.
|
||||
|
||||
A live demo is avalaible [here](http://www.viadeo-playground.com/pyramid/index)
|
||||
|
||||
Credits :
|
||||
---------
|
||||
|
||||
* Graphics : [Byron Knoll](http://code.google.com/p/vector-playing-cards)
|
||||
* Code : Fabrice Ecaille aka Febbweiss
|
||||
|
||||
Licences :
|
||||
----------
|
||||
|
||||
Source code is under [MIT Licence](http://opensource.org/licenses/mit-license.php)
|
||||
Cards sprite is under [Public domain](http://creativecommons.org/publicdomain/zero/1.0/)
|
||||
184
demo/pyramid/css/cards.css
Normal file
@@ -0,0 +1,184 @@
|
||||
.card {
|
||||
position: absolute;
|
||||
width: 80px;
|
||||
height: 124px;
|
||||
background-image: url('../images/cards.png');
|
||||
float: left;
|
||||
}
|
||||
|
||||
.card.selected {
|
||||
border: 2px solid yellow;
|
||||
}
|
||||
|
||||
.clubs_1 {
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
.clubs_2 {
|
||||
background-position: -80px 0px;
|
||||
}
|
||||
.clubs_3 {
|
||||
background-position: -160px 0px;
|
||||
}
|
||||
.clubs_4 {
|
||||
background-position: -240px 0px;
|
||||
}
|
||||
.clubs_5 {
|
||||
background-position: -320px 0px;
|
||||
}
|
||||
.clubs_6 {
|
||||
background-position: -400px 0px;
|
||||
}
|
||||
.clubs_7 {
|
||||
background-position: -480px 0px;
|
||||
}
|
||||
.clubs_8 {
|
||||
background-position: -560px 0px;
|
||||
}
|
||||
.clubs_9 {
|
||||
background-position: -640px 0px;
|
||||
}
|
||||
.clubs_10 {
|
||||
background-position: -720px 0px;
|
||||
}
|
||||
.clubs_11 {
|
||||
background-position: -800px 0px;
|
||||
}
|
||||
.clubs_12 {
|
||||
background-position: -880px 0px;
|
||||
}
|
||||
.clubs_13 {
|
||||
background-position: -960px 0px;
|
||||
}
|
||||
|
||||
.diamonds_1 {
|
||||
background-position: 0px -125px;
|
||||
}
|
||||
.diamonds_2 {
|
||||
background-position: -80px -125px;
|
||||
}
|
||||
.diamonds_3 {
|
||||
background-position: -160px -125px;
|
||||
}
|
||||
.diamonds_4 {
|
||||
background-position: -240px -125px;
|
||||
}
|
||||
.diamonds_5 {
|
||||
background-position: -320px -125px;
|
||||
}
|
||||
.diamonds_6 {
|
||||
background-position: -400px -125px;
|
||||
}
|
||||
.diamonds_7 {
|
||||
background-position: -480px -125px;
|
||||
}
|
||||
.diamonds_8 {
|
||||
background-position: -560px -125px;
|
||||
}
|
||||
.diamonds_9 {
|
||||
background-position: -640px -125px;
|
||||
}
|
||||
.diamonds_10 {
|
||||
background-position: -720px -125px;
|
||||
}
|
||||
.diamonds_11 {
|
||||
background-position: -800px -125px;
|
||||
}
|
||||
.diamonds_12 {
|
||||
background-position: -880px -125px;
|
||||
}
|
||||
.diamonds_13 {
|
||||
background-position: -960px -125px;
|
||||
}
|
||||
|
||||
.hearts_1 {
|
||||
background-position: 0px -249px;
|
||||
}
|
||||
.hearts_2 {
|
||||
background-position: -80px -249px;
|
||||
}
|
||||
.hearts_3 {
|
||||
background-position: -160px -249px;
|
||||
}
|
||||
.hearts_4 {
|
||||
background-position: -240px -249px;
|
||||
}
|
||||
.hearts_5 {
|
||||
background-position: -320px -249px;
|
||||
}
|
||||
.hearts_6 {
|
||||
background-position: -400px -249px;
|
||||
}
|
||||
.hearts_7 {
|
||||
background-position: -480px -249px;
|
||||
}
|
||||
.hearts_8 {
|
||||
background-position: -560px -249px;
|
||||
}
|
||||
.hearts_9 {
|
||||
background-position: -640px -249px;
|
||||
}
|
||||
.hearts_10 {
|
||||
background-position: -720px -249px;
|
||||
}
|
||||
.hearts_11 {
|
||||
background-position: -800px -249px;
|
||||
}
|
||||
.hearts_12 {
|
||||
background-position: -880px -249px;
|
||||
}
|
||||
.hearts_13 {
|
||||
background-position: -960px -249px;
|
||||
}
|
||||
|
||||
.spades_1 {
|
||||
background-position: 0px -374px;
|
||||
}
|
||||
.spades_2 {
|
||||
background-position: -80px -374px;
|
||||
}
|
||||
.spades_3 {
|
||||
background-position: -160px -374px;
|
||||
}
|
||||
.spades_4 {
|
||||
background-position: -240px -374px;
|
||||
}
|
||||
.spades_5 {
|
||||
background-position: -320px -374px;
|
||||
}
|
||||
.spades_6 {
|
||||
background-position: -400px -374px;
|
||||
}
|
||||
.spades_7 {
|
||||
background-position: -480px -374px;
|
||||
}
|
||||
.spades_8 {
|
||||
background-position: -560px -374px;
|
||||
}
|
||||
.spades_9 {
|
||||
background-position: -640px -374px;
|
||||
}
|
||||
.spades_10 {
|
||||
background-position: -720px -374px;
|
||||
}
|
||||
.spades_11 {
|
||||
background-position: -800px -374px;
|
||||
}
|
||||
.spades_12 {
|
||||
background-position: -880px -374px;
|
||||
}
|
||||
.spades_13 {
|
||||
background-position: -960px -374px;
|
||||
}
|
||||
|
||||
.joker_black {
|
||||
background-position: 0px -498px;
|
||||
}
|
||||
.joker_red {
|
||||
background-position: -80px -498px;
|
||||
}
|
||||
.background {
|
||||
background-position: -160px -498px;
|
||||
}
|
||||
.none {
|
||||
background-position: -240px -498px;
|
||||
}
|
||||
BIN
demo/pyramid/images/cards.png
Normal file
|
After Width: | Height: | Size: 306 KiB |
35
demo/pyramid/index.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Pyramid.js</title>
|
||||
<script src="lib/jquery-1.7.1.min.js" type="text/javascript"></script>
|
||||
<script src="js/pyramid.js" type="text/javascript"></script>
|
||||
<script src="js/cards.js" type="text/javascript"></script>
|
||||
<link href="css/cards.css" type="text/css"rel="stylesheet">
|
||||
<link href="../../extra/css/extra.css" type="text/css" rel="stylesheet" media="screen, projection" />
|
||||
<script src="../../extra/js/pyramid.js" type="text/javascript" ></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="playground" style="height: 370px">
|
||||
<div id="stock" class="card background" style="position: absolute; left: 0;"></div>
|
||||
<img id="drawn" class="card none"style="position: absolute; right: 0;" />
|
||||
</div>
|
||||
<div style="text-align: center;margin-top: 00px;">
|
||||
<button id="startBtn" class="push--skeuo">Start</button>
|
||||
</div>
|
||||
<script language="javascript">
|
||||
$(document).ready(function () {
|
||||
Pyramid.init();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
59
demo/pyramid/js/cards.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var CARD_WIDTH = 80;
|
||||
var CARD_HEIGHT = 124;
|
||||
|
||||
var Deck = {
|
||||
cards: [
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52
|
||||
],
|
||||
|
||||
values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||
|
||||
value: function(card) {
|
||||
return card % Deck.values.length + 1;
|
||||
},
|
||||
|
||||
familly: function( card ) {
|
||||
if( card < 14 )
|
||||
return "clubs";
|
||||
else if( card < 27 )
|
||||
return "diamonds";
|
||||
else if( card < 40 )
|
||||
return "hearts";
|
||||
else
|
||||
return "spades";
|
||||
},
|
||||
|
||||
point: function(card) {
|
||||
return Deck.values[Deck.value(card) - 1];
|
||||
},
|
||||
|
||||
shuffle: function() {
|
||||
for (var i = 0; i < Deck.cards.length; ++i) {
|
||||
var x = parseInt(Math.random() * Deck.cards.length);
|
||||
var y = parseInt(Math.random() * Deck.cards.length);
|
||||
if (x == y)
|
||||
continue;
|
||||
var tmp = Deck.cards[x];
|
||||
Deck.cards[x] = Deck.cards[y];
|
||||
Deck.cards[y] = tmp;
|
||||
}
|
||||
return Deck.cards;
|
||||
},
|
||||
|
||||
pop: function() {
|
||||
return Deck.cards.pop();
|
||||
}
|
||||
}
|
||||
185
demo/pyramid/js/pyramid.js
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var Pyramid = {
|
||||
initial_set: [1, 2, 3, 4, 5, 6, 7],
|
||||
|
||||
pyramid: new Array(7),
|
||||
|
||||
selected: null,
|
||||
drawn: new Array(),
|
||||
drawn_count: 0,
|
||||
|
||||
init: function() {
|
||||
Pyramid.pyramid = new Array(7);
|
||||
Pyramid.selected = null;
|
||||
Pyramid.drawn = new Array();
|
||||
Pyramid.drawn_count = 0;
|
||||
|
||||
var maxCard = Pyramid.initial_set[ Pyramid.initial_set.length - 1];
|
||||
var initial_x = (maxCard * CARD_WIDTH) / 2;
|
||||
|
||||
var initial_y = 0;
|
||||
var playground = $("#playground");
|
||||
playground.width( maxCard * CARD_WIDTH);
|
||||
playground.height( Pyramid.initial_set.lentgh * CARD_HEIGHT);
|
||||
|
||||
|
||||
Deck.shuffle();
|
||||
|
||||
for( var i = 0; i < Pyramid.initial_set.length; i++) {
|
||||
var cards = Pyramid.initial_set[i];
|
||||
var offsetx = initial_x - cards * CARD_WIDTH / 2;
|
||||
Pyramid.pyramid[i] = new Array(cards);
|
||||
for( var j = 0; j < cards; j++ ) {
|
||||
var value = Deck.pop();
|
||||
Pyramid.pyramid[i][j] = value;
|
||||
$("<img/>",{
|
||||
id:"card" + i +j,
|
||||
class: "card " + Deck.familly( value ) + "_" + Deck.value(value),
|
||||
style: "left: " + offsetx + "px; top: " + ( i * CARD_HEIGHT / 3 ) + "px;"
|
||||
}).appendTo(playground);
|
||||
|
||||
offsetx += CARD_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
$("#stock").width( CARD_WIDTH ).height( CARD_HEIGHT );
|
||||
$("#drawn").width( CARD_WIDTH ).height( CARD_HEIGHT );
|
||||
$("#control").width( CARD_WIDTH ).height( 2 * CARD_HEIGHT );
|
||||
|
||||
$(".card").click( Pyramid.click );
|
||||
},
|
||||
|
||||
click: function(e) {
|
||||
var elt = $(this);
|
||||
var id = elt.attr('id');
|
||||
|
||||
if( id === "stock" ) {
|
||||
Pyramid.draw();
|
||||
return false;
|
||||
}
|
||||
|
||||
var card = Pyramid.card(elt);
|
||||
|
||||
if( !card )
|
||||
return false;
|
||||
|
||||
var point = Deck.point(card);
|
||||
|
||||
if( point == 13 ) {
|
||||
Pyramid.remove(elt);
|
||||
Pyramid.win();
|
||||
return true;
|
||||
}
|
||||
|
||||
if( elt.hasClass("selected") ) {
|
||||
elt.removeClass("selected");
|
||||
Pyramid.selected = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var selected = Pyramid.selected;
|
||||
if( selected ) {
|
||||
var card = Pyramid.card(Pyramid.selected);
|
||||
|
||||
if( (point + Deck.point(card)) == 13 ) {
|
||||
Pyramid.remove(elt);
|
||||
Pyramid.remove( selected );
|
||||
Pyramid.win();
|
||||
} else {
|
||||
selected.removeClass("selected");
|
||||
}
|
||||
|
||||
Pyramid.selected = null;
|
||||
} else {
|
||||
elt.addClass("selected");
|
||||
Pyramid.selected = elt;
|
||||
}
|
||||
},
|
||||
|
||||
next: function() {
|
||||
var card = Deck.pop();
|
||||
Pyramid.drawn.push( card );
|
||||
$("#drawn").removeClass().addClass("card").addClass("card " + Deck.familly( card ) + "_" + Deck.value(card));
|
||||
if( Deck.cards.length == 0 ) {
|
||||
$("#stock").removeClass();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
card: function(elt) {
|
||||
var id = elt.attr('id');
|
||||
|
||||
if( id === "drawn" ) {
|
||||
if( Pyramid.drawn.length > 0 ) {
|
||||
return Pyramid.drawn[Pyramid.drawn.length - 1];
|
||||
} else
|
||||
return false;
|
||||
} else {
|
||||
var i = parseInt(id.charAt(4));
|
||||
var j = parseInt(id.charAt(5));
|
||||
|
||||
if( typeof Pyramid.pyramid[i + 1] != "undefined"
|
||||
&& ( typeof Pyramid.pyramid[i + 1][ j ] != "undefined" || typeof Pyramid.pyramid[i + 1][ j + 1] != "undefined") )
|
||||
return false;
|
||||
|
||||
return Pyramid.pyramid[i][j];
|
||||
}
|
||||
},
|
||||
|
||||
remove: function(elt) {
|
||||
var id = elt.attr('id');
|
||||
|
||||
if( id === "drawn" ) {
|
||||
Pyramid.drawn.pop();
|
||||
$("#drawn").removeClass();
|
||||
if( Pyramid.drawn.length > 0 ) {
|
||||
card = Pyramid.drawn[Pyramid.drawn.length - 1];
|
||||
$("#drawn").addClass("card").addClass("card " + Deck.familly( card ) + "_" + Deck.value(card));
|
||||
}
|
||||
} else {
|
||||
var i = parseInt(id.charAt(4));
|
||||
var j = parseInt(id.charAt(5));
|
||||
Pyramid.pyramid[i][j] = undefined;
|
||||
elt.remove();
|
||||
}
|
||||
},
|
||||
|
||||
draw: function() {
|
||||
if( Deck.cards.length > 0 ) {
|
||||
Pyramid.drawn_count++;
|
||||
Pyramid.next();
|
||||
return false;
|
||||
}
|
||||
|
||||
Deck.cards = Pyramid.drawn.reverse();
|
||||
Pyramid.drawn = new Array();
|
||||
$("#drawn").removeClass();
|
||||
$("#stock").addClass("card").addClass("background");
|
||||
$("#")
|
||||
},
|
||||
|
||||
win: function() {
|
||||
var win = true;
|
||||
$.each($(".card"), function(index, elt) {
|
||||
var id = $(elt).attr('id');
|
||||
if( id !== "stock" && id !== "drawn")
|
||||
win = false;
|
||||
});
|
||||
if( win )
|
||||
Pyramid.show_win();
|
||||
return win;
|
||||
},
|
||||
|
||||
show_win: function() {
|
||||
alert( "Win in " + Pyramid.drawn_count + " draws !!!");
|
||||
}
|
||||
}
|
||||
4
demo/pyramid/lib/jquery-1.7.1.min.js
vendored
Normal file
1
demo/sis/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*~
|
||||
7
demo/sis/MIT-LICENCE.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
63
demo/sis/css/countdown.css
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#countdown {
|
||||
float: left;
|
||||
margin-top:12px;
|
||||
margin-left:12px;
|
||||
width:210px;
|
||||
padding: 3px;
|
||||
color: white;
|
||||
background-color: black;
|
||||
font-family: Tahoma;
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
.clock {
|
||||
background : transparent url("../images/hours.png") no-repeat top left;
|
||||
height:40px;
|
||||
width:30px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
.separator {
|
||||
background-position : -30px -220px;
|
||||
}
|
||||
|
||||
.n0 {
|
||||
background-position : 0 -7px;
|
||||
}
|
||||
.n1 {
|
||||
background-position : 0 -49px;
|
||||
}
|
||||
.n2 {
|
||||
background-position : 0 -91px;
|
||||
}
|
||||
.n3 {
|
||||
background-position : 0 -133px;
|
||||
}
|
||||
.n4 {
|
||||
background-position : 0 -176px;
|
||||
}
|
||||
.n5 {
|
||||
background-position : -30px -7px;
|
||||
}
|
||||
.n6 {
|
||||
background-position : -30px -50px;
|
||||
}
|
||||
.n7 {
|
||||
background-position : -30px -91px;
|
||||
}
|
||||
.n8 {
|
||||
background-position : -30px -133px;
|
||||
}
|
||||
.n9 {
|
||||
background-position : -30px -176px;
|
||||
}
|
||||
64
demo/sis/css/scoreboard.css
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
.scoreboard {
|
||||
float: left;
|
||||
/* margin-top:12px;
|
||||
margin-left:12px;
|
||||
*/ width: 180px;
|
||||
height: 40px;
|
||||
padding: 3px;
|
||||
color: white;
|
||||
background-color: black;
|
||||
font-family: Tahoma;
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
.clock {
|
||||
background : transparent url("../images/hours.png") no-repeat top left;
|
||||
height:40px;
|
||||
width:30px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
.separator {
|
||||
background-position : -30px -220px;
|
||||
}
|
||||
|
||||
.n0 {
|
||||
background-position : 0 -7px;
|
||||
}
|
||||
.n1 {
|
||||
background-position : 0 -49px;
|
||||
}
|
||||
.n2 {
|
||||
background-position : 0 -91px;
|
||||
}
|
||||
.n3 {
|
||||
background-position : 0 -133px;
|
||||
}
|
||||
.n4 {
|
||||
background-position : 0 -176px;
|
||||
}
|
||||
.n5 {
|
||||
background-position : -30px -7px;
|
||||
}
|
||||
.n6 {
|
||||
background-position : -30px -50px;
|
||||
}
|
||||
.n7 {
|
||||
background-position : -30px -91px;
|
||||
}
|
||||
.n8 {
|
||||
background-position : -30px -133px;
|
||||
}
|
||||
.n9 {
|
||||
background-position : -30px -176px;
|
||||
}
|
||||
129
demo/sis/css/spaceinvaders.css
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#playground {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.alien {
|
||||
}
|
||||
|
||||
.shipShot {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.shipShot.carot {
|
||||
background-color: orange;
|
||||
}
|
||||
|
||||
.shipShot.shotgun {
|
||||
background-color: grey;
|
||||
}
|
||||
|
||||
.shipShot.shotCorn {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.alienShot {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.weapon_bar {
|
||||
height: 10px;
|
||||
width: 100px;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.weapon_level {
|
||||
height: 8px;
|
||||
position: relative;
|
||||
margin: 1px;
|
||||
}
|
||||
.weapon_level.good {
|
||||
background-color: green;
|
||||
}
|
||||
.weapon_level.middle {
|
||||
background-color: yellow;
|
||||
}
|
||||
.weapon_level.bad {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.life {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
float: left;
|
||||
background-image: url('../images/sprite.png');
|
||||
background-position: 0px -16px;
|
||||
}
|
||||
|
||||
/** SCOREBOARD**/
|
||||
|
||||
.clock {
|
||||
background : transparent url("../images/font.png") no-repeat top left;
|
||||
height:32px;
|
||||
width:32px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
.clock.red {
|
||||
background : transparent url("images/font-red.png") no-repeat top left;
|
||||
}
|
||||
|
||||
.clock.yellow {
|
||||
background : transparent url("images/font-yellow.png") no-repeat top left;
|
||||
}
|
||||
|
||||
.clock.small {
|
||||
position: relative;
|
||||
top: 45%;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.n0 {
|
||||
background-position : 0px 0px;
|
||||
}
|
||||
.n1 {
|
||||
background-position : -32px 0px;
|
||||
}
|
||||
.n2 {
|
||||
background-position : -64px 0px;
|
||||
}
|
||||
.n3 {
|
||||
background-position : -96px 0px;
|
||||
}
|
||||
.n4 {
|
||||
background-position : -128px 0px;
|
||||
}
|
||||
.n5 {
|
||||
background-position : -160px 0px;
|
||||
}
|
||||
.n6 {
|
||||
background-position : -192px 0px;
|
||||
}
|
||||
.n7 {
|
||||
background-position : -224px 0px;
|
||||
}
|
||||
.n8 {
|
||||
background-position : -256px 0px;
|
||||
}
|
||||
.n9 {
|
||||
background-position : -288px 0px;
|
||||
}
|
||||
/** Scoreboard end **/
|
||||
|
||||
|
||||
/** Modal **/
|
||||
.modal {
|
||||
background-color: yellow;
|
||||
/** Modal - end **/
|
||||
BIN
demo/sis/images/aliensprite.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
demo/sis/images/background.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
demo/sis/images/background2.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
demo/sis/images/explosion_big.png
Normal file
|
After Width: | Height: | Size: 360 KiB |
BIN
demo/sis/images/explosion_small.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
demo/sis/images/farm.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
demo/sis/images/font.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
demo/sis/images/invader.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
demo/sis/images/ufo.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
60
demo/sis/index.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<!--
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Space invaders - Story</title>
|
||||
|
||||
<script src="lib/jquery-1.7.1.min.js" type="text/javascript" ></script>
|
||||
<script src="lib//jquery-ui-1.8.23.custom.min.js" type="text/javascript" ></script>
|
||||
<script src="lib/gamequery-0.7.1.js" type="text/javascript" ></script>
|
||||
<script src="js/tools.js" type="text/javascript" ></script>
|
||||
<script src="js/scoreboard.js" type="text/javascript" ></script>
|
||||
<script src="js/countdown.js" type="text/javasccript" ></script>
|
||||
<script src="js/lettering.js" type="text/javascript" ></script>
|
||||
|
||||
<link href="css/scoreboard.css" type="text/css" rel="stylesheet"/>
|
||||
<link href="css/countdown.css" type="text/css" rel="stylesheet"/>
|
||||
|
||||
<script src="js/animations/animations.js" type="text/javascript" ></script>
|
||||
<script src="js/animations/aliens.js" type="text/javascript" ></script>
|
||||
<script src="js/animations/explosions.js" type="text/javascript" ></script>
|
||||
<script src="js/animations/worlds.js" type="text/javascript" ></script>
|
||||
|
||||
<script src="js/spaceinvaders-ui.js" type="text/javascript" ></script>
|
||||
<script src="js/spaceinvaders-core.js" type="text/javascript" ></script>
|
||||
<script src="js/models/weapons.js" type="text/javascript" ></script>
|
||||
<script src="js/models/models.js" type="text/javascript" ></script>
|
||||
<script src="js/models/aliens.js" type="text/javascript" ></script>
|
||||
<script src="js/models/waves.js" type="text/javascript" ></script>
|
||||
<script src="js/models/weapons.js" type="text/javascript" ></script>
|
||||
|
||||
<link href="css/spaceinvaders.css" type="text/css" rel="stylesheet"/>
|
||||
|
||||
<link href="../../extra/css/extra.css" type="text/css" rel="stylesheet" media="screen, projection" />
|
||||
<script src="../../extra/js/sis.js" type="text/javascript" ></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="playgroundContainer" style="height: 544;">
|
||||
<div id="playground">
|
||||
<div id="welcomeScreen">
|
||||
<div style="position: absolute; top: 120px; width: 700px; color: white;">
|
||||
<div id="loadingBar"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="width: 448px; text-align: center;margin-top: 00px;">
|
||||
<button id="startBtn" class="push--skeuo">Start</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
55
demo/sis/js/animations/aliens.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var ALIENS_WIDTH = 25,
|
||||
ALIENS_WIDTH_2 = 18,
|
||||
ALIENS_HEIGHT = 17,
|
||||
ALIENS_SPRITE = IMAGES_PREFIX + "invader.png",
|
||||
ALIENS_RATE = 400;
|
||||
|
||||
var ALIENS_TYPE = [
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : ALIENS_SPRITE,
|
||||
numberOfFrame : 2,
|
||||
delta : 24,
|
||||
rate : ALIENS_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL
|
||||
}),
|
||||
width : 24,
|
||||
height: 18
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : ALIENS_SPRITE,
|
||||
numberOfFrame : 2,
|
||||
delta : ALIENS_WIDTH_2,
|
||||
offsety : 20,
|
||||
rate : ALIENS_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL
|
||||
}),
|
||||
width : ALIENS_WIDTH_2,
|
||||
height: 17
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : ALIENS_SPRITE,
|
||||
numberOfFrame : 2,
|
||||
delta : ALIENS_WIDTH,
|
||||
offsety : 40,
|
||||
rate : ALIENS_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL
|
||||
}),
|
||||
width : ALIENS_WIDTH,
|
||||
height: 18
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
11
demo/sis/js/animations/animations.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var IMAGES_PREFIX = "images/";
|
||||
127
demo/sis/js/animations/explosions.js
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var EXPLOSION_BIG = IMAGES_PREFIX + "explosion_big.png",
|
||||
EXPLOSION_BIG_RATE = 50,
|
||||
EXPLOSION_SMALL = IMAGES_PREFIX + "explosion_small.png",
|
||||
EXPLOSION_SMALL_RATE = 50;
|
||||
|
||||
var EXPLOSIONS = {
|
||||
BIG : [
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
offsety : 128,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
offsety : 256,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
offsety : 384,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
offsety : 512,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
offsety : 640,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
offsety : 768,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK | $.gQ.ANIMATION_ONCE
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
},
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_BIG,
|
||||
offsety : 896,
|
||||
numberOfFrame : 8,
|
||||
delta : 128,
|
||||
rate : EXPLOSION_BIG_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK | $.gQ.ANIMATION_ONCE
|
||||
}),
|
||||
width : 128,
|
||||
height: 128
|
||||
}
|
||||
],
|
||||
SMALL : [
|
||||
{
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : EXPLOSION_SMALL,
|
||||
numberOfFrame : 10,
|
||||
delta : 64,
|
||||
rate : EXPLOSION_SMALL_RATE,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL | $.gQ.ANIMATION_CALLBACK | $.gQ.ANIMATION_ONCE
|
||||
}),
|
||||
width : 64,
|
||||
height: 64
|
||||
}
|
||||
]
|
||||
}
|
||||
131
demo/sis/js/animations/worlds.js
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var FARM_SPRITE = IMAGES_PREFIX + "farm.png",
|
||||
FARM_BACKGROUND_1 = IMAGES_PREFIX + "background.png",
|
||||
FARM_BACKGROUND_2 = IMAGES_PREFIX + "background2.png";
|
||||
|
||||
var WORLD = {
|
||||
farm : {
|
||||
hero : {
|
||||
ship : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE
|
||||
}),
|
||||
width : 48,
|
||||
height : 24,
|
||||
posx : 0,
|
||||
posy : 17
|
||||
},
|
||||
/*cockpit : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE,
|
||||
offsety : 24,
|
||||
offsetx : 20
|
||||
}),
|
||||
width : 20,
|
||||
height : 33,
|
||||
posx : 28,
|
||||
posy : 3
|
||||
},*/
|
||||
smallWheel : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE,
|
||||
offsetx : 0,
|
||||
offsety : 24
|
||||
}),
|
||||
posx : 4,
|
||||
posy : 30,
|
||||
width: 14,
|
||||
height: 14
|
||||
},
|
||||
bigWheel : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE,
|
||||
offsetx : 0,
|
||||
offsety : 38
|
||||
}),
|
||||
width : 19,
|
||||
height : 19,
|
||||
posx : 25,
|
||||
posy : 27
|
||||
}
|
||||
},
|
||||
alien : {
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : IMAGES_PREFIX + "invader.png",
|
||||
numberOfFrame : 2,
|
||||
delta : ALIENS_WIDTH,
|
||||
rate : 400,
|
||||
type : $.gQ.ANIMATION_HORIZONTAL
|
||||
}),
|
||||
width : ALIENS_WIDTH,
|
||||
height : ALIENS_HEIGHT
|
||||
},
|
||||
ufo : {
|
||||
animation: new $.gQ.Animation({imageURL: IMAGES_PREFIX + "ufo.png"}),
|
||||
width: 48,
|
||||
height: 32,
|
||||
posy: 10
|
||||
},
|
||||
life : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE,
|
||||
offsetx : 14,
|
||||
offsety : 24
|
||||
}),
|
||||
width: 32,
|
||||
height: 16
|
||||
},
|
||||
weapons : {
|
||||
corn : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE,
|
||||
offsetx : 19,
|
||||
offsety : 37
|
||||
}),
|
||||
width: 19,
|
||||
height: 19
|
||||
},
|
||||
carot : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE,
|
||||
offsetx : 38,
|
||||
offsety : 37
|
||||
}),
|
||||
width: 19,
|
||||
height: 19
|
||||
},
|
||||
gun : {
|
||||
animation : new $.gameQuery.Animation({
|
||||
imageURL : FARM_SPRITE,
|
||||
offsetx : 57,
|
||||
offsety : 37
|
||||
}),
|
||||
width: 19,
|
||||
height: 19
|
||||
}
|
||||
},
|
||||
backgrounds : {
|
||||
farm: {
|
||||
background1 : {
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : FARM_BACKGROUND_1
|
||||
})
|
||||
},
|
||||
background2 : {
|
||||
animation : new $.gQ.Animation({
|
||||
imageURL : FARM_BACKGROUND_2
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
94
demo/sis/js/countdown.js
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var COUNTDOWN = {
|
||||
mustStop: false,
|
||||
|
||||
init: function( minutes, seconds ) {
|
||||
COUNTDOWN.minutes = minutes;
|
||||
COUNTDOWN.seconds = seconds;
|
||||
COUNTDOWN.mustStop = false;
|
||||
// $( "#countdown" ).width( ( minutes > 0 ? 90 : 0 ) + 90);
|
||||
// $( "#countdown" ).css( "background-color", "black" );
|
||||
},
|
||||
|
||||
start: function() {
|
||||
if( COUNTDOWN.mustStop )
|
||||
return;
|
||||
|
||||
COUNTDOWN.running = true;
|
||||
|
||||
var currentMinutes = "";
|
||||
var currentSeconds = "";
|
||||
var imageMinutes = "";
|
||||
var imageSeconds = "";
|
||||
|
||||
currentMinutes = COUNTDOWN.minutes;
|
||||
currentSeconds = COUNTDOWN.seconds;
|
||||
|
||||
var nextMinutes = COUNTDOWN.minutes;
|
||||
var nextSeconds = COUNTDOWN.seconds - 1;
|
||||
|
||||
if( nextSeconds < 0 && nextMinutes > 0 ) {
|
||||
nextSeconds = 59;
|
||||
nextMinutes = Math.min(0, nextMinutes -1);
|
||||
}
|
||||
|
||||
COUNTDOWN.minutes = nextMinutes;
|
||||
COUNTDOWN.seconds = nextSeconds;
|
||||
|
||||
if( currentMinutes <= 0 && currentSeconds < 10 )
|
||||
$( "#countdown" ).css( "background-color", "red" );
|
||||
|
||||
if(parseInt(currentMinutes) < 10 ) currentMinutes = "0" + currentMinutes;
|
||||
if(parseInt(currentSeconds) < 10 ) currentSeconds = "0" + currentSeconds;
|
||||
|
||||
for(i = 0; i < String(currentMinutes).length; i++) {
|
||||
imageMinutes += "<div class='clock n"+ String(currentMinutes)[i]+"'></div>";
|
||||
}
|
||||
|
||||
for(i = 0; i < String(currentSeconds).length; i++) {
|
||||
imageSeconds += "<div class='clock n"+ String(currentSeconds)[i]+"'></div>";
|
||||
}
|
||||
|
||||
if( COUNTDOWN.minutes > 0) {
|
||||
$("#subMinutes").empty().removeClass( "hide" ).append( imageMinutes );;
|
||||
$(".clock.clock.separator").removeClass( "hide" );
|
||||
} else {
|
||||
$("#subMinutes").empty().addClass( "hide" );
|
||||
$(".clock.clock.separator").addClass( "hide" );
|
||||
}
|
||||
|
||||
$("#subSeconds").empty().append( imageSeconds );
|
||||
|
||||
if( nextMinutes >= 0 && nextSeconds >= 0 )
|
||||
setTimeout( "COUNTDOWN.start()", 1000 );
|
||||
else
|
||||
COUNTDOWN.callback();
|
||||
},
|
||||
|
||||
add: function(seconds) {
|
||||
console.log( "Adding " + seconds + " seconds to countdown" );
|
||||
COUNTDOWN.seconds = COUNTDOWN.seconds + seconds;
|
||||
},
|
||||
|
||||
setTime: function( seconds ) {
|
||||
console.log( "Setting " + seconds + " seconds to countdown" );
|
||||
COUNTDOWN.seconds = seconds;
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
COUNTDOWN.mustStop = true;
|
||||
},
|
||||
|
||||
callback: function() {
|
||||
console.log( "COUNTDOWN.callback" );
|
||||
}
|
||||
};
|
||||
78
demo/sis/js/lettering.js
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
function injector(t, splitter, forceSmallParam) {
|
||||
var a = t.text().split(splitter);
|
||||
var html = "",
|
||||
clazz = "clock",
|
||||
letterSize = 32,
|
||||
count = 0,
|
||||
width = 0,
|
||||
height = 0,
|
||||
lineSize,
|
||||
letter, iLetter,
|
||||
i, x, y
|
||||
forceSmall = false;//forceSmallParam ? forceSmallParam : false;
|
||||
if( typeof customClazz != "undefined" ) {
|
||||
clazz = " clock " + customClazz;
|
||||
}
|
||||
if (a.length) {
|
||||
$(a).each(
|
||||
function(i, letter) {
|
||||
iLetter = (letter.charCodeAt(0) - 97);
|
||||
if( letter === " " ) {
|
||||
html += "<span class='blank'></span>";
|
||||
width += 16;
|
||||
count = count + 1;
|
||||
} else {
|
||||
if( letter.charCodeAt(0) > 47 && letter.charCodeAt(0) < 58 ) { // Numbers
|
||||
letterSize = 32;
|
||||
if( forceSmall ) {
|
||||
letterSize = 16;
|
||||
}
|
||||
html += "<span class='" + clazz + (forceSmall ? "small" : "") + "' style='top: -50%;background-position: -" + ( parseInt( letter, null ) * letterSize) + "px -" + (forceSmall ? 128 : 0) +"px'></span>";
|
||||
count = count + 1;
|
||||
} else { // Letters
|
||||
if( ( letter.charCodeAt(0) >= 'a'.charCodeAt(0) && letter.charCodeAt(0) <= 'z'.charCodeAt(0)) ) {
|
||||
if( height < 16 ) {
|
||||
height = 16;
|
||||
}
|
||||
width += 16;
|
||||
lineSize = 20;
|
||||
x = (iLetter % lineSize) * 16;
|
||||
y = Math.floor(iLetter / lineSize) * 16 + 144;
|
||||
html += "<span class='" + clazz + " small' style='background-position: -" + x + "px -" + y + "px'></span>";
|
||||
count = count + 1;
|
||||
} else {
|
||||
if( letter.charCodeAt(0) >= 'A'.charCodeAt(0) && letter.charCodeAt(0) <= 'Z'.charCodeAt(0)) {
|
||||
iLetter = letter.charCodeAt(0) - 'A'.charCodeAt(0);
|
||||
if( height < 32 ) {
|
||||
height = 32;
|
||||
}
|
||||
width += 32;
|
||||
lineSize = 10;
|
||||
x = (iLetter % lineSize) * 32;
|
||||
y = Math.floor(iLetter / lineSize) * 32 + 32;
|
||||
html += "<span class='" + clazz + "' style='background-position: -" + x + "px -" + y + "px'></span>";
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
t.empty().append(html);
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.lettering = function() {
|
||||
return injector( $(this), '', 'char', '' ); // always pass an array
|
||||
};
|
||||
})(jQuery);
|
||||
91
demo/sis/js/models/aliens.js
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var ALIENS = {
|
||||
alien1 : {
|
||||
health : 1,
|
||||
weapon : WEAPONS.ALIEN,
|
||||
score : 5,
|
||||
aggression : 0.0005,
|
||||
animation : ALIENS_TYPE[0]
|
||||
},
|
||||
alien2 : {
|
||||
health : 2,
|
||||
weapon : WEAPONS.ALIEN,
|
||||
score : 10,
|
||||
aggression : 0.001,
|
||||
animation : ALIENS_TYPE[1]
|
||||
},
|
||||
alien3 : {
|
||||
health : 3,
|
||||
weapon : WEAPONS.ALIEN,
|
||||
score : 20,
|
||||
aggression : 0.0015,
|
||||
animation : ALIENS_TYPE[2]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** Actors - Aliens ***/
|
||||
function Alien(id, start, move, type) {
|
||||
"use strict";
|
||||
|
||||
this.id = id;
|
||||
this.x = start.x;
|
||||
this.y = start.y;
|
||||
this.moveFct = move;
|
||||
|
||||
this.weapon = new Weapon(type.weapon);
|
||||
this.fireDirectionY = 1;
|
||||
|
||||
this.originX = this.x;
|
||||
this.originY = this.y;
|
||||
this.directionX = -1;
|
||||
this.speed = 0.5;
|
||||
this.animation = type.animation;
|
||||
this.width = type.animation.width;
|
||||
this.height = type.animation.height;
|
||||
this.health = type.health;
|
||||
this.aggression = type.aggression;
|
||||
this.score = type.score;
|
||||
}
|
||||
|
||||
Alien.prototype = {
|
||||
moveFct : null,
|
||||
width : 0,
|
||||
height : 0,
|
||||
aggression : 0,
|
||||
animation : null,
|
||||
score : 0,
|
||||
|
||||
init : function() {
|
||||
"use strict";
|
||||
this.speed = 0;
|
||||
this.node.x(this.x);
|
||||
this.node.y(this.y);
|
||||
},
|
||||
|
||||
move : function() {
|
||||
"use strict";
|
||||
this._super("move", arguments);
|
||||
if (typeof this.moveFct !== undefined) {
|
||||
this.moveFct();
|
||||
}
|
||||
},
|
||||
|
||||
destroy : function() {
|
||||
this._super("destroy", arguments);
|
||||
Game.addToScore( this.score );
|
||||
}
|
||||
};
|
||||
|
||||
heriter(Alien.prototype, Actor.prototype);
|
||||
|
||||
/*** Actors - Aliens - END ***/
|
||||
234
demo/sis/js/models/models.js
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
function getAliensMidHeight() {
|
||||
var higherAlien = Math.max.apply( null,
|
||||
$(".alien").map(function() {
|
||||
return $(this).y();
|
||||
}).get() ),
|
||||
lowerAlien = Math.min.apply( null,
|
||||
$(".alien").map(function() {
|
||||
return $(this).y();
|
||||
}).get() );
|
||||
|
||||
return (higherAlien + lowerAlien) / 2;
|
||||
}
|
||||
|
||||
WORLD.farm.bonus = [
|
||||
{
|
||||
type: "weapon",
|
||||
clazz: WEAPONS.CAROT,
|
||||
animation: WORLD.farm.weapons.carot
|
||||
},
|
||||
{
|
||||
type: "weapon",
|
||||
clazz: WEAPONS.CORN,
|
||||
animation: WORLD.farm.weapons.corn
|
||||
}
|
||||
];
|
||||
|
||||
/*** Actors ***/
|
||||
function Actor() {
|
||||
"use strict";
|
||||
}
|
||||
Actor.prototype = {
|
||||
id : null,
|
||||
node : null,
|
||||
x : null,
|
||||
y : null,
|
||||
originX : 0,
|
||||
originY : 0,
|
||||
speed : 0,
|
||||
health : 1,
|
||||
directionX : 0,
|
||||
directionY : 0,
|
||||
fireDirectionX : 0,
|
||||
fireDirectionY : 0,
|
||||
weapon : null,
|
||||
animations : {},
|
||||
|
||||
getX : function() {
|
||||
"use strict";
|
||||
return this.x;
|
||||
},
|
||||
|
||||
getY : function() {
|
||||
"use strict";
|
||||
return this.y;
|
||||
},
|
||||
|
||||
move : function() {
|
||||
"use strict";
|
||||
if (!Game.running) {
|
||||
return;
|
||||
}
|
||||
this.x += this.directionX * this.speed;
|
||||
this.y += this.directionY * this.speed;
|
||||
this.x = Math.min(this.x, PLAYGROUND_WIDTH - this.node.w());
|
||||
this.x = Math.max(this.x, 0);
|
||||
this.node.x(this.x);
|
||||
this.node.y(this.y);
|
||||
},
|
||||
|
||||
getOriginX : function() {
|
||||
return this.originX;
|
||||
},
|
||||
|
||||
getOriginY : function() {
|
||||
return this.originY;
|
||||
},
|
||||
|
||||
up : function(active) {
|
||||
"use strict";
|
||||
this.directionY = active ? -1 : 0;
|
||||
},
|
||||
|
||||
down : function(active) {
|
||||
"use strict";
|
||||
this.directionY = active ? 1 : 0;
|
||||
},
|
||||
|
||||
left : function(active) {
|
||||
"use strict";
|
||||
this.directionX = active ? -1 : 0;
|
||||
},
|
||||
|
||||
right : function(active) {
|
||||
"use strict";
|
||||
this.directionX = active ? 1 : 0;
|
||||
},
|
||||
|
||||
fire : function(layout, clazz) {
|
||||
var name = "shot" + Math.ceil(Math.random() * 1000);
|
||||
if (this.weapon.fire(layout)) {
|
||||
layout.addSprite(name, $.extend({ posx : this.x + this.node.w() / 2, posy : this.y + this.fireDirectionY * this.node.h()}, this.weapon));
|
||||
$("#" + name).addClass(clazz).addClass(this.weapon.clazz);
|
||||
$("#" + name)[0].weapon = this.weapon;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
hit : function() {
|
||||
this.health = this.health - 1;
|
||||
if( this.health == 0 ) {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
return this.health;
|
||||
},
|
||||
|
||||
destroy : function() {
|
||||
$("#" + this.id).remove();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*** Actors - Heroes - END ***/
|
||||
function Ship(id, start, speed, animation) {
|
||||
"use strict";
|
||||
this.id = id;
|
||||
this.x = start.x;
|
||||
this.y = start.y;
|
||||
|
||||
this.weapon = new Weapon(WEAPONS.SHOTGUN);
|
||||
this.fireDirectionY = -1;
|
||||
|
||||
this.originX = this.x;
|
||||
this.originY = this.y;
|
||||
this.speed = speed;
|
||||
|
||||
this.animation = animation;
|
||||
|
||||
/*this.bigWheel = $("#bigWheel");
|
||||
this.smallWheel = $("#smallWheel");
|
||||
var bigWheelRadius = bigWheel.h() / 2,
|
||||
smallWheelRadius = smallWheel.h() / 2;
|
||||
this.bigWheelAngle = this.speed * 360 / ( 2 * Math.PI * bigWheelRadius );
|
||||
this.smallWheelAngle = this.speed * 360 / ( 2 * Math.PI * smallWheelRadius );*/
|
||||
|
||||
}
|
||||
|
||||
Ship.prototype = {
|
||||
speed : 0,
|
||||
directionX : 0,
|
||||
directionY : 0,
|
||||
lives : 3,
|
||||
animation : null,
|
||||
/*bigWheel : null,
|
||||
bigWheelAngle : 0,
|
||||
smallWheel : null,
|
||||
smallWheelAngle : 0,*/
|
||||
|
||||
init : function() {
|
||||
"use strict";
|
||||
this.speed = 0;
|
||||
this.node.x(this.x);
|
||||
this.node.y(this.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* Arc = (2* Pi * R) / (360) * alpha
|
||||
*
|
||||
*/
|
||||
move : function() {
|
||||
"use strict";
|
||||
this._super("move", arguments);
|
||||
},
|
||||
|
||||
up : function(active) {
|
||||
if (this.y < (PLAYGROUND_HEIGHT - 2 * HUD_HEIGHT)) {
|
||||
return false;
|
||||
}
|
||||
this._super("up", arguments);
|
||||
},
|
||||
|
||||
destroy : function() {
|
||||
var _this = this,
|
||||
_hero = $("#hero"),
|
||||
explosion = EXPLOSIONS.BIG;
|
||||
|
||||
$("#life" + this.lives).remove();
|
||||
this.lives = this.lives - 1;
|
||||
|
||||
$("#actors").addSprite("heroExplosion",
|
||||
{
|
||||
width: explosion[0].width,
|
||||
height: explosion[0].height,
|
||||
posx: _hero.x() - explosion[0].width / 2 + _hero.w(),
|
||||
posy: _hero.y() - explosion[0].height / 2 - _hero.h() /4
|
||||
}
|
||||
);
|
||||
explosionBig($("#heroExplosion"), function() {$("#heroExplosion").remove()});
|
||||
_hero.children().hide();
|
||||
},
|
||||
|
||||
respawn : function() {
|
||||
$("#heroExplosion").remove();
|
||||
$("#hero").children().show();
|
||||
},
|
||||
|
||||
fire : function() {
|
||||
if(this._super("fire", arguments)) {
|
||||
Game.shots.total = Game.shots.total + 1;
|
||||
this.weapon.stock--;
|
||||
if( this.weapon.stock == 0 ) {
|
||||
this.weapon = new Weapon(WEAPONS.SHOTGUN);
|
||||
$("#current_weapon").setAnimation(this.weapon.animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
heriter(Ship.prototype, Actor.prototype);
|
||||
/*** Actors - Heroes - END ***/
|
||||
|
||||
/*** Actors - END ***/
|
||||
183
demo/sis/js/models/waves.js
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*** Move ***/
|
||||
|
||||
var MOVE = {
|
||||
translation : {
|
||||
init : function (x, y) {
|
||||
return {directionX : 1, directionY : 0};
|
||||
},
|
||||
move : function() {
|
||||
var offset = (PLAYGROUND_WIDTH - 16 * this.width) / 2;
|
||||
if (Math.abs((this.getOriginX() - this.getX())) >= offset) {
|
||||
this.directionX *= -1;
|
||||
this.y = (this.y + this.height / 4);
|
||||
}
|
||||
},
|
||||
},
|
||||
mirror : {
|
||||
init : function(x, y) {
|
||||
if( x < PLAYGROUND_WIDTH / 2 ) {
|
||||
return {directionX: -1, directionY: 0};
|
||||
}
|
||||
return {directionX: 1, directionY: 0};
|
||||
},
|
||||
move : function() {
|
||||
var offset = this.width / 2;
|
||||
if (Math.abs((this.getOriginX() - this.getX())) >= offset) {
|
||||
this.directionX *= -1;
|
||||
this.y = (this.y + this.height / 4);
|
||||
}
|
||||
},
|
||||
},
|
||||
half_part_rotation : {
|
||||
init : function (x, y) {
|
||||
return {directionX:0, directionY:0};
|
||||
},
|
||||
move : function () {
|
||||
var _this = $(this)[0],
|
||||
mid = PLAYGROUND_WIDTH / 2,
|
||||
center = _this.center,
|
||||
width = _this.width;
|
||||
|
||||
if( this.directionX == 0 && this.directionY == 0 ) {
|
||||
center = {x: ( this.getOriginX() < mid ? PLAYGROUND_WIDTH / 4 : 3 * PLAYGROUND_WIDTH / 4), y: getAliensMidHeight() };
|
||||
width = distance(center, {x: this.x, y: this.y});
|
||||
var xAxis = {x: width, y: 0},
|
||||
current = {x: center.x - this.getOriginX(), y: center.y - this.getOriginY()},
|
||||
alpha = angle( xAxis, current );
|
||||
this.directionX = 0.01;
|
||||
this.directionY = alpha;
|
||||
$(this)[0].center = center;
|
||||
$(this)[0].width = width;
|
||||
}
|
||||
|
||||
if( this.getOriginX() < mid ) {
|
||||
this.directionY = this.directionY + this.directionX;
|
||||
} else {
|
||||
this.directionY = this.directionY - this.directionX;
|
||||
}
|
||||
if( Math.abs(this.directionY) > 2 * Math.PI ) {
|
||||
this.directionY = 0;
|
||||
}
|
||||
center.y = center.y + 0.1;
|
||||
_this.center = center;
|
||||
this.x = center.x + width * Math.cos(this.directionY);
|
||||
this.y = center.y + width * Math.sin(this.directionY);
|
||||
}
|
||||
},
|
||||
|
||||
rotation : {
|
||||
init : function (x, y) {
|
||||
return {directionX:0, directionY:0};
|
||||
},
|
||||
move : function () {
|
||||
var _this = $(this)[0],
|
||||
mid = PLAYGROUND_WIDTH / 2,
|
||||
center = _this.center,
|
||||
width = _this.width;
|
||||
|
||||
if( this.directionX == 0 && this.directionY == 0 ) {
|
||||
center = {x: mid, y: getAliensMidHeight() };
|
||||
width = distance(center, {x: this.x, y: this.y});
|
||||
var xAxis = {x: width, y: 0},
|
||||
current = {x: center.x - this.getOriginX(), y: center.y - this.getOriginY()},
|
||||
alpha = angle( xAxis, current );
|
||||
this.directionX = 0.01;
|
||||
this.directionY = alpha;
|
||||
$(this)[0].center = center;
|
||||
$(this)[0].width = width;
|
||||
}
|
||||
|
||||
this.directionY = this.directionY - this.directionX;
|
||||
if( Math.abs(this.directionY) > 2 * Math.PI ) {
|
||||
this.directionY = 0;
|
||||
}
|
||||
center.y = center.y + 0.1;
|
||||
_this.center = center;
|
||||
this.x = center.x + width * Math.cos(this.directionY);
|
||||
this.y = center.y + width * Math.sin(this.directionY);
|
||||
}
|
||||
},
|
||||
|
||||
sinusoid : {
|
||||
init : function (x, y) {
|
||||
return {directionX : 1, directionY : 1};
|
||||
},
|
||||
move : function () {
|
||||
var offset = this.width / 2;
|
||||
if (Math.abs((this.getOriginX() - this.getX())) >= offset) {
|
||||
this.directionX *= -1;
|
||||
}
|
||||
|
||||
if( Math.abs(this.getOriginY() - this.getY()) >= 3 * this.height ) {
|
||||
this.directionY *= -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*** Move - end ***/
|
||||
|
||||
|
||||
/*** Waves ***/
|
||||
|
||||
var WAVES = [
|
||||
{
|
||||
wave : [
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ]
|
||||
],
|
||||
move : MOVE.translation,
|
||||
bonus : [40, 20]
|
||||
},
|
||||
{
|
||||
wave : [ [ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ]
|
||||
],
|
||||
move : MOVE.mirror,
|
||||
bonus : [30, 15]
|
||||
},
|
||||
{
|
||||
wave : [ [ undefined, undefined, ALIENS.alien1, undefined, undefined, undefined, undefined, undefined, ALIENS.alien1, undefined, undefined ],
|
||||
[ undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, undefined, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined ],
|
||||
[ undefined, undefined, ALIENS.alien1, undefined, undefined, undefined, undefined, undefined, ALIENS.alien1, undefined, undefined ]
|
||||
],
|
||||
move : MOVE.half_part_rotation,
|
||||
bonus : [20, 10]
|
||||
},
|
||||
{
|
||||
wave : [
|
||||
[ undefined, undefined, undefined, undefined, ALIENS.alien1, undefined, undefined, undefined, undefined ],
|
||||
[ undefined, undefined, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, undefined, undefined ],
|
||||
[ undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined ],
|
||||
[ undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined ],
|
||||
[ ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, undefined, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1 ],
|
||||
[ undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined ],
|
||||
[ undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined ],
|
||||
[ undefined, undefined, undefined, ALIENS.alien1, ALIENS.alien1, ALIENS.alien1, undefined, undefined, undefined ],
|
||||
[ undefined, undefined, undefined, undefined, ALIENS.alien1, undefined, undefined, undefined, undefined ]
|
||||
],
|
||||
move : MOVE.rotation,
|
||||
bonus : [25, 12]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
/*** Waves - end ***/
|
||||
140
demo/sis/js/models/weapons.js
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var WEAPONS = {
|
||||
SHOTGUN : {
|
||||
directionY : -1,
|
||||
rof : 200,
|
||||
ror : 1500,
|
||||
load : 2,
|
||||
max_load : 2,
|
||||
width : 3,
|
||||
height : 3,
|
||||
clazz : "Shotgun"
|
||||
},
|
||||
CAROT : {
|
||||
directionY : -1,
|
||||
stock : 10,
|
||||
clazz : "carot",
|
||||
load : 5,
|
||||
max_load : 5,
|
||||
width : 5,
|
||||
height : 10
|
||||
},
|
||||
CORN : {
|
||||
directionY : -1,
|
||||
stock : 3,
|
||||
clazz : "corn",
|
||||
load : 1,
|
||||
max_load : 1,
|
||||
callback : function(shot) {
|
||||
var mediumAlien = getAliensMidHeight();
|
||||
|
||||
if( shot.y() < mediumAlien ) {
|
||||
var x = shot.x(),
|
||||
y = shot.y(),
|
||||
explosion = EXPLOSIONS.SMALL[0];
|
||||
$("#shipShots").addSprite("cornExplosion", {width: explosion.width, height: explosion.height, posx: x - explosion.width / 2, posy: y - explosion.height / 2});
|
||||
explosionSmall($("#cornExplosion"), function() {$("#cornExplosion").remove()});
|
||||
shot.remove();
|
||||
|
||||
var shipShots = $("#shipShots");
|
||||
for( var i = 0; i < 8; i++) {
|
||||
var cos = Math.cos( (Math.PI / 4) * i ),
|
||||
sin = Math.sin( (Math.PI / 4) * i);
|
||||
if( Math.abs(cos) < 0.01 ) {
|
||||
cos = 0;
|
||||
}
|
||||
if( Math.abs(sin) < 0.01) {
|
||||
sin = 0;
|
||||
}
|
||||
shipShots.addSprite( "shotCorn" + i, { posx : x + 5 * cos, posy : y + 5 * sin, width: 2, height: 2});
|
||||
var shotCorn = $("#shotCorn" + i);
|
||||
shotCorn.addClass("shipShot").addClass("shotCorn");
|
||||
$("#shotCorn" + i)[0].weapon = $.extend({
|
||||
directionX : cos < 0 ? -1 : cos > 0 ? 1 : 0,
|
||||
directionY : sin < 0 ? -1 : sin > 0 ? 1 : 0,
|
||||
speed : 1
|
||||
}, shot.weapon);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ALIEN : {
|
||||
directionY : 1,
|
||||
width : 5,
|
||||
height : 10
|
||||
}
|
||||
}
|
||||
|
||||
function Weapon(type) {
|
||||
"use strict";
|
||||
this.directionY = type.directionY || 1;
|
||||
this.directionX = type.directionX || 0;
|
||||
this.width = type.width;
|
||||
this.height = type.height;
|
||||
this.speed = type.speed || 5;
|
||||
this.strenght = type.strength || 10;
|
||||
this.stock = type.stock || Infinity;
|
||||
this.rof = type.rof || 300;
|
||||
this.ror = type.ror || 1500;
|
||||
this.load = type.load || 1;
|
||||
this.max_load = type.max_load || 1;
|
||||
this.animation = type.animation;
|
||||
this.clazz = type.clazz || "default";
|
||||
this.callback = type.callback;
|
||||
|
||||
}
|
||||
|
||||
Weapon.prototype = {
|
||||
speed : 5,
|
||||
strength : 10,
|
||||
stock: Infinity,
|
||||
rof : 300,
|
||||
ror : 1500,
|
||||
load : 1,
|
||||
max_load : 1,
|
||||
width : 5,
|
||||
height : 5,
|
||||
shot_timer : false,
|
||||
reload_timer : false,
|
||||
directionX : 0,
|
||||
directionY : 1,
|
||||
animation : null,
|
||||
clazz : "default",
|
||||
callback : undefined,
|
||||
|
||||
fire : function() {
|
||||
if (this.shot_timer || this.load <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var _this = this;
|
||||
this.load = Math.max(0,this.load - 1);
|
||||
this.shot_timer = setInterval(function() {
|
||||
if (_this.load > 0) {
|
||||
clearTimeout(_this.shot_timer);
|
||||
_this.shot_timer = false;
|
||||
}
|
||||
}, this.rof);
|
||||
|
||||
if( !this.reload_timer) {
|
||||
this.reload_timer = setInterval( function() {
|
||||
_this.load = Math.min(_this.load + 1, Math.min(_this.max_load, _this.stock));
|
||||
if( _this.load == _this.max_load ) {
|
||||
clearInterval(_this.reload_timer);
|
||||
_this.reload_timer = false;
|
||||
}
|
||||
}, this.ror);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
54
demo/sis/js/scoreboard.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var SCOREBOARD = {
|
||||
score: 0,
|
||||
scoreLength: 6,
|
||||
|
||||
init: function(size) {
|
||||
if( typeof size !== "undefined" )
|
||||
SCOREBOARD.scoreLength = size;
|
||||
SCOREBOARD.score = 0;
|
||||
SCOREBOARD.set_score( 0 );
|
||||
},
|
||||
|
||||
add: function(addToScore, div) {
|
||||
SCOREBOARD.set_score( SCOREBOARD.score + addToScore, div);
|
||||
},
|
||||
|
||||
set_score: function( score, div ) {
|
||||
var currentScore = "";
|
||||
var imageScore = "";
|
||||
|
||||
SCOREBOARD.score = score;
|
||||
currentScore = SCOREBOARD.pad();
|
||||
|
||||
for(i = 0; i < String(currentScore).length; i++) {
|
||||
imageScore += "<div class='clock n"+ String(currentScore)[i]+"'></div>";
|
||||
}
|
||||
|
||||
if( typeof div === "undefined" )
|
||||
div = $(".subScoreboard");
|
||||
div.empty();
|
||||
div.append( imageScore );
|
||||
},
|
||||
|
||||
pad: function() {
|
||||
var str = '' + SCOREBOARD.score;
|
||||
while (str.length < SCOREBOARD.scoreLength) {
|
||||
str = '0' + str;
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
callback: function() {
|
||||
console.log( "SCOREBOARD.callback" );
|
||||
}
|
||||
};
|
||||
318
demo/sis/js/spaceinvaders-core.js
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
Game = {
|
||||
running : false,
|
||||
wave_index : -1,
|
||||
wave : undefined,
|
||||
aliens : [],
|
||||
ship : null,
|
||||
score : 0,
|
||||
shots : {
|
||||
total : 0,
|
||||
lost : 0
|
||||
},
|
||||
|
||||
init : function() {
|
||||
"use strict";
|
||||
animations = WORLD.farm;
|
||||
Game.wave_index = Game.wave_index + 1;
|
||||
Game.wave = WAVES[Math.min(Game.wave_index, WAVES.length - 1)];
|
||||
Game.wave.score = 0;
|
||||
|
||||
var row, col, wave = Game.wave.wave;
|
||||
|
||||
for (row = 0; row < wave.length; row = row + 1) {
|
||||
var alien_width_avg = 0,
|
||||
aliens_row = wave[row],
|
||||
offset = 0;
|
||||
|
||||
for (col = 0; col < aliens_row.length; col = col + 1) {
|
||||
var current_width = typeof aliens_row[col] !== "undefined" ? aliens_row[col].animation.width : ALIENS_TYPE[2].width;
|
||||
alien_width_avg = alien_width_avg + current_width;
|
||||
}
|
||||
|
||||
alien_width_avg = alien_width_avg / aliens_row.length;
|
||||
offset = (PLAYGROUND_WIDTH - (aliens_row.length * 1.5 - 0.5) * alien_width_avg) / 2;
|
||||
|
||||
for (col = 0; col < aliens_row.length; col = col + 1) {
|
||||
Game.setAlien(col, row, offset, alien_width_avg, aliens_row[col], Game.wave.move);
|
||||
}
|
||||
}
|
||||
|
||||
SCOREBOARD.init();
|
||||
SCOREBOARD.set_score( Game.score );
|
||||
|
||||
updateLevel(Game.wave_index + 1);
|
||||
|
||||
Game.setShip();
|
||||
|
||||
hideModal();
|
||||
Game.running = true;
|
||||
},
|
||||
|
||||
game_over : function() {
|
||||
displayModal( {
|
||||
end: "Loose",
|
||||
score: Game.score
|
||||
});
|
||||
},
|
||||
|
||||
levelComplete : function() {
|
||||
"use strict";
|
||||
Game.running = false;
|
||||
var bonus = Math.round(((Game.shots.total - Game.shots.lost) / Game.shots.total) * Game.wave.score),
|
||||
wave_score = Game.wave.score;
|
||||
Game.addToScore(bonus);
|
||||
|
||||
displayModal( {
|
||||
bonus: bonus,
|
||||
wave_score: wave_score,
|
||||
score: Game.score,
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
Game.init();
|
||||
}, 5000);
|
||||
},
|
||||
|
||||
hit : function() {
|
||||
"use strict";
|
||||
if( !Game.running ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var health = Game.ship.hit();
|
||||
$(".alienShot").remove();
|
||||
$(".shipShot").remove();
|
||||
$("#life" + Game.ship.lives).remove();
|
||||
Game.running = false;
|
||||
$("#hero").children().hide();
|
||||
|
||||
if( Game.ship.lives > 0 ) {
|
||||
var _this = Game.ship;
|
||||
setTimeout(function() {
|
||||
Game.ship.respawn();
|
||||
Game.running = true;
|
||||
}, 5000);
|
||||
}
|
||||
else {
|
||||
Game.game_over();
|
||||
}
|
||||
},
|
||||
|
||||
setAlien : function(x, y, offset, width, type, move) {
|
||||
"use strict";
|
||||
if( typeof type === "undefined" ) {
|
||||
return;
|
||||
}
|
||||
var id = Game.aliens.length + 1,
|
||||
alien = new Alien("alien" + id, {
|
||||
x : offset + x * width * 1.5,
|
||||
y : START_Y + (y * 1.25 * type.animation.height)
|
||||
}, move.move, type),
|
||||
directions = move.init( alien.x, alien.y );
|
||||
alien.directionX = directions.directionX;
|
||||
alien.directionY = directions.directionY;
|
||||
$("#actors").addSprite("alien" + id, $.extend({posx : alien.x, posy : alien.y}, alien.animation));
|
||||
alien.node = $("#alien" + id);
|
||||
alien.node.addClass("alien");
|
||||
$("#alien" + id)[0].alien = alien;
|
||||
Game.aliens.push(alien);
|
||||
},
|
||||
|
||||
setShip : function() {
|
||||
Game.ship = new Ship("ship", {
|
||||
x : $("#hero").x(),
|
||||
y : $("#hero").y()
|
||||
}, 3, animations.hero.ship.animation);
|
||||
var hero = $("#hero");
|
||||
$.each(animations.hero,
|
||||
function(id, obj){
|
||||
hero.addSprite(id, obj);
|
||||
});
|
||||
Game.ship.node = $("#hero");
|
||||
},
|
||||
|
||||
addToScore : function( toAdd ) {
|
||||
Game.score = Game.score + toAdd;
|
||||
Game.wave.score = Game.wave.score + toAdd;
|
||||
SCOREBOARD.add( toAdd );
|
||||
},
|
||||
|
||||
control : function() {
|
||||
if( !Game.running ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).keyup(function(e){
|
||||
switch(e.keyCode) {
|
||||
case 37:
|
||||
e.preventDefault();
|
||||
Game.ship.left(false);
|
||||
break;
|
||||
case 39:
|
||||
e.preventDefault();
|
||||
Game.ship.right(false);
|
||||
break;
|
||||
}
|
||||
});
|
||||
$(document).keydown(function(e){
|
||||
switch(e.keyCode) {
|
||||
case 37:
|
||||
e.preventDefault();
|
||||
Game.ship.left(true);
|
||||
break;
|
||||
case 39:
|
||||
e.preventDefault();
|
||||
Game.ship.right(true);
|
||||
break;
|
||||
case 32:
|
||||
e.preventDefault();
|
||||
Game.ship.fire($("#shipShots"), "shipShot");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
alienControl : function() {
|
||||
if( !Game.running ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$.each(Game.aliens, function(index, alien ) {
|
||||
alien.move();
|
||||
var node = alien.node;
|
||||
if( (node.y() + node.h()) > $("#hero").y() ) {
|
||||
Game.running = false;
|
||||
Game.game_over();
|
||||
return false;
|
||||
}
|
||||
if( alien.health > 0 && Math.random() < (alien.aggression * (Game.wave_index + 1)) ) {
|
||||
alien.fire($("#aliensShots"), "alienShot");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
heroShotCollision : function() {
|
||||
if( !Game.running ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var shots = $(".shipShot");
|
||||
if( shots.length == 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
shots.each(function(i,e) {
|
||||
var posy = $(this).y(),
|
||||
posx = $(this).x(),
|
||||
weapon = $(this)[0].weapon;
|
||||
|
||||
// Lost shots
|
||||
if( posy < -$(this).height() || posy > PLAYGROUND_HEIGHT || posx < -$(this).width() || posx > PLAYGROUND_WIDTH ) {
|
||||
Game.shots.lost = Game.shots.lost + 1;
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
$(this).y(weapon.directionY * weapon.speed, true);
|
||||
$(this).x(weapon.directionX * weapon.speed, true);
|
||||
|
||||
if( weapon.callback ) {
|
||||
weapon.callback($(this));
|
||||
} else {
|
||||
// Shots collisions
|
||||
var collisions = $(this).collision(".alien,."+$.gQ.groupCssClass);
|
||||
collisions.each( function() {
|
||||
var alien = $(this)[0],
|
||||
alienX = alien.alien.x,
|
||||
alienY = alien.alien.y,
|
||||
alienWidth = alien.alien.width,
|
||||
alienHeight = alien.alien.height;
|
||||
|
||||
alien.alien.hit();
|
||||
Game.aliens = $.grep( Game.aliens, function( elementOfArray, index) {
|
||||
return elementOfArray.health == 0 && elementOfArray.id == alien.id;
|
||||
}, true);
|
||||
var remainingAliens = $(".alien").length;
|
||||
if( remainingAliens == Game.wave.bonus[0] || remainingAliens == Game.wave.bonus[1] ) {
|
||||
Game.bonus(alienX, alienY, alienWidth, alienHeight);
|
||||
}
|
||||
});
|
||||
if( collisions.length > 0 ) {
|
||||
this.remove()
|
||||
}
|
||||
|
||||
if( Game.aliens.length == 0 ) {
|
||||
Game.running = false;
|
||||
Game.levelComplete();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
bonusCollision : function() {
|
||||
if( !Game.running ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$(".bonus").each(function(i,e) {
|
||||
var collisions = $(this).collision("#ship,."+$.gQ.groupCssClass);
|
||||
var bonus = $(this)[0].bonus;
|
||||
if( collisions.length > 0 ) {
|
||||
if( bonus.type === "weapon" ) {
|
||||
Game.ship.weapon = new Weapon(bonus.clazz);
|
||||
$("#current_weapon").setAnimation(bonus.animation.animation);
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
bonus : function(alienX, alienY, alienWidth, alienHeight) {
|
||||
var bonus = animations.bonus[Math.round(Math.random() * (animations.bonus.length - 1)) ];
|
||||
var id = Math.round(Math.random() * 10000);
|
||||
$("#actors").addSprite("bonus" + id,
|
||||
$.extend(
|
||||
{
|
||||
posx: alienX + (alienWidth - bonus.animation.width) / 2,
|
||||
posy: alienY
|
||||
}, bonus.animation));
|
||||
$("#bonus" + id).addClass("bonus");
|
||||
$("#bonus" + id)[0].bonus = bonus;
|
||||
},
|
||||
|
||||
alienShotCollision : function() {
|
||||
if( !Game.running ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$(".alienShot").each(function(i,e) {
|
||||
var posy = $(this).y();
|
||||
if( posy > PLAYGROUND_HEIGHT ) {
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
var weapon = $(this)[0].weapon;
|
||||
$(this).y(weapon.directionY * weapon.speed, true);
|
||||
$(this).x(weapon.directionX * weapon.speed, true);
|
||||
// var collisions = $(this).collision("#ship,."+$.gQ.groupCssClass);
|
||||
try {
|
||||
var collisions = $(this).collision("#actors,#hero,#ship");
|
||||
if( collisions.length > 0 ) {
|
||||
Game.hit();
|
||||
this.remove();
|
||||
}
|
||||
}catch(e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
226
demo/sis/js/spaceinvaders-ui.js
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*global jQuery */
|
||||
|
||||
var PLAYGROUND_WIDTH = 448,
|
||||
PLAYGROUND_HEIGHT = 544,
|
||||
MODAL_WIDTH = 300,
|
||||
REFRESH_RATE = 15,
|
||||
HUD_HEIGHT = 70,
|
||||
|
||||
ROWS = 5,
|
||||
ALIENS = 11,
|
||||
|
||||
ALIENS_WIDTH = 24,
|
||||
ALIENS_HEIGHT = 17,
|
||||
|
||||
START_Y = 40;
|
||||
|
||||
var animations = WORLD.farm;
|
||||
|
||||
|
||||
function explose( div, explosion, step, callback ) {
|
||||
if( step < explosion.length - 2 ) {
|
||||
div.setAnimation( explosion[step].animation, function() {
|
||||
explose( div, explosion, step + 1, callback );
|
||||
});
|
||||
} else {
|
||||
div.setAnimation( explosion[step].animation, callback);
|
||||
}
|
||||
};
|
||||
|
||||
function explosionBig( div, callback ) {
|
||||
explose(div, EXPLOSIONS.BIG, 0, callback );
|
||||
};
|
||||
|
||||
function explosionSmall( div, callback ) {
|
||||
explose(div, EXPLOSIONS.SMALL, 0, callback );
|
||||
};
|
||||
|
||||
function displayModal(data) {
|
||||
var score = data.score.toString();
|
||||
$.playground()
|
||||
.addGroup( "modal_pane", {width: MODAL_WIDTH, height: data.end ? 190 : 140, posx: (PLAYGROUND_WIDTH - MODAL_WIDTH ) /2, posy: (PLAYGROUND_HEIGHT - (140 ))/2})
|
||||
.addSprite("scoreLbl", {width: 180, height: 32, posx: 10, posy: data.end ? 50 : 10})
|
||||
.addSprite("scoreNbr", {width: score.length * 32, height: 32, posx: (MODAL_WIDTH - 10 - score.length * 32), posy: data.end ? 50 : 10})
|
||||
.end();
|
||||
if( data.end ) {
|
||||
var width = (data.end.length - 1 ) * 16 + 32;
|
||||
$("#modal_pane").addSprite("gameSt", {width: width, height: 32, posx: (MODAL_WIDTH - width) / 2, posy: 10});
|
||||
$("#gameSt").append(data.end).lettering();
|
||||
}
|
||||
|
||||
if( data.bonus ) {
|
||||
var bonus = data.bonus.toString(),
|
||||
total = data.wave_score.toString();
|
||||
$("#modal_pane")
|
||||
.addSprite("totalLbl", {width: 180, height: 32, posx: 10, posy: data.end ? 130 : 90})
|
||||
.addSprite("totalNbr", {width: total.length * 32, height: 32, posx: (MODAL_WIDTH - 10 - total.length * 32), posy: data.end ? 130 : 90})
|
||||
.addSprite("bonusLbl", {width: 180, height: 32, posx: 10, posy: data.end ? 90 : 50})
|
||||
.addSprite("bonusNbr", {width: bonus.length * 32, height: 32, posx: (MODAL_WIDTH - 10 - bonus.length * 32), posy: data.end ? 90 : 50})
|
||||
;
|
||||
$("#totalLbl").append("Wave").lettering();
|
||||
$("#totalNbr").append(total).lettering();
|
||||
$("#bonusLbl").append("Bonus").lettering();
|
||||
$("#bonusNbr").append(bonus).lettering();
|
||||
}
|
||||
|
||||
$("#modal_pane").addClass( "modal" );
|
||||
$("#scoreLbl").append("Score").lettering();
|
||||
$("#scoreNbr").append(score).lettering();
|
||||
}
|
||||
|
||||
function hideModal() {
|
||||
$("#modal_pane").remove();
|
||||
}
|
||||
|
||||
function updateWeaponLoad( load ) {
|
||||
"use strict";
|
||||
var HTMLDiv = $("#weapon_load");
|
||||
HTMLDiv.removeClass().addClass("weapon_level");
|
||||
if( load > 2/3) {
|
||||
HTMLDiv.addClass("good");
|
||||
} else {
|
||||
if( load > 1/3) {
|
||||
HTMLDiv.addClass("middle");
|
||||
} else {
|
||||
HTMLDiv.addClass("bad");
|
||||
}
|
||||
}
|
||||
HTMLDiv.width( (load * 100) + "%" );
|
||||
}
|
||||
|
||||
function updateLevel(level) {
|
||||
var strLevel = level.toString();
|
||||
var div = $("#level");
|
||||
div.w(strLevel.length * 32);
|
||||
div.x( PLAYGROUND_WIDTH / 2 - 10 - strLevel.length * 32);
|
||||
div.empty().append(strLevel).lettering();
|
||||
}
|
||||
|
||||
$(function(){
|
||||
"use strict";
|
||||
|
||||
//Playground Sprites
|
||||
$("#playground").playground({height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH, keyTracker: true});
|
||||
|
||||
$.playground({refreshRate: 60})
|
||||
.addGroup("background", {posx: 0, posy: HUD_HEIGHT, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
||||
.addSprite( "background1", {animation: animations.backgrounds.farm.background1.animation, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
||||
.addSprite( "background2", {animation: animations.backgrounds.farm.background2.animation, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
||||
.addSprite("ground", {posx: 0, posy : PLAYGROUND_HEIGHT - HUD_HEIGHT - 20, width: PLAYGROUND_WIDTH, height: 20})
|
||||
.end()
|
||||
.addGroup("actors", {posx: 0, posy: HUD_HEIGHT, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
||||
.addGroup("hero", {
|
||||
width: 48,
|
||||
height: 60,
|
||||
posx: (PLAYGROUND_WIDTH - 48) / 2,
|
||||
posy: PLAYGROUND_HEIGHT - HUD_HEIGHT - 50
|
||||
})
|
||||
.end()
|
||||
/* .addSprite("alienA", $.extend({posx : 50, posy : 300}, ALIENS[0]))
|
||||
.addSprite("alienB", $.extend({posx : 50, posy : 400}, ALIENS[1]))
|
||||
.addSprite("alienC", $.extend({posx : 50, posy : 500}, ALIENS[2]))
|
||||
*/ .addSprite("explosion", {
|
||||
width: 64,
|
||||
height: 64,
|
||||
posx: 100,
|
||||
posy: 100
|
||||
})
|
||||
.end()
|
||||
.addGroup( "shipShots", {posx: 0, posy: HUD_HEIGHT, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
||||
.end()
|
||||
.addGroup( "aliensShots", {posx: 0, posy: HUD_HEIGHT, width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT - HUD_HEIGHT})
|
||||
.end()
|
||||
.addGroup( "hud", {width: PLAYGROUND_WIDTH, height: HUD_HEIGHT, posx: 0, posy: 0})
|
||||
.addSprite( "current_weapon", $.extend({posx: 10, posy: 40}, animations.weapons.gun))
|
||||
.addGroup("weapon_bar", {
|
||||
posx : 50,
|
||||
posy : 40,
|
||||
width : 100,
|
||||
height : 10
|
||||
})
|
||||
.addSprite("weapon_load", {
|
||||
width : 100,
|
||||
height : 10
|
||||
})
|
||||
.end()
|
||||
.addGroup("scoreboard", {
|
||||
posx: 10,
|
||||
posy: 2,
|
||||
width: 6 * 32,
|
||||
height: 32
|
||||
})
|
||||
.addSprite( "subScoreboard", {
|
||||
width: 6 * 32,
|
||||
height: 32
|
||||
})
|
||||
.end()
|
||||
.addGroup("lives", {
|
||||
posx: PLAYGROUND_WIDTH - 100,
|
||||
posy: 32,
|
||||
width: 100,
|
||||
height: 32
|
||||
})
|
||||
.addSprite("life2", animations.life)
|
||||
.addSprite("life1", $.extend({posx: 32}, animations.life))
|
||||
.addSprite("life0", $.extend({posx: 64}, animations.life))
|
||||
.end()
|
||||
.addGroup("levelGrp", {
|
||||
posx: PLAYGROUND_WIDTH / 2,
|
||||
posy: 2,
|
||||
width: PLAYGROUND_WIDTH / 2,
|
||||
height: 16
|
||||
})
|
||||
.addSprite("levelLbl", {
|
||||
width: 32 + 5 * 16,
|
||||
posx: 10
|
||||
})
|
||||
.addSprite("level", {
|
||||
width : 64,
|
||||
posx: 32 + 7 * 16,
|
||||
height: 32
|
||||
})
|
||||
.end()
|
||||
.end()
|
||||
;
|
||||
|
||||
$("#ground").css("background-color", "brown");
|
||||
$("#levelLbl").append("Level").lettering();
|
||||
$("#level").append("0").lettering();
|
||||
$("#scoreboard").addClass("scoreboard");
|
||||
$("#subScoreboard").addClass("subScoreboard");
|
||||
var hud = $("#hud");
|
||||
|
||||
// Controls
|
||||
$.playground().registerCallback(Game.control, REFRESH_RATE);
|
||||
$.playground().registerCallback(Game.alienControl, REFRESH_RATE);
|
||||
|
||||
// Collisions management
|
||||
$.playground().registerCallback(Game.bonusCollision, REFRESH_RATE);
|
||||
$.playground().registerCallback(Game.heroShotCollision, REFRESH_RATE);
|
||||
$.playground().registerCallback(Game.alienShotCollision, REFRESH_RATE);
|
||||
|
||||
// Refresh playground
|
||||
$.playground().registerCallback(function(){
|
||||
updateWeaponLoad(Game.ship.weapon.load / Game.ship.weapon.max_load);
|
||||
if( Game.running ) {
|
||||
Game.ship.move();
|
||||
$(".bonus").each( function(index, bonus) {
|
||||
var posy = $(this).y();
|
||||
if( posy < Game.ship.y + 10 ) {
|
||||
$(this).y(3, true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, REFRESH_RATE);
|
||||
});
|
||||
83
demo/sis/js/tools.js
Normal file
@@ -0,0 +1,83 @@
|
||||
function heriter(destination, source) {
|
||||
function initClassIfNecessary(obj) {
|
||||
if( typeof obj["_super"] == "undefined" ) {
|
||||
obj["_super"] = function() {
|
||||
var methodName = arguments[0];
|
||||
var parameters = arguments[1];
|
||||
return this["__parent_methods"][methodName].apply(this, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
if( typeof obj["__parent_methods"] == "undefined" ) {
|
||||
obj["__parent_methods"] = {};
|
||||
}
|
||||
}
|
||||
|
||||
for (var element in source) {
|
||||
if( typeof destination[element] != "undefined" ) {
|
||||
initClassIfNecessary(destination);
|
||||
destination["__parent_methods"][element] = source[element];
|
||||
} else {
|
||||
destination[element] = source[element];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function distance(point1, point2) {
|
||||
return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
|
||||
}
|
||||
|
||||
function normalize(vector) {
|
||||
var norm = Math.sqrt(vector.x * vector.x + vector.y * vector.y);
|
||||
if (norm == 0)
|
||||
return {
|
||||
x : 0,
|
||||
y : 0
|
||||
};
|
||||
|
||||
var x = vector.x / norm;
|
||||
var y = vector.y / norm;
|
||||
return {
|
||||
x : x,
|
||||
y : y
|
||||
}
|
||||
}
|
||||
|
||||
function angle(vector1, vector2) {
|
||||
if ((vector1.x == 0 && vector1.y == 0)
|
||||
&& (vector1.x == 0 && vector1.y == 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vector1.x == 0 && vector1.y == 0) {
|
||||
return Math.acos(vector2.x
|
||||
/ Math.sqrt(vector2.x * vector2.x + vector2.y * vector2.y));
|
||||
}
|
||||
|
||||
if (vector2.x == 0 && vector2.y == 0) {
|
||||
return Math.acos(vector1.x
|
||||
/ Math.sqrt(vector1.x * vector1.x + vector1.y * vector1.y));
|
||||
}
|
||||
|
||||
var product = vector1.x * vector2.x + vector1.y * vector2.y,
|
||||
alpha = Math.acos(product
|
||||
/ (Math.sqrt(vector1.x * vector1.x + vector1.y * vector1.y) * Math
|
||||
.sqrt(vector2.x * vector2.x + vector2.y * vector2.y))),
|
||||
sign = normalize(vector1).y > normalize(vector2).y ? -1 : 1;
|
||||
|
||||
return sign * alpha;
|
||||
}
|
||||
|
||||
|
||||
function getAliensMidHeight() {
|
||||
var higherAlien = Math.max.apply( null,
|
||||
$(".alien").map(function() {
|
||||
return $(this).y();
|
||||
}).get() ),
|
||||
lowerAlien = Math.min.apply( null,
|
||||
$(".alien").map(function() {
|
||||
return $(this).y();
|
||||
}).get() );
|
||||
|
||||
return (higherAlien + lowerAlien) / 2;
|
||||
}
|
||||
1849
demo/sis/lib/gamequery-0.7.1.js
Normal file
4
demo/sis/lib/jquery-1.7.1.min.js
vendored
Normal file
125
demo/sis/lib/jquery-ui-1.8.23.custom.min.js
vendored
Normal file
7
demo/yahtzee/LICENSE.md
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
31
demo/yahtzee/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
The classical dice game Yahtzee
|
||||
|
||||
|
||||
How to :
|
||||
--------
|
||||
|
||||
The goal is to complete the two combinaisons grids with five dice
|
||||
|
||||
Each player can launch three times the dice to have a combinaison. After each launch, the player chooses to keep or not some dice. Each combinaison has a score.
|
||||
|
||||
When both grids are completed, their scores are added and the player with the higher score wins. If the upper grid has a score higher than 63 points, the player wins a bonus of 35 points.
|
||||
|
||||
A live demo is avalaible [here](http://www.viadeo-playground.com/yahtzee/index)
|
||||
|
||||
Credits :
|
||||
---------
|
||||
|
||||
* Graphics : Fabrice Ecaille aka Febbweiss
|
||||
* Code : Fabrice Ecaille aka Febbweiss
|
||||
|
||||
Licences :
|
||||
----------
|
||||
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
65
demo/yahtzee/css/yahtzee.css
Normal file
@@ -0,0 +1,65 @@
|
||||
.possibility {
|
||||
}
|
||||
|
||||
.dice {
|
||||
float: left;
|
||||
margin: 4px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background-image: url('../images/dices.png');
|
||||
}
|
||||
|
||||
.dice.face6 {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.dice.face5 {
|
||||
background-position: -50px 0;
|
||||
}
|
||||
|
||||
.dice.face4 {
|
||||
background-position: -100px 0;
|
||||
}
|
||||
|
||||
.dice.face3 {
|
||||
background-position: -149px 0;
|
||||
}
|
||||
|
||||
.dice.face2 {
|
||||
background-position: -199px 0;
|
||||
}
|
||||
|
||||
.dice.face1 {
|
||||
background-position: -249px 0;
|
||||
}
|
||||
|
||||
.dice.empty {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.dice.selected {
|
||||
background-image: url('../images/red_dices.png');
|
||||
}
|
||||
|
||||
.keep {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.trash {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.score {
|
||||
font-family: "Zeyada", verdana, arial, helvetica, cursive;
|
||||
color: blue;
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
.score.trashed {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.progress {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
BIN
demo/yahtzee/images/dices.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
demo/yahtzee/images/red_dices.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
394
demo/yahtzee/index.html
Normal file
@@ -0,0 +1,394 @@
|
||||
<!--
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Yahtzee</title>
|
||||
<!--[if IE]>
|
||||
<style type="text/css" media="screen">
|
||||
body {
|
||||
behavior: url("/css/hack/csshover3.htc");
|
||||
}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<link href='http://fonts.googleapis.com/css?family=Zeyada' rel='stylesheet' type='text/css'>
|
||||
<script src="lib/jquery-1.7.1.min.js" type="text/javascript" ></script>
|
||||
<link href="css/yahtzee.css" type="text/css" rel="stylesheet" media="screen, projection" />
|
||||
<link href="../../extra/css/extra.css" type="text/css" rel="stylesheet" media="screen, projection" />
|
||||
<script src="../../extra/js/yahtzee.js" type="text/javascript" ></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="width: 50%;float: left;">
|
||||
<div class="dice empty" id="dice1"></div>
|
||||
<div class="dice empty" id="dice2"></div>
|
||||
<div class="dice empty" id="dice3"></div>
|
||||
<div class="dice empty" id="dice4"></div>
|
||||
<div class="dice empty" id="dice5"></div>
|
||||
<div class="dice empty" id="dice6"></div>
|
||||
<div class="clear"></div>
|
||||
<div>
|
||||
<span>Launch</span>
|
||||
<span id="launch"></span>
|
||||
</div>
|
||||
<a href="javascript:void(0)" id="launchBtn">Launch</a>
|
||||
<div style="margin-top: 25px;">
|
||||
<dl>
|
||||
<dt>Three of a kind</dt>
|
||||
<dd>Three dice showing the same face</dd>
|
||||
<dd>Sum of all dice</dd>
|
||||
<dt>Four of a kind</dt>
|
||||
<dd>Four dice showing the same face</dd>
|
||||
<dd>Sum of all dice</dd>
|
||||
<dt>Full</dt>
|
||||
<dd>A three-of-a-kind and a pair</dd>
|
||||
<dd>25 points</dd>
|
||||
<dt>Small straight</dt>
|
||||
<dd>Four sequential dice</dd>
|
||||
<dd>30 points</dd>
|
||||
<dt>Large straight</dt>
|
||||
<dd>Five sequential dice</dd>
|
||||
<dd>40 points</dd>
|
||||
<dt>Yahtzee</dt>
|
||||
<dd>Five dice showing the same face</dd>
|
||||
<dd>50 points</dd>
|
||||
<dt>Chance</dt>
|
||||
<dd>Sum of all dice</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div id="scorePanel" style="display: none;">
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<td>Upper grid score</td>
|
||||
<td id="upperScore" style="text-align: center"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bonus</td>
|
||||
<td id="bonus" style="text-align: center"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lower grid score</td>
|
||||
<td id="lowerScore" style="text-align: center"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Total</b></td>
|
||||
<td id="totalScore" style="text-align: center"><b></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 50%;float: left;">
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center;">Combinaison</th>
|
||||
<th style="text-align: center;" width="84px">
|
||||
Score
|
||||
</th>
|
||||
<th style="text-align: center;" width="100px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="oneLabel">
|
||||
One
|
||||
</span>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="oneScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="oneKeep" data-id="one" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="oneTrash" data-id="one" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="twoLabel">
|
||||
Two
|
||||
</span>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="twoScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="twoKeep" data-id="two" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="twoTrash" data-id="two" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="threeLabel">
|
||||
Three
|
||||
</span>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="threeScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="threeKeep" data-id="three" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="threeTrash" data-id="three" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="fourLabel">
|
||||
Four
|
||||
</span>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="fourScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="fourKeep" data-id="four" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="fourTrash" data-id="four" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="fiveLabel">
|
||||
Five
|
||||
</span>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="fiveScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="fiveKeep" data-id="five" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="fiveTrash" data-id="five" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="sixLabel">
|
||||
Six
|
||||
</span>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="sixScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="sixKeep" data-id="six" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="sixTrash" data-id="six" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center;">Combinaison</th>
|
||||
<th style="text-align: center;">Probability</th>
|
||||
<th style="text-align: center;" width="84px">
|
||||
Score
|
||||
</th>
|
||||
<th style="text-align: center;" width="100px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="threeOfAKindLabel">
|
||||
Three of a kind
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="bar" id="threeOfAKindBar"></div>
|
||||
<span id="threeOfAKindProbability" style="padding-left: 1px;"> </span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="threeOfAKindScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="threeOfAKindKeep" data-id="threeOfAKind" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="threeOfAKindTrash" data-id="threeOfAKind" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="fourOfAKindLabel">
|
||||
Four of a kind
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="bar" id="fourOfAKindBar"></div>
|
||||
<span id="fourOfAKindProbability" style="padding-left: 1px;"> </span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="fourOfAKindScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="fourOfAKindKeep" data-id="fourOfAKind" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="fourOfAKindTrash" data-id="fourOfAKind" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="fullLabel">
|
||||
Full
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="bar" id="fullBar"></div>
|
||||
<span id="fullProbability" style="padding-left: 1px;"> </span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="fullScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="fullKeep" data-id="full" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="fullTrash" data-id="full" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="smallStraightLabel">
|
||||
Small straight
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="bar" id="smallStraightBar"></div>
|
||||
<span id="smallStraightProbability" style="padding-left: 1px;"> </span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="smallStraightScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="smallStraightKeep" data-id="smallStraight" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="smallStraightTrash" data-id="smallStraight" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="largeStraightLabel">
|
||||
Large straight
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="bar" id="largeStraightBar"></div>
|
||||
<span id="largeStraightProbability" style="padding-left: 1px;"> </span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="largeStraightScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="largeStraightKeep" data-id="largeStraight" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="largeStraightTrash" data-id="largeStraight" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="yahtzeeLabel">
|
||||
Yahtzee
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="bar" id="yahtzeeBar"></div>
|
||||
<span id="yahtzeeProbability" style="padding-left: 1px;"> </span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="yahtzeeScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="yahtzeeKeep" data-id="yahtzee" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="yahtzeeTrash" data-id="yahtzee" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span id="luckLabel">
|
||||
Chance
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="bar" id="luckBar"></div>
|
||||
<span id="luckProbability" style="padding-left: 1px;"> </span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span id="luckScore" class="score"> </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"id="luckKeep" data-id="luck" class="keep">Keep</a>
|
||||
<a href="javascript:void(0)"id="luckTrash" data-id="luck" class="trash">Trash</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!-- End of span9 -->
|
||||
<div style="text-align: center;margin-top: 00px;">
|
||||
<button id="startBtn" class="push--skeuo">Start</button>
|
||||
</div>
|
||||
<script src="js/yahtzee.js" type="text/javascript" ></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$(".dice").click(function(evt) {
|
||||
if( $(this).hasClass("selected") )
|
||||
$(this).removeClass("selected");
|
||||
else
|
||||
$(this).addClass("selected");
|
||||
});
|
||||
|
||||
$(".keep").click(function(evt) {
|
||||
console.log("Keeping " + $(this).attr('data-id'));
|
||||
Yahtzee.keep($(this).attr('data-id'));
|
||||
});
|
||||
|
||||
$(".trash").click(function(evt) {
|
||||
console.log("Trashing " + $(this).attr('data-id'));
|
||||
Yahtzee.trash($(this).attr('data-id'));
|
||||
});
|
||||
|
||||
$("#launchBtn").click(function() {
|
||||
Yahtzee.shuffle();
|
||||
Yahtzee.findCombinaisons();
|
||||
if( Yahtzee.launch < 3 )
|
||||
Yahtzee.findPossibilities();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
310
demo/yahtzee/js/yahtzee.js
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
Copyright (c) 2013 Fabrice ECAILLE aka Febbweiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
var SMALL_STRAIGHT_MASK1 = (1 << 0) + (1 << 1) + (1 << 2) + (1 << 3);
|
||||
var SMALL_STRAIGHT_MASK2 = (1 << 1) + (1 << 2) + (1 << 3) + (1 << 4);
|
||||
var SMALL_STRAIGHT_MASK3 = (1 << 2) + (1 << 3) + (1 << 4) + (1 << 5);
|
||||
var LARGE_STRAIGHT_MASK1 = (1 << 0) + (1 << 1) + (1 << 2) + (1 << 3) + (1 << 4);
|
||||
var LARGE_STRAIGHT_MASK2 = (1 << 1) + (1 << 2) + (1 << 3) + (1 << 4) + (1 << 5);
|
||||
var INCOMPLETE_STRAIGHT_MASK1 = (1 << 0) + (1 << 1) + (1 << 2);
|
||||
var INCOMPLETE_STRAIGHT_MASK2 = (1 << 1) + (1 << 2) + (1 << 3);
|
||||
var INCOMPLETE_STRAIGHT_MASK3 = (1 << 2) + (1 << 3) + (1 << 4);
|
||||
var INCOMPLETE_STRAIGHT_MASK4 = (1 << 3) + (1 << 4) + (1 << 5);
|
||||
|
||||
Yahtzee = {
|
||||
|
||||
launch : 0,
|
||||
dices : [],
|
||||
combinaisons : [],
|
||||
pair : false,
|
||||
doublePair : false,
|
||||
three_of_a_kind : false,
|
||||
four_of_a_kind : false,
|
||||
full : false,
|
||||
yahtzee : false,
|
||||
small_straight : false,
|
||||
large_straight : false,
|
||||
straight : 0,
|
||||
|
||||
scoreUp : 0,
|
||||
scoreDown: 0,
|
||||
keptCombinaisons: [],
|
||||
|
||||
clear: function(all) {
|
||||
if( all )
|
||||
Yahtzee.launch = 0;
|
||||
|
||||
Yahtzee.pair = false;
|
||||
Yahtzee.doublePair = false;
|
||||
Yahtzee.three_of_a_kind = false;
|
||||
Yahtzee.four_of_a_kind = false;
|
||||
Yahtzee.full = false;
|
||||
Yahtzee.yahtzee = false;
|
||||
Yahtzee.small_straight = false;
|
||||
Yahtzee.large_straight = false;
|
||||
Yahtzee.straight = 0;
|
||||
|
||||
if( all )
|
||||
for( var i = 0; i < 5; i++ ) {
|
||||
Yahtzee.dices[i] = 0;
|
||||
$("#dice" + (i+1)).removeClass().addClass("dice").addClass("empty");
|
||||
}
|
||||
|
||||
for( var i = 0; i < 6; i++ ) {
|
||||
Yahtzee.combinaisons[i] = 0;
|
||||
}
|
||||
|
||||
$(".possibility").each(function(incr, elt) {
|
||||
$(elt).removeClass("possibility");
|
||||
$(elt).empty();
|
||||
});
|
||||
|
||||
$(".keep").each(function(incr, elt) {
|
||||
$(elt).attr('style', 'visibility:hidden;');
|
||||
})
|
||||
$(".trash").each(function(incr, elt) {
|
||||
$(elt).attr('style', 'visibility:hidden;');
|
||||
})
|
||||
},
|
||||
|
||||
shuffle: function() {
|
||||
if($("#launchBtn").hasClass("disabled") )
|
||||
return false;
|
||||
|
||||
if( Yahtzee.launch == 3 )
|
||||
Yahtzee.clear(true);
|
||||
else
|
||||
Yahtzee.clear(false);
|
||||
|
||||
Yahtzee.launch++;
|
||||
|
||||
for( var i = 0; i < 5; i++ ) {
|
||||
var html = $("#dice" + (i+1));
|
||||
if( !html.hasClass("selected") ) {
|
||||
var value = Math.round(5 * Math.random());
|
||||
Yahtzee.dices[i] = value;
|
||||
html.removeClass().addClass("dice").addClass("face" + (value + 1));
|
||||
}
|
||||
}
|
||||
|
||||
$("#launch").html(Yahtzee.launch);
|
||||
if( Yahtzee.launch == 3 )
|
||||
$("#launchBtn").addClass("disabled");
|
||||
},
|
||||
|
||||
findCombinaisons: function() {
|
||||
for( var i = 0; i < 5; i++) {
|
||||
Yahtzee.combinaisons[Yahtzee.dices[i]]++;
|
||||
Yahtzee.straight = Yahtzee.straight | (1 << Yahtzee.dices[i]);
|
||||
}
|
||||
|
||||
for( var i = 0; i < 6; i++ ) {
|
||||
var value = Yahtzee.combinaisons[i];
|
||||
switch( value ) {
|
||||
case 2:
|
||||
if( Yahtzee.pair )
|
||||
Yahtzee.doublePair = true;
|
||||
Yahtzee.pair = true;
|
||||
break;
|
||||
case 5:
|
||||
Yahtzee.yahtzee = true;
|
||||
case 4:
|
||||
Yahtzee.four_of_a_kind = true;
|
||||
case 3:
|
||||
Yahtzee.three_of_a_kind = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Yahtzee.full = Yahtzee.pair && Yahtzee.three_of_a_kind && !Yahtzee.doublePair;
|
||||
|
||||
if( (Yahtzee.straight & LARGE_STRAIGHT_MASK1) == LARGE_STRAIGHT_MASK1 ) {
|
||||
Yahtzee.large_straight = true;
|
||||
Yahtzee.small_straight = true;
|
||||
} else if( (Yahtzee.straight & LARGE_STRAIGHT_MASK2) == LARGE_STRAIGHT_MASK2 ) {
|
||||
Yahtzee.large_straight = true;
|
||||
Yahtzee.small_straight = true;
|
||||
} else if( (Yahtzee.straight & SMALL_STRAIGHT_MASK1) == SMALL_STRAIGHT_MASK1 ) {
|
||||
Yahtzee.small_straight = true;
|
||||
} else if( (Yahtzee.straight & SMALL_STRAIGHT_MASK2) == SMALL_STRAIGHT_MASK2 ) {
|
||||
Yahtzee.small_straight = true;
|
||||
} else if( (Yahtzee.straight & SMALL_STRAIGHT_MASK3) == SMALL_STRAIGHT_MASK3 ) {
|
||||
Yahtzee.small_straight = true;
|
||||
}
|
||||
|
||||
if( Yahtzee.three_of_a_kind && Yahtzee.keptCombinaisons.indexOf("threeOfAKind") == -1 )
|
||||
$("#threeOfAKindKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.four_of_a_kind && Yahtzee.keptCombinaisons.indexOf("fourOfAKind") == -1 )
|
||||
$("#fourOfAKindKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.full && Yahtzee.keptCombinaisons.indexOf("full") == -1 )
|
||||
$("#fullKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.yahtzee && Yahtzee.keptCombinaisons.indexOf("yahtzee") == -1 )
|
||||
$("#yahtzeeKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.small_straight && Yahtzee.keptCombinaisons.indexOf("smallStraight") == -1 )
|
||||
$("#smallStraightKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.large_straight && Yahtzee.keptCombinaisons.indexOf("largeStraight") == -1 )
|
||||
$("#largeStraightKeep").attr('style', 'visibility:visible;');
|
||||
|
||||
if( Yahtzee.combinaisons[0] > 0 && Yahtzee.keptCombinaisons.indexOf("one") == -1 )
|
||||
$("#oneKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.combinaisons[1] > 0 && Yahtzee.keptCombinaisons.indexOf("two") == -1 )
|
||||
$("#twoKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.combinaisons[2] > 0 && Yahtzee.keptCombinaisons.indexOf("three") == -1 )
|
||||
$("#threeKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.combinaisons[3] > 0 && Yahtzee.keptCombinaisons.indexOf("four") == -1 )
|
||||
$("#fourKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.combinaisons[4] > 0 && Yahtzee.keptCombinaisons.indexOf("five") == -1 )
|
||||
$("#fiveKeep").attr('style', 'visibility:visible;');
|
||||
if( Yahtzee.combinaisons[5] > 0 && Yahtzee.keptCombinaisons.indexOf("six") == -1 )
|
||||
$("#sixKeep").attr('style', 'visibility:visible;');
|
||||
|
||||
if( Yahtzee.keptCombinaisons.indexOf("luck") == -1 )
|
||||
$("#luckKeep").attr('style', 'visibility:visible;');
|
||||
|
||||
$(".trash").each(function(incr, elt){
|
||||
var html = $(elt)
|
||||
if( Yahtzee.keptCombinaisons.indexOf(html.attr('data-id')) == -1 )
|
||||
html.attr('style', 'visibility:visible;');
|
||||
});
|
||||
},
|
||||
|
||||
findPossibilities: function() {
|
||||
var possibilities = {
|
||||
"threeOfAKind" : 0,
|
||||
"fourOfAKind" : 0,
|
||||
"full" : 0,
|
||||
"yahtzee" : 0,
|
||||
"smallStraight" : 0,
|
||||
"largeStraight" : 0
|
||||
};
|
||||
|
||||
if( Yahtzee.three_of_a_kind && !Yahtzee.full) {
|
||||
possibilities["full"] = Math.max( possibilities["full"], 17 );
|
||||
possibilities["fourOfAKind"] = Math.max( possibilities["fourOfAKind"], 31);
|
||||
possibilities["yahtzee"] = Math.max( possibilities["yahtzee"], 3);
|
||||
}
|
||||
if( Yahtzee.pair ) {
|
||||
if( !Yahtzee.three_of_a_kind )
|
||||
possibilities["threeOfAKind"] = Math.max( possibilities["threeOfAKind"], 42);
|
||||
possibilities["fourOfAKind"] = Math.max( possibilities["fourOfAKind"], 7);
|
||||
if( !Yahtzee.full )
|
||||
possibilities["full"] = Math.max( possibilities["full"], 10);
|
||||
possibilities["yahtzee"] = Math.max( possibilities["yahtzee"], 7);
|
||||
}
|
||||
if( Yahtzee.four_of_a_kind ) {
|
||||
possibilities["yahtzee"] = Math.max( possibilities["yahtzee"], 17);
|
||||
}
|
||||
if( Yahtzee.doublePair ) {
|
||||
possibilities["full"] = Math.max( possibilities["full"], 33);
|
||||
}
|
||||
if( !Yahtzee.large_straight &&
|
||||
((Yahtzee.straight & SMALL_STRAIGHT_MASK1) == SMALL_STRAIGHT_MASK1 || (Yahtzee.straight & SMALL_STRAIGHT_MASK3) == SMALL_STRAIGHT_MASK3) ) {
|
||||
possibilities["largeStraight"] = Math.max( possibilities["largeStraight"], 17);
|
||||
} else if( !Yahtzee.large_straight && (Yahtzee.straight & SMALL_STRAIGHT_MASK2) == SMALL_STRAIGHT_MASK2 ) {
|
||||
possibilities["largeStraight"] = Math.max( possibilities["largeStraight"], 33);
|
||||
}
|
||||
|
||||
$.each(possibilities, function(key, value) {
|
||||
var html = $("#" + key + "Probability");
|
||||
html.empty().addClass("possibility");
|
||||
if( value > 0 && Yahtzee.keptCombinaisons.indexOf(key) == -1 ) {
|
||||
html.append(value + "%");
|
||||
} else
|
||||
html.append(" ");
|
||||
});
|
||||
},
|
||||
|
||||
keep: function(id) {
|
||||
var score = 0;
|
||||
switch(id) {
|
||||
case "one" :
|
||||
score = Yahtzee.combinaisons[0] * 1;
|
||||
Yahtzee.scoreUp += score;
|
||||
break;
|
||||
case "two" :
|
||||
score = Yahtzee.combinaisons[1] * 2;
|
||||
Yahtzee.scoreUp += score;
|
||||
break;
|
||||
case "three" :
|
||||
score = Yahtzee.combinaisons[2] * 3;
|
||||
Yahtzee.scoreUp += score;
|
||||
break;
|
||||
case "four" :
|
||||
score = Yahtzee.combinaisons[3] * 4;
|
||||
Yahtzee.scoreUp += score;
|
||||
break;
|
||||
case "five" :
|
||||
score = Yahtzee.combinaisons[4] * 5;
|
||||
Yahtzee.scoreUp += score;
|
||||
break;
|
||||
case "six" :
|
||||
score = Yahtzee.combinaisons[5] * 6;
|
||||
Yahtzee.scoreUp += score;
|
||||
break;
|
||||
case "threeOfAKind" :
|
||||
case "fourOfAKind" :
|
||||
case "luck" :
|
||||
$.each(Yahtzee.dices, function(index, elt){score += (elt + 1)});
|
||||
Yahtzee.scoreDown += score;
|
||||
break;
|
||||
case "full" :
|
||||
score = 25;
|
||||
Yahtzee.scoreDown += score;
|
||||
break;
|
||||
case "smallStraight" :
|
||||
score = 30;
|
||||
Yahtzee.scoreDown += score;
|
||||
break;
|
||||
case "largeStraight" :
|
||||
score = 40;
|
||||
Yahtzee.scoreDown += score;
|
||||
break;
|
||||
case "yahtzee" :
|
||||
score = 50;
|
||||
Yahtzee.scoreDown += score;
|
||||
break;
|
||||
}
|
||||
|
||||
$("#" + id + "Score").html(score);
|
||||
|
||||
Yahtzee.keptCombinaisons.push(id);
|
||||
Yahtzee.clear(true);
|
||||
|
||||
if( Yahtzee.keptCombinaisons.length < 13 )
|
||||
$("#launchBtn").removeClass("disabled");
|
||||
else
|
||||
Yahtzee.show_game_over();
|
||||
},
|
||||
|
||||
trash : function(id) {
|
||||
$("#" + id + "Score").html(0).addClass('trashed');
|
||||
$("#" + id + "Label").attr('style', 'text-decoration:line-through;');
|
||||
Yahtzee.keptCombinaisons.push(id);
|
||||
Yahtzee.clear(true);
|
||||
if( Yahtzee.keptCombinaisons.length < 13 )
|
||||
$("#launchBtn").removeClass("disabled");
|
||||
else
|
||||
Yahtzee.show_game_over();
|
||||
},
|
||||
|
||||
show_game_over: function() {
|
||||
$("#upperScore").append(Yahtzee.scoreUp);
|
||||
if( Yahtzee.scoreUp > 63 ) {
|
||||
$("#bonus").append(35);
|
||||
Yahtzee.scoreUp += 35;
|
||||
} else
|
||||
$("#bonus").append(0);
|
||||
$("#lowerScore").append(Yahtzee.scoreDown);
|
||||
$("#totalScore").append(Yahtzee.scoreDown + Yahtzee.upperScore);
|
||||
|
||||
$("#scorePanel").show();
|
||||
}
|
||||
}
|
||||
4
demo/yahtzee/lib/jquery-1.7.1.min.js
vendored
Normal file
53
docs/development/cloudbudget.md
Normal file
@@ -0,0 +1,53 @@
|
||||
#Introduction [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url]
|
||||
Cloudbudget is a work-in-progress online Money-like application.
|
||||
|
||||
It's written using ExpressJS and provided only REST services. The web interface is in a different project [CloudBugdet-AngularJS](/development/cloudbudget_angularjs).
|
||||
|
||||
##Requirements
|
||||
CloudBudget needs a Mongo database. Database configuration is done in the _config/db.js_ file.
|
||||
|
||||
The environment mode is defined by the environment variable NODE_ENV.
|
||||
|
||||
##Features
|
||||
The following features are developed:
|
||||
|
||||
* API security done with JWT
|
||||
* API documentation
|
||||
* User log on / log in
|
||||
* User deregistration
|
||||
* Bank account CRUD
|
||||
* Bank accounts listing
|
||||
* Deposit / Bill entry CRUD
|
||||
* Deposit / Bill entries listing
|
||||
|
||||
##Usage
|
||||
To initialize the application, install all dependencies with
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
To launch CloudBudget, use the following command :
|
||||
```
|
||||
NODE_ENV=development node app.js
|
||||
```
|
||||
|
||||
If the PORT environment variable is set, it will be used, if not, the default port is 3000.
|
||||
The server configuration is done with the _config/server.js_ file.
|
||||
|
||||
##API documentation
|
||||
The root URL is linked to the API documentation.
|
||||
The API documentation is generated with apidocs into the _public_ folder. To generate it, use the following command :
|
||||
```
|
||||
npm run-script generate-doc
|
||||
```
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.min.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.ie.min.css" />
|
||||
<![endif]-->
|
||||
<a class="github-fork-ribbon" href="https://github.com/Febbweiss/CloudBudget" target="_blank" title="Fork me on GitHub">Fork me on GitHub</a>
|
||||
|
||||
[build-image]: https://travis-ci.org/Febbweiss/CloudBudget.svg?branch=master
|
||||
[build-url]: https://travis-ci.org/Febbweiss/CloudBudget
|
||||
[coverage-image]:https://coveralls.io/repos/Febbweiss/CloudBudget/badge.svg?branch=master&service=github
|
||||
[coverage-url]: https://coveralls.io/github/Febbweiss/CloudBudget?branch=master
|
||||
35
docs/development/cloudbudget_angularjs.md
Normal file
@@ -0,0 +1,35 @@
|
||||
#Introduction [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url]
|
||||
Cloudbudget-AngularJS is a work-in-progress web application for [CloudBugdet](/development/cloudbudget) written in AngularJS.
|
||||
|
||||
##Requirements
|
||||
CloudBudget-AngularJS needs a running CloudBudget instance. The access to this instance is set in the _public/js/app.js_ file with the _HOST_ variable.
|
||||
|
||||
|
||||
##Features
|
||||
This web application covers all CloudBudget features.
|
||||
|
||||
##Usage
|
||||
To initialize the application, install all dependencies with
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
To launch CloudBudget, use the following command :
|
||||
```
|
||||
NODE_ENV=development node app.js
|
||||
```
|
||||
|
||||
If the PORT environment variable is set, it will be used, if not, the default port is 3000.
|
||||
The server configuration is done with the _config/server.js_ file.
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.min.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.ie.min.css" />
|
||||
<![endif]-->
|
||||
<a class="github-fork-ribbon" href="https://github.com/Febbweiss/CloudBudget-AngularJS" target="_blank" title="Fork me on GitHub">Fork me on GitHub</a>
|
||||
|
||||
[build-image]: https://travis-ci.org/Febbweiss/CloudBudget-AngularJS.svg?branch=master
|
||||
[build-url]: https://travis-ci.org/Febbweiss/CloudBudget-AngularJS
|
||||
[coverage-image]:https://coveralls.io/repos/Febbweiss/CloudBudget-AngularJS/badge.svg?branch=master&service=github
|
||||
[coverage-url]: https://coveralls.io/github/Febbweiss/CloudBudget-AngularJS?branch=master
|
||||
33
docs/development/filebrowser_durandal_widget.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Durandal Filebrowser widget
|
||||
|
||||
## What's this widget ?
|
||||
|
||||
This [Durandal](http://durandaljs.com/) widget allows to display a folder tree and add some actions to manipulate this items :
|
||||
|
||||
- A clic on a file or folder selects it
|
||||
- A double-clic opens / closes a folder
|
||||
- A double-clic displays the file content in the editor
|
||||
- A right-clic opens a context menu with different options
|
||||
- Rename the item
|
||||
- Copy the selected item(s)
|
||||
- Paste the selected item(s)
|
||||
- Create an item (in a folder)
|
||||
- Delete an item (and its components)
|
||||
|
||||
##Demo
|
||||
<object data="/demo/filebrowser-durandal-widget/index.html" width="800" height="600">
|
||||
<embed src="/demo/filebrowser-durandal-widget/index.html" width="800" height="600"> </embed>
|
||||
<iframe scrolling="no" frameborder="0" src="/demo/filebrowser-durandal-widget/index.html" style="width: 800px; height: 600px; overflow:hidden;">
|
||||
</iframe>
|
||||
</object>
|
||||
|
||||
##Licence
|
||||
|
||||
Source code is under [MIT Licence](http://opensource.org/licenses/mit-license.php)
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.min.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.ie.min.css" />
|
||||
<![endif]-->
|
||||
<a class="github-fork-ribbon" href="https://github.com/Febbweiss/filebrowser-durandal-widget" target="_blank" title="Fork me on GitHub">Fork me on GitHub</a>
|
||||