commit 2e64cb961ec6da05377b13decac93d38680cb0dd Author: ECAILLE Fabrice (externe) Date: Wed May 3 16:46:01 2017 +0200 Initial commit diff --git a/demo/filebrowser-durandal-widget/.bowerrc b/demo/filebrowser-durandal-widget/.bowerrc new file mode 100644 index 0000000..7905fb7 --- /dev/null +++ b/demo/filebrowser-durandal-widget/.bowerrc @@ -0,0 +1,4 @@ +{ + "directory" : "lib", + "json" : "bower.json" +} \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/.gitignore b/demo/filebrowser-durandal-widget/.gitignore new file mode 100644 index 0000000..078170f --- /dev/null +++ b/demo/filebrowser-durandal-widget/.gitignore @@ -0,0 +1,2 @@ +lib +.codenvy \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/MIT-LICENCE.txt b/demo/filebrowser-durandal-widget/MIT-LICENCE.txt new file mode 100644 index 0000000..df4e3fc --- /dev/null +++ b/demo/filebrowser-durandal-widget/MIT-LICENCE.txt @@ -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. \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/README.md b/demo/filebrowser-durandal-widget/README.md new file mode 100644 index 0000000..cfd3f8c --- /dev/null +++ b/demo/filebrowser-durandal-widget/README.md @@ -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) \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/main.js b/demo/filebrowser-durandal-widget/app/main.js new file mode 100644 index 0000000..a358874 --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/main.js @@ -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'); + }); +}); diff --git a/demo/filebrowser-durandal-widget/app/shell.html b/demo/filebrowser-durandal-widget/app/shell.html new file mode 100644 index 0000000..82327c5 --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/shell.html @@ -0,0 +1,34 @@ +
+ + +
+
+			
+		
+ Open file to view it. +
+ + +
\ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/shell.js b/demo/filebrowser-durandal-widget/app/shell.js new file mode 100644 index 0000000..7c43e0f --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/shell.js @@ -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 + }; +}); \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/widgets/filebrowser/newItemModal.html b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/newItemModal.html new file mode 100644 index 0000000..4ea7936 --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/newItemModal.html @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/widgets/filebrowser/newItemModal.js b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/newItemModal.js new file mode 100644 index 0000000..47fe31f --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/newItemModal.js @@ -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; +}); \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/widgets/filebrowser/renameModal.html b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/renameModal.html new file mode 100644 index 0000000..35ee67a --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/renameModal.html @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/widgets/filebrowser/renameModal.js b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/renameModal.js new file mode 100644 index 0000000..4948874 --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/renameModal.js @@ -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; +}); \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/widgets/filebrowser/view.html b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/view.html new file mode 100644 index 0000000..5099563 --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/view.html @@ -0,0 +1,56 @@ +
+ + + + + + + + + + + + +
\ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/app/widgets/filebrowser/viewmodel.js b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/viewmodel.js new file mode 100644 index 0000000..8bac7c7 --- /dev/null +++ b/demo/filebrowser-durandal-widget/app/widgets/filebrowser/viewmodel.js @@ -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; +}); \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/bower.json b/demo/filebrowser-durandal-widget/bower.json new file mode 100644 index 0000000..3324afc --- /dev/null +++ b/demo/filebrowser-durandal-widget/bower.json @@ -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" + } +} \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/data/filesystem.json b/demo/filebrowser-durandal-widget/data/filesystem.json new file mode 100644 index 0000000..d5ba135 --- /dev/null +++ b/demo/filebrowser-durandal-widget/data/filesystem.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/index.html b/demo/filebrowser-durandal-widget/index.html new file mode 100644 index 0000000..0c37a0e --- /dev/null +++ b/demo/filebrowser-durandal-widget/index.html @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + +
+
+

Filebrowser Durandal widget

+ +
+
+ + + + + + + \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/style/filebrowser.less b/demo/filebrowser-durandal-widget/style/filebrowser.less new file mode 100644 index 0000000..94a704a --- /dev/null +++ b/demo/filebrowser-durandal-widget/style/filebrowser.less @@ -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; +} \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/style/global.less b/demo/filebrowser-durandal-widget/style/global.less new file mode 100644 index 0000000..95cf96c --- /dev/null +++ b/demo/filebrowser-durandal-widget/style/global.less @@ -0,0 +1,9 @@ +body { + padding-bottom: 100px; +} + +#editor { + position: relative; + + overflow: hidden; +} \ No newline at end of file diff --git a/demo/filebrowser-durandal-widget/style/starterkit.css b/demo/filebrowser-durandal-widget/style/starterkit.css new file mode 100644 index 0000000..06ee2f3 --- /dev/null +++ b/demo/filebrowser-durandal-widget/style/starterkit.css @@ -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; +} \ No newline at end of file diff --git a/demo/pacman/MIT-LICENCE.txt b/demo/pacman/MIT-LICENCE.txt new file mode 100644 index 0000000..8668d02 --- /dev/null +++ b/demo/pacman/MIT-LICENCE.txt @@ -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. diff --git a/demo/pacman/README.md b/demo/pacman/README.md new file mode 100644 index 0000000..4a2d89d --- /dev/null +++ b/demo/pacman/README.md @@ -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) diff --git a/demo/pacman/css/hack/csshover3.htc b/demo/pacman/css/hack/csshover3.htc new file mode 100644 index 0000000..bf68686 --- /dev/null +++ b/demo/pacman/css/hack/csshover3.htc @@ -0,0 +1,12 @@ + + \ No newline at end of file diff --git a/demo/pacman/css/pacman.css b/demo/pacman/css/pacman.css new file mode 100644 index 0000000..8cd0b12 --- /dev/null +++ b/demo/pacman/css/pacman.css @@ -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; +} diff --git a/demo/pacman/img/banner.png b/demo/pacman/img/banner.png new file mode 100644 index 0000000..2cabdb7 Binary files /dev/null and b/demo/pacman/img/banner.png differ diff --git a/demo/pacman/img/font-red.png b/demo/pacman/img/font-red.png new file mode 100644 index 0000000..65d6f9c Binary files /dev/null and b/demo/pacman/img/font-red.png differ diff --git a/demo/pacman/img/font-yellow.png b/demo/pacman/img/font-yellow.png new file mode 100644 index 0000000..718446e Binary files /dev/null and b/demo/pacman/img/font-yellow.png differ diff --git a/demo/pacman/img/font.png b/demo/pacman/img/font.png new file mode 100644 index 0000000..d22022b Binary files /dev/null and b/demo/pacman/img/font.png differ diff --git a/demo/pacman/img/sprite.png b/demo/pacman/img/sprite.png new file mode 100644 index 0000000..fe94a65 Binary files /dev/null and b/demo/pacman/img/sprite.png differ diff --git a/demo/pacman/index.html b/demo/pacman/index.html new file mode 100644 index 0000000..165f7f7 --- /dev/null +++ b/demo/pacman/index.html @@ -0,0 +1,44 @@ + + + + + Pacman + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+ + + + diff --git a/demo/pacman/js/pacman-core.js b/demo/pacman/js/pacman-core.js new file mode 100644 index 0000000..3326771 --- /dev/null +++ b/demo/pacman/js/pacman-core.js @@ -0,0 +1,1009 @@ +/* +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 Game = { + id : null, + type : "offline", + player : 1, + + PACMAN_START_X : 14 * TILE_SIZE, + PACMAN_START_Y : 24 * TILE_SIZE, + + GHOST_STATE_CHASE : 1, + GHOST_STATE_SCATTER : 2, + GHOST_STATE_FRIGHTENED : 3, + GHOST_STATE_IN_JAIL : 4, + GHOST_STATE_EATEN : 5, + GHOST_STATE_FRIGHTENED_BLINK : 6, + + + GHOST_EVENT_CHASE : "ghost_event_chase", + GHOST_EVENT_SCATTER : "ghost_event_scatter", + GHOST_EVENT_DOT_EATEN : "ghost_event_dot_eaten", + + DOT_POINTS : 10, + BIG_DOT_POINTS : 50, + totalDots : 0, + + dots : {}, + timer : null, + frightTimer : null, + bonusTimer : null, + level : -1, + levelData : null, + step : 0, + score : 0, + eatenDots : 0, + lives : 3, + running : false, + mode : 2, // Game.GHOST_STATE_SCATTER + frightMode : false, + eaten: 0, + + pacman : null, + miss : null, + hero : null, + blinky : null, + pinky : null, + inky : null, + clyde : null, + ghosts : new Array(), + actors : {}, + heroes : new Array(), + maze : MAZE, + + init : function() { + + GUI.updateMessage("READY"); + + $(".dot.hiddenDot").each( function(incr, elt) { + Game.dots[elt.id] = "dot"; + }); + $(".dot.hiddenDot").removeClass("hiddenDot"); + + $(".bigDot.hiddenDot").each( function(incr, elt) { + Game.dots[elt.id] = "bigDot"; + }); + $(".bigDot.hiddenDot").removeClass("hiddenDot") + + Game.totalDots = $(".dot").length + $(".bigDot").length; + + SCOREBOARD.init(); + SCOREBOARD.set_score( Game.score ); + + Game.level++; + Game.step = 0; + Game.eatenDots = 0; + + GUI.updateLevelNumber( Game.level + 1 ); + + Game.build(LEVELS[Math.min(Game.level, LEVELS.length)]); + }, + + build : function(data) { + Game.levelData = data; + Game.addPacman(); + Game.addGhosts(); + Sound.play("opening"); + setTimeout("Game.start();", 4500); + }, + + start : function() { + //if( $.browser.webkit ) + $(document).keydown( function( event ) { + if( event.which > 36 && event.which < 41 ) + return false; + } ); + // $(document).keypress(scrollPreventFct ); + + GUI.updateMessage(""); + Game.timer = new PausableTimer(Game.timerManager, Game.levelData.mode[Game.step] * 1000); + Game.running = true; + }, + + levelComplete : function() { + Game.running = false; + Game.timer.stop(); + Game.timer = null; + + setTimeout("Game.init();", 3000); + }, + + eat : function(type) { + Game.eatenDots++; + if( type === "bigDot" ) { + Game.score += Game.BIG_DOT_POINTS; +// console.log( "Eating big dot " + Game.score ); + SCOREBOARD.add( Game.BIG_DOT_POINTS ); + } else { + Game.score += Game.DOT_POINTS; +// console.log( "Eating dot " + Game.score ); + SCOREBOARD.add( Game.DOT_POINTS ); + } + + if( Game.eatenDots == 70 || Game.eatenDots == 170 ) { + Game.bonusTimer = setTimeout("Game.hideBonus();", ( 9 + Math.random() ) * 1000 ); + $("#" + Game.maze.bonus_target).addClass( Game.levelData.bonus.type); + } + + if( Game.eatenDots === Game.totalDots ) + Game.levelComplete(); + }, + + eatGhost : function(ghost) { + Sound.play("ghost"); + Game.eaten++; + var points = Game.eaten * 200; + Game.score += points; +// console.log(new Date() + " Eating " + ghost.id + " " + (Game.eaten * 200) + " "+ Game.score ); + SCOREBOARD.add( points ); + }, + + hideBonus : function() { + $("#" + Game.maze.bonus_target).removeClass( Game.levelData.bonus.type); + Game.bonusTimer = null; + }, + + die : function() { + Game.running = false; + $.each( Game.actors, function(index, actor) { + actor.speed = 0; + }) + Game.pacman.die(); + Game.timer.stop(); + Game.step = 0; + Game.timer = null; + $("#life" + Game.lives).effect( "pulsate", {times:3, mode:"hide"}, 500 ); + Game.lives--; + if( Game.lives > 0 ) + setTimeout( "Game.startAfterDie();", 3000); + else { + GUI.drawText( $("#message"), "GAME OVER", true ); + Game.show_game_over(); + } + }, + + show_game_over: function() { + }, + + startAfterDie : function() { + var dotsCounters = new Array(); + $.each(Game.ghosts, function(index, ghost ) { + dotsCounters[index] = ghost.dotsCounter; + }); + + Game.addGhosts(); + Game.addPacman(); + //Game.addMissPacman(); + + $.each(Game.ghosts, function(index, ghost ) { + ghost.dotsCounter = dotsCounters[index]; + if( ghost.dotsCounter >= ghost.dotsLimits[Math.min(Game.level, ghost.dotsLimits.length - 1)] ) { + ghost.speed = ghost.initialSpeed; + ghost.state_to(Game.GHOST_STATE_SCATTER); + } + }); + + Game.running = true; + Game.step = 0; + Game.timer = new PausableTimer(Game.timerManager, Game.levelData.mode[Game.step] * 1000); + }, + + timerManager : function() { + Game.step++; + if( Game.step % 2 == 1 ) { + $(".actor").trigger(Game.GHOST_EVENT_CHASE); + Game.mode = Game.GHOST_STATE_CHASE; + } else { + $(".actor").trigger(Game.GHOST_EVENT_SCATTER); + Game.mode = Game.GHOST_STATE_SCATTER; + } + if( Game.step < Game.levelData.mode.length - 1 && Game.levelData.mode[Game.step] != INFINITY ) + Game.timer = new PausableTimer(Game.timerManager, Game.levelData.mode[Game.step] * 1000); + }, + + addPacman : function() { + if( $("#pacman").length == 0) { + Game.pacman = new Pacman(); + $("#actors").addSprite("pacman", {animation: Game.pacman.animations["right"], posx:Game.pacman.x, posy: Game.pacman.y, width: ACTOR_SIZE, height: ACTOR_SIZE}); + Game.pacman.node = $("#pacman"); + Game.pacman.node.addClass( "actor" ); + Game.actors[ "pacman" ] = Game.pacman; + Game.heroes[ "pacman" ] = Game.pacman; + + Game.hero = Game.pacman; + } + Game.pacman.init(); + Game.pacman.speed = Game.levelData.pacman.speed; + Game.pacman.left(); + }, + + addMissPacman : function() { + if( $("#miss_pacman").length == 0) { + Game.miss = new Pacman(); + Game.miss.animations["right"] = new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 3, offsety: 272, delta: ACTOR_SIZE, rate: 120, type: $.gameQuery.ANIMATION_HORIZONTAL }); + Game.miss.animations["up"] = new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 3, offsetx: 96, offsety: 272, delta: ACTOR_SIZE, rate: 120, type: $.gameQuery.ANIMATION_HORIZONTAL }); + + $("#actors").addSprite("miss_pacman", {animation: Game.miss.animations["right"], posx:Game.miss.x, posy: Game.miss.y, width: ACTOR_SIZE, height: ACTOR_SIZE}); + Game.miss.node = $("#miss_pacman"); + Game.miss.node.addClass( "actor" ); + Game.actors[ "miss_pacman" ] = Game.miss; + Game.heroes[ "miss_pacman" ] = Game.miss; + } + Game.miss.init(); + Game.miss.x = Game.MISS_PACMAN_START_X; + Game.miss.y = Game.MISS_PACMAN_START_Y; + Game.miss.speed = Game.levelData.pacman.speed; + Game.miss.right(true); + Game.miss.left(true); + Game.miss.node.x(Game.miss.x); + Game.miss.node.y(Game.miss.y); + Game.miss.right(); + }, + + addGhosts : function() { + Game.addBlinky(); + Game.addPinky(); + Game.addInky(); + Game.addClyde(); + }, + + addBlinky : function() { + if( $("#blinky").length == 0 ) { + Game.blinky = new Ghost("blinky", 0, {x: 14 * TILE_SIZE, y: 14 * TILE_SIZE}, {x: 25, y: 0 }, function() { + var prey = Game.actors[ "blinky" ].prey; + return {x: prey.getTileX(), y: prey.getTileY()}; + }, [0,0,0], Game.GHOST_STATE_SCATTER); + Game.blinky.center(); + $("#actors").addSprite("blinky", {animation: Game.blinky.animations["right"], posx:Game.blinky.x, posy: Game.blinky.y, width: ACTOR_SIZE, height: ACTOR_SIZE}); + Game.blinky.node = $("#blinky"); + Game.blinky.node.addClass( "actor" ); + Game.actors[ "blinky" ] = Game.blinky; + Game.blinky.loadBindings(); + + Game.blinky.originalTarget = Game.blinky.target; + Game.blinky.target = function() { + var remainingDots = Game.totalDots - Game.eatenDots; + var elroySpecs = Game.levelData.ghost; + if( ( Game.blinky.state == Game.GHOST_STATE_SCATTER || Game.blinky.state == Game.GHOST_STATE_CHASE ) && remainingDots <= elroySpecs.elroy1Dots ) { + if( remainingDots <= elroySpecs.elroy2Dots ) { + Game.blinky.speed = elroySpecs.elroy2Speed; + } + else { + Game.blinky.speed = elroySpecs.elroy1Speed; + } + + return Game.blinky.personnalTarget(); + } + return Game.blinky.originalTarget(); + }; + + Game.ghosts.push( Game.blinky ); + } else { + Game.blinky.init(); + } + Game.blinky.state = Game.GHOST_STATE_SCATTER; + Game.blinky.left(); + Game.blinky.initialSpeed = Game.levelData.ghost.speed; + Game.blinky.speed = Game.blinky.initialSpeed; + }, + + addPinky : function() { + if( $("#pinky").length == 0 ) { + Game.pinky = new Ghost("pinky", 1, {x: 14 * TILE_SIZE, y: 16 * TILE_SIZE}, {x: 2, y: 0 }, function() { + var prey = Game.actors[ "pinky" ].prey; + var direction = this.prey.direction; + if( direction % 2 == 0 ) + return {x: prey.getTileX() + (direction == LEFT ? -4 : 4), y: prey.getTileY()}; + else + return {x: prey.getTileX(), y: prey.getTileY() + (direction == UP ? -4 : 4) }; + }, [0,0,0], Game.GHOST_STATE_IN_JAIL); + Game.pinky.center(); + $("#actors").addSprite("pinky", {animation: Game.pinky.animations["right"], posx: Game.pinky.x, posy: Game.pinky.y, width: ACTOR_SIZE, height: ACTOR_SIZE}); + Game.pinky.node = $("#pinky"); + Game.pinky.node.addClass( "actor" ); + Game.actors[ "pinky" ] = Game.pinky; + Game.pinky.loadBindings(); + + Game.ghosts.push( Game.pinky ); + } else { + Game.pinky.init(); + } + Game.pinky.initialSpeed = Game.levelData.ghost.speed; + Game.pinky.left(); + }, + + addInky : function() { + if( $("#inky").length == 0 ) { + Game.inky = new Ghost("inky", 2, {x: 12 * TILE_SIZE, y: 16 * TILE_SIZE}, {x: 27, y: 34 }, function() { + var prey = Game.actors[ "inky" ].prey; + var direction = prey.direction; + if( direction % 2 == 0 ) + direction = {x: prey.getTileX() + (direction == LEFT ? -2 : 2) - Game.blinky.getTileX(), y: prey.getTileY() - Game.blinky.getTileY()}; + else + direction = {x: prey.getTileX() - Game.blinky.getTileX(), y: prey.getTileY() + (direction == UP ? -2 : 2) - Game.blinky.getTileY()}; + return {x: direction.x * 2, y: direction.y * 2}; + }, [30,0,0], Game.GHOST_STATE_IN_JAIL); + Game.inky.center(); + $("#actors").addSprite("inky", {animation: Game.inky.animations["right"], posx:Game.inky.x, posy: Game.inky.y, width: ACTOR_SIZE, height: ACTOR_SIZE}); + Game.inky.node = $("#inky"); + Game.inky.node.addClass( "actor" ); + Game.actors[ "inky" ] = Game.inky; + Game.inky.loadBindings(); + + Game.ghosts.push( Game.inky ); + } else { + Game.inky.init(); + } + Game.inky.initialSpeed = Game.levelData.ghost.speed; + Game.inky.right(); + }, + + addClyde : function() { + if( $("#clyde").length == 0 ) { + Game.clyde = new Ghost("clyde", 3, {x: 16 * TILE_SIZE, y: 16 * TILE_SIZE}, {x: 0, y: 34 }, function() { + var prey = Game.actors[ "clyde" ].prey; + return distance( {x: this.getTileX(), y: this.getTileY()} , {x: prey.getTileX(), y: prey.getTileY()}) < 8 ? + this.scatterTarget : {x: prey.getTileX(), y: prey.getTileY()}; + }, [60,50,0], Game.GHOST_STATE_IN_JAIL); + Game.clyde.center(); + $("#actors").addSprite("clyde", {animation: Game.clyde.animations["right"], posx:Game.clyde.x, posy: Game.clyde.y, width: ACTOR_SIZE, height: ACTOR_SIZE}); + Game.clyde.node = $("#clyde"); + Game.clyde.node.addClass( "actor" ); + Game.actors[ "clyde" ] = Game.clyde; + Game.clyde.loadBindings(); + + Game.ghosts.push( Game.clyde ); + } else { + Game.clyde.init(); + } + Game.clyde.initialSpeed = Game.levelData.ghost.speed; + Game.clyde.left(); + }, + + moveGhosts : function() { + $.each(Game.ghosts, function(index, ghost ) { + ghost.move(); + }); + }, + + nearEndFright : function() { + $.each(Game.ghosts, function(index, ghost ) { + if( ghost.state != Game.GHOST_STATE_IN_JAIL && ghost.state != Game.GHOST_STATE_EATEN ) + ghost.state_to(Game.GHOST_STATE_FRIGHTENED_BLINK); + }); + + setTimeout( 'Game.endFright();', 160 * 4 * Game.levelData.frightFlashesCount); + }, + + endFright : function() { + if( Game.timer ) + Game.timer.resume(); + Game.frightTimer = null; + Game.eaten = 0; + $('.actor').trigger( Game.mode == Game.GHOST_STATE_CHASE ? Game.GHOST_EVENT_CHASE : Game.GHOST_EVENT_SCATTER ); + } +} + +function distance(currentTile, target) { + return Math.sqrt( (target.x - currentTile.x) * (target.x - currentTile.x) + (target.y - currentTile.y)*(target.y - currentTile.y)); +}; + +//Game objects: +function Actor(){} +Actor.prototype = { + node : null, + animations : null, + x : null, + y : null, + speed : null, + direction : null, // 1: up, 2: left, 3:down, 4: right + directionX : 0, + directionY : 0, + + getX : function() { + return x; + }, + + getY : function() { + return y; + }, + + getTileX : function() { + return Math.floor(this.x / TILE_SIZE); + }, + + getTileY : function() { + return Math.floor(this.y / TILE_SIZE); + }, + + getTile : function() { + return this.getTileX() + this.getTileY() * WIDTH_TILE_COUNT; + }, + + getInsideTileX : function() { + return this.x % TILE_SIZE; + }, + + getInsideTileY : function() { + return this.y % TILE_SIZE; + }, + + move : function() { + if( !Game.running ) + return; + this.x += this.directionX * this.speed * ACTOR_SPEED; + this.y += this.directionY * this.speed * ACTOR_SPEED; + this.node.x(this.x ); + this.node.y(this.y ); + }, + + up : function( force ) { + if( force || this.direction != UP ) { + this.directionX = 0; + this.directionY = -1; + this.direction = UP; + this.node.setAnimation(this.animations["up"]); + this.node.flipv(false); + this.node.fliph(false); + this.center(); + } + }, + + down : function( force ) { + if( force || this.direction != DOWN ) { + this.directionX = 0; + this.directionY = 1; + this.direction = DOWN; + if( this.animations["down"] ) { + this.node.setAnimation(this.animations["down"]); + this.node.fliph( false ); + } else { + this.node.setAnimation(this.animations["up"]); + this.node.flipv( true ); + this.node.fliph( false ); + } + this.center(); + } + }, + + left : function( force ) { + if( force || this.direction != LEFT ) { + this.directionX = -1; + this.directionY = 0; + this.direction = LEFT; + this.node.flipv( false ); + if( this.animations["left"] ) { + this.node.setAnimation(this.animations["left"]); + } else { + this.node.setAnimation(this.animations["right"]); + this.node.fliph( true ); + } + this.center(); + } + }, + + right : function( force ) { + if( force || this.direction != RIGHT ) { + this.directionX = 1; + this.directionY = 0; + this.direction = RIGHT; + this.node.setAnimation(this.animations["right"]); + this.node.fliph( false ); + this.node.flipv( false ); + this.center(); + } + }, + + canLeft : function() { + return Game.maze.structure[this.getTileX() + this.getTileY() * WIDTH_TILE_COUNT - 1] <= 0; + }, + + canRight : function() { + return Game.maze.structure[this.getTileX() + this.getTileY() * WIDTH_TILE_COUNT + 1] <= 0; + }, + + canUp : function() { + return Game.maze.structure[this.getTileX() + (this.getTileY() - 1 ) * WIDTH_TILE_COUNT ] <= 0; + }, + + canDown : function() { + return Game.maze.structure[this.getTileX() + (this.getTileY() + 1 ) * WIDTH_TILE_COUNT ] <= 0; + }, + + isNearMiddleTile : function() { + return Math.abs( HALF_TILE_SIZE - this.getInsideTileX() ) < 4 && Math.abs( HALF_TILE_SIZE - this.getInsideTileY() ) < 4; + }, + + center : function() { + this.x = this.getTileX() * TILE_SIZE + HALF_TILE_SIZE; + this.y = this.getTileY() * TILE_SIZE + HALF_TILE_SIZE; + }, + + isInTunnel : function() { + var tile = this.getTile(); + return $.inArray(tile, Game.maze.tunnel) > -1; + } +}; + +/*********************************************/ +/****************** PACMAN *******************/ +/*********************************************/ +function Pacman() { + this.animations = { + "right": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 3, offsety: 16, delta: ACTOR_SIZE, rate: 120, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "up": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 3, offsetx: 64, offsety: 16, delta: ACTOR_SIZE, rate: 120, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "die": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 7, offsety: 208, delta: ACTOR_SIZE, rate: 120, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE | $.gameQuery.ANIMATION_CALLBACK }), + "die2": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 4, offsety: 240, delta: ACTOR_SIZE, rate: 120, type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_ONCE }) + } +}; +Pacman.prototype = { + x : Game.PACMAN_START_X, + y : Game.PACMAN_START_Y, + speed : null, + directionX : 0, + directionY : 0, + lastEatenGhost : null, + + stop : false, + previousTile : null, + + init : function() { + this.x = Game.PACMAN_START_X; + this.y = Game.PACMAN_START_Y; + this.speed = Game.levelData.pacman.speed; + this.right(true); + this.left(true); + this.node.x(this.x); + this.node.y(this.y); + }, + + left : function() { + if( this.direction != LEFT && this.canLeft() ) { + this.stop = false; + this._super("left", arguments); + } + }, + + right : function() { + if( this.direction != RIGHT && this.canRight() ) { + this.stop = false; + this._super("right", arguments); + } + }, + + up : function() { + if( this.direction != UP && this.canUp() ) { + this.stop = false; + this._super("up", arguments); + } + }, + + down : function() { + if( this.direction != DOWN && this.canDown() ) { + this.stop = false; + this._super("down", arguments); + } + }, + + move : function() { + if( !this.stop ) { + this.previousTile = {x: this.getTileX(), y: this.getTileY()}; + this._super("move", arguments); + var currentTile = {x: this.getTileX(), y: this.getTileY()}; + if( this.previousTile.x !== currentTile.x || this.previousTile.y !== currentTile.y ) { + var id = this.getTile(); + if( Game.dots[ id ] ) + this.eatDot( id ); + if( id == Game.maze.bonus_target ) + this.eatBonus(); + this.eatGhosts(); + } + + var inTunnel = this.isInTunnel(); + if( this.x < 0 ) + this.x += PLAYGROUND_WIDTH; + if( this.x > PLAYGROUND_WIDTH ) + this.x -= PLAYGROUND_WIDTH; + switch( this.direction ) { + case LEFT : + if( !inTunnel && !this.canLeft() ) + this.stop = true; + break; + case RIGHT : + if( !inTunnel && !this.canRight() ) + this.stop = true; + break; + case UP : + if( !this.canUp() ) + this.stop = true; + break; + case DOWN : + if( !this.canDown() ) + this.stop = true; + break; + } + } + }, + + eatDot : function(id) { + Game.eat(Game.dots[id]); + $('.actor').trigger(Game.GHOST_EVENT_DOT_EATEN); + if( Game.dots[id] === "bigDot" ) { + $.each(Game.ghosts, function(index, ghost ) { + if( ghost.state != Game.GHOST_STATE_IN_JAIL && ghost.state != Game.GHOST_STATE_EATEN ) + ghost.state_to(Game.GHOST_STATE_FRIGHTENED) + }); + + Game.timer.pause(); + if( Game.frightTimer ) + clearTimeout( Game.frightTimer ); + Game.frightTimer = setTimeout( 'Game.nearEndFright();', Game.levelData.frightTime * 1000 - 160 * 4 * Game.levelData.frightFlashesCount); + } + + Game.dots[id] = null; + $("#" + id ).addClass("hiddenDot"); + }, + + eatGhosts : function() { + var tile = this.getTile(); + $.each(Game.ghosts, function(index, ghost ) { + if( tile == ghost.getTile() ) { + Game.pacman.eatGhost( ghost ); + } + }); + }, + + eatGhost : function( ghost ) { + if( ghost.state == Game.GHOST_STATE_EATEN ) { +// console.log( ghost.id + " already eaten" ); + return; + } + if( ghost.state != Game.GHOST_STATE_FRIGHTENED && ghost.state != Game.GHOST_STATE_FRIGHTENED_BLINK ) { + Game.die(); + } else if( Game.pacman.lastEatenGhost !== ghost.id ){ + ghost.state_to(Game.GHOST_STATE_EATEN); +// console.log( "Eating " + ghost.id + " " + ghost.state ); + Game.eatGhost(ghost); + } + }, + + eatBonus : function() { + if( !$("#" + Game.maze.bonus_target).hasClass( Game.levelData.bonus.type) && Game.bonusTimer == null ) + return; + + Sound.play("fruit"); + + eatenBonus.push(Game.levelData.bonus.type); + Game.score += Game.levelData.bonus.points; +// console.log( "Eating bonus " + Game.levelData.bonus.points + " " + Game.score ); + SCOREBOARD.add( Game.levelData.bonus.points ); + Game.hideBonus(); + }, + + die : function() { + Sound.play("dies"); + this.node.setAnimation(this.animations["die"], function(node) { + Game.pacman.node.setAnimation(Game.pacman.animations["die2"]); + }); + } +}; + +// Overriding Actor.methods() method +heriter(Pacman.prototype, Actor.prototype); + +function Ghost(id, ghostIndex, start, scatterTarget, personnalTarget, dotsLimits, state ) { + this.animations = { + "normal_up": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 2, offsety: 48 + ghostIndex * 32, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "normal_right": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 2, offsetx: 128, offsety: 48 + ghostIndex * 32, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "normal_down": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 2, offsetx: 64, offsety: 48 + ghostIndex * 32, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "frightened": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 2, offsetx: 0, offsety: 176, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "frightened_blink": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 4, offsetx: 0, offsety: 176, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "eaten_up": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 1, offsetx: 128, offsety: 176, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "eaten_down": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 1, offsetx: 160, offsety: 176, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }), + "eaten_right": new $.gameQuery.Animation({imageURL: "img/sprite.png", numberOfFrame: 1, offsetx: 192, offsety: 176, delta: ACTOR_SIZE, rate: 160, type: $.gameQuery.ANIMATION_HORIZONTAL }) + } + this.animations["up"] = this.animations["normal_up"]; + this.animations["down"] = this.animations["normal_down"]; + this.animations["right"] = this.animations["normal_right"]; + + this.id = id; + this.scatterTarget = scatterTarget; + this.personnalTarget = personnalTarget; + this.x = start.x; + this.y = start.y; + this.startingTileX = start.x; + this.startingTileY = start.y; + + this.state = state; + + this.dotsLimits = dotsLimits; + + this.prey = Game.pacman; +}; + +Ghost.prototype = { + id : null, + startingTileX : 0, + startingTileY : 0, + initialSpeed : 0, + speed : 0, + directionX : 0, + directionY : 0, + + state: null, + scatterTarget : null, + lastDirectionTile : null, + + prey : null, + + dotsCounter : 0, + dotsLimits : [], + + init : function() { + this.dotsCounter = 0; + this.speed = 0; + this.x = this.startingTileX; + this.y = this.startingTileY; + this.right(true); + this.left(true); + this.state = Game.GHOST_STATE_IN_JAIL; + this.node.x(this.x); + this.node.y(this.y); + }, + + target : function() { + switch( this.state ) { + case Game.GHOST_STATE_CHASE : + return this.personnalTarget(); + case Game.GHOST_STATE_SCATTER : + return this.scatterTarget; + case Game.GHOST_STATE_FRIGHTENED : + var currentTile = {x: this.getTileX(), y: this.getTileY()}; + var targets = new Array(); + if( this.canUp() && this.direction != DOWN ) + targets.push( {x:currentTile.x, y:currentTile.y - 1} ); + if( this.canDown() && this.direction != UP ) + targets.push( {x:currentTile.x, y:currentTile.y + 1} ); + if( this.canLeft() && this.direction != RIGHT ) + targets.push( {x:currentTile.x - 1, y:currentTile.y} ); + if( this.canRight() && this.direction != LEFT ) + targets.push( {x:currentTile.x + 1, y:currentTile.y} ); + return targets[ parseInt(Math.random() * targets.length ) ]; + case Game.GHOST_STATE_IN_JAIL : + case Game.GHOST_STATE_EATEN : + return {x: 13, y: 14}; + } + }, + + loadBindings : function() { + this.node.bind(Game.GHOST_EVENT_CHASE, {ghost: this}, function(evt) { + var ghost = evt.data.ghost; + if( ghost.state != Game.GHOST_STATE_IN_JAIL && ghost.state != Game.GHOST_STATE_EATEN ) + ghost.state_to(Game.GHOST_STATE_CHASE); + }); + this.node.bind(Game.GHOST_EVENT_SCATTER, {ghost: this}, function(evt) { + var ghost = evt.data.ghost; + if( ghost.state != Game.GHOST_STATE_IN_JAIL && ghost.state != Game.GHOST_STATE_EATEN ) + ghost.state_to(Game.GHOST_STATE_SCATTER); + }); + this.node.bind(Game.GHOST_EVENT_DOT_EATEN, {ghost: this}, function(evt) { + var ghost = evt.data.ghost; + if( ghost.state == Game.GHOST_STATE_IN_JAIL && ghost.dotsCounter++ >= ghost.dotsLimits[Math.min(Game.level, ghost.dotsLimits.length - 1)] ) { + ghost.speed = ghost.initialSpeed; + ghost.state_to(Game.mode); + } + }); + }, + + personnalTarget : function() { + }, + + state_to : function( state ) { + var up; + var down; + var right; + var reverse = this.state != Game.GHOST_STATE_FRIGHTENED && this.state != Game.GHOST_STATE_IN_JAIL; // previous state + this.state = state; + switch( state ) { + case Game.GHOST_STATE_CHASE : + this.speed = Game.levelData.ghost.speed; + case Game.GHOST_STATE_SCATTER : + this.speed = Game.levelData.ghost.speed; + case Game.GHOST_STATE_IN_JAIL : + up = this.animations["normal_up"]; + down = this.animations["normal_down"]; + right = this.animations["normal_right"]; + break; + case Game.GHOST_STATE_FRIGHTENED : + up = down = right = this.animations["frightened"]; + this.speed = Game.levelData.ghost.frightSpeed; + break; + case Game.GHOST_STATE_FRIGHTENED_BLINK : + up = down = right = this.animations["frightened_blink"]; + this.state = Game.GHOST_STATE_FRIGHTENED; + break; + case Game.GHOST_STATE_EATEN : + up = this.animations["eaten_up"]; + down = this.animations["eaten_down"]; + right = this.animations["eaten_right"]; + this.speed = 1; + break; + } + + + this.animations["up"] = up; + this.animations["down"] = down; + this.animations["right"] = right; + + if( reverse ) + switch( this.direction ) { + case UP: + this.direction = DOWN; + break; + case LEFT: + this.direction = RIGHT; + break; + case DOWN: + this.direction = UP; + break; + case RIGHT: + this.direction = LEFT; + break; + } + + var inTunnel = this.isInTunnel(); + var distances = [ + {direction: UP, distance: this.canUp() && this.direction != DOWN ? 1 : INFINITY}, + {direction: LEFT, distance: (inTunnel && this.direction == LEFT ) || (this.canLeft() && this.direction != RIGHT) ? 1 : INFINITY}, + {direction: DOWN, distance: this.canDown() && this.direction != UP ? 1 : INFINITY}, + {direction: RIGHT, distance: (inTunnel && this.direction == RIGHT ) || (this.canRight() && this.direction != LEFT) ? 1 : INFINITY}, + ]; + distances.sort( function(a, b) { + if( a.distance == b.distance ) + return a.direction - b.direction; + return a.distance - b.distance; + }) + var selected = distances[0]; + + switch( selected.direction ) { + case UP: + this.up(true); + break; + case LEFT: + this.left(true); + break; + case DOWN: + this.down(true); + break; + case RIGHT: + this.right(true); + break; + } + + }, + + canUp : function() { + switch( this.getTile() ) { + case 404: + case 407: + case 684: + case 687: + return false; + case 461: + case 462: + return true; + default: + return Game.maze.structure[ this.getTileX() + (this.getTileY() - 1 ) * WIDTH_TILE_COUNT ] <= 0; + } + }, + + canDown : function() { + switch( this.getTile() ) { + case 405: + case 406: + return false; + default: + return Game.maze.structure[ this.getTileX() + (this.getTileY() + 1 ) * WIDTH_TILE_COUNT ] <= 0; + } + }, + + move : function() { + this._super("move", arguments); + var currentTile = {x: this.getTileX(), y: this.getTileY()}; + var id = this.getTile();; + if( this.lastDirectionTile != id && this.isNearMiddleTile()) { + this.lastDirectionTile = id; + this.eaten(); + + var distances = null; + var target = this.target(); + if( this.state == Game.GHOST_STATE_EATEN && id == Game.maze.ghost_frightened_target ) { + this.state_to(Game.mode); + } + + var inTunnel = this.isInTunnel(); + if( inTunnel ) + this.speed = Game.levelData.ghost.tunnelSpeed; + else if( this.state != Game.GHOST_STATE_IN_JAIL ) + this.speed = this.state == Game.GHOST_STATE_FRIGHTENED ? Game.levelData.ghost.frightSpeed : Game.levelData.ghost.speed; + + if( this.x < 0 ) + this.x += PLAYGROUND_WIDTH; + if( this.x > PLAYGROUND_WIDTH ) + this.x -= PLAYGROUND_WIDTH; + + if( Game.maze.choice_tiles.indexOf( id ) != -1 ) { + distances = [ + {direction: UP, distance: this.canUp() && this.direction != DOWN ? distance({x:currentTile.x, y:currentTile.y - 1}, target ) : INFINITY}, + {direction: LEFT, distance: this.canLeft() && this.direction != RIGHT ? distance( {x:currentTile.x - 1, y:currentTile.y }, target ) : INFINITY}, + {direction: DOWN, distance: this.canDown() && this.direction != UP ? distance({x:currentTile.x, y:currentTile.y + 1}, target ) : INFINITY}, + {direction: RIGHT, distance: this.canRight() && this.direction != LEFT ? distance({x:currentTile.x + 1, y:currentTile.y}, target ) : INFINITY}, + ]; + } else { + distances = [ + {direction: UP, distance: this.canUp() && this.direction != DOWN ? 1 : INFINITY}, + {direction: LEFT, distance: (inTunnel && this.direction == LEFT ) || (this.canLeft() && this.direction != RIGHT) ? 1 : INFINITY}, + {direction: DOWN, distance: this.canDown() && this.direction != UP ? 1 : INFINITY}, + {direction: RIGHT, distance: (inTunnel && this.direction == RIGHT ) || (this.canRight() && this.direction != LEFT) ? 1 : INFINITY}, + ]; + } + distances.sort( function(a, b) { + if( a.distance == b.distance ) + return a.direction - b.direction; + return a.distance - b.distance; + }) + var selected = distances[0]; + + switch( selected.direction ) { + case LEFT : + if( this.direction != LEFT ) + this.left(); + break; + case RIGHT : + if( this.direction != RIGHT ) + this.right(); + break; + case UP : + if( this.direction != UP ) + this.up(); + break; + case DOWN : + if( this.direction != DOWN ) + this.down(); + break; + } + } + + var inTunnel = this.isInTunnel(); + if( this.x < 0 ) + this.x += PLAYGROUND_WIDTH; + if( this.x > PLAYGROUND_WIDTH ) + this.x -= PLAYGROUND_WIDTH; + + }, + + eaten : function(target) { + if( typeof target === "undefined" ) + target = this; + if( target.getTile() == Game.pacman.getTile() ) { +// console.log(" Eaten from ghost" ); + Game.pacman.eatGhost(target); +// if( target.state != Game.GHOST_STATE_FRIGHTENED && target.state != Game.GHOST_STATE_EATEN ) { +// Game.die(); +// } else { +// target.state_to(Game.GHOST_STATE_EATEN); +// Game.eatGhost(this); +// } + } + } +}; + +heriter(Ghost.prototype, Actor.prototype); diff --git a/demo/pacman/js/pacman-data.js b/demo/pacman/js/pacman-data.js new file mode 100644 index 0000000..c41e1d2 --- /dev/null +++ b/demo/pacman/js/pacman-data.js @@ -0,0 +1,13 @@ +/* +/* +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. +*/ + +MAZE = {"structure":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,9,9,9,9,9,9,9,9,9,9,9,9,2,1,9,9,9,9,9,9,9,9,9,9,9,9,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,-1,1,9,9,2,-1,1,9,9,9,2,-1,11,10,-1,1,9,9,9,2,-1,1,9,9,2,-1,10,11,-2,10,0,0,11,-1,11,0,0,0,10,-1,11,10,-1,11,0,0,0,10,-1,11,0,0,10,-2,10,11,-1,3,9,9,4,-1,3,9,9,9,4,-1,3,4,-1,3,9,9,9,4,-1,3,9,9,4,-1,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,-1,1,9,9,2,-1,1,2,-1,1,9,9,9,9,9,9,2,-1,1,2,-1,1,9,9,2,-1,10,11,-1,3,9,9,4,-1,10,11,-1,3,9,9,2,1,9,9,4,-1,10,11,-1,3,9,9,4,-1,10,11,-1,-1,-1,-1,-1,-1,10,11,-1,-1,-1,-1,11,10,-1,-1,-1,-1,10,11,-1,-1,-1,-1,-1,-1,10,3,9,9,9,9,2,-1,10,3,9,9,2,0,11,10,0,1,9,9,4,11,-1,1,9,9,9,9,4,0,0,0,0,0,10,-1,10,1,9,9,4,0,3,4,0,3,9,9,2,11,-1,11,0,0,0,0,0,0,0,0,0,0,10,-1,10,11,0,0,0,0,0,0,0,0,0,0,10,11,-1,11,0,0,0,0,0,9,9,9,9,9,4,-1,3,4,0,5,9,9,12,12,9,9,6,0,3,4,-1,3,9,9,9,9,9,0,0,0,0,0,0,-1,0,0,0,11,0,0,0,0,0,0,10,0,0,0,-1,0,0,0,0,0,0,9,9,9,9,9,2,-1,1,2,0,7,9,9,9,9,9,9,8,0,1,2,-1,1,9,9,9,9,9,0,0,0,0,0,10,-1,11,10,0,0,0,0,0,0,0,0,0,0,11,10,-1,11,0,0,0,0,0,0,0,0,0,0,10,-1,11,10,0,1,9,9,9,9,9,9,2,0,11,10,-1,11,0,0,0,0,0,1,9,9,9,9,4,-1,3,4,0,3,9,9,2,1,9,9,4,0,3,4,-1,3,9,9,9,9,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,-1,1,9,9,2,-1,1,9,9,9,2,-1,11,10,-1,1,9,9,9,2,-1,1,9,9,2,-1,10,11,-1,3,9,2,10,-1,3,9,9,9,4,-1,3,4,-1,3,9,9,9,4,-1,11,1,9,4,-1,10,11,-2,-1,-1,10,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,10,-1,-1,-2,10,3,9,2,-1,10,10,-1,1,2,-1,1,9,9,9,9,9,9,2,-1,1,2,-1,11,10,-1,1,9,4,1,9,4,-1,3,4,-1,11,10,-1,3,9,9,2,1,9,9,4,-1,11,10,-1,3,4,-1,3,9,2,11,-1,-1,-1,-1,-1,-1,11,10,-1,-1,-1,-1,11,10,-1,-1,-1,-1,11,10,-1,-1,-1,-1,-1,-1,10,11,-1,1,9,9,9,9,4,3,9,9,2,-1,11,10,-1,1,9,9,4,3,9,9,9,9,2,-1,10,11,-1,3,9,9,9,9,9,9,9,9,4,-1,3,4,-1,3,9,9,9,9,9,9,9,9,4,-1,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,3,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,4],"bonus_target":518,"tunnel":[448,449,450,451,452,471,472,473,474,475],"ghost_frightened_target":405,"choice_tiles":[118,133,225,230,233,236,239,242,245,250,314,329,404,407,454,457,466,469,513,522,594,597,606,609,678,681,684,687,690,693,759,780,852,855]}; + var LEVELS = [{"pacman":{"speed":0.8,"eating":0.71,"frightSpeed":0.9,"frightSpeedEating":0.79},"ghost":{"speed":0.75,"tunnelSpeed":0.4,"elroy1Speed":0.8,"elroy1Dots":20,"elroy2Speed":0.85,"elroy2Dots":10,"frightSpeed":0.5},"frightTime":6,"frightFlashesCount":5,"mode":[7,20,7,20,5,20,5,1410065407],"bonus":{"type":"cherries","points":100}},{"pacman":{"speed":0.9,"eating":0.79,"frightSpeed":0.95,"frightSpeedEating":0.83},"ghost":{"speed":0.85,"tunnelSpeed":0.45,"elroy1Speed":0.9,"elroy1Dots":30,"elroy2Speed":0.95,"elroy2Dots":15,"frightSpeed":0.55},"frightTime":5,"frightFlashesCount":5,"mode":[7,20,7,20,5,1033,0.0166666667,1410065407],"bonus":{"type":"strawberry","points":300}},{"pacman":{"speed":0.9,"eating":0.79,"frightSpeed":0.95,"frightSpeedEating":0.83},"ghost":{"speed":0.85,"tunnelSpeed":0.45,"elroy1Speed":0.9,"elroy1Dots":40,"elroy2Speed":0.95,"elroy2Dots":20,"frightSpeed":0.55},"frightTime":4,"frightFlashesCount":5,"mode":[7,20,7,20,5,1033,0.0166666667,1410065407],"bonus":{"type":"peach","points":500}},{"pacman":{"speed":0.9,"eating":0.79,"frightSpeed":0.95,"frightSpeedEating":0.83},"ghost":{"speed":0.85,"tunnelSpeed":0.45,"elroy1Speed":0.9,"elroy1Dots":40,"elroy2Speed":0.95,"elroy2Dots":20,"frightSpeed":0.55},"frightTime":3,"frightFlashesCount":5,"mode":[7,20,7,20,5,1033,0.0166666667,1410065407],"bonus":{"type":"peach","points":500}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":40,"elroy2Speed":1.05,"elroy2Dots":20,"frightSpeed":0.6},"frightTime":2,"frightFlashesCount":5,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"apple","points":700}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":50,"elroy2Speed":1.05,"elroy2Dots":25,"frightSpeed":0.6},"frightTime":5,"frightFlashesCount":5,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"apple","points":700}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":50,"elroy2Speed":1.05,"elroy2Dots":25,"frightSpeed":0.6},"frightTime":2,"frightFlashesCount":5,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"grapes","points":1000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":50,"elroy2Speed":1.05,"elroy2Dots":25,"frightSpeed":0.6},"frightTime":2,"frightFlashesCount":5,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"grapes","points":1000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":60,"elroy2Speed":1.05,"elroy2Dots":30,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"galaxian","points":2000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":60,"elroy2Speed":1.05,"elroy2Dots":30,"frightSpeed":0.6},"frightTime":5,"frightFlashesCount":5,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"galaxian","points":2000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":60,"elroy2Speed":1.05,"elroy2Dots":30,"frightSpeed":0.6},"frightTime":2,"frightFlashesCount":5,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"bell","points":3000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":80,"elroy2Speed":1.05,"elroy2Dots":40,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"bell","points":3000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":80,"elroy2Speed":1.05,"elroy2Dots":40,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":80,"elroy2Speed":1.05,"elroy2Dots":40,"frightSpeed":0.6},"frightTime":3,"frightFlashesCount":5,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":100,"elroy2Speed":1.05,"elroy2Dots":50,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":100,"elroy2Speed":1.05,"elroy2Dots":50,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":100,"elroy2Speed":1.05,"elroy2Dots":50,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":100,"elroy2Speed":1.05,"elroy2Dots":50,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":120,"elroy2Speed":1.05,"elroy2Dots":60,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":1,"eating":0.87,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":120,"elroy2Speed":1.05,"elroy2Dots":60,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}},{"pacman":{"speed":0.9,"eating":0.79,"frightSpeed":1,"frightSpeedEating":0.87},"ghost":{"speed":0.95,"tunnelSpeed":0.5,"elroy1Speed":1,"elroy1Dots":120,"elroy2Speed":1.05,"elroy2Dots":60,"frightSpeed":0.6},"frightTime":1,"frightFlashesCount":3,"mode":[7,20,7,20,5,1037,0.0166666667,1410065407],"bonus":{"type":"key","points":5000}}]; diff --git a/demo/pacman/js/pacman-ui.js b/demo/pacman/js/pacman-ui.js new file mode 100644 index 0000000..ed121e3 --- /dev/null +++ b/demo/pacman/js/pacman-ui.js @@ -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("
"); + hud.append("
"); + hud.append("
"); + hud.append("
'"); + hud.append("
'"); + hud.append("
'"); + + 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('
'); + + if(i % 28 == 27 ) { + background.append('
'); + } + } + + // 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 += "
"; + width += 16; + count++; + } else if( letter.charCodeAt(0) > 47 && letter.charCodeAt(0) < 58 ) { + var letterSize = 32; + if( forceSmall ) { + letterSize = 16; + } + html += "
"; + 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 += "
"; + 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 += "
"; + 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 ); + } +} diff --git a/demo/pacman/js/scoreboard.js b/demo/pacman/js/scoreboard.js new file mode 100644 index 0000000..db45d2c --- /dev/null +++ b/demo/pacman/js/scoreboard.js @@ -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 += "
"; + } + + 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" ); + } +}; diff --git a/demo/pacman/js/utils.js b/demo/pacman/js/utils.js new file mode 100644 index 0000000..e4a903b --- /dev/null +++ b/demo/pacman/js/utils.js @@ -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(); + diff --git a/demo/pacman/lib/gamequery-0.7.0.js b/demo/pacman/lib/gamequery-0.7.0.js new file mode 100644 index 0000000..3c74fc3 --- /dev/null +++ b/demo/pacman/lib/gamequery-0.7.0.js @@ -0,0 +1,1738 @@ +/* + * gameQuery rev. 0.7.0 + * + * Copyright (c) 2012 Selim Arsever (http://gamequeryjs.com) + * licensed under the MIT-License + */ + +// This allows use of the convenient $ notation in a plugin +(function($) { + + // This prefix can be use whenever needed to namespace CSS classes, .data() inputs aso. + var gQprefix = "gQ_"; + + // Those are the possible states of the engine + var STATE_NEW = 0; // Not yet started for the first time + var STATE_RUNNING = 1; // Started and running + var STATE_PAUSED = 2; // Paused + + /** + * Utility function that returns the radius for a geometry. + * + * @param {object} elem DOM element + * @param {float} angle the angle in degrees + * @return {object} .x, .y radius of geometry + */ + var proj = function (elem, angle) { + switch (elem.geometry){ + case $.gameQuery.GEOMETRY_RECTANGLE : + var b = angle*Math.PI*2/360; + var Rx = Math.abs(Math.cos(b)*elem.width/2*elem.factor)+Math.abs(Math.sin(b)*elem.height/2*elem.factor); + var Ry = Math.abs(Math.cos(b)*elem.height/2*elem.factor)+Math.abs(Math.sin(b)*elem.width/2*elem.factor); + + return {x: Rx, y: Ry}; + } + }; + + /** + * Utility function that checks for collision between two elements. + * + * @param {object} elem1 DOM for the first element + * @param {float} offset1 offset of the first element + * @param {object} elem2 DOM for the second element + * @param {float} offset2 offset of the second element + * @return {boolean} if the two elements collide or not + */ + var collide = function(elem1, offset1, elem2, offset2) { + // test real collision (only for two rectangles...) + if((elem1.geometry == $.gameQuery.GEOMETRY_RECTANGLE && elem2.geometry == $.gameQuery.GEOMETRY_RECTANGLE)){ + + var dx = offset2.x + elem2.boundingCircle.x - elem1.boundingCircle.x - offset1.x; + var dy = offset2.y + elem2.boundingCircle.y - elem1.boundingCircle.y - offset1.y; + var a = Math.atan(dy/dx); + + var Dx = Math.abs(Math.cos(a-elem1.angle*Math.PI*2/360)/Math.cos(a)*dx); + var Dy = Math.abs(Math.sin(a-elem1.angle*Math.PI*2/360)/Math.sin(a)*dy); + + var R = proj(elem2, elem2.angle-elem1.angle); + + if((elem1.width/2*elem1.factor+R.x <= Dx) || (elem1.height/2*elem1.factor+R.y <= Dy)) { + return false; + } else { + var Dx = Math.abs(Math.cos(a-elem2.angle*Math.PI*2/360)/Math.cos(a)*-dx); + var Dy = Math.abs(Math.sin(a-elem2.angle*Math.PI*2/360)/Math.sin(a)*-dy); + + var R = proj(elem1, elem1.angle-elem2.angle); + + if((elem2.width/2*elem2.factor+R.x <= Dx) || (elem2.height/2*elem2.factor+R.y <= Dy)) { + return false; + } else { + return true; + } + } + } else { + return false; + } + }; + + /** + * Utility function computes the offset relative to the playground of a gameQuery element without using DOM's position. + * This should be faster than the standand .offset() function. + * + * Warning: No non-gameQuery elements should be present between this element and the playground div! + * + * @param {jQuery} element the jQuery wrapped DOM element representing the gameQuery object. + * @return {object} an object {x:, y: } containing the x and y offset. (Not top and left like jQuery's .offset()) + */ + var offset = function(element) { + // Get the tileSet offset (relative to the playground) + var offset = {x: 0, y: 0}; + var parent = element[0]; + + while(parent !== $.gameQuery.playground[0] && parent.gameQuery !== undefined) { + offset.x += parent.gameQuery.posx; + offset.y += parent.gameQuery.posy; + parent = parent.parentNode; + } + + return offset + } + + /** + * Utility function computes the index range of the tiles for a tilemap. + * + * @param {jQuery} element the jQuery wrapped DOM element representing the tilemap. + * @param {object} offset an object holding the x and y offset of the tilemap, this is optional and will be computed if not provided. + * @return {object} an object {firstColumn: , lastColumn: , fristRow: , lastRow: } + */ + var visibleTilemapIndexes = function (element, elementOffset) { + if (elementOffset === undefined) { + elementOffset = offset(element); + } + + var gameQuery = element[0].gameQuery; + // Activate the visible tiles + return { + firstRow: Math.max(Math.min(Math.floor(-elementOffset.y/gameQuery.height), gameQuery.sizey), 0), + lastRow: Math.max(Math.min(Math.ceil(($.gameQuery.playground[0].height-elementOffset.y)/gameQuery.height), gameQuery.sizey), 0), + firstColumn: Math.max(Math.min(Math.floor(-elementOffset.x/gameQuery.width), gameQuery.sizex), 0), + lastColumn: Math.max(Math.min(Math.ceil(($.gameQuery.playground[0].width-elementOffset.x)/gameQuery.width), gameQuery.sizex), 0) + } + } + + /** + * Utility function thast computes the buffered zone of a tilemap + * + * @param {jQuery} element the jQuery wrapped DOM element representing the tilemap. + * @param {object} visible an object describing the visible zone + * @return {object} an object {firstColumn: , lastColumn: , fristRow: , lastRow: } + */ + var bufferedTilemapIndexes = function (element, visible) { + var gameQuery = element[0].gameQuery; + + return { + firstRow: Math.max(Math.min(visible.firstRow - gameQuery.buffer, gameQuery.sizey), 0), + lastRow: Math.max(Math.min(visible.lastRow + gameQuery.buffer, gameQuery.sizey), 0), + firstColumn: Math.max(Math.min(visible.firstColumn - gameQuery.buffer, gameQuery.sizex), 0), + lastColumn: Math.max(Math.min(visible.lastColumn + gameQuery.buffer, gameQuery.sizex), 0) + } + } + + /** + * Utility function that creates a tile in the given tilemap + * + * @param {jQuery} tileSet the jQuery element representing the tile map + * @param {integer} row the row index of the tile in the tile map + * @param {integer} column the column index of the tile in the tile map + */ + var addTile = function(tileSet, row, column) { + var gameQuery = tileSet[0].gameQuery; + var name = tileSet.attr("id"); + + var tileDescription; + if(gameQuery.func) { + tileDescription = gameQuery.tiles(row,column)-1; + } else { + tileDescription = gameQuery.tiles[row][column]-1; + } + + var animation; + if(gameQuery.multi) { + animation = gameQuery.animations; + } else { + animation = gameQuery.animations[tileDescription]; + } + + if(tileDescription >= 0){ + tileSet.addSprite($.gameQuery.tileIdPrefix+name+"_"+row+"_"+column, + {width: gameQuery.width, + height: gameQuery.height, + posx: column*gameQuery.width, + posy: row*gameQuery.height, + animation: animation}); + + var newTile = tileSet.find("#"+$.gameQuery.tileIdPrefix+name+"_"+row+"_"+column); + if (gameQuery.multi) { + newTile.setAnimation(tileDescription); + } else { + newTile[0].gameQuery.animationNumber = tileDescription; + } + newTile.removeClass($.gameQuery.spriteCssClass); + newTile.addClass($.gameQuery.tileCssClass); + newTile.addClass($.gameQuery.tileTypePrefix+tileDescription); + } + } + + // Define the list of object/function accessible through $. + $.extend({ gameQuery: { + /** + * This is the Animation Object + */ + Animation: function (options, imediateCallback) { + // private default values + var defaults = { + imageURL: "", + numberOfFrame: 1, + delta: 0, + rate: 30, + type: 0, + distance: 0, + offsetx: 0, + offsety: 0 + }; + + // options extends defaults + options = $.extend(defaults, options); + + // "public" attributes: + this.imageURL = options.imageURL; // The url of the image to be used as an animation or sprite + this.numberOfFrame = options.numberOfFrame; // The number of frames to be displayed when playing the animation + this.delta = options.delta; // The distance in pixels between two frames + this.rate = options.rate; // The rate at which the frames change in miliseconds + this.type = options.type; // The type of the animation.This is a bitwise OR of the properties. + this.distance = options.distance; // The distance in pixels between two animations + this.offsetx = options.offsetx; // The x coordinate where the first sprite begins + this.offsety = options.offsety; // The y coordinate where the first sprite begins + + // Whenever a new animation is created we add it to the ResourceManager animation list + $.gameQuery.resourceManager.addAnimation(this, imediateCallback); + + return true; + }, + + /** + * "constants" for the different types of an animation + */ + ANIMATION_VERTICAL: 1, // Generated by a vertical offset of the background + ANIMATION_HORIZONTAL: 2, // Generated by a horizontal offset of the background + ANIMATION_ONCE: 4, // Played only once (else looping indefinitely) + ANIMATION_CALLBACK: 8, // A callback is exectued at the end of a cycle + ANIMATION_MULTI: 16, // The image file contains many animations + ANIMATION_PINGPONG: 32, // At the last frame of the animation it reverses (if used in conjunction with ONCE it will have no effect) + + // "constants" for the different type of geometry for a sprite + GEOMETRY_RECTANGLE: 1, + GEOMETRY_DISC: 2, + + // basic values + refreshRate: 30, + + /** + * An object to manage resource loading + */ + resourceManager: { + animations: [], // List of animations / images used in the game + sounds: [], // List of sounds used in the game + callbacks: [], // List of the functions called at each refresh + loadedAnimationsPointer: 0, // Keep track of the last loaded animation + loadedSoundsPointer: 0, // Keep track of the last loaded sound + + /** + * Load resources before starting the game. + */ + preload: function() { + // Start loading the images + for (var i = this.animations.length-1 ; i >= this.loadedAnimationsPointer; i --){ + this.animations[i].domO = new Image(); + this.animations[i].domO.src = this.animations[i].imageURL; + } + + // Start loading the sounds + for (var i = this.sounds.length-1 ; i >= this.loadedSoundsPointer; i --){ + this.sounds[i].load(); + } + + $.gameQuery.resourceManager.waitForResources(); + }, + + /** + * Wait for all the resources called for in preload() to finish loading. + */ + waitForResources: function() { + // Check the images + var imageCount = 0; + for(var i=this.loadedAnimationsPointer; i < this.animations.length; i++){ + if(this.animations[i].domO.complete){ + imageCount++; + } + } + // Check the sounds + var soundCount = 0; + for(var i=this.loadedSoundsPointer; i < this.sounds.length; i++){ + var temp = this.sounds[i].ready(); + if(temp){ + soundCount++; + } + } + // Call the load callback with the current progress + if($.gameQuery.resourceManager.loadCallback){ + var percent = (imageCount + soundCount)/(this.animations.length + this.sounds.length - this.loadedAnimationsPointer - this.loadedSoundsPointer)*100; + $.gameQuery.resourceManager.loadCallback(percent); + } + if(imageCount + soundCount < (this.animations.length + this.sounds.length - this.loadedAnimationsPointer - this.loadedSoundsPointer)){ + imgWait=setTimeout(function () { + $.gameQuery.resourceManager.waitForResources(); + }, 100); + } else { + this.loadedAnimationsPointer = this.animations.length; + this.loadedSoundsPointer = this.sounds.length; + + // All the resources are loaded! We can now associate the animation's images to their corresponding sprites + $.gameQuery.scenegraph.children().each(function(){ + // recursive call on the children: + $(this).children().each(arguments.callee); + // add the image as a background + if(this.gameQuery && this.gameQuery.animation){ + $(this).css("background-image", "url("+this.gameQuery.animation.imageURL+")"); + // we set the correct kind of repeat + if(this.gameQuery.animation.type & $.gameQuery.ANIMATION_VERTICAL) { + $(this).css("background-repeat", "repeat-x"); + } else if(this.gameQuery.animation.type & $.gameQuery.ANIMATION_HORIZONTAL) { + $(this).css("background-repeat", "repeat-y"); + } else { + $(this).css("background-repeat", "no-repeat"); + } + } + }); + + // Launch the refresh loop + if($.gameQuery.state === STATE_NEW){ + setInterval(function () { + $.gameQuery.resourceManager.refresh(); + },($.gameQuery.refreshRate)); + } + $.gameQuery.state = STATE_RUNNING; + if($.gameQuery.startCallback){ + $.gameQuery.startCallback(); + } + // Make the scenegraph visible + $.gameQuery.scenegraph.css("visibility","visible"); + } + }, + + /** + * This function refresh a unique sprite here 'this' represent a dom object + */ + refreshSprite: function() { + // Check if 'this' is a gameQuery element + if(this.gameQuery != undefined){ + var gameQuery = this.gameQuery; + // Does 'this' has an animation ? + if(gameQuery.animation){ + // Do we have anything to do? + if ( (gameQuery.idleCounter == gameQuery.animation.rate-1) && gameQuery.playing){ + + // Does 'this' loops? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_ONCE){ + if(gameQuery.currentFrame < gameQuery.animation.numberOfFrame-1){ + gameQuery.currentFrame += gameQuery.frameIncrement; + } else if(gameQuery.currentFrame == gameQuery.animation.numberOfFrame-1) { + // Does 'this' has a callback ? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_CALLBACK){ + if($.isFunction(gameQuery.callback)){ + gameQuery.callback(this); + } + } + } + } else { + if(gameQuery.animation.type & $.gameQuery.ANIMATION_PINGPONG){ + if(gameQuery.currentFrame == gameQuery.animation.numberOfFrame-1 && gameQuery.frameIncrement == 1) { + gameQuery.frameIncrement = -1; + } else if (gameQuery.currentFrame == 0 && gameQuery.frameIncrement == -1) { + gameQuery.frameIncrement = 1; + } + } + + gameQuery.currentFrame = (gameQuery.currentFrame+gameQuery.frameIncrement)%gameQuery.animation.numberOfFrame; + if(gameQuery.currentFrame == 0){ + // Does 'this' has a callback ? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_CALLBACK){ + if($.isFunction(gameQuery.callback)){ + gameQuery.callback(this); + } + } + } + } + // Update the background + if((gameQuery.animation.type & $.gameQuery.ANIMATION_VERTICAL) && (gameQuery.animation.numberOfFrame > 1)){ + if(gameQuery.multi){ + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.multi)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px"); + } else { + $(this).css("background-position",""+(-gameQuery.animation.offsetx)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px"); + } + } else if((gameQuery.animation.type & $.gameQuery.ANIMATION_HORIZONTAL) && (gameQuery.animation.numberOfFrame > 1)) { + if(gameQuery.multi){ + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety-gameQuery.multi)+"px"); + } else { + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety)+"px"); + } + } + } + gameQuery.idleCounter = (gameQuery.idleCounter+1)%gameQuery.animation.rate; + } + } + return true; + }, + + /** + * This function refresh a unique tile-map, here 'this' represent a dom object + */ + refreshTilemap: function() { + // Check if 'this' is a gameQuery element + if(this.gameQuery != undefined){ + var gameQuery = this.gameQuery; + if($.isArray(gameQuery.frameTracker)){ + for(var i=0; i 1)){ + $(this).css("background-position",""+(-gameQuery.animations[animationNumber].offsetx)+"px "+(-gameQuery.animations[animationNumber].offsety-gameQuery.animations[animationNumber].delta*gameQuery.frameTracker[animationNumber])+"px"); + } else if((gameQuery.animations[animationNumber].type & $.gameQuery.ANIMATION_HORIZONTAL) && (gameQuery.animations[animationNumber].numberOfFrame > 1)) { + $(this).css("background-position",""+(-gameQuery.animations[animationNumber].offsetx-gameQuery.animations[animationNumber].delta*gameQuery.frameTracker[animationNumber])+"px "+(-gameQuery.animations[animationNumber].offsety)+"px"); + } + } else { + if((gameQuery.animations.type & $.gameQuery.ANIMATION_VERTICAL) && (gameQuery.animations.numberOfFrame > 1)){ + $(this).css("background-position",""+(-gameQuery.animations.offsetx-this.gameQuery.multi)+"px "+(-gameQuery.animations.offsety-gameQuery.animations.delta*gameQuery.frameTracker)+"px"); + } else if((gameQuery.animations.type & $.gameQuery.ANIMATION_HORIZONTAL) && (gameQuery.animations.numberOfFrame > 1)) { + $(this).css("background-position",""+(-gameQuery.animations.offsetx-gameQuery.animations.delta*gameQuery.frameTracker)+"px "+(-gameQuery.animations.offsety-this.gameQuery.multi)+"px"); + } + } + }); + } + return true; + }, + + /** + * Called periodically to refresh the state of the game. + */ + refresh: function() { + if($.gameQuery.state === STATE_RUNNING) { + $.gameQuery.playground.find("."+$.gameQuery.spriteCssClass).each(this.refreshSprite); + $.gameQuery.playground.find("."+$.gameQuery.tilemapCssClass).each(this.refreshTilemap); + var deadCallback= new Array(); + for (var i = this.callbacks.length-1; i >= 0; i--){ + if(this.callbacks[i].idleCounter == this.callbacks[i].rate-1){ + var returnedValue = this.callbacks[i].fn(); + if(typeof returnedValue == 'boolean'){ + // If we have a boolean: 'true' means 'no more execution', 'false' means 'keep on executing' + if(returnedValue){ + deadCallback.push(i); + } + } else if(typeof returnedValue == 'number') { + // If we have a number it re-defines the time to the next call + this.callbacks[i].rate = Math.round(returnedValue/$.gameQuery.refreshRate); + this.callbacks[i].idleCounter = 0; + } + } + this.callbacks[i].idleCounter = (this.callbacks[i].idleCounter+1)%this.callbacks[i].rate; + } + for(var i = deadCallback.length-1; i >= 0; i--){ + this.callbacks.splice(deadCallback[i],1); + } + } + }, + + /** + * Add an animation to the resource Manager + */ + addAnimation: function(animation, callback) { + if($.inArray(animation,this.animations)<0){ + //normalize the animation rate: + animation.rate = Math.round(animation.rate/$.gameQuery.refreshRate); + if(animation.rate==0){ + animation.rate = 1; + } + this.animations.push(animation); + switch ($.gameQuery.state){ + case STATE_NEW: + case STATE_PAUSED: + // Nothing to do for now + break; + case STATE_RUNNING: + // immediatly load the animation and call the callback if any + this.animations[this.loadedAnimationsPointer].domO = new Image(); + this.animations[this.loadedAnimationsPointer].domO.src = animation.imageURL; + if (callback !== undefined){ + this.animations[this.loadedAnimationsPointer].domO.onload = callback; + } + this.loadedAnimationsPointer++; + break; + } + } + }, + + /** + * Add a sound to the resource Manager + */ + addSound: function(sound, callback){ + if($.inArray(sound,this.sounds)<0){ + this.sounds.push(sound); + switch ($.gameQuery.state){ + case STATE_NEW: + case STATE_PAUSED: + // Nothing to do for now + break; + case STATE_RUNNING: + // immediatly load the sound and call the callback if any + sound.load(); + // TODO callback.... + this.loadedSoundsPointer++; + break; + } + } + }, + + /** + * Register a callback + * + * @param {function} fn the callback + * @param {integer} rate the rate in ms at which the callback should be called (should be a multiple of the playground rate or will be rounded) + */ + registerCallback: function(fn, rate){ + rate = Math.round(rate/$.gameQuery.refreshRate); + if(rate==0){ + rate = 1; + } + this.callbacks.push({fn: fn, rate: rate, idleCounter: 0}); + }, + + /** + * Clear the animations and sounds + */ + clear: function(callbacksToo){ + this.animations = []; + this.loadedAnimationsPointer = 0; + this.sounds = []; + this.loadedSoundsPointer = 0; + if(callbacksToo) { + this.callbacks = []; + } + } + }, + + /** + * This is a single place to update the underlying data of sprites/groups/tiles after a position or dimesion modification. + */ + update: function(descriptor, transformation) { + // Did we really receive a descriptor or a jQuery object instead? + if(!$.isPlainObject(descriptor)){ + // Then we must get real descriptor + if(descriptor.length > 0){ + var gameQuery = descriptor[0].gameQuery; + } else { + var gameQuery = descriptor.gameQuery; + } + } else { + var gameQuery = descriptor; + } + // If we couldn't find one we return + if(!gameQuery) return; + if(gameQuery.tileSet === true){ + // We have a tilemap + + var visible = visibleTilemapIndexes(descriptor); + var buffered = gameQuery.buffered; + + // Test what kind of transformation we have and react accordingly + for(property in transformation){ + switch(property){ + case "x": + + if(visible.lastColumn > buffered.lastColumn) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var i = gameQuery.buffered.firstRow; i < gameQuery.buffered.lastRow; i++){ + // Remove the newly invisible tiles + for(var j = gameQuery.buffered.firstColumn; j < Math.min(newBuffered.firstColumn, gameQuery.buffered.lastColumn); j++) { + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var j = Math.max(gameQuery.buffered.lastColumn,newBuffered.firstColumn); j < newBuffered.lastColumn ; j++) { + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstColumn = newBuffered.firstColumn; + gameQuery.buffered.lastColumn = newBuffered.lastColumn; + + // Attach the tilemap back + tilemap.appendTo(parent); + + } + + if(visible.firstColumn < buffered.firstColumn) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var i = gameQuery.buffered.firstRow; i < gameQuery.buffered.lastRow; i++){ + // Remove the newly invisible tiles + for(var j = Math.max(newBuffered.lastColumn,gameQuery.buffered.firstColumn); j < gameQuery.buffered.lastColumn ; j++) { + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var j = newBuffered.firstColumn; j < Math.min(gameQuery.buffered.firstColumn,newBuffered.lastColumn); j++) { + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstColumn = newBuffered.firstColumn; + gameQuery.buffered.lastColumn = newBuffered.lastColumn; + + // Attach the tilemap back + tilemap.appendTo(parent); + } + break; + + case "y": + + if(visible.lastRow > buffered.lastRow) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var j = gameQuery.buffered.firstColumn; j < gameQuery.buffered.lastColumn ; j++) { + // Remove the newly invisible tiles + for(var i = gameQuery.buffered.firstRow; i < Math.min(newBuffered.firstRow, gameQuery.buffered.lastRow); i++){ + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var i = Math.max(gameQuery.buffered.lastRow, newBuffered.firstRow); i < newBuffered.lastRow; i++){ + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstRow = newBuffered.firstRow; + gameQuery.buffered.lastRow = newBuffered.lastRow; + + // Attach the tilemap back + tilemap.appendTo(parent); + + } + + if(visible.firstRow < buffered.firstRow) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var j = gameQuery.buffered.firstColumn; j < gameQuery.buffered.lastColumn ; j++) { + // Remove the newly invisible tiles + for(var i = Math.max(newBuffered.lastRow, gameQuery.buffered.firstRow); i < gameQuery.buffered.lastRow; i++){ + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var i = newBuffered.firstRow; i < Math.min(gameQuery.buffered.firstRow, newBuffered.lastRow); i++){ + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstRow = newBuffered.firstRow; + gameQuery.buffered.lastRow = newBuffered.lastRow; + + // Attach the tilemap back + tilemap.appendTo(parent); + } + break; + + case "angle": + //TODO + break; + + case "factor": + //TODO + break; + } + } + + } else { + var refreshBoundingCircle = $.gameQuery.playground && !$.gameQuery.playground.disableCollision; + + // Update the descriptor + for(property in transformation){ + switch(property){ + case "x": + if(refreshBoundingCircle){ + gameQuery.boundingCircle.x = gameQuery.posx+gameQuery.width/2; + } + break; + case "y": + if(refreshBoundingCircle){ + gameQuery.boundingCircle.y = gameQuery.posy+gameQuery.height/2; + } + break; + case "w": + case "h": + gameQuery.boundingCircle.originalRadius = Math.sqrt(Math.pow(gameQuery.width,2) + Math.pow(gameQuery.height,2))/2 + gameQuery.boundingCircle.radius = gameQuery.factor*gameQuery.boundingCircle.originalRadius; + break; + case "angle": //(in degrees) + gameQuery.angle = parseFloat(transformation.angle); + break; + case "factor": + gameQuery.factor = parseFloat(transformation.factor); + if(refreshBoundingCircle){ + gameQuery.boundingCircle.radius = gameQuery.factor*gameQuery.boundingCircle.originalRadius; + } + break; + } + } + } + }, + // State of the engine + state: STATE_NEW, + + // CSS classes used to mark game element + spriteCssClass: gQprefix + "sprite", + groupCssClass: gQprefix + "group", + tilemapCssClass: gQprefix + "tilemap", + tileCssClass: gQprefix + "tile", + // Prefix for CSS Ids or Classes + tileTypePrefix: gQprefix + "tileType_", + tileIdPrefix: gQprefix + "tile_" + }, + + /** + * Mute (or unmute) all the sounds. + */ + muteSound: function(muted){ + for (var i = $.gameQuery.resourceManager.sounds.length-1 ; i >= 0; i --) { + $.gameQuery.resourceManager.sounds[i].muted(muted); + } + }, + + /** + * Accessor for the currently defined playground as a jQuery object + */ + playground: function() { + return $.gameQuery.playground + }, + + /** + * Define a callback called during the loading of the game's resources. + * + * The function will recieve as unique parameter + * a number representing the progess percentage. + */ + loadCallback: function(callback){ + $.gameQuery.resourceManager.loadCallback = callback; + } + }); // end of the extensio of $ + + + // fragments used to create DOM element + var spriteFragment = $("
"); + var groupFragment = $("
"); + var tilemapFragment = $("
"); + + + // Define the list of object/function accessible through $("selector"). + $.fn.extend({ + /** + * Defines the currently selected div to which contains the game and initialize it. + * + * This is a non-destructive call + */ + playground: function(options) { + if(this.length == 1){ + if(this[0] == document){ + // Old usage detected, this is not supported anymore + throw "Old playground usage, use $.playground() to retreive the playground and $('mydiv').playground(options) to set the div!"; + } + options = $.extend({ + height: 320, + width: 480, + refreshRate: 30, + position: "absolute", + keyTracker: false, + mouseTracker: false, + disableCollision: false + }, options); + // We save the playground node and set some variable for this node: + $.gameQuery.playground = this; + $.gameQuery.refreshRate = options.refreshRate; + $.gameQuery.playground[0].height = options.height; + $.gameQuery.playground[0].width = options.width; + + // We initialize the display of the div + $.gameQuery.playground.css({ + position: options.position, + display: "block", + overflow: "hidden", + height: options.height+"px", + width: options.width+"px" + }) + .append(""+(g[0]>0&&N==g[1]-1?'
':""):""),M+=Q}K+=M}return K+=x+($.browser.msie&&parseInt($.browser.version,10)<7&&!a.inline?'':""),a._keyEvent=!1,K},_generateMonthYearHeader:function(a,b,c,d,e,f,g,h){var i=this._get(a,"changeMonth"),j=this._get(a,"changeYear"),k=this._get(a,"showMonthAfterYear"),l='
',m="";if(f||!i)m+=''+g[b]+"";else{var n=d&&d.getFullYear()==c,o=e&&e.getFullYear()==c;m+='"}k||(l+=m+(f||!i||!j?" ":""));if(!a.yearshtml){a.yearshtml="";if(f||!j)l+=''+c+"";else{var q=this._get(a,"yearRange").split(":"),r=(new Date).getFullYear(),s=function(a){var b=a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?r+parseInt(a,10):parseInt(a,10);return isNaN(b)?r:b},t=s(q[0]),u=Math.max(t,s(q[1]||""));t=d?Math.max(t,d.getFullYear()):t,u=e?Math.min(u,e.getFullYear()):u,a.yearshtml+='",l+=a.yearshtml,a.yearshtml=null}}return l+=this._get(a,"yearSuffix"),k&&(l+=(f||!i||!j?" ":"")+m),l+="
",l},_adjustInstDate:function(a,b,c){var d=a.drawYear+(c=="Y"?b:0),e=a.drawMonth+(c=="M"?b:0),f=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+(c=="D"?b:0),g=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,f)));a.selectedDay=g.getDate(),a.drawMonth=a.selectedMonth=g.getMonth(),a.drawYear=a.selectedYear=g.getFullYear(),(c=="M"||c=="Y")&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),e=c&&bd?d:e,e},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){var b=this._get(a,"numberOfMonths");return b==null?[1,1]:typeof b=="number"?[1,b]:b},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),f=this._daylightSavingAdjust(new Date(c,d+(b<0?b:e[0]*e[1]),1));return b<0&&f.setDate(this._getDaysInMonth(f.getFullYear(),f.getMonth())),this._isInRange(a,f)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<=d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");return b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10),{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);var e=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(d,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),e,this._getFormatConfig(a))}}),$.fn.datepicker=function(a){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find("body").append($.datepicker.dpDiv),$.datepicker.initialized=!0);var b=Array.prototype.slice.call(arguments,1);return typeof a!="string"||a!="isDisabled"&&a!="getDate"&&a!="widget"?a=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b)):this.each(function(){typeof a=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this].concat(b)):$.datepicker._attachDatepicker(this,a)}):$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.8.23",window["DP_jQuery_"+dpuuid]=$})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.progressbar.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=a("
").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove(),a.Widget.prototype.destroy.apply(this,arguments)},value:function(a){return a===b?this._value():(this._setOption("value",a),this)},_setOption:function(b,c){b==="value"&&(this.options.value=c,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),a.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;return typeof a!="number"&&(a=0),Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var a=this.value(),b=this._percentage();this.oldValue!==a&&(this.oldValue=a,this._trigger("change")),this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(b.toFixed(0)+"%"),this.element.attr("aria-valuenow",a)}}),a.extend(a.ui.progressbar,{version:"1.8.23"})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.core.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +jQuery.effects||function(a,b){function c(b){var c;return b&&b.constructor==Array&&b.length==3?b:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))?[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))?[parseFloat(c[1])*2.55,parseFloat(c[2])*2.55,parseFloat(c[3])*2.55]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))?[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:(c=/rgba\(0, 0, 0, 0\)/.exec(b))?e.transparent:e[a.trim(b).toLowerCase()]}function d(b,d){var e;do{e=(a.curCSS||a.css)(b,d);if(e!=""&&e!="transparent"||a.nodeName(b,"body"))break;d="backgroundColor"}while(b=b.parentNode);return c(e)}function h(){var a=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,b={},c,d;if(a&&a.length&&a[0]&&a[a[0]]){var e=a.length;while(e--)c=a[e],typeof a[c]=="string"&&(d=c.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),b[d]=a[c])}else for(c in a)typeof a[c]=="string"&&(b[c]=a[c]);return b}function i(b){var c,d;for(c in b)d=b[c],(d==null||a.isFunction(d)||c in g||/scrollbar/.test(c)||!/color/i.test(c)&&isNaN(parseFloat(d)))&&delete b[c];return b}function j(a,b){var c={_:0},d;for(d in b)a[d]!=b[d]&&(c[d]=b[d]);return c}function k(b,c,d,e){typeof b=="object"&&(e=c,d=null,c=b,b=c.effect),a.isFunction(c)&&(e=c,d=null,c={});if(typeof c=="number"||a.fx.speeds[c])e=d,d=c,c={};return a.isFunction(d)&&(e=d,d=null),c=c||{},d=d||c.duration,d=a.fx.off?0:typeof d=="number"?d:d in a.fx.speeds?a.fx.speeds[d]:a.fx.speeds._default,e=e||c.complete,[b,c,d,e]}function l(b){return!b||typeof b=="number"||a.fx.speeds[b]?!0:typeof b=="string"&&!a.effects[b]?!0:!1}a.effects={},a.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","borderColor","color","outlineColor"],function(b,e){a.fx.step[e]=function(a){a.colorInit||(a.start=d(a.elem,e),a.end=c(a.end),a.colorInit=!0),a.elem.style[e]="rgb("+Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2],10),255),0)+")"}});var e={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},f=["add","remove","toggle"],g={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};a.effects.animateClass=function(b,c,d,e){return a.isFunction(d)&&(e=d,d=null),this.queue(function(){var g=a(this),k=g.attr("style")||" ",l=i(h.call(this)),m,n=g.attr("class")||"";a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),m=i(h.call(this)),g.attr("class",n),g.animate(j(l,m),{queue:!1,duration:c,easing:d,complete:function(){a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),typeof g.attr("style")=="object"?(g.attr("style").cssText="",g.attr("style").cssText=k):g.attr("style",k),e&&e.apply(this,arguments),a.dequeue(this)}})})},a.fn.extend({_addClass:a.fn.addClass,addClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{add:b},c,d,e]):this._addClass(b)},_removeClass:a.fn.removeClass,removeClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{remove:b},c,d,e]):this._removeClass(b)},_toggleClass:a.fn.toggleClass,toggleClass:function(c,d,e,f,g){return typeof d=="boolean"||d===b?e?a.effects.animateClass.apply(this,[d?{add:c}:{remove:c},e,f,g]):this._toggleClass(c,d):a.effects.animateClass.apply(this,[{toggle:c},d,e,f])},switchClass:function(b,c,d,e,f){return a.effects.animateClass.apply(this,[{add:c,remove:b},d,e,f])}}),a.extend(a.effects,{version:"1.8.23",save:function(a,b){for(var c=0;c
").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),e=document.activeElement;try{e.id}catch(f){e=document.body}return b.wrap(d),(b[0]===e||a.contains(b[0],e))&&a(e).focus(),d=b.parent(),b.css("position")=="static"?(d.css({position:"relative"}),b.css({position:"relative"})):(a.extend(c,{position:b.css("position"),zIndex:b.css("z-index")}),a.each(["top","left","bottom","right"],function(a,d){c[d]=b.css(d),isNaN(parseInt(c[d],10))&&(c[d]="auto")}),b.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),d.css(c).show()},removeWrapper:function(b){var c,d=document.activeElement;return b.parent().is(".ui-effects-wrapper")?(c=b.parent().replaceWith(b),(b[0]===d||a.contains(b[0],d))&&a(d).focus(),c):b},setTransition:function(b,c,d,e){return e=e||{},a.each(c,function(a,c){var f=b.cssUnit(c);f[0]>0&&(e[c]=f[0]*d+f[1])}),e}}),a.fn.extend({effect:function(b,c,d,e){var f=k.apply(this,arguments),g={options:f[1],duration:f[2],callback:f[3]},h=g.options.mode,i=a.effects[b];return a.fx.off||!i?h?this[h](g.duration,g.callback):this.each(function(){g.callback&&g.callback.call(this)}):i.call(this,g)},_show:a.fn.show,show:function(a){if(l(a))return this._show.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="show",this.effect.apply(this,b)},_hide:a.fn.hide,hide:function(a){if(l(a))return this._hide.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="hide",this.effect.apply(this,b)},__toggle:a.fn.toggle,toggle:function(b){if(l(b)||typeof b=="boolean"||a.isFunction(b))return this.__toggle.apply(this,arguments);var c=k.apply(this,arguments);return c[1].mode="toggle",this.effect.apply(this,c)},cssUnit:function(b){var c=this.css(b),d=[];return a.each(["em","px","%","pt"],function(a,b){c.indexOf(b)>0&&(d=[parseFloat(c),b])}),d}});var m={};a.each(["Quad","Cubic","Quart","Quint","Expo"],function(a,b){m[b]=function(b){return Math.pow(b,a+2)}}),a.extend(m,{Sine:function(a){return 1-Math.cos(a*Math.PI/2)},Circ:function(a){return 1-Math.sqrt(1-a*a)},Elastic:function(a){return a===0||a===1?a:-Math.pow(2,8*(a-1))*Math.sin(((a-1)*80-7.5)*Math.PI/15)},Back:function(a){return a*a*(3*a-2)},Bounce:function(a){var b,c=4;while(a<((b=Math.pow(2,--c))-1)/11);return 1/Math.pow(4,3-c)-7.5625*Math.pow((b*3-2)/22-a,2)}}),a.each(m,function(b,c){a.easing["easeIn"+b]=c,a.easing["easeOut"+b]=function(a){return 1-c(1-a)},a.easing["easeInOut"+b]=function(a){return a<.5?c(a*2)/2:c(a*-2+2)/-2+1}})}(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.blind.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.blind=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"vertical";a.effects.save(c,d),c.show();var g=a.effects.createWrapper(c).css({overflow:"hidden"}),h=f=="vertical"?"height":"width",i=f=="vertical"?g.height():g.width();e=="show"&&g.css(h,0);var j={};j[h]=e=="show"?i:0,g.animate(j,b.duration,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.bounce.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.bounce=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"effect"),f=b.options.direction||"up",g=b.options.distance||20,h=b.options.times||5,i=b.duration||250;/show|hide/.test(e)&&d.push("opacity"),a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var j=f=="up"||f=="down"?"top":"left",k=f=="up"||f=="left"?"pos":"neg",g=b.options.distance||(j=="top"?c.outerHeight(!0)/3:c.outerWidth(!0)/3);e=="show"&&c.css("opacity",0).css(j,k=="pos"?-g:g),e=="hide"&&(g=g/(h*2)),e!="hide"&&h--;if(e=="show"){var l={opacity:1};l[j]=(k=="pos"?"+=":"-=")+g,c.animate(l,i/2,b.options.easing),g=g/2,h--}for(var m=0;m
").css({position:"absolute",visibility:"visible",left:-j*(g/d),top:-i*(h/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:g/d,height:h/c,left:f.left+j*(g/d)+(b.options.mode=="show"?(j-Math.floor(d/2))*(g/d):0),top:f.top+i*(h/c)+(b.options.mode=="show"?(i-Math.floor(c/2))*(h/c):0),opacity:b.options.mode=="show"?0:1}).animate({left:f.left+j*(g/d)+(b.options.mode=="show"?0:(j-Math.floor(d/2))*(g/d)),top:f.top+i*(h/c)+(b.options.mode=="show"?0:(i-Math.floor(c/2))*(h/c)),opacity:b.options.mode=="show"?1:0},b.duration||500);setTimeout(function(){b.options.mode=="show"?e.css({visibility:"visible"}):e.css({visibility:"visible"}).hide(),b.callback&&b.callback.apply(e[0]),e.dequeue(),a("div.ui-effects-explode").remove()},b.duration||500)})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.fade.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.fade=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"hide");c.animate({opacity:d},{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.fold.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.fold=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.size||15,g=!!b.options.horizFirst,h=b.duration?b.duration/2:a.fx.speeds._default/2;a.effects.save(c,d),c.show();var i=a.effects.createWrapper(c).css({overflow:"hidden"}),j=e=="show"!=g,k=j?["width","height"]:["height","width"],l=j?[i.width(),i.height()]:[i.height(),i.width()],m=/([0-9]+)%/.exec(f);m&&(f=parseInt(m[1],10)/100*l[e=="hide"?0:1]),e=="show"&&i.css(g?{height:0,width:f}:{height:f,width:0});var n={},p={};n[k[0]]=e=="show"?l[0]:f,p[k[1]]=e=="show"?l[1]:0,i.animate(n,h,b.options.easing).animate(p,h,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.highlight.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.highlight=function(b){return this.queue(function(){var c=a(this),d=["backgroundImage","backgroundColor","opacity"],e=a.effects.setMode(c,b.options.mode||"show"),f={backgroundColor:c.css("backgroundColor")};e=="hide"&&(f.opacity=0),a.effects.save(c,d),c.show().css({backgroundImage:"none",backgroundColor:b.options.color||"#ffff99"}).animate(f,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),e=="show"&&!a.support.opacity&&this.style.removeAttribute("filter"),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.pulsate.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.pulsate=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"show"),e=(b.options.times||5)*2-1,f=b.duration?b.duration/2:a.fx.speeds._default/2,g=c.is(":visible"),h=0;g||(c.css("opacity",0).show(),h=1),(d=="hide"&&g||d=="show"&&!g)&&e--;for(var i=0;i
').appendTo(document.body).addClass(b.options.className).css({top:g.top,left:g.left,height:c.innerHeight(),width:c.innerWidth(),position:"absolute"}).animate(f,b.duration,b.options.easing,function(){h.remove(),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);; \ No newline at end of file diff --git a/demo/pacman/lib/soundmanager2.min.js b/demo/pacman/lib/soundmanager2.min.js new file mode 100644 index 0000000..c7987c1 --- /dev/null +++ b/demo/pacman/lib/soundmanager2.min.js @@ -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=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||(0opera.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&& +8opera.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;el)&&(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'}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=['', +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):"",""].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(),0a&&(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); \ No newline at end of file diff --git a/demo/pacman/sound/dies.mp3 b/demo/pacman/sound/dies.mp3 new file mode 100644 index 0000000..14c76bc Binary files /dev/null and b/demo/pacman/sound/dies.mp3 differ diff --git a/demo/pacman/sound/eatingfruit.mp3 b/demo/pacman/sound/eatingfruit.mp3 new file mode 100644 index 0000000..d63cb9e Binary files /dev/null and b/demo/pacman/sound/eatingfruit.mp3 differ diff --git a/demo/pacman/sound/eatingghost.mp3 b/demo/pacman/sound/eatingghost.mp3 new file mode 100644 index 0000000..13d25bb Binary files /dev/null and b/demo/pacman/sound/eatingghost.mp3 differ diff --git a/demo/pacman/sound/opening.mp3 b/demo/pacman/sound/opening.mp3 new file mode 100644 index 0000000..7aac980 Binary files /dev/null and b/demo/pacman/sound/opening.mp3 differ diff --git a/demo/pacman/sound/siren.mp3 b/demo/pacman/sound/siren.mp3 new file mode 100644 index 0000000..cbe9c4a Binary files /dev/null and b/demo/pacman/sound/siren.mp3 differ diff --git a/demo/pacman/sound/wakawaka.mp3 b/demo/pacman/sound/wakawaka.mp3 new file mode 100644 index 0000000..69791d3 Binary files /dev/null and b/demo/pacman/sound/wakawaka.mp3 differ diff --git a/demo/pacman/swf/soundmanager2.swf b/demo/pacman/swf/soundmanager2.swf new file mode 100644 index 0000000..b62fa6e Binary files /dev/null and b/demo/pacman/swf/soundmanager2.swf differ diff --git a/demo/pacman/swf/soundmanager2_debug.swf b/demo/pacman/swf/soundmanager2_debug.swf new file mode 100644 index 0000000..3539251 Binary files /dev/null and b/demo/pacman/swf/soundmanager2_debug.swf differ diff --git a/demo/pacman/swf/soundmanager2_flash9.swf b/demo/pacman/swf/soundmanager2_flash9.swf new file mode 100644 index 0000000..707a558 Binary files /dev/null and b/demo/pacman/swf/soundmanager2_flash9.swf differ diff --git a/demo/pacman/swf/soundmanager2_flash9_debug.swf b/demo/pacman/swf/soundmanager2_flash9_debug.swf new file mode 100644 index 0000000..370ecba Binary files /dev/null and b/demo/pacman/swf/soundmanager2_flash9_debug.swf differ diff --git a/demo/pyramid/MIT-LICENCE.txt b/demo/pyramid/MIT-LICENCE.txt new file mode 100644 index 0000000..8668d02 --- /dev/null +++ b/demo/pyramid/MIT-LICENCE.txt @@ -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. diff --git a/demo/pyramid/README.md b/demo/pyramid/README.md new file mode 100644 index 0000000..82fc1e1 --- /dev/null +++ b/demo/pyramid/README.md @@ -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/) diff --git a/demo/pyramid/css/cards.css b/demo/pyramid/css/cards.css new file mode 100644 index 0000000..2f0013a --- /dev/null +++ b/demo/pyramid/css/cards.css @@ -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; +} diff --git a/demo/pyramid/images/cards.png b/demo/pyramid/images/cards.png new file mode 100644 index 0000000..669c8d5 Binary files /dev/null and b/demo/pyramid/images/cards.png differ diff --git a/demo/pyramid/index.html b/demo/pyramid/index.html new file mode 100644 index 0000000..f1c786e --- /dev/null +++ b/demo/pyramid/index.html @@ -0,0 +1,35 @@ + + + + Pyramid.js + + + + + + + + + +
+
+ +
+
+ +
+ + + diff --git a/demo/pyramid/js/cards.js b/demo/pyramid/js/cards.js new file mode 100644 index 0000000..0c9f60d --- /dev/null +++ b/demo/pyramid/js/cards.js @@ -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(); + } +} diff --git a/demo/pyramid/js/pyramid.js b/demo/pyramid/js/pyramid.js new file mode 100644 index 0000000..8e3e88f --- /dev/null +++ b/demo/pyramid/js/pyramid.js @@ -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; + $("",{ + 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 !!!"); + } +} diff --git a/demo/pyramid/lib/jquery-1.7.1.min.js b/demo/pyramid/lib/jquery-1.7.1.min.js new file mode 100644 index 0000000..ee02337 --- /dev/null +++ b/demo/pyramid/lib/jquery-1.7.1.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/demo/sis/.gitignore b/demo/sis/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/demo/sis/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/demo/sis/MIT-LICENCE.txt b/demo/sis/MIT-LICENCE.txt new file mode 100644 index 0000000..8668d02 --- /dev/null +++ b/demo/sis/MIT-LICENCE.txt @@ -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. diff --git a/demo/sis/css/countdown.css b/demo/sis/css/countdown.css new file mode 100644 index 0000000..e057a24 --- /dev/null +++ b/demo/sis/css/countdown.css @@ -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; +} diff --git a/demo/sis/css/scoreboard.css b/demo/sis/css/scoreboard.css new file mode 100644 index 0000000..a5a15cd --- /dev/null +++ b/demo/sis/css/scoreboard.css @@ -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; +} diff --git a/demo/sis/css/spaceinvaders.css b/demo/sis/css/spaceinvaders.css new file mode 100644 index 0000000..69fb333 --- /dev/null +++ b/demo/sis/css/spaceinvaders.css @@ -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 **/ diff --git a/demo/sis/images/aliensprite.png b/demo/sis/images/aliensprite.png new file mode 100644 index 0000000..0b03048 Binary files /dev/null and b/demo/sis/images/aliensprite.png differ diff --git a/demo/sis/images/background.png b/demo/sis/images/background.png new file mode 100644 index 0000000..2724894 Binary files /dev/null and b/demo/sis/images/background.png differ diff --git a/demo/sis/images/background2.png b/demo/sis/images/background2.png new file mode 100644 index 0000000..e66b9db Binary files /dev/null and b/demo/sis/images/background2.png differ diff --git a/demo/sis/images/explosion_big.png b/demo/sis/images/explosion_big.png new file mode 100644 index 0000000..8ada14a Binary files /dev/null and b/demo/sis/images/explosion_big.png differ diff --git a/demo/sis/images/explosion_small.png b/demo/sis/images/explosion_small.png new file mode 100644 index 0000000..61588d5 Binary files /dev/null and b/demo/sis/images/explosion_small.png differ diff --git a/demo/sis/images/farm.png b/demo/sis/images/farm.png new file mode 100644 index 0000000..5d3cc1b Binary files /dev/null and b/demo/sis/images/farm.png differ diff --git a/demo/sis/images/font.png b/demo/sis/images/font.png new file mode 100644 index 0000000..d22022b Binary files /dev/null and b/demo/sis/images/font.png differ diff --git a/demo/sis/images/invader.png b/demo/sis/images/invader.png new file mode 100644 index 0000000..b48e58a Binary files /dev/null and b/demo/sis/images/invader.png differ diff --git a/demo/sis/images/ufo.png b/demo/sis/images/ufo.png new file mode 100644 index 0000000..25c7390 Binary files /dev/null and b/demo/sis/images/ufo.png differ diff --git a/demo/sis/index.html b/demo/sis/index.html new file mode 100644 index 0000000..5a30074 --- /dev/null +++ b/demo/sis/index.html @@ -0,0 +1,60 @@ + + + + + Space invaders - Story + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+ +
+ +
+ + diff --git a/demo/sis/js/animations/aliens.js b/demo/sis/js/animations/aliens.js new file mode 100644 index 0000000..c4439c1 --- /dev/null +++ b/demo/sis/js/animations/aliens.js @@ -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 + } +] + + diff --git a/demo/sis/js/animations/animations.js b/demo/sis/js/animations/animations.js new file mode 100644 index 0000000..fd34eb0 --- /dev/null +++ b/demo/sis/js/animations/animations.js @@ -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/"; \ No newline at end of file diff --git a/demo/sis/js/animations/explosions.js b/demo/sis/js/animations/explosions.js new file mode 100644 index 0000000..aadd1b0 --- /dev/null +++ b/demo/sis/js/animations/explosions.js @@ -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 + } + ] +} diff --git a/demo/sis/js/animations/worlds.js b/demo/sis/js/animations/worlds.js new file mode 100644 index 0000000..efb336d --- /dev/null +++ b/demo/sis/js/animations/worlds.js @@ -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 + }) + } + } + } + } +}; diff --git a/demo/sis/js/countdown.js b/demo/sis/js/countdown.js new file mode 100644 index 0000000..f925fd9 --- /dev/null +++ b/demo/sis/js/countdown.js @@ -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 += "
"; + } + + for(i = 0; i < String(currentSeconds).length; i++) { + imageSeconds += "
"; + } + + 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" ); + } +}; diff --git a/demo/sis/js/lettering.js b/demo/sis/js/lettering.js new file mode 100644 index 0000000..6eee851 --- /dev/null +++ b/demo/sis/js/lettering.js @@ -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 += ""; + width += 16; + count = count + 1; + } else { + if( letter.charCodeAt(0) > 47 && letter.charCodeAt(0) < 58 ) { // Numbers + letterSize = 32; + if( forceSmall ) { + letterSize = 16; + } + html += ""; + 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 += ""; + 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 += ""; + count = count + 1; + } + } + } + } + }); + t.empty().append(html); + } + } + + $.fn.lettering = function() { + return injector( $(this), '', 'char', '' ); // always pass an array + }; +})(jQuery); diff --git a/demo/sis/js/models/aliens.js b/demo/sis/js/models/aliens.js new file mode 100644 index 0000000..a731f33 --- /dev/null +++ b/demo/sis/js/models/aliens.js @@ -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 ***/ diff --git a/demo/sis/js/models/models.js b/demo/sis/js/models/models.js new file mode 100644 index 0000000..ed2b9d3 --- /dev/null +++ b/demo/sis/js/models/models.js @@ -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 ***/ diff --git a/demo/sis/js/models/waves.js b/demo/sis/js/models/waves.js new file mode 100644 index 0000000..2cf68a4 --- /dev/null +++ b/demo/sis/js/models/waves.js @@ -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 ***/ diff --git a/demo/sis/js/models/weapons.js b/demo/sis/js/models/weapons.js new file mode 100644 index 0000000..1460b95 --- /dev/null +++ b/demo/sis/js/models/weapons.js @@ -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; + } + +} \ No newline at end of file diff --git a/demo/sis/js/scoreboard.js b/demo/sis/js/scoreboard.js new file mode 100644 index 0000000..56ccdac --- /dev/null +++ b/demo/sis/js/scoreboard.js @@ -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 += "
"; + } + + 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" ); + } +}; diff --git a/demo/sis/js/spaceinvaders-core.js b/demo/sis/js/spaceinvaders-core.js new file mode 100644 index 0000000..b6c0083 --- /dev/null +++ b/demo/sis/js/spaceinvaders-core.js @@ -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) { + } + }); + } +}; diff --git a/demo/sis/js/spaceinvaders-ui.js b/demo/sis/js/spaceinvaders-ui.js new file mode 100644 index 0000000..dd58f39 --- /dev/null +++ b/demo/sis/js/spaceinvaders-ui.js @@ -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); +}); diff --git a/demo/sis/js/tools.js b/demo/sis/js/tools.js new file mode 100644 index 0000000..68e8763 --- /dev/null +++ b/demo/sis/js/tools.js @@ -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; +} \ No newline at end of file diff --git a/demo/sis/lib/gamequery-0.7.1.js b/demo/sis/lib/gamequery-0.7.1.js new file mode 100644 index 0000000..b9f6416 --- /dev/null +++ b/demo/sis/lib/gamequery-0.7.1.js @@ -0,0 +1,1849 @@ +/* + * gameQuery rev. 0.7.1 + * + * Copyright (c) 2012 Selim Arsever (http://gamequeryjs.com) + * licensed under the MIT-License + */ + +// This allows use of the convenient $ notation in a plugin +(function($) { + + // CSS Feature detection from: Craig Buckler (http://www.sitepoint.com/detect-css3-property-browser-support/) + var cssTransform = false; + + var detectElement = document.createElement("detect"), + CSSprefix = "Webkit,Moz,O,ms,Khtml".split(","), + All = ("transform," + CSSprefix.join("Transform,") + "Transform").split(","); + for (var i = 0, l = All.length; i < l; i++) { + if (detectElement.style[All[i]] === "") { + cssTransform = All[i]; + } + } + + // This prefix can be use whenever needed to namespace CSS classes, .data() inputs aso. + var gQprefix = "gQ_"; + + // Those are the possible states of the engine + var STATE_NEW = 0; // Not yet started for the first time + var STATE_RUNNING = 1; // Started and running + var STATE_PAUSED = 2; // Paused + + /** + * Utility function that returns the radius for a geometry. + * + * @param {object} elem DOM element + * @param {float} angle the angle in degrees + * @return {object} .x, .y radius of geometry + */ + var proj = function (elem, angle) { + switch (elem.geometry){ + case $.gameQuery.GEOMETRY_RECTANGLE : + var b = angle*Math.PI*2/360; + var Rx = Math.abs(Math.cos(b)*elem.width/2*elem.factor)+Math.abs(Math.sin(b)*elem.height/2*elem.factor); + var Ry = Math.abs(Math.cos(b)*elem.height/2*elem.factor)+Math.abs(Math.sin(b)*elem.width/2*elem.factor); + + return {x: Rx, y: Ry}; + } + }; + + /** + * Utility function that checks for collision between two elements. + * + * @param {object} elem1 DOM for the first element + * @param {float} offset1 offset of the first element + * @param {object} elem2 DOM for the second element + * @param {float} offset2 offset of the second element + * @return {boolean} if the two elements collide or not + */ + var collide = function(elem1, offset1, elem2, offset2) { + // test real collision (only for two rectangles...) + if((elem1.geometry == $.gameQuery.GEOMETRY_RECTANGLE && elem2.geometry == $.gameQuery.GEOMETRY_RECTANGLE)){ + + var dx = offset2.x + elem2.boundingCircle.x - elem1.boundingCircle.x - offset1.x; + var dy = offset2.y + elem2.boundingCircle.y - elem1.boundingCircle.y - offset1.y; + var a = Math.atan(dy/dx); + + var Dx = Math.abs(Math.cos(a-elem1.angle*Math.PI*2/360)/Math.cos(a)*dx); + var Dy = Math.abs(Math.sin(a-elem1.angle*Math.PI*2/360)/Math.sin(a)*dy); + + var R = proj(elem2, elem2.angle-elem1.angle); + + if((elem1.width/2*elem1.factor+R.x <= Dx) || (elem1.height/2*elem1.factor+R.y <= Dy)) { + return false; + } else { + var Dx = Math.abs(Math.cos(a-elem2.angle*Math.PI*2/360)/Math.cos(a)*-dx); + var Dy = Math.abs(Math.sin(a-elem2.angle*Math.PI*2/360)/Math.sin(a)*-dy); + + var R = proj(elem1, elem1.angle-elem2.angle); + + if((elem2.width/2*elem2.factor+R.x <= Dx) || (elem2.height/2*elem2.factor+R.y <= Dy)) { + return false; + } else { + return true; + } + } + } else { + return false; + } + }; + + /** + * Utility function computes the offset relative to the playground of a gameQuery element without using DOM's position. + * This should be faster than the standand .offset() function. + * + * Warning: No non-gameQuery elements should be present between this element and the playground div! + * + * @param {jQuery} element the jQuery wrapped DOM element representing the gameQuery object. + * @return {object} an object {x:, y: } containing the x and y offset. (Not top and left like jQuery's .offset()) + */ + var offset = function(element) { + // Get the tileSet offset (relative to the playground) + var offset = {x: 0, y: 0}; + var parent = element[0]; + + while(parent !== $.gameQuery.playground[0] && parent.gameQuery !== undefined) { + offset.x += parent.gameQuery.posx; + offset.y += parent.gameQuery.posy; + parent = parent.parentNode; + } + + return offset + } + + /** + * Utility function computes the index range of the tiles for a tilemap. + * + * @param {jQuery} element the jQuery wrapped DOM element representing the tilemap. + * @param {object} offset an object holding the x and y offset of the tilemap, this is optional and will be computed if not provided. + * @return {object} an object {firstColumn: , lastColumn: , fristRow: , lastRow: } + */ + var visibleTilemapIndexes = function (element, elementOffset) { + if (elementOffset === undefined) { + elementOffset = offset(element); + } + + var gameQuery = element[0].gameQuery; + // Activate the visible tiles + return { + firstRow: Math.max(Math.min(Math.floor(-elementOffset.y/gameQuery.height), gameQuery.sizey), 0), + lastRow: Math.max(Math.min(Math.ceil(($.gameQuery.playground[0].height-elementOffset.y)/gameQuery.height), gameQuery.sizey), 0), + firstColumn: Math.max(Math.min(Math.floor(-elementOffset.x/gameQuery.width), gameQuery.sizex), 0), + lastColumn: Math.max(Math.min(Math.ceil(($.gameQuery.playground[0].width-elementOffset.x)/gameQuery.width), gameQuery.sizex), 0) + } + } + + /** + * Utility function thast computes the buffered zone of a tilemap + * + * @param {jQuery} element the jQuery wrapped DOM element representing the tilemap. + * @param {object} visible an object describing the visible zone + * @return {object} an object {firstColumn: , lastColumn: , fristRow: , lastRow: } + */ + var bufferedTilemapIndexes = function (element, visible) { + var gameQuery = element[0].gameQuery; + + return { + firstRow: Math.max(Math.min(visible.firstRow - gameQuery.buffer, gameQuery.sizey), 0), + lastRow: Math.max(Math.min(visible.lastRow + gameQuery.buffer, gameQuery.sizey), 0), + firstColumn: Math.max(Math.min(visible.firstColumn - gameQuery.buffer, gameQuery.sizex), 0), + lastColumn: Math.max(Math.min(visible.lastColumn + gameQuery.buffer, gameQuery.sizex), 0) + } + } + + /** + * Utility function that creates a tile in the given tilemap + * + * @param {jQuery} tileSet the jQuery element representing the tile map + * @param {integer} row the row index of the tile in the tile map + * @param {integer} column the column index of the tile in the tile map + */ + var addTile = function(tileSet, row, column) { + var gameQuery = tileSet[0].gameQuery; + var name = tileSet.attr("id"); + + var tileDescription; + if(gameQuery.func) { + tileDescription = gameQuery.tiles(row,column)-1; + } else { + tileDescription = gameQuery.tiles[row][column]-1; + } + + var animation; + if(gameQuery.multi) { + animation = gameQuery.animations; + } else { + animation = gameQuery.animations[tileDescription]; + } + + if(tileDescription >= 0){ + tileSet.addSprite($.gameQuery.tileIdPrefix+name+"_"+row+"_"+column, + {width: gameQuery.width, + height: gameQuery.height, + posx: column*gameQuery.width, + posy: row*gameQuery.height, + animation: animation}); + + var newTile = tileSet.find("#"+$.gameQuery.tileIdPrefix+name+"_"+row+"_"+column); + if (gameQuery.multi) { + newTile.setAnimation(tileDescription); + } else { + newTile[0].gameQuery.animationNumber = tileDescription; + } + newTile.removeClass($.gameQuery.spriteCssClass); + newTile.addClass($.gameQuery.tileCssClass); + newTile.addClass($.gameQuery.tileTypePrefix+tileDescription); + } + } + + // Define the list of object/function accessible through $. + $.extend({ gameQuery: { + /** + * This is the Animation Object + */ + Animation: function (options, imediateCallback) { + // private default values + var defaults = { + imageURL: "", + numberOfFrame: 1, + delta: 0, + rate: 30, + type: 0, + distance: 0, + offsetx: 0, + offsety: 0 + }; + + // options extends defaults + options = $.extend(defaults, options); + + // "public" attributes: + this.imageURL = options.imageURL; // The url of the image to be used as an animation or sprite + this.numberOfFrame = options.numberOfFrame; // The number of frames to be displayed when playing the animation + this.delta = options.delta; // The distance in pixels between two frames + this.rate = options.rate; // The rate at which the frames change in miliseconds + this.type = options.type; // The type of the animation.This is a bitwise OR of the properties. + this.distance = options.distance; // The distance in pixels between two animations + this.offsetx = options.offsetx; // The x coordinate where the first sprite begins + this.offsety = options.offsety; // The y coordinate where the first sprite begins + + // Whenever a new animation is created we add it to the ResourceManager animation list + $.gameQuery.resourceManager.addAnimation(this, imediateCallback); + + return true; + }, + + /** + * "constants" for the different types of an animation + */ + ANIMATION_VERTICAL: 1, // Generated by a vertical offset of the background + ANIMATION_HORIZONTAL: 2, // Generated by a horizontal offset of the background + ANIMATION_ONCE: 4, // Played only once (else looping indefinitely) + ANIMATION_CALLBACK: 8, // A callback is exectued at the end of a cycle + ANIMATION_MULTI: 16, // The image file contains many animations + ANIMATION_PINGPONG: 32, // At the last frame of the animation it reverses (if used in conjunction with ONCE it will have no effect) + + // "constants" for the different type of geometry for a sprite + GEOMETRY_RECTANGLE: 1, + GEOMETRY_DISC: 2, + + // basic values + refreshRate: 30, + + /** + * An object to manage resource loading + */ + resourceManager: { + animations: [], // List of animations / images used in the game + sounds: [], // List of sounds used in the game + callbacks: [], // List of the functions called at each refresh + loadedAnimationsPointer: 0, // Keep track of the last loaded animation + loadedSoundsPointer: 0, // Keep track of the last loaded sound + + /** + * Load resources before starting the game. + */ + preload: function() { + // Start loading the images + for (var i = this.animations.length-1 ; i >= this.loadedAnimationsPointer; i --){ + this.animations[i].domO = new Image(); + this.animations[i].domO.src = this.animations[i].imageURL; + } + + // Start loading the sounds + for (var i = this.sounds.length-1 ; i >= this.loadedSoundsPointer; i --){ + this.sounds[i].load(); + } + + $.gameQuery.resourceManager.waitForResources(); + }, + + /** + * Wait for all the resources called for in preload() to finish loading. + */ + waitForResources: function() { + // Check the images + var imageCount = 0; + for(var i=this.loadedAnimationsPointer; i < this.animations.length; i++){ + if(this.animations[i].domO.complete){ + imageCount++; + } + } + // Check the sounds + var soundCount = 0; + for(var i=this.loadedSoundsPointer; i < this.sounds.length; i++){ + var temp = this.sounds[i].ready(); + if(temp){ + soundCount++; + } + } + // Call the load callback with the current progress + if($.gameQuery.resourceManager.loadCallback){ + var percent = (imageCount + soundCount)/(this.animations.length + this.sounds.length - this.loadedAnimationsPointer - this.loadedSoundsPointer)*100; + $.gameQuery.resourceManager.loadCallback(percent); + } + if(imageCount + soundCount < (this.animations.length + this.sounds.length - this.loadedAnimationsPointer - this.loadedSoundsPointer)){ + imgWait=setTimeout(function () { + $.gameQuery.resourceManager.waitForResources(); + }, 100); + } else { + this.loadedAnimationsPointer = this.animations.length; + this.loadedSoundsPointer = this.sounds.length; + + // All the resources are loaded! We can now associate the animation's images to their corresponding sprites + $.gameQuery.scenegraph.children().each(function(){ + // recursive call on the children: + $(this).children().each(arguments.callee); + // add the image as a background + if(this.gameQuery && this.gameQuery.animation){ + $(this).css("background-image", "url("+this.gameQuery.animation.imageURL+")"); + // we set the correct kind of repeat + if(this.gameQuery.animation.type & $.gameQuery.ANIMATION_VERTICAL) { + $(this).css("background-repeat", "repeat-x"); + } else if(this.gameQuery.animation.type & $.gameQuery.ANIMATION_HORIZONTAL) { + $(this).css("background-repeat", "repeat-y"); + } else { + $(this).css("background-repeat", "no-repeat"); + } + } + }); + + // Launch the refresh loop + if($.gameQuery.state === STATE_NEW){ + setInterval(function () { + $.gameQuery.resourceManager.refresh(); + },($.gameQuery.refreshRate)); + } + $.gameQuery.state = STATE_RUNNING; + if($.gameQuery.startCallback){ + $.gameQuery.startCallback(); + } + // Make the scenegraph visible + $.gameQuery.scenegraph.css("visibility","visible"); + } + }, + + /** + * This function refresh a unique sprite here 'this' represent a dom object + */ + refreshSprite: function() { + // Check if 'this' is a gameQuery element + if(this.gameQuery != undefined){ + var gameQuery = this.gameQuery; + // Does 'this' has an animation ? + if(gameQuery.animation){ + // Do we have anything to do? + if ( (gameQuery.idleCounter == gameQuery.animation.rate-1) && gameQuery.playing){ + + // Does 'this' loops? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_ONCE){ + if(gameQuery.currentFrame < gameQuery.animation.numberOfFrame-1){ + gameQuery.currentFrame += gameQuery.frameIncrement; + } else if(gameQuery.currentFrame == gameQuery.animation.numberOfFrame-1) { + // Does 'this' has a callback ? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_CALLBACK){ + if($.isFunction(gameQuery.callback)){ + gameQuery.callback(this); + gameQuery.callback = false; + } + } + } + } else { + if(gameQuery.animation.type & $.gameQuery.ANIMATION_PINGPONG){ + if(gameQuery.currentFrame == gameQuery.animation.numberOfFrame-1 && gameQuery.frameIncrement == 1) { + gameQuery.frameIncrement = -1; + } else if (gameQuery.currentFrame == 0 && gameQuery.frameIncrement == -1) { + gameQuery.frameIncrement = 1; + } + } + + gameQuery.currentFrame = (gameQuery.currentFrame+gameQuery.frameIncrement)%gameQuery.animation.numberOfFrame; + if(gameQuery.currentFrame == 0){ + // Does 'this' has a callback ? + if(gameQuery.animation.type & $.gameQuery.ANIMATION_CALLBACK){ + if($.isFunction(gameQuery.callback)){ + gameQuery.callback(this); + } + } + } + } + // Update the background + if((gameQuery.animation.type & $.gameQuery.ANIMATION_VERTICAL) && (gameQuery.animation.numberOfFrame > 1)){ + if(gameQuery.multi){ + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.multi)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px"); + } else { + $(this).css("background-position",""+(-gameQuery.animation.offsetx)+"px "+(-gameQuery.animation.offsety-gameQuery.animation.delta*gameQuery.currentFrame)+"px"); + } + } else if((gameQuery.animation.type & $.gameQuery.ANIMATION_HORIZONTAL) && (gameQuery.animation.numberOfFrame > 1)) { + if(gameQuery.multi){ + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety-gameQuery.multi)+"px"); + } else { + $(this).css("background-position",""+(-gameQuery.animation.offsetx-gameQuery.animation.delta*gameQuery.currentFrame)+"px "+(-gameQuery.animation.offsety)+"px"); + } + } + } + gameQuery.idleCounter = (gameQuery.idleCounter+1)%gameQuery.animation.rate; + } + } + return true; + }, + + /** + * This function refresh a unique tile-map, here 'this' represent a dom object + */ + refreshTilemap: function() { + // Check if 'this' is a gameQuery element + if(this.gameQuery != undefined){ + var gameQuery = this.gameQuery; + if($.isArray(gameQuery.frameTracker)){ + for(var i=0; i 1)){ + $(this).css("background-position",""+(-gameQuery.animations[animationNumber].offsetx)+"px "+(-gameQuery.animations[animationNumber].offsety-gameQuery.animations[animationNumber].delta*gameQuery.frameTracker[animationNumber])+"px"); + } else if((gameQuery.animations[animationNumber].type & $.gameQuery.ANIMATION_HORIZONTAL) && (gameQuery.animations[animationNumber].numberOfFrame > 1)) { + $(this).css("background-position",""+(-gameQuery.animations[animationNumber].offsetx-gameQuery.animations[animationNumber].delta*gameQuery.frameTracker[animationNumber])+"px "+(-gameQuery.animations[animationNumber].offsety)+"px"); + } + } else { + if((gameQuery.animations.type & $.gameQuery.ANIMATION_VERTICAL) && (gameQuery.animations.numberOfFrame > 1)){ + $(this).css("background-position",""+(-gameQuery.animations.offsetx-this.gameQuery.multi)+"px "+(-gameQuery.animations.offsety-gameQuery.animations.delta*gameQuery.frameTracker)+"px"); + } else if((gameQuery.animations.type & $.gameQuery.ANIMATION_HORIZONTAL) && (gameQuery.animations.numberOfFrame > 1)) { + $(this).css("background-position",""+(-gameQuery.animations.offsetx-gameQuery.animations.delta*gameQuery.frameTracker)+"px "+(-gameQuery.animations.offsety-this.gameQuery.multi)+"px"); + } + } + }); + } + return true; + }, + + /** + * Called periodically to refresh the state of the game. + */ + refresh: function() { + if($.gameQuery.state === STATE_RUNNING) { + $.gameQuery.playground.find("."+$.gameQuery.spriteCssClass).each(this.refreshSprite); + $.gameQuery.playground.find("."+$.gameQuery.tilemapCssClass).each(this.refreshTilemap); + var deadCallback= new Array(); + for (var i = this.callbacks.length-1; i >= 0; i--){ + if(this.callbacks[i].idleCounter == this.callbacks[i].rate-1){ + var returnedValue = this.callbacks[i].fn(); + if(typeof returnedValue == 'boolean'){ + // If we have a boolean: 'true' means 'no more execution', 'false' means 'keep on executing' + if(returnedValue){ + deadCallback.push(i); + } + } else if(typeof returnedValue == 'number') { + // If we have a number it re-defines the time to the next call + this.callbacks[i].rate = Math.round(returnedValue/$.gameQuery.refreshRate); + this.callbacks[i].idleCounter = 0; + } + } + this.callbacks[i].idleCounter = (this.callbacks[i].idleCounter+1)%this.callbacks[i].rate; + } + for(var i = deadCallback.length-1; i >= 0; i--){ + this.callbacks.splice(deadCallback[i],1); + } + } + }, + + /** + * Add an animation to the resource Manager + */ + addAnimation: function(animation, callback) { + if($.inArray(animation,this.animations)<0){ + //normalize the animation rate: + animation.rate = Math.round(animation.rate/$.gameQuery.refreshRate); + if(animation.rate==0){ + animation.rate = 1; + } + this.animations.push(animation); + switch ($.gameQuery.state){ + case STATE_NEW: + case STATE_PAUSED: + // Nothing to do for now + break; + case STATE_RUNNING: + // immediatly load the animation and call the callback if any + this.animations[this.loadedAnimationsPointer].domO = new Image(); + this.animations[this.loadedAnimationsPointer].domO.src = animation.imageURL; + if (callback !== undefined){ + this.animations[this.loadedAnimationsPointer].domO.onload = callback; + } + this.loadedAnimationsPointer++; + break; + } + } + }, + + /** + * Add a sound to the resource Manager + */ + addSound: function(sound, callback){ + if($.inArray(sound,this.sounds)<0){ + this.sounds.push(sound); + switch ($.gameQuery.state){ + case STATE_NEW: + case STATE_PAUSED: + // Nothing to do for now + break; + case STATE_RUNNING: + // immediatly load the sound and call the callback if any + sound.load(); + // TODO callback.... + this.loadedSoundsPointer++; + break; + } + } + }, + + /** + * Register a callback + * + * @param {function} fn the callback + * @param {integer} rate the rate in ms at which the callback should be called (should be a multiple of the playground rate or will be rounded) + */ + registerCallback: function(fn, rate){ + rate = Math.round(rate/$.gameQuery.refreshRate); + if(rate==0){ + rate = 1; + } + this.callbacks.push({fn: fn, rate: rate, idleCounter: 0}); + }, + + /** + * Clear the animations and sounds + */ + clear: function(callbacksToo){ + this.animations = []; + this.loadedAnimationsPointer = 0; + this.sounds = []; + this.loadedSoundsPointer = 0; + if(callbacksToo) { + this.callbacks = []; + } + } + }, + + /** + * This is a single place to update the underlying data of sprites/groups/tiles after a position or dimesion modification. + */ + update: function(descriptor, transformation) { + // Did we really receive a descriptor or a jQuery object instead? + if(!$.isPlainObject(descriptor)){ + // Then we must get real descriptor + if(descriptor.length > 0){ + var gameQuery = descriptor[0].gameQuery; + } else { + var gameQuery = descriptor.gameQuery; + } + } else { + var gameQuery = descriptor; + } + // If we couldn't find one we return + if(!gameQuery) return; + if(gameQuery.tileSet === true){ + // We have a tilemap + + var visible = visibleTilemapIndexes(descriptor); + var buffered = gameQuery.buffered; + + // Test what kind of transformation we have and react accordingly + for(property in transformation){ + switch(property){ + case "x": + + if(visible.lastColumn > buffered.lastColumn) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var i = gameQuery.buffered.firstRow; i < gameQuery.buffered.lastRow; i++){ + // Remove the newly invisible tiles + for(var j = gameQuery.buffered.firstColumn; j < Math.min(newBuffered.firstColumn, gameQuery.buffered.lastColumn); j++) { + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var j = Math.max(gameQuery.buffered.lastColumn,newBuffered.firstColumn); j < newBuffered.lastColumn ; j++) { + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstColumn = newBuffered.firstColumn; + gameQuery.buffered.lastColumn = newBuffered.lastColumn; + + // Attach the tilemap back + tilemap.appendTo(parent); + + } + + if(visible.firstColumn < buffered.firstColumn) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var i = gameQuery.buffered.firstRow; i < gameQuery.buffered.lastRow; i++){ + // Remove the newly invisible tiles + for(var j = Math.max(newBuffered.lastColumn,gameQuery.buffered.firstColumn); j < gameQuery.buffered.lastColumn ; j++) { + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var j = newBuffered.firstColumn; j < Math.min(gameQuery.buffered.firstColumn,newBuffered.lastColumn); j++) { + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstColumn = newBuffered.firstColumn; + gameQuery.buffered.lastColumn = newBuffered.lastColumn; + + // Attach the tilemap back + tilemap.appendTo(parent); + } + break; + + case "y": + + if(visible.lastRow > buffered.lastRow) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var j = gameQuery.buffered.firstColumn; j < gameQuery.buffered.lastColumn ; j++) { + // Remove the newly invisible tiles + for(var i = gameQuery.buffered.firstRow; i < Math.min(newBuffered.firstRow, gameQuery.buffered.lastRow); i++){ + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var i = Math.max(gameQuery.buffered.lastRow, newBuffered.firstRow); i < newBuffered.lastRow; i++){ + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstRow = newBuffered.firstRow; + gameQuery.buffered.lastRow = newBuffered.lastRow; + + // Attach the tilemap back + tilemap.appendTo(parent); + + } + + if(visible.firstRow < buffered.firstRow) { + + // Detach the tilemap + var parent = descriptor[0].parentNode; + var tilemap = descriptor.detach(); + + var newBuffered = bufferedTilemapIndexes(descriptor, visible); + for(var j = gameQuery.buffered.firstColumn; j < gameQuery.buffered.lastColumn ; j++) { + // Remove the newly invisible tiles + for(var i = Math.max(newBuffered.lastRow, gameQuery.buffered.firstRow); i < gameQuery.buffered.lastRow; i++){ + tilemap.find("#"+$.gameQuery.tileIdPrefix+descriptor.attr("id")+"_"+i+"_"+j).remove(); + } + // And add the newly visible tiles + for(var i = newBuffered.firstRow; i < Math.min(gameQuery.buffered.firstRow, newBuffered.lastRow); i++){ + addTile(tilemap,i,j); + } + } + + gameQuery.buffered.firstRow = newBuffered.firstRow; + gameQuery.buffered.lastRow = newBuffered.lastRow; + + // Attach the tilemap back + tilemap.appendTo(parent); + } + break; + + case "angle": + //TODO + break; + + case "factor": + //TODO + break; + } + } + + } else { + var refreshBoundingCircle = $.gameQuery.playground && !$.gameQuery.playground.disableCollision; + + // Update the descriptor + for(property in transformation){ + switch(property){ + case "x": + if(refreshBoundingCircle){ + gameQuery.boundingCircle.x = gameQuery.posx+gameQuery.width/2; + } + break; + case "y": + if(refreshBoundingCircle){ + gameQuery.boundingCircle.y = gameQuery.posy+gameQuery.height/2; + } + break; + case "w": + case "h": + gameQuery.boundingCircle.originalRadius = Math.sqrt(Math.pow(gameQuery.width,2) + Math.pow(gameQuery.height,2))/2 + gameQuery.boundingCircle.radius = gameQuery.factor*gameQuery.boundingCircle.originalRadius; + break; + case "angle": //(in degrees) + gameQuery.angle = parseFloat(transformation.angle); + break; + case "factor": + gameQuery.factor = parseFloat(transformation.factor); + if(refreshBoundingCircle){ + gameQuery.boundingCircle.radius = gameQuery.factor*gameQuery.boundingCircle.originalRadius; + } + break; + } + } + } + }, + // State of the engine + state: STATE_NEW, + + // CSS classes used to mark game element + spriteCssClass: gQprefix + "sprite", + groupCssClass: gQprefix + "group", + tilemapCssClass: gQprefix + "tilemap", + tileCssClass: gQprefix + "tile", + // Prefix for CSS Ids or Classes + tileTypePrefix: gQprefix + "tileType_", + tileIdPrefix: gQprefix + "tile_" + }, + + /** + * Mute (or unmute) all the sounds. + */ + muteSound: function(muted){ + for (var i = $.gameQuery.resourceManager.sounds.length-1 ; i >= 0; i --) { + $.gameQuery.resourceManager.sounds[i].muted(muted); + } + }, + + /** + * Accessor for the currently defined playground as a jQuery object + */ + playground: function() { + return $.gameQuery.playground + }, + + /** + * Define a callback called during the loading of the game's resources. + * + * The function will recieve as unique parameter + * a number representing the progess percentage. + */ + loadCallback: function(callback){ + $.gameQuery.resourceManager.loadCallback = callback; + } + }); // end of the extensio of $ + + + // fragments used to create DOM element + var spriteFragment = $("
"); + var groupFragment = $("
"); + var tilemapFragment = $("
"); + + + // Define the list of object/function accessible through $("selector"). + $.fn.extend({ + /** + * Defines the currently selected div to which contains the game and initialize it. + * + * This is a non-destructive call + */ + playground: function(options) { + if(this.length == 1){ + if(this[0] == document){ + // Old usage detected, this is not supported anymore + throw "Old playground usage, use $.playground() to retreive the playground and $('mydiv').playground(options) to set the div!"; + } + options = $.extend({ + height: 320, + width: 480, + refreshRate: 30, + position: "absolute", + keyTracker: false, + mouseTracker: false, + disableCollision: false + }, options); + // We save the playground node and set some variable for this node: + $.gameQuery.playground = this; + $.gameQuery.refreshRate = options.refreshRate; + $.gameQuery.playground[0].height = options.height; + $.gameQuery.playground[0].width = options.width; + + // We initialize the display of the div + $.gameQuery.playground.css({ + position: options.position, + display: "block", + overflow: "hidden", + height: options.height+"px", + width: options.width+"px" + }) + .append("
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/demo/sis/lib/jquery-ui-1.8.23.custom.min.js b/demo/sis/lib/jquery-ui-1.8.23.custom.min.js new file mode 100644 index 0000000..7835454 --- /dev/null +++ b/demo/sis/lib/jquery-ui-1.8.23.custom.min.js @@ -0,0 +1,125 @@ +/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.core.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.23",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;return a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a("").outerWidth(1).jquery||a.each(["Width","Height"],function(c,d){function h(b,c,d,f){return a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)}),c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?g["inner"+d].call(this):this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return typeof b!="number"?g["outer"+d].call(this,b):this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:a.expr.createPseudo?a.expr.createPseudo(function(b){return function(c){return!!a.data(c,b)}}):function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.curCSS||(a.curCSS=a.css),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!d||!a.element[0].parentNode)return;for(var e=0;e0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)},isOverAxis:function(a,b,c){return a>b&&a=9||!!b.button?this._mouseStarted?(this._mouseDrag(b),b.preventDefault()):(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b)),!this._mouseStarted):this._mouseUp(b)},_mouseUp:function(b){return a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b)),!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.position.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.ui=a.ui||{};var c=/left|center|right/,d=/top|center|bottom/,e="center",f={},g=a.fn.position,h=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return g.apply(this,arguments);b=a.extend({},b);var h=a(b.of),i=h[0],j=(b.collision||"flip").split(" "),k=b.offset?b.offset.split(" "):[0,0],l,m,n;return i.nodeType===9?(l=h.width(),m=h.height(),n={top:0,left:0}):i.setTimeout?(l=h.width(),m=h.height(),n={top:h.scrollTop(),left:h.scrollLeft()}):i.preventDefault?(b.at="left top",l=m=0,n={top:b.of.pageY,left:b.of.pageX}):(l=h.outerWidth(),m=h.outerHeight(),n=h.offset()),a.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),j.length===1&&(j[1]=j[0]),k[0]=parseInt(k[0],10)||0,k.length===1&&(k[1]=k[0]),k[1]=parseInt(k[1],10)||0,b.at[0]==="right"?n.left+=l:b.at[0]===e&&(n.left+=l/2),b.at[1]==="bottom"?n.top+=m:b.at[1]===e&&(n.top+=m/2),n.left+=k[0],n.top+=k[1],this.each(function(){var c=a(this),d=c.outerWidth(),g=c.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,i=parseInt(a.curCSS(this,"marginTop",!0))||0,o=d+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),p=g+i+(parseInt(a.curCSS(this,"marginBottom",!0))||0),q=a.extend({},n),r;b.my[0]==="right"?q.left-=d:b.my[0]===e&&(q.left-=d/2),b.my[1]==="bottom"?q.top-=g:b.my[1]===e&&(q.top-=g/2),f.fractions||(q.left=Math.round(q.left),q.top=Math.round(q.top)),r={left:q.left-h,top:q.top-i},a.each(["left","top"],function(c,e){a.ui.position[j[c]]&&a.ui.position[j[c]][e](q,{targetWidth:l,targetHeight:m,elemWidth:d,elemHeight:g,collisionPosition:r,collisionWidth:o,collisionHeight:p,offset:k,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(q,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]===e)return;var d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0},top:function(b,c){if(c.at[1]===e)return;var d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var c=this[0];return!c||!c.ownerDocument?null:b?a.isFunction(b)?this.each(function(c){a(this).offset(b.call(this,c,a(this).offset()))}):this.each(function(){a.offset.setOffset(this,b)}):h.call(this)}),a.curCSS||(a.curCSS=a.css),function(){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d,e,g,h,i;d=document.createElement(b?"div":"body"),g={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},b&&a.extend(g,{position:"absolute",left:"-1000px",top:"-1000px"});for(var j in g)d.style[j]=g[j];d.appendChild(c),e=b||document.documentElement,e.insertBefore(d,e.firstChild),c.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;",h=a(c).offset(function(a,b){return b}).offset(),d.innerHTML="",e.removeChild(d),i=h.top+h.left+(b?2e3:0),f.fractions=i>21&&i<22}()})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.draggable.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},destroy:function(){if(!this.element.data("draggable"))return;return this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy(),this},_mouseCapture:function(b){var c=this.options;return this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(b),this.handle?(c.iframeFix&&a(c.iframeFix===!0?"iframe":c.iframeFix).each(function(){a('
').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(a(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(b){var c=this.options;return this.helper=this._createHelper(b),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),a.ui.ddmanager&&(a.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt),c.containment&&this._setContainment(),this._trigger("start",b)===!1?(this._clear(),!1):(this._cacheHelperProportions(),a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this._mouseDrag(b,!0),a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,b),!0)},_mouseDrag:function(b,c){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute");if(!c){var d=this._uiHash();if(this._trigger("drag",b,d)===!1)return this._mouseUp({}),!1;this.position=d.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),!1},_mouseStop:function(b){var c=!1;a.ui.ddmanager&&!this.options.dropBehaviour&&(c=a.ui.ddmanager.drop(this,b)),this.dropped&&(c=this.dropped,this.dropped=!1);var d=this.element[0],e=!1;while(d&&(d=d.parentNode))d==document&&(e=!0);if(!e&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!c||this.options.revert=="valid"&&c||this.options.revert===!0||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,c)){var f=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){f._trigger("stop",b)!==!1&&f._clear()})}else this._trigger("stop",b)!==!1&&this._clear();return!1},_mouseUp:function(b){return this.options.iframeFix===!0&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,b),a.ui.mouse.prototype._mouseUp.call(this,b)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(b){var c=!this.options.handle||!a(this.options.handle,this.element).length?!0:!1;return a(this.options.handle,this.element).find("*").andSelf().each(function(){this==b.target&&(c=!0)}),c},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b])):c.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return d.parents("body").length||d.appendTo(c.appendTo=="parent"?this.element[0].parentNode:c.appendTo),d[0]!=this.element[0]&&!/(fixed|absolute)/.test(d.css("position"))&&d.css("position","absolute"),d},_adjustOffsetFromHelper:function(b){typeof b=="string"&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[b.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,b.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(b.containment=="document"?0:a(window).scrollLeft())+a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(b.containment=="document"?0:a(window).scrollTop())+(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)&&b.containment.constructor!=Array){var c=a(b.containment),d=c[0];if(!d)return;var e=c.offset(),f=a(d).css("overflow")!="hidden";this.containment=[(parseInt(a(d).css("borderLeftWidth"),10)||0)+(parseInt(a(d).css("paddingLeft"),10)||0),(parseInt(a(d).css("borderTopWidth"),10)||0)+(parseInt(a(d).css("paddingTop"),10)||0),(f?Math.max(d.scrollWidth,d.offsetWidth):d.offsetWidth)-(parseInt(a(d).css("borderLeftWidth"),10)||0)-(parseInt(a(d).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(f?Math.max(d.scrollHeight,d.offsetHeight):d.offsetHeight)-(parseInt(a(d).css("borderTopWidth"),10)||0)-(parseInt(a(d).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=c}else b.containment.constructor==Array&&(this.containment=b.containment)},_convertPositionTo:function(b,c){c||(c=this.position);var d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName),f=b.pageX,g=b.pageY;if(this.originalPosition){var h;if(this.containment){if(this.relative_container){var i=this.relative_container.offset();h=[this.containment[0]+i.left,this.containment[1]+i.top,this.containment[2]+i.left,this.containment[3]+i.top]}else h=this.containment;b.pageX-this.offset.click.lefth[2]&&(f=h[2]+this.offset.click.left),b.pageY-this.offset.click.top>h[3]&&(g=h[3]+this.offset.click.top)}if(c.grid){var j=c.grid[1]?this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1]:this.originalPageY;g=h?j-this.offset.click.toph[3]?j-this.offset.click.toph[2]?k-this.offset.click.left=0;k--){var l=d.snapElements[k].left,m=l+d.snapElements[k].width,n=d.snapElements[k].top,o=n+d.snapElements[k].height;if(!(l-f=k&&g<=l||h>=k&&h<=l||gl)&&(e>=i&&e<=j||f>=i&&f<=j||ej);default:return!1}},a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(b,c){var d=a.ui.ddmanager.droppables[b.options.scope]||[],e=c?c.type:null,f=(b.currentItem||b.element).find(":data(droppable)").andSelf();g:for(var h=0;h
').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=c.handles||(a(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var d=this.handles.split(",");this.handles={};for(var e=0;e');h.css({zIndex:c.zIndex}),"se"==f&&h.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[f]=".ui-resizable-"+f,this.element.append(h)}}this._renderAxis=function(b){b=b||this.element;for(var c in this.handles){this.handles[c].constructor==String&&(this.handles[c]=a(this.handles[c],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var d=a(this.handles[c],this.element),e=0;e=/sw|ne|nw|se|n|s/.test(c)?d.outerHeight():d.outerWidth();var f=["padding",/ne|nw|n/.test(c)?"Top":/se|sw|s/.test(c)?"Bottom":/^e$/.test(c)?"Right":"Left"].join("");b.css(f,e),this._proportionallyResize()}if(!a(this.handles[c]).length)continue}},this._renderAxis(this.element),this._handles=a(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!b.resizing){if(this.className)var a=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=a&&a[1]?a[1]:"se"}}),c.autoHide&&(this._handles.hide(),a(this.element).addClass("ui-resizable-autohide").hover(function(){if(c.disabled)return;a(this).removeClass("ui-resizable-autohide"),b._handles.show()},function(){if(c.disabled)return;b.resizing||(a(this).addClass("ui-resizable-autohide"),b._handles.hide())})),this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(b){a(b).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var c=this.element;c.after(this.originalElement.css({position:c.css("position"),width:c.outerWidth(),height:c.outerHeight(),top:c.css("top"),left:c.css("left")})).remove()}return this.originalElement.css("resize",this.originalResizeStyle),b(this.originalElement),this},_mouseCapture:function(b){var c=!1;for(var d in this.handles)a(this.handles[d])[0]==b.target&&(c=!0);return!this.options.disabled&&c},_mouseStart:function(b){var d=this.options,e=this.element.position(),f=this.element;this.resizing=!0,this.documentScroll={top:a(document).scrollTop(),left:a(document).scrollLeft()},(f.is(".ui-draggable")||/absolute/.test(f.css("position")))&&f.css({position:"absolute",top:e.top,left:e.left}),this._renderProxy();var g=c(this.helper.css("left")),h=c(this.helper.css("top"));d.containment&&(g+=a(d.containment).scrollLeft()||0,h+=a(d.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:g,top:h},this.size=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalSize=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalPosition={left:g,top:h},this.sizeDiff={width:f.outerWidth()-f.width(),height:f.outerHeight()-f.height()},this.originalMousePosition={left:b.pageX,top:b.pageY},this.aspectRatio=typeof d.aspectRatio=="number"?d.aspectRatio:this.originalSize.width/this.originalSize.height||1;var i=a(".ui-resizable-"+this.axis).css("cursor");return a("body").css("cursor",i=="auto"?this.axis+"-resize":i),f.addClass("ui-resizable-resizing"),this._propagate("start",b),!0},_mouseDrag:function(b){var c=this.helper,d=this.options,e={},f=this,g=this.originalMousePosition,h=this.axis,i=b.pageX-g.left||0,j=b.pageY-g.top||0,k=this._change[h];if(!k)return!1;var l=k.apply(this,[b,i,j]),m=a.browser.msie&&a.browser.version<7,n=this.sizeDiff;this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)l=this._updateRatio(l,b);return l=this._respectSize(l,b),this._propagate("resize",b),c.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",b,this.ui()),!1},_mouseStop:function(b){this.resizing=!1;var c=this.options,d=this;if(this._helper){var e=this._proportionallyResizeElements,f=e.length&&/textarea/i.test(e[0].nodeName),g=f&&a.ui.hasScroll(e[0],"left")?0:d.sizeDiff.height,h=f?0:d.sizeDiff.width,i={width:d.helper.width()-h,height:d.helper.height()-g},j=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,k=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;c.animate||this.element.css(a.extend(i,{top:k,left:j})),d.helper.height(d.size.height),d.helper.width(d.size.width),this._helper&&!c.animate&&this._proportionallyResize()}return a("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",b),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(a){var b=this.options,c,e,f,g,h;h={minWidth:d(b.minWidth)?b.minWidth:0,maxWidth:d(b.maxWidth)?b.maxWidth:Infinity,minHeight:d(b.minHeight)?b.minHeight:0,maxHeight:d(b.maxHeight)?b.maxHeight:Infinity};if(this._aspectRatio||a)c=h.minHeight*this.aspectRatio,f=h.minWidth/this.aspectRatio,e=h.maxHeight*this.aspectRatio,g=h.maxWidth/this.aspectRatio,c>h.minWidth&&(h.minWidth=c),f>h.minHeight&&(h.minHeight=f),ea.width,k=d(a.height)&&e.minHeight&&e.minHeight>a.height;j&&(a.width=e.minWidth),k&&(a.height=e.minHeight),h&&(a.width=e.maxWidth),i&&(a.height=e.maxHeight);var l=this.originalPosition.left+this.originalSize.width,m=this.position.top+this.size.height,n=/sw|nw|w/.test(g),o=/nw|ne|n/.test(g);j&&n&&(a.left=l-e.minWidth),h&&n&&(a.left=l-e.maxWidth),k&&o&&(a.top=m-e.minHeight),i&&o&&(a.top=m-e.maxHeight);var p=!a.width&&!a.height;return p&&!a.left&&a.top?a.top=null:p&&!a.top&&a.left&&(a.left=null),a},_proportionallyResize:function(){var b=this.options;if(!this._proportionallyResizeElements.length)return;var c=this.helper||this.element;for(var d=0;d');var d=a.browser.msie&&a.browser.version<7,e=d?1:0,f=d?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+f,height:this.element.outerHeight()+f,position:"absolute",left:this.elementOffset.left-e+"px",top:this.elementOffset.top-e+"px",zIndex:++c.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(a,b,c){return{width:this.originalSize.width+b}},w:function(a,b,c){var d=this.options,e=this.originalSize,f=this.originalPosition;return{left:f.left+b,width:e.width-b}},n:function(a,b,c){var d=this.options,e=this.originalSize,f=this.originalPosition;return{top:f.top+c,height:e.height-c}},s:function(a,b,c){return{height:this.originalSize.height+c}},se:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},sw:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,c,d]))},ne:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},nw:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,c,d]))}},_propagate:function(b,c){a.ui.plugin.call(this,b,[c,this.ui()]),b!="resize"&&this._trigger(b,c,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),a.extend(a.ui.resizable,{version:"1.8.23"}),a.ui.plugin.add("resizable","alsoResize",{start:function(b,c){var d=a(this).data("resizable"),e=d.options,f=function(b){a(b).each(function(){var b=a(this);b.data("resizable-alsoresize",{width:parseInt(b.width(),10),height:parseInt(b.height(),10),left:parseInt(b.css("left"),10),top:parseInt(b.css("top"),10)})})};typeof e.alsoResize=="object"&&!e.alsoResize.parentNode?e.alsoResize.length?(e.alsoResize=e.alsoResize[0],f(e.alsoResize)):a.each(e.alsoResize,function(a){f(a)}):f(e.alsoResize)},resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.originalSize,g=d.originalPosition,h={height:d.size.height-f.height||0,width:d.size.width-f.width||0,top:d.position.top-g.top||0,left:d.position.left-g.left||0},i=function(b,d){a(b).each(function(){var b=a(this),e=a(this).data("resizable-alsoresize"),f={},g=d&&d.length?d:b.parents(c.originalElement[0]).length?["width","height"]:["width","height","top","left"];a.each(g,function(a,b){var c=(e[b]||0)+(h[b]||0);c&&c>=0&&(f[b]=c||null)}),b.css(f)})};typeof e.alsoResize=="object"&&!e.alsoResize.nodeType?a.each(e.alsoResize,function(a,b){i(a,b)}):i(e.alsoResize)},stop:function(b,c){a(this).removeData("resizable-alsoresize")}}),a.ui.plugin.add("resizable","animate",{stop:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d._proportionallyResizeElements,g=f.length&&/textarea/i.test(f[0].nodeName),h=g&&a.ui.hasScroll(f[0],"left")?0:d.sizeDiff.height,i=g?0:d.sizeDiff.width,j={width:d.size.width-i,height:d.size.height-h},k=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,l=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;d.element.animate(a.extend(j,l&&k?{top:l,left:k}:{}),{duration:e.animateDuration,easing:e.animateEasing,step:function(){var c={width:parseInt(d.element.css("width"),10),height:parseInt(d.element.css("height"),10),top:parseInt(d.element.css("top"),10),left:parseInt(d.element.css("left"),10)};f&&f.length&&a(f[0]).css({width:c.width,height:c.height}),d._updateCache(c),d._propagate("resize",b)}})}}),a.ui.plugin.add("resizable","containment",{start:function(b,d){var e=a(this).data("resizable"),f=e.options,g=e.element,h=f.containment,i=h instanceof a?h.get(0):/parent/.test(h)?g.parent().get(0):h;if(!i)return;e.containerElement=a(i);if(/document/.test(h)||h==document)e.containerOffset={left:0,top:0},e.containerPosition={left:0,top:0},e.parentData={element:a(document),left:0,top:0,width:a(document).width(),height:a(document).height()||document.body.parentNode.scrollHeight};else{var j=a(i),k=[];a(["Top","Right","Left","Bottom"]).each(function(a,b){k[a]=c(j.css("padding"+b))}),e.containerOffset=j.offset(),e.containerPosition=j.position(),e.containerSize={height:j.innerHeight()-k[3],width:j.innerWidth()-k[1]};var l=e.containerOffset,m=e.containerSize.height,n=e.containerSize.width,o=a.ui.hasScroll(i,"left")?i.scrollWidth:n,p=a.ui.hasScroll(i)?i.scrollHeight:m;e.parentData={element:i,left:l.left,top:l.top,width:o,height:p}}},resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.containerSize,g=d.containerOffset,h=d.size,i=d.position,j=d._aspectRatio||b.shiftKey,k={top:0,left:0},l=d.containerElement;l[0]!=document&&/static/.test(l.css("position"))&&(k=g),i.left<(d._helper?g.left:0)&&(d.size.width=d.size.width+(d._helper?d.position.left-g.left:d.position.left-k.left),j&&(d.size.height=d.size.width/d.aspectRatio),d.position.left=e.helper?g.left:0),i.top<(d._helper?g.top:0)&&(d.size.height=d.size.height+(d._helper?d.position.top-g.top:d.position.top),j&&(d.size.width=d.size.height*d.aspectRatio),d.position.top=d._helper?g.top:0),d.offset.left=d.parentData.left+d.position.left,d.offset.top=d.parentData.top+d.position.top;var m=Math.abs((d._helper?d.offset.left-k.left:d.offset.left-k.left)+d.sizeDiff.width),n=Math.abs((d._helper?d.offset.top-k.top:d.offset.top-g.top)+d.sizeDiff.height),o=d.containerElement.get(0)==d.element.parent().get(0),p=/relative|absolute/.test(d.containerElement.css("position"));o&&p&&(m-=d.parentData.left),m+d.size.width>=d.parentData.width&&(d.size.width=d.parentData.width-m,j&&(d.size.height=d.size.width/d.aspectRatio)),n+d.size.height>=d.parentData.height&&(d.size.height=d.parentData.height-n,j&&(d.size.width=d.size.height*d.aspectRatio))},stop:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.position,g=d.containerOffset,h=d.containerPosition,i=d.containerElement,j=a(d.helper),k=j.offset(),l=j.outerWidth()-d.sizeDiff.width,m=j.outerHeight()-d.sizeDiff.height;d._helper&&!e.animate&&/relative/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m}),d._helper&&!e.animate&&/static/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m})}}),a.ui.plugin.add("resizable","ghost",{start:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.size;d.ghost=d.originalElement.clone(),d.ghost.css({opacity:.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof e.ghost=="string"?e.ghost:""),d.ghost.appendTo(d.helper)},resize:function(b,c){var d=a(this).data("resizable"),e=d.options;d.ghost&&d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})},stop:function(b,c){var d=a(this).data("resizable"),e=d.options;d.ghost&&d.helper&&d.helper.get(0).removeChild(d.ghost.get(0))}}),a.ui.plugin.add("resizable","grid",{resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.size,g=d.originalSize,h=d.originalPosition,i=d.axis,j=e._aspectRatio||b.shiftKey;e.grid=typeof e.grid=="number"?[e.grid,e.grid]:e.grid;var k=Math.round((f.width-g.width)/(e.grid[0]||1))*(e.grid[0]||1),l=Math.round((f.height-g.height)/(e.grid[1]||1))*(e.grid[1]||1);/^(se|s|e)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l):/^(ne)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l):/^(sw)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.left=h.left-k):(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l,d.position.left=h.left-k)}});var c=function(a){return parseInt(a,10)||0},d=function(a){return!isNaN(parseInt(a,10))}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.selectable.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.widget("ui.selectable",a.ui.mouse,{options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var b=this;this.element.addClass("ui-selectable"),this.dragged=!1;var c;this.refresh=function(){c=a(b.options.filter,b.element[0]),c.addClass("ui-selectee"),c.each(function(){var b=a(this),c=b.offset();a.data(this,"selectable-item",{element:this,$element:b,left:c.left,top:c.top,right:c.left+b.outerWidth(),bottom:c.top+b.outerHeight(),startselected:!1,selected:b.hasClass("ui-selected"),selecting:b.hasClass("ui-selecting"),unselecting:b.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=c.addClass("ui-selectee"),this._mouseInit(),this.helper=a("
")},destroy:function(){return this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable"),this._mouseDestroy(),this},_mouseStart:function(b){var c=this;this.opos=[b.pageX,b.pageY];if(this.options.disabled)return;var d=this.options;this.selectees=a(d.filter,this.element[0]),this._trigger("start",b),a(d.appendTo).append(this.helper),this.helper.css({left:b.clientX,top:b.clientY,width:0,height:0}),d.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var d=a.data(this,"selectable-item");d.startselected=!0,!b.metaKey&&!b.ctrlKey&&(d.$element.removeClass("ui-selected"),d.selected=!1,d.$element.addClass("ui-unselecting"),d.unselecting=!0,c._trigger("unselecting",b,{unselecting:d.element}))}),a(b.target).parents().andSelf().each(function(){var d=a.data(this,"selectable-item");if(d){var e=!b.metaKey&&!b.ctrlKey||!d.$element.hasClass("ui-selected");return d.$element.removeClass(e?"ui-unselecting":"ui-selected").addClass(e?"ui-selecting":"ui-unselecting"),d.unselecting=!e,d.selecting=e,d.selected=e,e?c._trigger("selecting",b,{selecting:d.element}):c._trigger("unselecting",b,{unselecting:d.element}),!1}})},_mouseDrag:function(b){var c=this;this.dragged=!0;if(this.options.disabled)return;var d=this.options,e=this.opos[0],f=this.opos[1],g=b.pageX,h=b.pageY;if(e>g){var i=g;g=e,e=i}if(f>h){var i=h;h=f,f=i}return this.helper.css({left:e,top:f,width:g-e,height:h-f}),this.selectees.each(function(){var i=a.data(this,"selectable-item");if(!i||i.element==c.element[0])return;var j=!1;d.tolerance=="touch"?j=!(i.left>g||i.righth||i.bottome&&i.rightf&&i.bottom *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var a=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},destroy:function(){a.Widget.prototype.destroy.call(this),this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var b=this.items.length-1;b>=0;b--)this.items[b].item.removeData(this.widgetName+"-item");return this},_setOption:function(b,c){b==="disabled"?(this.options[b]=c,this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){var d=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(b);var e=null,f=this,g=a(b.target).parents().each(function(){if(a.data(this,d.widgetName+"-item")==f)return e=a(this),!1});a.data(b.target,d.widgetName+"-item")==f&&(e=a(b.target));if(!e)return!1;if(this.options.handle&&!c){var h=!1;a(this.options.handle,e).find("*").andSelf().each(function(){this==b.target&&(h=!0)});if(!h)return!1}return this.currentItem=e,this._removeCurrentsFromItems(),!0},_mouseStart:function(b,c,d){var e=this.options,f=this;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(b),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,e.cursorAt&&this._adjustOffsetFromHelper(e.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),e.containment&&this._setContainment(),e.cursor&&(a("body").css("cursor")&&(this._storedCursor=a("body").css("cursor")),a("body").css("cursor",e.cursor)),e.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",e.opacity)),e.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",e.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",b,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!d)for(var g=this.containers.length-1;g>=0;g--)this.containers[g]._trigger("activate",b,f._uiHash(this));return a.ui.ddmanager&&(a.ui.ddmanager.current=this),a.ui.ddmanager&&!e.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(b),!0},_mouseDrag:function(b){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var c=this.options,d=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY=0;e--){var f=this.items[e],g=f.item[0],h=this._intersectsWithPointer(f);if(!h)continue;if(g!=this.currentItem[0]&&this.placeholder[h==1?"next":"prev"]()[0]!=g&&!a.ui.contains(this.placeholder[0],g)&&(this.options.type=="semi-dynamic"?!a.ui.contains(this.element[0],g):!0)){this.direction=h==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(f))this._rearrange(b,f);else break;this._trigger("change",b,this._uiHash());break}}return this._contactContainers(b),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),this._trigger("sort",b,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(b,c){if(!b)return;a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b);if(this.options.revert){var d=this,e=d.placeholder.offset();d.reverting=!0,a(this.helper).animate({left:e.left-this.offset.parent.left-d.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:e.top-this.offset.parent.top-d.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1},cancel:function(){var b=this;if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("deactivate",null,b._uiHash(this)),this.containers[c].containerCache.over&&(this.containers[c]._trigger("out",null,b._uiHash(this)),this.containers[c].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))}),!d.length&&b.key&&d.push(b.key+"="),d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},c.each(function(){d.push(a(b.item||this).attr(b.attribute||"id")||"")}),d},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,d=this.positionAbs.top,e=d+this.helperProportions.height,f=a.left,g=f+a.width,h=a.top,i=h+a.height,j=this.offset.click.top,k=this.offset.click.left,l=d+j>h&&d+jf&&b+ka[this.floating?"width":"height"]?l:f0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){return this._refreshItems(a),this.refreshPositions(),this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c=this,d=[],e=[],f=this._connectWith();if(f&&b)for(var g=f.length-1;g>=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&e.push([a.isFunction(j.options.items)?j.options.items.call(j.element):a(j.options.items,j.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),j])}}e.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var g=e.length-1;g>=0;g--)e[g][0].each(function(){d.push(this)});return a(d)},_removeCurrentsFromItems:function(){var a=this.currentItem.find(":data("+this.widgetName+"-item)");for(var b=0;b=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&(e.push([a.isFunction(j.options.items)?j.options.items.call(j.element[0],b,{item:this.currentItem}):a(j.options.items,j.element),j]),this.containers.push(j))}}for(var g=e.length-1;g>=0;g--){var k=e[g][1],l=e[g][0];for(var i=0,m=l.length;i=0;c--){var d=this.items[c];if(d.instance!=this.currentContainer&&this.currentContainer&&d.item[0]!=this.currentItem[0])continue;var e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item;b||(d.width=e.outerWidth(),d.height=e.outerHeight());var f=e.offset();d.left=f.left,d.top=f.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var c=this.containers.length-1;c>=0;c--){var f=this.containers[c].element.offset();this.containers[c].containerCache.left=f.left,this.containers[c].containerCache.top=f.top,this.containers[c].containerCache.width=this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight()}return this},_createPlaceholder:function(b){var c=b||this,d=c.options;if(!d.placeholder||d.placeholder.constructor==String){var e=d.placeholder;d.placeholder={element:function(){var b=a(document.createElement(c.currentItem[0].nodeName)).addClass(e||c.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return e||(b.style.visibility="hidden"),b},update:function(a,b){if(e&&!d.forcePlaceholderSize)return;b.height()||b.height(c.currentItem.innerHeight()-parseInt(c.currentItem.css("paddingTop")||0,10)-parseInt(c.currentItem.css("paddingBottom")||0,10)),b.width()||b.width(c.currentItem.innerWidth()-parseInt(c.currentItem.css("paddingLeft")||0,10)-parseInt(c.currentItem.css("paddingRight")||0,10))}}}c.placeholder=a(d.placeholder.element.call(c.element,c.currentItem)),c.currentItem.after(c.placeholder),d.placeholder.update(c,c.placeholder)},_contactContainers:function(b){var c=null,d=null;for(var e=this.containers.length-1;e>=0;e--){if(a.ui.contains(this.currentItem[0],this.containers[e].element[0]))continue;if(this._intersectsWith(this.containers[e].containerCache)){if(c&&a.ui.contains(this.containers[e].element[0],c.element[0]))continue;c=this.containers[e],d=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",b,this._uiHash(this)),this.containers[e].containerCache.over=0)}if(!c)return;if(this.containers.length===1)this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1;else if(this.currentContainer!=this.containers[d]){var f=1e4,g=null,h=this.positionAbs[this.containers[d].floating?"left":"top"];for(var i=this.items.length-1;i>=0;i--){if(!a.ui.contains(this.containers[d].element[0],this.items[i].item[0]))continue;var j=this.containers[d].floating?this.items[i].item.offset().left:this.items[i].item.offset().top;Math.abs(j-h)0?"down":"up")}if(!g&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[d],g?this._rearrange(b,g,null,!0):this._rearrange(b,null,this.containers[d].element,!0),this._trigger("change",b,this._uiHash()),this.containers[d]._trigger("change",b,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1}},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b,this.currentItem])):c.helper=="clone"?this.currentItem.clone():this.currentItem;return d.parents("body").length||a(c.appendTo!="parent"?c.appendTo:this.currentItem[0].parentNode)[0].appendChild(d[0]),d[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(d[0].style.width==""||c.forceHelperSize)&&d.width(this.currentItem.width()),(d[0].style.height==""||c.forceHelperSize)&&d.height(this.currentItem.height()),d},_adjustOffsetFromHelper:function(b){typeof b=="string"&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)){var c=a(b.containment)[0],d=a(b.containment).offset(),e=a(c).css("overflow")!="hidden";this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,d.left+(e?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,d.top+(e?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(b,c){c||(c=this.position);var d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var f=b.pageX,g=b.pageY;if(this.originalPosition){this.containment&&(b.pageX-this.offset.click.leftthis.containment[2]&&(f=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(g=this.containment[3]+this.offset.click.top));if(c.grid){var h=this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1];g=this.containment?h-this.offset.click.topthis.containment[3]?h-this.offset.click.topthis.containment[2]?i-this.offset.click.left=0;f--)a.ui.contains(this.containers[f].element[0],this.currentItem[0])&&!c&&(d.push(function(a){return function(b){a._trigger("receive",b,this._uiHash(this))}}.call(this,this.containers[f])),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.containers[f])))}for(var f=this.containers.length-1;f>=0;f--)c||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over&&(d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over=0);this._storedCursor&&a("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!c){this._trigger("beforeStop",b,this._uiHash());for(var f=0;f li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var b=this,c=b.options;b.running=0,b.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix"),b.headers=b.element.find(c.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){if(c.disabled)return;a(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){if(c.disabled)return;a(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){if(c.disabled)return;a(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){if(c.disabled)return;a(this).removeClass("ui-state-focus")}),b.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");if(c.navigation){var d=b.element.find("a").filter(c.navigationFilter).eq(0);if(d.length){var e=d.closest(".ui-accordion-header");e.length?b.active=e:b.active=d.closest(".ui-accordion-content").prev()}}b.active=b._findActive(b.active||c.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"),b.active.next().addClass("ui-accordion-content-active"),b._createIcons(),b.resize(),b.element.attr("role","tablist"),b.headers.attr("role","tab").bind("keydown.accordion",function(a){return b._keydown(a)}).next().attr("role","tabpanel"),b.headers.not(b.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide(),b.active.length?b.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):b.headers.eq(0).attr("tabIndex",0),a.browser.safari||b.headers.find("a").attr("tabIndex",-1),c.event&&b.headers.bind(c.event.split(" ").join(".accordion ")+".accordion",function(a){b._clickHandler.call(b,a,this),a.preventDefault()})},_createIcons:function(){var b=this.options;b.icons&&(a("").addClass("ui-icon "+b.icons.header).prependTo(this.headers),this.active.children(".ui-icon").toggleClass(b.icons.header).toggleClass(b.icons.headerSelected),this.element.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.children(".ui-icon").remove(),this.element.removeClass("ui-accordion-icons")},destroy:function(){var b=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex"),this.headers.find("a").removeAttr("tabIndex"),this._destroyIcons();var c=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");return(b.autoHeight||b.fillHeight)&&c.css("height",""),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments),b=="active"&&this.activate(c),b=="icons"&&(this._destroyIcons(),c&&this._createIcons()),b=="disabled"&&this.headers.add(this.headers.next())[c?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(b){if(this.options.disabled||b.altKey||b.ctrlKey)return;var c=a.ui.keyCode,d=this.headers.length,e=this.headers.index(b.target),f=!1;switch(b.keyCode){case c.RIGHT:case c.DOWN:f=this.headers[(e+1)%d];break;case c.LEFT:case c.UP:f=this.headers[(e-1+d)%d];break;case c.SPACE:case c.ENTER:this._clickHandler({target:b.target},b.target),b.preventDefault()}return f?(a(b.target).attr("tabIndex",-1),a(f).attr("tabIndex",0),f.focus(),!1):!0},resize:function(){var b=this.options,c;if(b.fillSpace){if(a.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}c=this.element.parent().height(),a.browser.msie&&this.element.parent().css("overflow",d),this.headers.each(function(){c-=a(this).outerHeight(!0)}),this.headers.next().each(function(){a(this).height(Math.max(0,c-a(this).innerHeight()+a(this).height()))}).css("overflow","auto")}else b.autoHeight&&(c=0,this.headers.next().each(function(){c=Math.max(c,a(this).height("").height())}).height(c));return this},activate:function(a){this.options.active=a;var b=this._findActive(a)[0];return this._clickHandler({target:b},b),this},_findActive:function(b){return b?typeof b=="number"?this.headers.filter(":eq("+b+")"):this.headers.not(this.headers.not(b)):b===!1?a([]):this.headers.filter(":eq(0)")},_clickHandler:function(b,c){var d=this.options;if(d.disabled)return;if(!b.target){if(!d.collapsible)return;this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header),this.active.next().addClass("ui-accordion-content-active");var e=this.active.next(),f={options:d,newHeader:a([]),oldHeader:d.active,newContent:a([]),oldContent:e},g=this.active=a([]);this._toggle(g,e,f);return}var h=a(b.currentTarget||c),i=h[0]===this.active[0];d.active=d.collapsible&&i?!1:this.headers.index(h);if(this.running||!d.collapsible&&i)return;var j=this.active,g=h.next(),e=this.active.next(),f={options:d,newHeader:i&&d.collapsible?a([]):h,oldHeader:this.active,newContent:i&&d.collapsible?a([]):g,oldContent:e},k=this.headers.index(this.active[0])>this.headers.index(h[0]);this.active=i?a([]):h,this._toggle(g,e,f,i,k),j.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header),i||(h.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected),h.next().addClass("ui-accordion-content-active"));return},_toggle:function(b,c,d,e,f){var g=this,h=g.options;g.toShow=b,g.toHide=c,g.data=d;var i=function(){if(!g)return;return g._completed.apply(g,arguments)};g._trigger("changestart",null,g.data),g.running=c.size()===0?b.size():c.size();if(h.animated){var j={};h.collapsible&&e?j={toShow:a([]),toHide:c,complete:i,down:f,autoHeight:h.autoHeight||h.fillSpace}:j={toShow:b,toHide:c,complete:i,down:f,autoHeight:h.autoHeight||h.fillSpace},h.proxied||(h.proxied=h.animated),h.proxiedDuration||(h.proxiedDuration=h.duration),h.animated=a.isFunction(h.proxied)?h.proxied(j):h.proxied,h.duration=a.isFunction(h.proxiedDuration)?h.proxiedDuration(j):h.proxiedDuration;var k=a.ui.accordion.animations,l=h.duration,m=h.animated;m&&!k[m]&&!a.easing[m]&&(m="slide"),k[m]||(k[m]=function(a){this.slide(a,{easing:m,duration:l||700})}),k[m](j)}else h.collapsible&&e?b.toggle():(c.hide(),b.show()),i(!0);c.prev().attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).blur(),b.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(a){this.running=a?0:--this.running;if(this.running)return;this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""}),this.toHide.removeClass("ui-accordion-content-active"),this.toHide.length&&(this.toHide.parent()[0].className=this.toHide.parent()[0].className),this._trigger("change",null,this.data)}}),a.extend(a.ui.accordion,{version:"1.8.23",animations:{slide:function(b,c){b=a.extend({easing:"swing",duration:300},b,c);if(!b.toHide.size()){b.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},b);return}if(!b.toShow.size()){b.toHide.animate({height:"hide",paddingTop:"hide",paddingBottom:"hide"},b);return}var d=b.toShow.css("overflow"),e=0,f={},g={},h=["height","paddingTop","paddingBottom"],i,j=b.toShow;i=j[0].style.width,j.width(j.parent().width()-parseFloat(j.css("paddingLeft"))-parseFloat(j.css("paddingRight"))-(parseFloat(j.css("borderLeftWidth"))||0)-(parseFloat(j.css("borderRightWidth"))||0)),a.each(h,function(c,d){g[d]="hide";var e=(""+a.css(b.toShow[0],d)).match(/^([\d+-.]+)(.*)$/);f[d]={value:e[1],unit:e[2]||"px"}}),b.toShow.css({height:0,overflow:"hidden"}).show(),b.toHide.filter(":hidden").each(b.complete).end().filter(":visible").animate(g,{step:function(a,c){c.prop=="height"&&(e=c.end-c.start===0?0:(c.now-c.start)/(c.end-c.start)),b.toShow[0].style[c.prop]=e*f[c.prop].value+f[c.prop].unit},duration:b.duration,easing:b.easing,complete:function(){b.autoHeight||b.toShow.css("height",""),b.toShow.css({width:i,overflow:d}),b.complete()}})},bounceslide:function(a){this.slide(a,{easing:a.down?"easeOutBounce":"swing",duration:a.down?1e3:200})}}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.autocomplete.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){var c=0;a.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var b=this,c=this.element[0].ownerDocument,d;this.isMultiLine=this.element.is("textarea"),this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(b.options.disabled||b.element.propAttr("readOnly"))return;d=!1;var e=a.ui.keyCode;switch(c.keyCode){case e.PAGE_UP:b._move("previousPage",c);break;case e.PAGE_DOWN:b._move("nextPage",c);break;case e.UP:b._keyEvent("previous",c);break;case e.DOWN:b._keyEvent("next",c);break;case e.ENTER:case e.NUMPAD_ENTER:b.menu.active&&(d=!0,c.preventDefault());case e.TAB:if(!b.menu.active)return;b.menu.select(c);break;case e.ESCAPE:b.element.val(b.term),b.close(c);break;default:clearTimeout(b.searching),b.searching=setTimeout(function(){b.term!=b.element.val()&&(b.selectedItem=null,b.search(null,c))},b.options.delay)}}).bind("keypress.autocomplete",function(a){d&&(d=!1,a.preventDefault())}).bind("focus.autocomplete",function(){if(b.options.disabled)return;b.selectedItem=null,b.previous=b.element.val()}).bind("blur.autocomplete",function(a){if(b.options.disabled)return;clearTimeout(b.searching),b.closing=setTimeout(function(){b.close(a),b._change(a)},150)}),this._initSource(),this.menu=a("
    ").addClass("ui-autocomplete").appendTo(a(this.options.appendTo||"body",c)[0]).mousedown(function(c){var d=b.menu.element[0];a(c.target).closest(".ui-menu-item").length||setTimeout(function(){a(document).one("mousedown",function(c){c.target!==b.element[0]&&c.target!==d&&!a.ui.contains(d,c.target)&&b.close()})},1),setTimeout(function(){clearTimeout(b.closing)},13)}).menu({focus:function(a,c){var d=c.item.data("item.autocomplete");!1!==b._trigger("focus",a,{item:d})&&/^key/.test(a.originalEvent.type)&&b.element.val(d.value)},selected:function(a,d){var e=d.item.data("item.autocomplete"),f=b.previous;b.element[0]!==c.activeElement&&(b.element.focus(),b.previous=f,setTimeout(function(){b.previous=f,b.selectedItem=e},1)),!1!==b._trigger("select",a,{item:e})&&b.element.val(e.value),b.term=b.element.val(),b.close(a),b.selectedItem=e},blur:function(a,c){b.menu.element.is(":visible")&&b.element.val()!==b.term&&b.element.val(b.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu"),a.fn.bgiframe&&this.menu.element.bgiframe(),b.beforeunloadHandler=function(){b.element.removeAttr("autocomplete")},a(window).bind("beforeunload",b.beforeunloadHandler)},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup"),this.menu.element.remove(),a(window).unbind("beforeunload",this.beforeunloadHandler),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments),b==="source"&&this._initSource(),b==="appendTo"&&this.menu.element.appendTo(a(c||"body",this.element[0].ownerDocument)[0]),b==="disabled"&&c&&this.xhr&&this.xhr.abort()},_initSource:function(){var b=this,c,d;a.isArray(this.options.source)?(c=this.options.source,this.source=function(b,d){d(a.ui.autocomplete.filter(c,b.term))}):typeof this.options.source=="string"?(d=this.options.source,this.source=function(c,e){b.xhr&&b.xhr.abort(),b.xhr=a.ajax({url:d,data:c,dataType:"json",success:function(a,b){e(a)},error:function(){e([])}})}):this.source=this.options.source},search:function(a,b){a=a!=null?a:this.element.val(),this.term=this.element.val();if(a.length").data("item.autocomplete",c).append(a("
    ").text(c.label)).appendTo(b)},_move:function(a,b){if(!this.menu.element.is(":visible")){this.search(null,b);return}if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term),this.menu.deactivate();return}this.menu[a](b)},widget:function(){return this.menu.element},_keyEvent:function(a,b){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(a,b),b.preventDefault()}}),a.extend(a.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(b,c){var d=new RegExp(a.ui.autocomplete.escapeRegex(c),"i");return a.grep(b,function(a){return d.test(a.label||a.value||a)})}})})(jQuery),function(a){a.widget("ui.menu",{_create:function(){var b=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){if(!a(c.target).closest(".ui-menu-item a").length)return;c.preventDefault(),b.select(c)}),this.refresh()},refresh:function(){var b=this,c=this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem");c.children("a").addClass("ui-corner-all").attr("tabindex",-1).mouseenter(function(c){b.activate(c,a(this).parent())}).mouseleave(function(){b.deactivate()})},activate:function(a,b){this.deactivate();if(this.hasScroll()){var c=b.offset().top-this.element.offset().top,d=this.element.scrollTop(),e=this.element.height();c<0?this.element.scrollTop(d+c):c>=e&&this.element.scrollTop(d+c-e+b.height())}this.active=b.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end(),this._trigger("focus",a,{item:b})},deactivate:function(){if(!this.active)return;this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),this._trigger("blur"),this.active=null},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(a,b,c){if(!this.active){this.activate(c,this.element.children(b));return}var d=this.active[a+"All"](".ui-menu-item").eq(0);d.length?this.activate(c,d):this.activate(c,this.element.children(b))},nextPage:function(b){if(this.hasScroll()){if(!this.active||this.last()){this.activate(b,this.element.children(".ui-menu-item:first"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c-d+a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:last")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},previousPage:function(b){if(this.hasScroll()){if(!this.active||this.first()){this.activate(b,this.element.children(".ui-menu-item:last"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c+d-a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:first")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()",this.element[0].ownerDocument).addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(),d=this.options.icons,e=d.primary&&d.secondary,f=[];d.primary||d.secondary?(this.options.text&&f.push("ui-button-text-icon"+(e?"s":d.primary?"-primary":"-secondary")),d.primary&&b.prepend(""),d.secondary&&b.append(""),this.options.text||(f.push(e?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||b.attr("title",c))):f.push("ui-button-text-only"),b.addClass(f.join(" "))}}),a.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(b,c){b==="disabled"&&this.buttons.button("option",b,c),a.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var b=this.element.css("direction")==="rtl";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(b?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(b?"ui-corner-left":"ui-corner-right").end().end()},destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"),a.Widget.prototype.destroy.call(this)}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.dialog.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){var c="ui-dialog ui-widget ui-widget-content ui-corner-all ",d={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},e={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};a.widget("ui.dialog",{options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",collision:"fit",using:function(b){var c=a(this).css(b).offset().top;c<0&&a(this).css("top",b.top-c)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.options.title=this.options.title||this.originalTitle;var b=this,d=b.options,e=d.title||" ",f=a.ui.dialog.getTitleId(b.element),g=(b.uiDialog=a("
    ")).appendTo(document.body).hide().addClass(c+d.dialogClass).css({zIndex:d.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(c){d.closeOnEscape&&!c.isDefaultPrevented()&&c.keyCode&&c.keyCode===a.ui.keyCode.ESCAPE&&(b.close(c),c.preventDefault())}).attr({role:"dialog","aria-labelledby":f}).mousedown(function(a){b.moveToTop(!1,a)}),h=b.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g),i=(b.uiDialogTitlebar=a("
    ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),j=a('').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){j.addClass("ui-state-hover")},function(){j.removeClass("ui-state-hover")}).focus(function(){j.addClass("ui-state-focus")}).blur(function(){j.removeClass("ui-state-focus")}).click(function(a){return b.close(a),!1}).appendTo(i),k=(b.uiDialogTitlebarCloseText=a("")).addClass("ui-icon ui-icon-closethick").text(d.closeText).appendTo(j),l=a("").addClass("ui-dialog-title").attr("id",f).html(e).prependTo(i);a.isFunction(d.beforeclose)&&!a.isFunction(d.beforeClose)&&(d.beforeClose=d.beforeclose),i.find("*").add(i).disableSelection(),d.draggable&&a.fn.draggable&&b._makeDraggable(),d.resizable&&a.fn.resizable&&b._makeResizable(),b._createButtons(d.buttons),b._isOpen=!1,a.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;return a.overlay&&a.overlay.destroy(),a.uiDialog.hide(),a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),a.uiDialog.remove(),a.originalTitle&&a.element.attr("title",a.originalTitle),a},widget:function(){return this.uiDialog},close:function(b){var c=this,d,e;if(!1===c._trigger("beforeClose",b))return;return c.overlay&&c.overlay.destroy(),c.uiDialog.unbind("keypress.ui-dialog"),c._isOpen=!1,c.options.hide?c.uiDialog.hide(c.options.hide,function(){c._trigger("close",b)}):(c.uiDialog.hide(),c._trigger("close",b)),a.ui.dialog.overlay.resize(),c.options.modal&&(d=0,a(".ui-dialog").each(function(){this!==c.uiDialog[0]&&(e=a(this).css("z-index"),isNaN(e)||(d=Math.max(d,e)))}),a.ui.dialog.maxZ=d),c},isOpen:function(){return this._isOpen},moveToTop:function(b,c){var d=this,e=d.options,f;return e.modal&&!b||!e.stack&&!e.modal?d._trigger("focus",c):(e.zIndex>a.ui.dialog.maxZ&&(a.ui.dialog.maxZ=e.zIndex),d.overlay&&(a.ui.dialog.maxZ+=1,d.overlay.$el.css("z-index",a.ui.dialog.overlay.maxZ=a.ui.dialog.maxZ)),f={scrollTop:d.element.scrollTop(),scrollLeft:d.element.scrollLeft()},a.ui.dialog.maxZ+=1,d.uiDialog.css("z-index",a.ui.dialog.maxZ),d.element.attr(f),d._trigger("focus",c),d)},open:function(){if(this._isOpen)return;var b=this,c=b.options,d=b.uiDialog;return b.overlay=c.modal?new a.ui.dialog.overlay(b):null,b._size(),b._position(c.position),d.show(c.show),b.moveToTop(!0),c.modal&&d.bind("keydown.ui-dialog",function(b){if(b.keyCode!==a.ui.keyCode.TAB)return;var c=a(":tabbable",this),d=c.filter(":first"),e=c.filter(":last");if(b.target===e[0]&&!b.shiftKey)return d.focus(1),!1;if(b.target===d[0]&&b.shiftKey)return e.focus(1),!1}),a(b.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus(),b._isOpen=!0,b._trigger("open"),b},_createButtons:function(b){var c=this,d=!1,e=a("
    ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),f=a("
    ").addClass("ui-dialog-buttonset").appendTo(e);c.uiDialog.find(".ui-dialog-buttonpane").remove(),typeof b=="object"&&b!==null&&a.each(b,function(){return!(d=!0)}),d&&(a.each(b,function(b,d){d=a.isFunction(d)?{click:d,text:b}:d;var e=a('').click(function(){d.click.apply(c.element[0],arguments)}).appendTo(f);a.each(d,function(a,b){if(a==="click")return;a in e?e[a](b):e.attr(a,b)}),a.fn.button&&e.button()}),e.appendTo(c.uiDialog))},_makeDraggable:function(){function f(a){return{position:a.position,offset:a.offset}}var b=this,c=b.options,d=a(document),e;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(d,g){e=c.height==="auto"?"auto":a(this).height(),a(this).height(a(this).height()).addClass("ui-dialog-dragging"),b._trigger("dragStart",d,f(g))},drag:function(a,c){b._trigger("drag",a,f(c))},stop:function(g,h){c.position=[h.position.left-d.scrollLeft(),h.position.top-d.scrollTop()],a(this).removeClass("ui-dialog-dragging").height(e),b._trigger("dragStop",g,f(h)),a.ui.dialog.overlay.resize()}})},_makeResizable:function(c){function h(a){return{originalPosition:a.originalPosition,originalSize:a.originalSize,position:a.position,size:a.size}}c=c===b?this.options.resizable:c;var d=this,e=d.options,f=d.uiDialog.css("position"),g=typeof c=="string"?c:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:g,start:function(b,c){a(this).addClass("ui-dialog-resizing"),d._trigger("resizeStart",b,h(c))},resize:function(a,b){d._trigger("resize",a,h(b))},stop:function(b,c){a(this).removeClass("ui-dialog-resizing"),e.height=a(this).height(),e.width=a(this).width(),d._trigger("resizeStop",b,h(c)),a.ui.dialog.overlay.resize()}}).css("position",f).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(b){var c=[],d=[0,0],e;if(b){if(typeof b=="string"||typeof b=="object"&&"0"in b)c=b.split?b.split(" "):[b[0],b[1]],c.length===1&&(c[1]=c[0]),a.each(["left","top"],function(a,b){+c[a]===c[a]&&(d[a]=c[a],c[a]=b)}),b={my:c.join(" "),at:c.join(" "),offset:d.join(" ")};b=a.extend({},a.ui.dialog.prototype.options.position,b)}else b=a.ui.dialog.prototype.options.position;e=this.uiDialog.is(":visible"),e||this.uiDialog.show(),this.uiDialog.css({top:0,left:0}).position(a.extend({of:window},b)),e||this.uiDialog.hide()},_setOptions:function(b){var c=this,f={},g=!1;a.each(b,function(a,b){c._setOption(a,b),a in d&&(g=!0),a in e&&(f[a]=b)}),g&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",f)},_setOption:function(b,d){var e=this,f=e.uiDialog;switch(b){case"beforeclose":b="beforeClose";break;case"buttons":e._createButtons(d);break;case"closeText":e.uiDialogTitlebarCloseText.text(""+d);break;case"dialogClass":f.removeClass(e.options.dialogClass).addClass(c+d);break;case"disabled":d?f.addClass("ui-dialog-disabled"):f.removeClass("ui-dialog-disabled");break;case"draggable":var g=f.is(":data(draggable)");g&&!d&&f.draggable("destroy"),!g&&d&&e._makeDraggable();break;case"position":e._position(d);break;case"resizable":var h=f.is(":data(resizable)");h&&!d&&f.resizable("destroy"),h&&typeof d=="string"&&f.resizable("option","handles",d),!h&&d!==!1&&e._makeResizable(d);break;case"title":a(".ui-dialog-title",e.uiDialogTitlebar).html(""+(d||" "))}a.Widget.prototype._setOption.apply(e,arguments)},_size:function(){var b=this.options,c,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),b.minWidth>b.width&&(b.width=b.minWidth),c=this.uiDialog.css({height:"auto",width:b.width}).height(),d=Math.max(0,b.minHeight-c);if(b.height==="auto")if(a.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();var f=this.element.css("height","auto").height();e||this.uiDialog.hide(),this.element.height(Math.max(f,d))}else this.element.height(Math.max(b.height-c,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),a.extend(a.ui.dialog,{version:"1.8.23",uuid:0,maxZ:0,getTitleId:function(a){var b=a.attr("id");return b||(this.uuid+=1,b=this.uuid),"ui-dialog-title-"+b},overlay:function(b){this.$el=a.ui.dialog.overlay.create(b)}}),a.extend(a.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:a.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),create:function(b){this.instances.length===0&&(setTimeout(function(){a.ui.dialog.overlay.instances.length&&a(document).bind(a.ui.dialog.overlay.events,function(b){if(a(b.target).zIndex()").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});return a.fn.bgiframe&&c.bgiframe(),this.instances.push(c),c},destroy:function(b){var c=a.inArray(b,this.instances);c!=-1&&this.oldInstances.push(this.instances.splice(c,1)[0]),this.instances.length===0&&a([document,window]).unbind(".dialog-overlay"),b.remove();var d=0;a.each(this.instances,function(){d=Math.max(d,this.css("z-index"))}),this.maxZ=d},height:function(){var b,c;return a.browser.msie&&a.browser.version<7?(b=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),c=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),b").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(d.range==="min"||d.range==="max"?" ui-slider-range-"+d.range:"")));for(var i=e.length;ic&&(f=c,g=a(this),i=b)}),c.range===!0&&this.values(1)===c.min&&(i+=1,g=a(this.handles[i])),j=this._start(b,i),j===!1?!1:(this._mouseSliding=!0,h._handleIndex=i,g.addClass("ui-state-active").focus(),k=g.offset(),l=!a(b.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:b.pageX-k.left-g.width()/2,top:b.pageY-k.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(b,i,e),this._animateOff=!0,!0))},_mouseStart:function(a){return!0},_mouseDrag:function(a){var b={x:a.pageX,y:a.pageY},c=this._normValueFromMouse(b);return this._slide(a,this._handleIndex,c),!1},_mouseStop:function(a){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,d,e,f;return this.orientation==="horizontal"?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),d=c/b,d>1&&(d=1),d<0&&(d=0),this.orientation==="vertical"&&(d=1-d),e=this._valueMax()-this._valueMin(),f=this._valueMin()+d*e,this._trimAlignValue(f)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};return this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,f;this.options.values&&this.options.values.length?(d=this.values(b?0:1),this.options.values.length===2&&this.options.range===!0&&(b===0&&c>d||b===1&&c1){this.options.values[b]=this._trimAlignValue(c),this._refreshValue(),this._change(null,b);return}if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(b):this.value();d=this.options.values,e=arguments[0];for(f=0;f=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b,d=a-c;return Math.abs(c)*2>=b&&(d+=c>0?b:-b),parseFloat(d.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b=this.options.range,c=this.options,d=this,e=this._animateOff?!1:c.animate,f,g={},h,i,j,k;this.options.values&&this.options.values.length?this.handles.each(function(b,i){f=(d.values(b)-d._valueMin())/(d._valueMax()-d._valueMin())*100,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",a(this).stop(1,1)[e?"animate":"css"](g,c.animate),d.options.range===!0&&(d.orientation==="horizontal"?(b===0&&d.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({width:f-h+"%"},{queue:!1,duration:c.animate})):(b===0&&d.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({height:f-h+"%"},{queue:!1,duration:c.animate}))),h=f}):(i=this.value(),j=this._valueMin(),k=this._valueMax(),f=k!==j?(i-j)/(k-j)*100:0,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",this.handle.stop(1,1)[e?"animate":"css"](g,c.animate),b==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[e?"animate":"css"]({width:f+"%"},c.animate),b==="max"&&this.orientation==="horizontal"&&this.range[e?"animate":"css"]({width:100-f+"%"},{queue:!1,duration:c.animate}),b==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},c.animate),b==="max"&&this.orientation==="vertical"&&this.range[e?"animate":"css"]({height:100-f+"%"},{queue:!1,duration:c.animate}))}}),a.extend(a.ui.slider,{version:"1.8.23"})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.tabs.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){function e(){return++c}function f(){return++d}var c=0,d=0;a.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:!1,cookie:null,collapsible:!1,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"
    ",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
  • #{label}
  • "},_create:function(){this._tabify(!0)},_setOption:function(a,b){if(a=="selected"){if(this.options.collapsible&&b==this.options.selected)return;this.select(b)}else this.options[a]=b,this._tabify()},_tabId:function(a){return a.title&&a.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+e()},_sanitizeSelector:function(a){return a.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+f());return a.cookie.apply(null,[b].concat(a.makeArray(arguments)))},_ui:function(a,b){return{tab:a,panel:b,index:this.anchors.index(a)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=a(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function m(b,c){b.css("display",""),!a.support.opacity&&c.opacity&&b[0].style.removeAttribute("filter")}var d=this,e=this.options,f=/^#.+/;this.list=this.element.find("ol,ul").eq(0),this.lis=a(" > li:has(a[href])",this.list),this.anchors=this.lis.map(function(){return a("a",this)[0]}),this.panels=a([]),this.anchors.each(function(b,c){var g=a(c).attr("href"),h=g.split("#")[0],i;h&&(h===location.toString().split("#")[0]||(i=a("base")[0])&&h===i.href)&&(g=c.hash,c.href=g);if(f.test(g))d.panels=d.panels.add(d.element.find(d._sanitizeSelector(g)));else if(g&&g!=="#"){a.data(c,"href.tabs",g),a.data(c,"load.tabs",g.replace(/#.*$/,""));var j=d._tabId(c);c.href="#"+j;var k=d.element.find("#"+j);k.length||(k=a(e.panelTemplate).attr("id",j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(d.panels[b-1]||d.list),k.data("destroy.tabs",!0)),d.panels=d.panels.add(k)}else e.disabled.push(b)}),c?(this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"),this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.lis.addClass("ui-state-default ui-corner-top"),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom"),e.selected===b?(location.hash&&this.anchors.each(function(a,b){if(b.hash==location.hash)return e.selected=a,!1}),typeof e.selected!="number"&&e.cookie&&(e.selected=parseInt(d._cookie(),10)),typeof e.selected!="number"&&this.lis.filter(".ui-tabs-selected").length&&(e.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))),e.selected=e.selected||(this.lis.length?0:-1)):e.selected===null&&(e.selected=-1),e.selected=e.selected>=0&&this.anchors[e.selected]||e.selected<0?e.selected:0,e.disabled=a.unique(e.disabled.concat(a.map(this.lis.filter(".ui-state-disabled"),function(a,b){return d.lis.index(a)}))).sort(),a.inArray(e.selected,e.disabled)!=-1&&e.disabled.splice(a.inArray(e.selected,e.disabled),1),this.panels.addClass("ui-tabs-hide"),this.lis.removeClass("ui-tabs-selected ui-state-active"),e.selected>=0&&this.anchors.length&&(d.element.find(d._sanitizeSelector(d.anchors[e.selected].hash)).removeClass("ui-tabs-hide"),this.lis.eq(e.selected).addClass("ui-tabs-selected ui-state-active"),d.element.queue("tabs",function(){d._trigger("show",null,d._ui(d.anchors[e.selected],d.element.find(d._sanitizeSelector(d.anchors[e.selected].hash))[0]))}),this.load(e.selected)),a(window).bind("unload",function(){d.lis.add(d.anchors).unbind(".tabs"),d.lis=d.anchors=d.panels=null})):e.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")),this.element[e.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible"),e.cookie&&this._cookie(e.selected,e.cookie);for(var g=0,h;h=this.lis[g];g++)a(h)[a.inArray(g,e.disabled)!=-1&&!a(h).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");e.cache===!1&&this.anchors.removeData("cache.tabs"),this.lis.add(this.anchors).unbind(".tabs");if(e.event!=="mouseover"){var i=function(a,b){b.is(":not(.ui-state-disabled)")&&b.addClass("ui-state-"+a)},j=function(a,b){b.removeClass("ui-state-"+a)};this.lis.bind("mouseover.tabs",function(){i("hover",a(this))}),this.lis.bind("mouseout.tabs",function(){j("hover",a(this))}),this.anchors.bind("focus.tabs",function(){i("focus",a(this).closest("li"))}),this.anchors.bind("blur.tabs",function(){j("focus",a(this).closest("li"))})}var k,l;e.fx&&(a.isArray(e.fx)?(k=e.fx[0],l=e.fx[1]):k=l=e.fx);var n=l?function(b,c){a(b).closest("li").addClass("ui-tabs-selected ui-state-active"),c.hide().removeClass("ui-tabs-hide").animate(l,l.duration||"normal",function(){m(c,l),d._trigger("show",null,d._ui(b,c[0]))})}:function(b,c){a(b).closest("li").addClass("ui-tabs-selected ui-state-active"),c.removeClass("ui-tabs-hide"),d._trigger("show",null,d._ui(b,c[0]))},o=k?function(a,b){b.animate(k,k.duration||"normal",function(){d.lis.removeClass("ui-tabs-selected ui-state-active"),b.addClass("ui-tabs-hide"),m(b,k),d.element.dequeue("tabs")})}:function(a,b,c){d.lis.removeClass("ui-tabs-selected ui-state-active"),b.addClass("ui-tabs-hide"),d.element.dequeue("tabs")};this.anchors.bind(e.event+".tabs",function(){var b=this,c=a(b).closest("li"),f=d.panels.filter(":not(.ui-tabs-hide)"),g=d.element.find(d._sanitizeSelector(b.hash));if(c.hasClass("ui-tabs-selected")&&!e.collapsible||c.hasClass("ui-state-disabled")||c.hasClass("ui-state-processing")||d.panels.filter(":animated").length||d._trigger("select",null,d._ui(this,g[0]))===!1)return this.blur(),!1;e.selected=d.anchors.index(this),d.abort();if(e.collapsible){if(c.hasClass("ui-tabs-selected"))return e.selected=-1,e.cookie&&d._cookie(e.selected,e.cookie),d.element.queue("tabs",function(){o(b,f)}).dequeue("tabs"),this.blur(),!1;if(!f.length)return e.cookie&&d._cookie(e.selected,e.cookie),d.element.queue("tabs",function(){n(b,g)}),d.load(d.anchors.index(this)),this.blur(),!1}e.cookie&&d._cookie(e.selected,e.cookie);if(g.length)f.length&&d.element.queue("tabs",function(){o(b,f)}),d.element.queue("tabs",function(){n(b,g)}),d.load(d.anchors.index(this));else throw"jQuery UI Tabs: Mismatching fragment identifier.";a.browser.msie&&this.blur()}),this.anchors.bind("click.tabs",function(){return!1})},_getIndex:function(a){return typeof a=="string"&&(a=this.anchors.index(this.anchors.filter("[href$='"+a+"']"))),a},destroy:function(){var b=this.options;return this.abort(),this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs"),this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.anchors.each(function(){var b=a.data(this,"href.tabs");b&&(this.href=b);var c=a(this).unbind(".tabs");a.each(["href","load","cache"],function(a,b){c.removeData(b+".tabs")})}),this.lis.unbind(".tabs").add(this.panels).each(function(){a.data(this,"destroy.tabs")?a(this).remove():a(this).removeClass(["ui-state-default","ui-corner-top","ui-tabs-selected","ui-state-active","ui-state-hover","ui-state-focus","ui-state-disabled","ui-tabs-panel","ui-widget-content","ui-corner-bottom","ui-tabs-hide"].join(" "))}),b.cookie&&this._cookie(null,b.cookie),this},add:function(c,d,e){e===b&&(e=this.anchors.length);var f=this,g=this.options,h=a(g.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,d)),i=c.indexOf("#")?this._tabId(a("a",h)[0]):c.replace("#","");h.addClass("ui-state-default ui-corner-top").data("destroy.tabs",!0);var j=f.element.find("#"+i);return j.length||(j=a(g.panelTemplate).attr("id",i).data("destroy.tabs",!0)),j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"),e>=this.lis.length?(h.appendTo(this.list),j.appendTo(this.list[0].parentNode)):(h.insertBefore(this.lis[e]),j.insertBefore(this.panels[e])),g.disabled=a.map(g.disabled,function(a,b){return a>=e?++a:a}),this._tabify(),this.anchors.length==1&&(g.selected=0,h.addClass("ui-tabs-selected ui-state-active"),j.removeClass("ui-tabs-hide"),this.element.queue("tabs",function(){f._trigger("show",null,f._ui(f.anchors[0],f.panels[0]))}),this.load(0)),this._trigger("add",null,this._ui(this.anchors[e],this.panels[e])),this},remove:function(b){b=this._getIndex(b);var c=this.options,d=this.lis.eq(b).remove(),e=this.panels.eq(b).remove();return d.hasClass("ui-tabs-selected")&&this.anchors.length>1&&this.select(b+(b+1=b?--a:a}),this._tabify(),this._trigger("remove",null,this._ui(d.find("a")[0],e[0])),this},enable:function(b){b=this._getIndex(b);var c=this.options;if(a.inArray(b,c.disabled)==-1)return;return this.lis.eq(b).removeClass("ui-state-disabled"),c.disabled=a.grep(c.disabled,function(a,c){return a!=b}),this._trigger("enable",null,this._ui(this.anchors[b],this.panels[b])),this},disable:function(a){a=this._getIndex(a);var b=this,c=this.options;return a!=c.selected&&(this.lis.eq(a).addClass("ui-state-disabled"),c.disabled.push(a),c.disabled.sort(),this._trigger("disable",null,this._ui(this.anchors[a],this.panels[a]))),this},select:function(a){a=this._getIndex(a);if(a==-1)if(this.options.collapsible&&this.options.selected!=-1)a=this.options.selected;else return this;return this.anchors.eq(a).trigger(this.options.event+".tabs"),this},load:function(b){b=this._getIndex(b);var c=this,d=this.options,e=this.anchors.eq(b)[0],f=a.data(e,"load.tabs");this.abort();if(!f||this.element.queue("tabs").length!==0&&a.data(e,"cache.tabs")){this.element.dequeue("tabs");return}this.lis.eq(b).addClass("ui-state-processing");if(d.spinner){var g=a("span",e);g.data("label.tabs",g.html()).html(d.spinner)}return this.xhr=a.ajax(a.extend({},d.ajaxOptions,{url:f,success:function(f,g){c.element.find(c._sanitizeSelector(e.hash)).html(f),c._cleanup(),d.cache&&a.data(e,"cache.tabs",!0),c._trigger("load",null,c._ui(c.anchors[b],c.panels[b]));try{d.ajaxOptions.success(f,g)}catch(h){}},error:function(a,f,g){c._cleanup(),c._trigger("load",null,c._ui(c.anchors[b],c.panels[b]));try{d.ajaxOptions.error(a,f,b,e)}catch(g){}}})),c.element.dequeue("tabs"),this},abort:function(){return this.element.queue([]),this.panels.stop(!1,!0),this.element.queue("tabs",this.element.queue("tabs").splice(-2,2)),this.xhr&&(this.xhr.abort(),delete this.xhr),this._cleanup(),this},url:function(a,b){return this.anchors.eq(a).removeData("cache.tabs").data("load.tabs",b),this},length:function(){return this.anchors.length}}),a.extend(a.ui.tabs,{version:"1.8.23"}),a.extend(a.ui.tabs.prototype,{rotation:null,rotate:function(a,b){var c=this,d=this.options,e=c._rotate||(c._rotate=function(b){clearTimeout(c.rotation),c.rotation=setTimeout(function(){var a=d.selected;c.select(++a'))}function bindHover(a){var b="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return a.bind("mouseout",function(a){var c=$(a.target).closest(b);if(!c.length)return;c.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(c){var d=$(c.target).closest(b);if($.datepicker._isDisabledDatepicker(instActive.inline?a.parent()[0]:instActive.input[0])||!d.length)return;d.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),d.addClass("ui-state-hover"),d.hasClass("ui-datepicker-prev")&&d.addClass("ui-datepicker-prev-hover"),d.hasClass("ui-datepicker-next")&&d.addClass("ui-datepicker-next-hover")})}function extendRemove(a,b){$.extend(a,b);for(var c in b)if(b[c]==null||b[c]==undefined)a[c]=b[c];return a}function isArray(a){return a&&($.browser.safari&&typeof a=="object"&&a.length||a.constructor&&a.constructor.toString().match(/\Array\(\)/))}$.extend($.ui,{datepicker:{version:"1.8.23"}});var PROP_NAME="datepicker",dpuuid=(new Date).getTime(),instActive;$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){return extendRemove(this._defaults,a||{}),this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase(),inline=nodeName=="div"||nodeName=="span";target.id||(this.uuid+=1,target.id="dp"+this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{}),nodeName=="input"?this._connectDatepicker(target,inst):inline&&this._inlineDatepicker(target,inst)},_newInst:function(a,b){var c=a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1");return{id:c,input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:b?bindHover($('
    ')):this.dpDiv}},_connectDatepicker:function(a,b){var c=$(a);b.append=$([]),b.trigger=$([]);if(c.hasClass(this.markerClassName))return;this._attachments(c,b),c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),this._autoSize(b),$.data(a,PROP_NAME,b),b.settings.disabled&&this._disableDatepicker(a)},_attachments:function(a,b){var c=this._get(b,"appendText"),d=this._get(b,"isRTL");b.append&&b.append.remove(),c&&(b.append=$(''+c+""),a[d?"before":"after"](b.append)),a.unbind("focus",this._showDatepicker),b.trigger&&b.trigger.remove();var e=this._get(b,"showOn");(e=="focus"||e=="both")&&a.focus(this._showDatepicker);if(e=="button"||e=="both"){var f=this._get(b,"buttonText"),g=this._get(b,"buttonImage");b.trigger=$(this._get(b,"buttonImageOnly")?$("").addClass(this._triggerClass).attr({src:g,alt:f,title:f}):$('').addClass(this._triggerClass).html(g==""?f:$("").attr({src:g,alt:f,title:f}))),a[d?"before":"after"](b.trigger),b.trigger.click(function(){return $.datepicker._datepickerShowing&&$.datepicker._lastInput==a[0]?$.datepicker._hideDatepicker():$.datepicker._datepickerShowing&&$.datepicker._lastInput!=a[0]?($.datepicker._hideDatepicker(),$.datepicker._showDatepicker(a[0])):$.datepicker._showDatepicker(a[0]),!1})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var d=function(a){var b=0,c=0;for(var d=0;db&&(b=a[d].length,c=d);return c};b.setMonth(d(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort"))),b.setDate(d(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=$(a);if(c.hasClass(this.markerClassName))return;c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),$.data(a,PROP_NAME,b),this._setDate(b,this._getDefaultDate(b),!0),this._updateDatepicker(b),this._updateAlternate(b),b.settings.disabled&&this._disableDatepicker(a),b.dpDiv.css("display","block")},_dialogDatepicker:function(a,b,c,d,e){var f=this._dialogInst;if(!f){this.uuid+=1;var g="dp"+this.uuid;this._dialogInput=$(''),this._dialogInput.keydown(this._doKeyDown),$("body").append(this._dialogInput),f=this._dialogInst=this._newInst(this._dialogInput,!1),f.settings={},$.data(this._dialogInput[0],PROP_NAME,f)}extendRemove(f.settings,d||{}),b=b&&b.constructor==Date?this._formatDate(f,b):b,this._dialogInput.val(b),this._pos=e?e.length?e:[e.pageX,e.pageY]:null;if(!this._pos){var h=document.documentElement.clientWidth,i=document.documentElement.clientHeight,j=document.documentElement.scrollLeft||document.body.scrollLeft,k=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[h/2-100+j,i/2-150+k]}return this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),f.settings.onSelect=c,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),$.blockUI&&$.blockUI(this.dpDiv),$.data(this._dialogInput[0],PROP_NAME,f),this},_destroyDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();$.removeData(a,PROP_NAME),d=="input"?(c.append.remove(),c.trigger.remove(),b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):(d=="div"||d=="span")&&b.removeClass(this.markerClassName).empty()},_enableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!1,c.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().removeClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b})},_disableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!0,c.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().addClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b}),this._disabledInputs[this._disabledInputs.length]=a},_isDisabledDatepicker:function(a){if(!a)return!1;for(var b=0;b-1}},_doKeyUp:function(a){var b=$.datepicker._getInst(a.target);if(b.input.val()!=b.lastVal)try{var c=$.datepicker.parseDate($.datepicker._get(b,"dateFormat"),b.input?b.input.val():null,$.datepicker._getFormatConfig(b));c&&($.datepicker._setDateFromField(b),$.datepicker._updateAlternate(b),$.datepicker._updateDatepicker(b))}catch(d){$.datepicker.log(d)}return!0},_showDatepicker:function(a){a=a.target||a,a.nodeName.toLowerCase()!="input"&&(a=$("input",a.parentNode)[0]);if($.datepicker._isDisabledDatepicker(a)||$.datepicker._lastInput==a)return;var b=$.datepicker._getInst(a);$.datepicker._curInst&&$.datepicker._curInst!=b&&($.datepicker._curInst.dpDiv.stop(!0,!0),b&&$.datepicker._datepickerShowing&&$.datepicker._hideDatepicker($.datepicker._curInst.input[0]));var c=$.datepicker._get(b,"beforeShow"),d=c?c.apply(a,[a,b]):{};if(d===!1)return;extendRemove(b.settings,d),b.lastVal=null,$.datepicker._lastInput=a,$.datepicker._setDateFromField(b),$.datepicker._inDialog&&(a.value=""),$.datepicker._pos||($.datepicker._pos=$.datepicker._findPos(a),$.datepicker._pos[1]+=a.offsetHeight);var e=!1;$(a).parents().each(function(){return e|=$(this).css("position")=="fixed",!e}),e&&$.browser.opera&&($.datepicker._pos[0]-=document.documentElement.scrollLeft,$.datepicker._pos[1]-=document.documentElement.scrollTop);var f={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null,b.dpDiv.empty(),b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),$.datepicker._updateDatepicker(b),f=$.datepicker._checkOffset(b,f,e),b.dpDiv.css({position:$.datepicker._inDialog&&$.blockUI?"static":e?"fixed":"absolute",display:"none",left:f.left+"px",top:f.top+"px"});if(!b.inline){var g=$.datepicker._get(b,"showAnim"),h=$.datepicker._get(b,"duration"),i=function(){var a=b.dpDiv.find("iframe.ui-datepicker-cover");if(!!a.length){var c=$.datepicker._getBorders(b.dpDiv);a.css({left:-c[0],top:-c[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex($(a).zIndex()+1),$.datepicker._datepickerShowing=!0,$.effects&&$.effects[g]?b.dpDiv.show(g,$.datepicker._get(b,"showOptions"),h,i):b.dpDiv[g||"show"](g?h:null,i),(!g||!h)&&i(),b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus(),$.datepicker._curInst=b}},_updateDatepicker:function(a){var b=this;b.maxRows=4;var c=$.datepicker._getBorders(a.dpDiv);instActive=a,a.dpDiv.empty().append(this._generateHTML(a)),this._attachHandlers(a);var d=a.dpDiv.find("iframe.ui-datepicker-cover");!d.length||d.css({left:-c[0],top:-c[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}),a.dpDiv.find("."+this._dayOverClass+" a").mouseover();var e=this._getNumberOfMonths(a),f=e[1],g=17;a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),f>1&&a.dpDiv.addClass("ui-datepicker-multi-"+f).css("width",g*f+"em"),a.dpDiv[(e[0]!=1||e[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi"),a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),a==$.datepicker._curInst&&$.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var h=a.yearshtml;setTimeout(function(){h===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml),h=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(a){return{thin:1,medium:2,thick:3}[a]||a};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var d=a.dpDiv.outerWidth(),e=a.dpDiv.outerHeight(),f=a.input?a.input.outerWidth():0,g=a.input?a.input.outerHeight():0,h=document.documentElement.clientWidth+(c?0:$(document).scrollLeft()),i=document.documentElement.clientHeight+(c?0:$(document).scrollTop());return b.left-=this._get(a,"isRTL")?d-f:0,b.left-=c&&b.left==a.input.offset().left?$(document).scrollLeft():0,b.top-=c&&b.top==a.input.offset().top+g?$(document).scrollTop():0,b.left-=Math.min(b.left,b.left+d>h&&h>d?Math.abs(b.left+d-h):0),b.top-=Math.min(b.top,b.top+e>i&&i>e?Math.abs(e+g):0),b},_findPos:function(a){var b=this._getInst(a),c=this._get(b,"isRTL");while(a&&(a.type=="hidden"||a.nodeType!=1||$.expr.filters.hidden(a)))a=a[c?"previousSibling":"nextSibling"];var d=$(a).offset();return[d.left,d.top]},_hideDatepicker:function(a){var b=this._curInst;if(!b||a&&b!=$.data(a,PROP_NAME))return;if(this._datepickerShowing){var c=this._get(b,"showAnim"),d=this._get(b,"duration"),e=function(){$.datepicker._tidyDialog(b)};$.effects&&$.effects[c]?b.dpDiv.hide(c,$.datepicker._get(b,"showOptions"),d,e):b.dpDiv[c=="slideDown"?"slideUp":c=="fadeIn"?"fadeOut":"hide"](c?d:null,e),c||e(),this._datepickerShowing=!1;var f=this._get(b,"onClose");f&&f.apply(b.input?b.input[0]:null,[b.input?b.input.val():"",b]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),$.blockUI&&($.unblockUI(),$("body").append(this.dpDiv))),this._inDialog=!1}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(!$.datepicker._curInst)return;var b=$(a.target),c=$.datepicker._getInst(b[0]);(b[0].id!=$.datepicker._mainDivId&&b.parents("#"+$.datepicker._mainDivId).length==0&&!b.hasClass($.datepicker.markerClassName)&&!b.closest("."+$.datepicker._triggerClass).length&&$.datepicker._datepickerShowing&&(!$.datepicker._inDialog||!$.blockUI)||b.hasClass($.datepicker.markerClassName)&&$.datepicker._curInst!=c)&&$.datepicker._hideDatepicker()},_adjustDate:function(a,b,c){var d=$(a),e=this._getInst(d[0]);if(this._isDisabledDatepicker(d[0]))return;this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c),this._updateDatepicker(e)},_gotoToday:function(a){var b=$(a),c=this._getInst(b[0]);if(this._get(c,"gotoCurrent")&&c.currentDay)c.selectedDay=c.currentDay,c.drawMonth=c.selectedMonth=c.currentMonth,c.drawYear=c.selectedYear=c.currentYear;else{var d=new Date;c.selectedDay=d.getDate(),c.drawMonth=c.selectedMonth=d.getMonth(),c.drawYear=c.selectedYear=d.getFullYear()}this._notifyChange(c),this._adjustDate(b)},_selectMonthYear:function(a,b,c){var d=$(a),e=this._getInst(d[0]);e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10),this._notifyChange(e),this._adjustDate(d)},_selectDay:function(a,b,c,d){var e=$(a);if($(d).hasClass(this._unselectableClass)||this._isDisabledDatepicker(e[0]))return;var f=this._getInst(e[0]);f.selectedDay=f.currentDay=$("a",d).html(),f.selectedMonth=f.currentMonth=b,f.selectedYear=f.currentYear=c,this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))},_clearDate:function(a){var b=$(a),c=this._getInst(b[0]);this._selectDate(b,"")},_selectDate:function(a,b){var c=$(a),d=this._getInst(c[0]);b=b!=null?b:this._formatDate(d),d.input&&d.input.val(b),this._updateAlternate(d);var e=this._get(d,"onSelect");e?e.apply(d.input?d.input[0]:null,[b,d]):d.input&&d.input.trigger("change"),d.inline?this._updateDatepicker(d):(this._hideDatepicker(),this._lastInput=d.input[0],typeof d.input[0]!="object"&&d.input.focus(),this._lastInput=null)},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),d=this._getDate(a),e=this.formatDate(c,d,this._getFormatConfig(a));$(b).each(function(){$(this).val(e)})}},noWeekends:function(a){var b=a.getDay();return[b>0&&b<6,""]},iso8601Week:function(a){var b=new Date(a.getTime());b.setDate(b.getDate()+4-(b.getDay()||7));var c=b.getTime();return b.setMonth(0),b.setDate(1),Math.floor(Math.round((c-b)/864e5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"?b.toString():b+"";if(b=="")return null;var d=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;d=typeof d!="string"?d:(new Date).getFullYear()%100+parseInt(d,10);var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,g=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,h=(c?c.monthNames:null)||this._defaults.monthNames,i=-1,j=-1,k=-1,l=-1,m=!1,n=function(b){var c=s+1-1){j=1,k=l;do{var u=this._getDaysInMonth(i,j-1);if(k<=u)break;j++,k-=u}while(!0)}var t=this._daylightSavingAdjust(new Date(i,j-1,k));if(t.getFullYear()!=i||t.getMonth()+1!=j||t.getDate()!=k)throw"Invalid date";return t},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1e7,formatDate:function(a,b,c){if(!b)return"";var d=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,e=(c?c.dayNames:null)||this._defaults.dayNames,f=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,h=function(b){var c=m+112?a.getHours()+2:0),a):null},_setDate:function(a,b,c){var d=!b,e=a.selectedMonth,f=a.selectedYear,g=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=g.getDate(),a.drawMonth=a.selectedMonth=a.currentMonth=g.getMonth(),a.drawYear=a.selectedYear=a.currentYear=g.getFullYear(),(e!=a.selectedMonth||f!=a.selectedYear)&&!c&&this._notifyChange(a),this._adjustInstDate(a),a.input&&a.input.val(d?"":this._formatDate(a))},_getDate:function(a){var b=!a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return b},_attachHandlers:function(a){var b=this._get(a,"stepMonths"),c="#"+a.id.replace(/\\\\/g,"\\");a.dpDiv.find("[data-handler]").map(function(){var a={prev:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(c,-b,"M")},next:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(c,+b,"M")},hide:function(){window["DP_jQuery_"+dpuuid].datepicker._hideDatepicker()},today:function(){window["DP_jQuery_"+dpuuid].datepicker._gotoToday(c)},selectDay:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectDay(c,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(c,this,"M"),!1},selectYear:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(c,this,"Y"),!1}};$(this).bind(this.getAttribute("data-event"),a[this.getAttribute("data-handler")])})},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),d=this._get(a,"showButtonPanel"),e=this._get(a,"hideIfNoPrevNext"),f=this._get(a,"navigationAsDateFormat"),g=this._getNumberOfMonths(a),h=this._get(a,"showCurrentAtPos"),i=this._get(a,"stepMonths"),j=g[0]!=1||g[1]!=1,k=this._daylightSavingAdjust(a.currentDay?new Date(a.currentYear,a.currentMonth,a.currentDay):new Date(9999,9,9)),l=this._getMinMaxDate(a,"min"),m=this._getMinMaxDate(a,"max"),n=a.drawMonth-h,o=a.drawYear;n<0&&(n+=12,o--);if(m){var p=this._daylightSavingAdjust(new Date(m.getFullYear(),m.getMonth()-g[0]*g[1]+1,m.getDate()));p=l&&pp)n--,n<0&&(n=11,o--)}a.drawMonth=n,a.drawYear=o;var q=this._get(a,"prevText");q=f?this.formatDate(q,this._daylightSavingAdjust(new Date(o,n-i,1)),this._getFormatConfig(a)):q;var r=this._canAdjustMonth(a,-1,o,n)?''+q+"":e?"":''+q+"",s=this._get(a,"nextText");s=f?this.formatDate(s,this._daylightSavingAdjust(new Date(o,n+i,1)),this._getFormatConfig(a)):s;var t=this._canAdjustMonth(a,1,o,n)?''+s+"":e?"":''+s+"",u=this._get(a,"currentText"),v=this._get(a,"gotoCurrent")&&a.currentDay?k:b;u=f?this.formatDate(u,v,this._getFormatConfig(a)):u;var w=a.inline?"":'",x=d?'
    '+(c?w:"")+(this._isInRange(a,v)?'":"")+(c?"":w)+"
    ":"",y=parseInt(this._get(a,"firstDay"),10);y=isNaN(y)?0:y;var z=this._get(a,"showWeek"),A=this._get(a,"dayNames"),B=this._get(a,"dayNamesShort"),C=this._get(a,"dayNamesMin"),D=this._get(a,"monthNames"),E=this._get(a,"monthNamesShort"),F=this._get(a,"beforeShowDay"),G=this._get(a,"showOtherMonths"),H=this._get(a,"selectOtherMonths"),I=this._get(a,"calculateWeek")||this.iso8601Week,J=this._getDefaultDate(a),K="";for(var L=0;L1)switch(N){case 0:Q+=" ui-datepicker-group-first",P=" ui-corner-"+(c?"right":"left");break;case g[1]-1:Q+=" ui-datepicker-group-last",P=" ui-corner-"+(c?"left":"right");break;default:Q+=" ui-datepicker-group-middle",P=""}Q+='">'}Q+='
    '+(/all|left/.test(P)&&L==0?c?t:r:"")+(/all|right/.test(P)&&L==0?c?r:t:"")+this._generateMonthYearHeader(a,n,o,l,m,L>0||N>0,D,E)+'
    '+"";var R=z?'":"";for(var S=0;S<7;S++){var T=(S+y)%7;R+="=5?' class="ui-datepicker-week-end"':"")+">"+''+C[T]+""}Q+=R+"";var U=this._getDaysInMonth(o,n);o==a.selectedYear&&n==a.selectedMonth&&(a.selectedDay=Math.min(a.selectedDay,U));var V=(this._getFirstDayOfMonth(o,n)-y+7)%7,W=Math.ceil((V+U)/7),X=j?this.maxRows>W?this.maxRows:W:W;this.maxRows=X;var Y=this._daylightSavingAdjust(new Date(o,n,1-V));for(var Z=0;Z";var _=z?'":"";for(var S=0;S<7;S++){var ba=F?F.apply(a.input?a.input[0]:null,[Y]):[!0,""],bb=Y.getMonth()!=n,bc=bb&&!H||!ba[0]||l&&Ym;_+='",Y.setDate(Y.getDate()+1),Y=this._daylightSavingAdjust(Y)}Q+=_+""}n++,n>11&&(n=0,o++),Q+="
    '+this._get(a,"weekHeader")+"
    '+this._get(a,"calculateWeek")(Y)+""+(bb&&!G?" ":bc?''+Y.getDate()+"":''+Y.getDate()+"")+"
    "+(j?""+(g[0]>0&&N==g[1]-1?'
    ':""):""),M+=Q}K+=M}return K+=x+($.browser.msie&&parseInt($.browser.version,10)<7&&!a.inline?'':""),a._keyEvent=!1,K},_generateMonthYearHeader:function(a,b,c,d,e,f,g,h){var i=this._get(a,"changeMonth"),j=this._get(a,"changeYear"),k=this._get(a,"showMonthAfterYear"),l='
    ',m="";if(f||!i)m+=''+g[b]+"";else{var n=d&&d.getFullYear()==c,o=e&&e.getFullYear()==c;m+='"}k||(l+=m+(f||!i||!j?" ":""));if(!a.yearshtml){a.yearshtml="";if(f||!j)l+=''+c+"";else{var q=this._get(a,"yearRange").split(":"),r=(new Date).getFullYear(),s=function(a){var b=a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?r+parseInt(a,10):parseInt(a,10);return isNaN(b)?r:b},t=s(q[0]),u=Math.max(t,s(q[1]||""));t=d?Math.max(t,d.getFullYear()):t,u=e?Math.min(u,e.getFullYear()):u,a.yearshtml+='",l+=a.yearshtml,a.yearshtml=null}}return l+=this._get(a,"yearSuffix"),k&&(l+=(f||!i||!j?" ":"")+m),l+="
    ",l},_adjustInstDate:function(a,b,c){var d=a.drawYear+(c=="Y"?b:0),e=a.drawMonth+(c=="M"?b:0),f=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+(c=="D"?b:0),g=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,f)));a.selectedDay=g.getDate(),a.drawMonth=a.selectedMonth=g.getMonth(),a.drawYear=a.selectedYear=g.getFullYear(),(c=="M"||c=="Y")&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),e=c&&bd?d:e,e},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){var b=this._get(a,"numberOfMonths");return b==null?[1,1]:typeof b=="number"?[1,b]:b},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),f=this._daylightSavingAdjust(new Date(c,d+(b<0?b:e[0]*e[1]),1));return b<0&&f.setDate(this._getDaysInMonth(f.getFullYear(),f.getMonth())),this._isInRange(a,f)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<=d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");return b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10),{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);var e=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(d,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),e,this._getFormatConfig(a))}}),$.fn.datepicker=function(a){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find("body").append($.datepicker.dpDiv),$.datepicker.initialized=!0);var b=Array.prototype.slice.call(arguments,1);return typeof a!="string"||a!="isDisabled"&&a!="getDate"&&a!="widget"?a=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b)):this.each(function(){typeof a=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this].concat(b)):$.datepicker._attachDatepicker(this,a)}):$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.8.23",window["DP_jQuery_"+dpuuid]=$})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.ui.progressbar.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=a("
    ").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove(),a.Widget.prototype.destroy.apply(this,arguments)},value:function(a){return a===b?this._value():(this._setOption("value",a),this)},_setOption:function(b,c){b==="value"&&(this.options.value=c,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),a.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;return typeof a!="number"&&(a=0),Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var a=this.value(),b=this._percentage();this.oldValue!==a&&(this.oldValue=a,this._trigger("change")),this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(b.toFixed(0)+"%"),this.element.attr("aria-valuenow",a)}}),a.extend(a.ui.progressbar,{version:"1.8.23"})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.core.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +jQuery.effects||function(a,b){function c(b){var c;return b&&b.constructor==Array&&b.length==3?b:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))?[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))?[parseFloat(c[1])*2.55,parseFloat(c[2])*2.55,parseFloat(c[3])*2.55]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))?[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:(c=/rgba\(0, 0, 0, 0\)/.exec(b))?e.transparent:e[a.trim(b).toLowerCase()]}function d(b,d){var e;do{e=(a.curCSS||a.css)(b,d);if(e!=""&&e!="transparent"||a.nodeName(b,"body"))break;d="backgroundColor"}while(b=b.parentNode);return c(e)}function h(){var a=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,b={},c,d;if(a&&a.length&&a[0]&&a[a[0]]){var e=a.length;while(e--)c=a[e],typeof a[c]=="string"&&(d=c.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),b[d]=a[c])}else for(c in a)typeof a[c]=="string"&&(b[c]=a[c]);return b}function i(b){var c,d;for(c in b)d=b[c],(d==null||a.isFunction(d)||c in g||/scrollbar/.test(c)||!/color/i.test(c)&&isNaN(parseFloat(d)))&&delete b[c];return b}function j(a,b){var c={_:0},d;for(d in b)a[d]!=b[d]&&(c[d]=b[d]);return c}function k(b,c,d,e){typeof b=="object"&&(e=c,d=null,c=b,b=c.effect),a.isFunction(c)&&(e=c,d=null,c={});if(typeof c=="number"||a.fx.speeds[c])e=d,d=c,c={};return a.isFunction(d)&&(e=d,d=null),c=c||{},d=d||c.duration,d=a.fx.off?0:typeof d=="number"?d:d in a.fx.speeds?a.fx.speeds[d]:a.fx.speeds._default,e=e||c.complete,[b,c,d,e]}function l(b){return!b||typeof b=="number"||a.fx.speeds[b]?!0:typeof b=="string"&&!a.effects[b]?!0:!1}a.effects={},a.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","borderColor","color","outlineColor"],function(b,e){a.fx.step[e]=function(a){a.colorInit||(a.start=d(a.elem,e),a.end=c(a.end),a.colorInit=!0),a.elem.style[e]="rgb("+Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2],10),255),0)+")"}});var e={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},f=["add","remove","toggle"],g={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};a.effects.animateClass=function(b,c,d,e){return a.isFunction(d)&&(e=d,d=null),this.queue(function(){var g=a(this),k=g.attr("style")||" ",l=i(h.call(this)),m,n=g.attr("class")||"";a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),m=i(h.call(this)),g.attr("class",n),g.animate(j(l,m),{queue:!1,duration:c,easing:d,complete:function(){a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),typeof g.attr("style")=="object"?(g.attr("style").cssText="",g.attr("style").cssText=k):g.attr("style",k),e&&e.apply(this,arguments),a.dequeue(this)}})})},a.fn.extend({_addClass:a.fn.addClass,addClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{add:b},c,d,e]):this._addClass(b)},_removeClass:a.fn.removeClass,removeClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{remove:b},c,d,e]):this._removeClass(b)},_toggleClass:a.fn.toggleClass,toggleClass:function(c,d,e,f,g){return typeof d=="boolean"||d===b?e?a.effects.animateClass.apply(this,[d?{add:c}:{remove:c},e,f,g]):this._toggleClass(c,d):a.effects.animateClass.apply(this,[{toggle:c},d,e,f])},switchClass:function(b,c,d,e,f){return a.effects.animateClass.apply(this,[{add:c,remove:b},d,e,f])}}),a.extend(a.effects,{version:"1.8.23",save:function(a,b){for(var c=0;c").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),e=document.activeElement;try{e.id}catch(f){e=document.body}return b.wrap(d),(b[0]===e||a.contains(b[0],e))&&a(e).focus(),d=b.parent(),b.css("position")=="static"?(d.css({position:"relative"}),b.css({position:"relative"})):(a.extend(c,{position:b.css("position"),zIndex:b.css("z-index")}),a.each(["top","left","bottom","right"],function(a,d){c[d]=b.css(d),isNaN(parseInt(c[d],10))&&(c[d]="auto")}),b.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),d.css(c).show()},removeWrapper:function(b){var c,d=document.activeElement;return b.parent().is(".ui-effects-wrapper")?(c=b.parent().replaceWith(b),(b[0]===d||a.contains(b[0],d))&&a(d).focus(),c):b},setTransition:function(b,c,d,e){return e=e||{},a.each(c,function(a,c){var f=b.cssUnit(c);f[0]>0&&(e[c]=f[0]*d+f[1])}),e}}),a.fn.extend({effect:function(b,c,d,e){var f=k.apply(this,arguments),g={options:f[1],duration:f[2],callback:f[3]},h=g.options.mode,i=a.effects[b];return a.fx.off||!i?h?this[h](g.duration,g.callback):this.each(function(){g.callback&&g.callback.call(this)}):i.call(this,g)},_show:a.fn.show,show:function(a){if(l(a))return this._show.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="show",this.effect.apply(this,b)},_hide:a.fn.hide,hide:function(a){if(l(a))return this._hide.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="hide",this.effect.apply(this,b)},__toggle:a.fn.toggle,toggle:function(b){if(l(b)||typeof b=="boolean"||a.isFunction(b))return this.__toggle.apply(this,arguments);var c=k.apply(this,arguments);return c[1].mode="toggle",this.effect.apply(this,c)},cssUnit:function(b){var c=this.css(b),d=[];return a.each(["em","px","%","pt"],function(a,b){c.indexOf(b)>0&&(d=[parseFloat(c),b])}),d}});var m={};a.each(["Quad","Cubic","Quart","Quint","Expo"],function(a,b){m[b]=function(b){return Math.pow(b,a+2)}}),a.extend(m,{Sine:function(a){return 1-Math.cos(a*Math.PI/2)},Circ:function(a){return 1-Math.sqrt(1-a*a)},Elastic:function(a){return a===0||a===1?a:-Math.pow(2,8*(a-1))*Math.sin(((a-1)*80-7.5)*Math.PI/15)},Back:function(a){return a*a*(3*a-2)},Bounce:function(a){var b,c=4;while(a<((b=Math.pow(2,--c))-1)/11);return 1/Math.pow(4,3-c)-7.5625*Math.pow((b*3-2)/22-a,2)}}),a.each(m,function(b,c){a.easing["easeIn"+b]=c,a.easing["easeOut"+b]=function(a){return 1-c(1-a)},a.easing["easeInOut"+b]=function(a){return a<.5?c(a*2)/2:c(a*-2+2)/-2+1}})}(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.blind.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.blind=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"vertical";a.effects.save(c,d),c.show();var g=a.effects.createWrapper(c).css({overflow:"hidden"}),h=f=="vertical"?"height":"width",i=f=="vertical"?g.height():g.width();e=="show"&&g.css(h,0);var j={};j[h]=e=="show"?i:0,g.animate(j,b.duration,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.bounce.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.bounce=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"effect"),f=b.options.direction||"up",g=b.options.distance||20,h=b.options.times||5,i=b.duration||250;/show|hide/.test(e)&&d.push("opacity"),a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var j=f=="up"||f=="down"?"top":"left",k=f=="up"||f=="left"?"pos":"neg",g=b.options.distance||(j=="top"?c.outerHeight(!0)/3:c.outerWidth(!0)/3);e=="show"&&c.css("opacity",0).css(j,k=="pos"?-g:g),e=="hide"&&(g=g/(h*2)),e!="hide"&&h--;if(e=="show"){var l={opacity:1};l[j]=(k=="pos"?"+=":"-=")+g,c.animate(l,i/2,b.options.easing),g=g/2,h--}for(var m=0;m").css({position:"absolute",visibility:"visible",left:-j*(g/d),top:-i*(h/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:g/d,height:h/c,left:f.left+j*(g/d)+(b.options.mode=="show"?(j-Math.floor(d/2))*(g/d):0),top:f.top+i*(h/c)+(b.options.mode=="show"?(i-Math.floor(c/2))*(h/c):0),opacity:b.options.mode=="show"?0:1}).animate({left:f.left+j*(g/d)+(b.options.mode=="show"?0:(j-Math.floor(d/2))*(g/d)),top:f.top+i*(h/c)+(b.options.mode=="show"?0:(i-Math.floor(c/2))*(h/c)),opacity:b.options.mode=="show"?1:0},b.duration||500);setTimeout(function(){b.options.mode=="show"?e.css({visibility:"visible"}):e.css({visibility:"visible"}).hide(),b.callback&&b.callback.apply(e[0]),e.dequeue(),a("div.ui-effects-explode").remove()},b.duration||500)})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.fade.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.fade=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"hide");c.animate({opacity:d},{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.fold.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.fold=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.size||15,g=!!b.options.horizFirst,h=b.duration?b.duration/2:a.fx.speeds._default/2;a.effects.save(c,d),c.show();var i=a.effects.createWrapper(c).css({overflow:"hidden"}),j=e=="show"!=g,k=j?["width","height"]:["height","width"],l=j?[i.width(),i.height()]:[i.height(),i.width()],m=/([0-9]+)%/.exec(f);m&&(f=parseInt(m[1],10)/100*l[e=="hide"?0:1]),e=="show"&&i.css(g?{height:0,width:f}:{height:f,width:0});var n={},p={};n[k[0]]=e=="show"?l[0]:f,p[k[1]]=e=="show"?l[1]:0,i.animate(n,h,b.options.easing).animate(p,h,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.highlight.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.highlight=function(b){return this.queue(function(){var c=a(this),d=["backgroundImage","backgroundColor","opacity"],e=a.effects.setMode(c,b.options.mode||"show"),f={backgroundColor:c.css("backgroundColor")};e=="hide"&&(f.opacity=0),a.effects.save(c,d),c.show().css({backgroundImage:"none",backgroundColor:b.options.color||"#ffff99"}).animate(f,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),e=="show"&&!a.support.opacity&&this.style.removeAttribute("filter"),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15 +* https://github.com/jquery/jquery-ui +* Includes: jquery.effects.pulsate.js +* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ +(function(a,b){a.effects.pulsate=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"show"),e=(b.options.times||5)*2-1,f=b.duration?b.duration/2:a.fx.speeds._default/2,g=c.is(":visible"),h=0;g||(c.css("opacity",0).show(),h=1),(d=="hide"&&g||d=="show"&&!g)&&e--;for(var i=0;i').appendTo(document.body).addClass(b.options.className).css({top:g.top,left:g.left,height:c.innerHeight(),width:c.innerWidth(),position:"absolute"}).animate(f,b.duration,b.options.easing,function(){h.remove(),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);; \ No newline at end of file diff --git a/demo/yahtzee/LICENSE.md b/demo/yahtzee/LICENSE.md new file mode 100644 index 0000000..8668d02 --- /dev/null +++ b/demo/yahtzee/LICENSE.md @@ -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. diff --git a/demo/yahtzee/README.md b/demo/yahtzee/README.md new file mode 100644 index 0000000..a447b37 --- /dev/null +++ b/demo/yahtzee/README.md @@ -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. + diff --git a/demo/yahtzee/css/yahtzee.css b/demo/yahtzee/css/yahtzee.css new file mode 100644 index 0000000..f14eef2 --- /dev/null +++ b/demo/yahtzee/css/yahtzee.css @@ -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; +} diff --git a/demo/yahtzee/images/dices.png b/demo/yahtzee/images/dices.png new file mode 100644 index 0000000..2669324 Binary files /dev/null and b/demo/yahtzee/images/dices.png differ diff --git a/demo/yahtzee/images/red_dices.png b/demo/yahtzee/images/red_dices.png new file mode 100644 index 0000000..44b52cd Binary files /dev/null and b/demo/yahtzee/images/red_dices.png differ diff --git a/demo/yahtzee/index.html b/demo/yahtzee/index.html new file mode 100644 index 0000000..bb0fad4 --- /dev/null +++ b/demo/yahtzee/index.html @@ -0,0 +1,394 @@ + + + + + + Yahtzee + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    + Launch + +
    + Launch +
    +
    +
    Three of a kind
    +
    Three dice showing the same face
    +
    Sum of all dice
    +
    Four of a kind
    +
    Four dice showing the same face
    +
    Sum of all dice
    +
    Full
    +
    A three-of-a-kind and a pair
    +
    25 points
    +
    Small straight
    +
    Four sequential dice
    +
    30 points
    +
    Large straight
    +
    Five sequential dice
    +
    40 points
    +
    Yahtzee
    +
    Five dice showing the same face
    +
    50 points
    +
    Chance
    +
    Sum of all dice
    +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Combinaison + Score +
    + + One + + +   + + Keep + Trash +
    + + Two + + +   + + Keep + Trash +
    + + Three + + +   + + Keep + Trash +
    + + Four + + +   + + Keep + Trash +
    + + Five + + +   + + Keep + Trash +
    + + Six + + +   + + Keep + Trash +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CombinaisonProbability + Score +
    + + Three of a kind + + +
    +
    +   +
    +
    +   + + Keep + Trash +
    + + Four of a kind + + +
    +
    +   +
    +
    +   + + Keep + Trash +
    + + Full + + +
    +
    +   +
    +
    +   + + Keep + Trash +
    + + Small straight + + +
    +
    +   +
    +
    +   + + Keep + Trash +
    + + Large straight + + +
    +
    +   +
    +
    +   + + Keep + Trash +
    + + Yahtzee + + +
    +
    +   +
    +
    +   + + Keep + Trash +
    + + Chance + + +
    +
    +   +
    +
    +   + + Keep + Trash +
    + +
    + + + +
    + +
    + + + + diff --git a/demo/yahtzee/js/yahtzee.js b/demo/yahtzee/js/yahtzee.js new file mode 100644 index 0000000..c2af0e9 --- /dev/null +++ b/demo/yahtzee/js/yahtzee.js @@ -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(); + } +} diff --git a/demo/yahtzee/lib/jquery-1.7.1.min.js b/demo/yahtzee/lib/jquery-1.7.1.min.js new file mode 100644 index 0000000..ee02337 --- /dev/null +++ b/demo/yahtzee/lib/jquery-1.7.1.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
    a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
    "+""+"
    ",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
    t
    ",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
    ",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

    ";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
    ";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
    ","
    "]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
    ").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/docs/development/cloudbudget.md b/docs/development/cloudbudget.md new file mode 100644 index 0000000..f940e52 --- /dev/null +++ b/docs/development/cloudbudget.md @@ -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 +``` + + + + Fork me on GitHub + + [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 \ No newline at end of file diff --git a/docs/development/cloudbudget_angularjs.md b/docs/development/cloudbudget_angularjs.md new file mode 100644 index 0000000..e194b19 --- /dev/null +++ b/docs/development/cloudbudget_angularjs.md @@ -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. + + + + + Fork me on GitHub + + [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 \ No newline at end of file diff --git a/docs/development/filebrowser_durandal_widget.md b/docs/development/filebrowser_durandal_widget.md new file mode 100644 index 0000000..1a36faf --- /dev/null +++ b/docs/development/filebrowser_durandal_widget.md @@ -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 + + + + + +##Licence + +Source code is under [MIT Licence](http://opensource.org/licenses/mit-license.php) + + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/development/project_deployer.md b/docs/development/project_deployer.md new file mode 100644 index 0000000..9ac0562 --- /dev/null +++ b/docs/development/project_deployer.md @@ -0,0 +1,25 @@ +#Introduction +ProjectDeployer is a work-in-progress web application to deploy Git projects on a server written with Meteor. + +##Features +In ProjectDeployer, it's possible to : + +* register / modify / delete Git project +* deployment is +* see deployment logs for each project + +##Usage +The location for deployed projects is set in the _server/constants.js_ file with the _DEPLOYMENT_FOLDER_ variable. + +To launch ProjectDeployer, use the following command : +``` +meteor --port $IP:$PORT +``` + + + + + Fork me on GitHub + diff --git a/docs/development/springboot_react_webpack.md b/docs/development/springboot_react_webpack.md new file mode 100644 index 0000000..63c9ac6 --- /dev/null +++ b/docs/development/springboot_react_webpack.md @@ -0,0 +1,155 @@ +# springboot-react-webpack +A demo project with Spring Boot, React and Webpack + +This project includes : + +* Spring Boot as backend resource +* React as client JS framework +* webpack to translate JSX to JS and manage client resources link +* maven-release-plugin +* cf-maven-plugin +* docker-maven-plugin (from Spotify) + +## Profile + +There are 3 profiles : + +* the default one (without specification) is for development mode. +* _production_ used to generate the production ready client resources +* _docker_ to access to the Docker plugin and generate an image + +## Launching + +To launch this project, just use the following command line : + +In development mode : +``` +mvn clean spring-boot:run +npm run watch +``` +In production mode : +``` +mvn clean spring-boot:run -P production +``` +Without a profile, you have to run the webpack watcher to deliver client resources. With the _production_ profile, no needs to launch the wepback watcher. + +## Configuration +To use the CloudFoundry and Release plugins, the _settings.xml_ must contains the following lines : + +```xml + + + cloudfoundry + username + password + + + github + username + password + + +``` + +## Spring Boot + +Spring Boot is used as the backend server. It provides the HTML pages and the REST endpoints. +React is server side compiled at runtime using nashorn. + +## React + +React is the client side library. It's possible to write JSX which will be translate by webpack. + + +## Webpack + +### Configuration + +Webpack configuration is done by the _webpack.config.js_ file at the project's root. + +### Usage + +Webpack is launched at the _generate-resources_ maven phase. +In this configuration, webpack provides resources (JS and CSS) for commons librairies and custom JS scripts. It takes in account LESS. The HTML final resource is generated from a template adding the needed resources. +Using the default profile and the watcher, the HotModuleReplacement module is activated, so no need to refresh the page when updating a JS or a CSS, webpack does it. + + +## Plugin release + +### Configuration + +To manage the release process with Git, you have to replace the link in the _developerConnection_ tag with the Git project URL. + +### Usage + +The _maven-release-plugin_ allows to release an app tagging the repository. A release is : +* changing from SNAPSHOT to stable +* creating a tag (locally and remotely) +* increasing the SNAPSHOT version + +Two steps : +``` +mvn release:prepare +mvn release:perform +``` + +To rollback a _prepare_ : +``` +mvn release:rollback +``` + +To test the release : +``` +mvn -DdryRun=true release:prepare +mvn release:clean (test cleaning) +``` + +### Documentation + + + +## Plugin CloudFoundry + +### Configuration + +Change the _TOFILL_ strings in the comment plugin's section. + +### Usage + +The _cf-maven-plugin_ plugin allows to manage the application in a CloudFoundry platform and specifically to push it : + +``` +mvn cf:push +``` + +### Documentation + + + + +## Plugin Docker + +### Configuration + +The _docker-maven-plugin_ (from Spotify) plugin has no configuration. + +### Usage + +The default project packaging (for CloudFoundry) is a WAR. In the Docker image, we use a JAR. To use this plugin (and the correct packaging), use the _docker_ profile : + +``` +mvn package -P docker +``` + +This command generates a local Docker image. To manage it, use the _docker_ profile to access the _docker-maven-plugin_ (such as push it). + +### Documentation + + + + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/docker/docker_apache_log_generator.md b/docs/docker/docker_apache_log_generator.md new file mode 100644 index 0000000..1184b11 --- /dev/null +++ b/docs/docker/docker_apache_log_generator.md @@ -0,0 +1,34 @@ +#Docker Apache log generator +This is a simple Docker container to provide random apache logs. +It's based on [Fake-Apache-Log-Generator](https://github.com/kiritbasu/Fake-Apache-Log-Generator) + +The default behaviour is the following : +```sql +python apache-fake-log-gen.py -o LOG -p /var/log/apache/apache -n 0 -s 3 +``` +The endless generated file is located in /var/log and a line is appended every 3 seconds. + +##Timezone + +You can change the timezone mounting */etc/timezone* and */etc/localtime* files with a file content such as : +```shell +Europe/Paris +``` + + +##Licences + +Copyright (c) 2017 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. + + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/docker/docker_gocd.md b/docs/docker/docker_gocd.md new file mode 100644 index 0000000..655407b --- /dev/null +++ b/docs/docker/docker_gocd.md @@ -0,0 +1,23 @@ +#Docker GoCD +GoCD is a Continuous Delivery solution. This project embedded different containers such as a server and nodes. + +##Embedded containers + + 1. [GoCD server](https://github.com/Febbweiss/gocd-docker/tree/master/gocd-server) - The main container based on Debian image + 2. [Cloudfoundry agent](https://github.com/Febbweiss/gocd-docker/tree/master/gocd-agent-cloudfoundry) - A node to deploy on CloudFoundry based on alpine image + 3. [Docker agent](https://github.com/Febbweiss/gocd-docker/tree/master/gocd-agent-docker) - A node to build and deploy Docker containers based on docker image + 4. [Java agent](https://github.com/Febbweiss/gocd-docker/tree/master/gocd-agent-jdk8) - A node to manage Java applications (compile / build) based on alpine-oraclejdk8 image + 5. [NodeJS agent](https://github.com/Febbweiss/gocd-docker/tree/master/gocd-agent-nodejs) - A node to manage NodeJS applications (compile / build) based on Debian image + 6. [Generic agent](https://github.com/Febbweiss/gocd-docker/tree/master/gocd-agent) - A node providing Java and NodeJS applications management based on Node image + +##Usage +The full stack is manage with docker-compose. So, to launch it, just use +``` +docker-compose up +``` + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/docker/docker_log_centralizer.md b/docs/docker/docker_log_centralizer.md new file mode 100644 index 0000000..4a08925 --- /dev/null +++ b/docs/docker/docker_log_centralizer.md @@ -0,0 +1,41 @@ +#Docker log centralizer +This a end-to-end log centralizer powered by the ELK stask. + +##Embedded containers + + 1. [Filebeat](https://www.elastic.co/products/beats/filebeat) - An agent to poll logs + 2. [Logstash-Forwarder](https://github.com/elastic/logstash-forwarder) - An other agent to poll logs + 3. [Logstash](https://www.elastic.co/products/logstash) - The collector / analyzer / parser solution + 4. [Kafka](http://kafka.apache.org) - The queueing solution for logs + 5. [ZooKeeper](https://zookeeper.apache.org/) - The cluster on which Kafka is running + 6. [ElasticSearch](https://www.elastic.co/products/elasticsearch) - The indexing engine + 7. [Kibana](https://www.elastic.co/products/kibana) - The visualization / dashboard tool for ElasticSearch + 8. [Kafka Manager](https://github.com/yahoo/kafka-manager) - The Kafka cluster web manager + 9. [Apache log generator](https://github.com/Febbweiss/docker-apache-log-generator) - A container generating fake apache logs + 10. [Random log generator](https://hub.docker.com/r/davidmccormick/random_log_generator) - A container genrating text logs (Star Wars quotes) + +##How it works + +There are 2 agent types : + + - Filebeat + - Logstash-Forward + +These agents push logs (from the apache and random generators) to a Logstasth shipper filling a Kafka queue (one type of log for one topic). +A Logstash indexer polls the Kafka topics indexing logs into a ElasticSearch. + +A short schema : +``` +Agent -> Logstach shipper -> Kafka <- Logstash indexer -> ElasticSearch +``` + +##Tools access + +Kibana is available at http://localhost:5601. +Kafka Manager is available at http://localhost:9000 + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/extra/css/extra.css b/docs/extra/css/extra.css new file mode 100644 index 0000000..4a033be --- /dev/null +++ b/docs/extra/css/extra.css @@ -0,0 +1,68 @@ +/* Source : https://codepen.io/thierrymichel/pen/Pwzbmd */ + +[class*="push"] { + position: relative; + display: inline-block; + width: 40px; + height: 40px; + border: 0; + margin: 1em; + outline: none; + background-color: #c2290a; + border-radius: 50%; + cursor: pointer; + -webkit-transition: box-shadow 200ms; + transition: box-shadow 200ms; +} + +.push--flat { + box-shadow: inset 0 1.25px 0 #da2e0b, inset 0 -1.25px 0 #aa2409, inset 0 0 0 1.25px #b32609, inset 0 0 0 3.33333px #c2290a, inset 0 0 0 4px #611405, inset 0 0 0 4.34783px black, inset 0 0 0 5.33333px rgba(247, 133, 110, 0.7), inset 0 0 0 7.27273px #c2290a, inset 0 16px 5.33333px #aa2409, inset 0 0 4px 6.66667px #911f08, 0 2px 0 rgba(0, 0, 0, 0.3); +} +.push--flat:after { + content: ''; + position: absolute; + bottom: 2px; + left: 4px; + display: block; + width: 32px; + height: 32px; + border: 2.66667px solid rgba(0, 0, 0, 0.3); + border-width: 0 0 2.66667px; + border-radius: 50%; + -webkit-transition-duration: 200ms; + transition-duration: 200ms; +} +.push--flat:active, .push--flat.is-pushed { + box-shadow: inset 0 1.25px 0 #da2e0b, inset 0 -1.25px 0 #aa2409, inset 0 0 0 1.25px #b32609, inset 0 0 0 3.33333px #c2290a, inset 0 0 0 4px #611405, inset 0 0 0 4.70588px black, inset 0 0 0 5.33333px rgba(247, 133, 110, 0.2), inset 0 0 0 7.27273px #b32609, inset 0 16px 5.33333px #9b2108, inset 0 0 4px 6.66667px #791a06, 0 2px 0 rgba(0, 0, 0, 0.3); + background-color: #b8270a; +} +.push--flat:active:after, .push--flat.is-pushed:after { + bottom: 4.66667px; + border-width: 0; +} + +.push--skeuo { + box-shadow: inset 0 1.66667px 0 #da2e0b, inset 0 -1.66667px 0.66667px #aa2409, 0 0 0.66667px #c2290a, inset 0 0 1.33333px #791a06, inset 0 0 1.33333px rgba(51, 51, 51, 0.5), inset 0 0 0.66667px 3.33333px #c2290a, inset 0 -1.33333px 1px 4px rgba(51, 51, 51, 0.7), inset 0 0 0.66667px 4px #611405, inset 0 0 0.66667px 4px rgba(51, 51, 51, 0.7), inset 0 0 0.33333px 4.34783px black, inset 0 0 0.33333px 5px rgba(247, 133, 110, 0.7), inset 0 2px 0 4.70588px rgba(244, 71, 37, 0.7), inset 0 -2px 0.66667px 4.70588px rgba(145, 31, 8, 0.2), inset 0 0 0 7.27273px #c2290a, inset 0 16px 5.33333px #aa2409, inset 0 0 4px 6.66667px #911f08, 0 1px 2px rgba(0, 0, 0, 0.5); +} +.push--skeuo:active, .push--skeuo.is-pushed { + box-shadow: inset 0 1.66667px 0 #da2e0b, inset 0 -1.66667px 0.66667px #aa2409, 0 0 0.66667px #c2290a, inset 0 0 1.33333px #791a06, inset 0 0 1.33333px rgba(51, 51, 51, 0.5), inset 0 0 0.66667px 3.33333px #c2290a, inset 0 -1.33333px 1px 4px rgba(51, 51, 51, 0.7), inset 0 0 0.66667px 4px #611405, inset 0 0 0.66667px 4px rgba(51, 51, 51, 0.7), inset 0 0 1px 4.70588px black, inset 0 0 0.33333px 5.33333px rgba(247, 133, 110, 0.2), inset 0 2px 0 28px rgba(244, 71, 37, 0.5), inset 0 -2px 0.66667px 28px rgba(97, 20, 5, 0.2), inset 0 0 0 7.27273px #b32609, inset 0 16px 5.33333px #9b2108, inset 0 0 4px 6.66667px #791a06, 0 1px 2px rgba(0, 0, 0, 0.5); + background-color: #b8270a; +} +.push--skeuo:active:before, .push--skeuo.is-pushed:before { + opacity: .5; +} +.push--skeuo:before { + content: ''; + position: absolute; + bottom: 8.88889px; + left: 11.11111px; + display: block; + width: 18.18182px; + height: 12.12121px; + background: rgba(247, 133, 110, 0.2); + background: -webkit-linear-gradient(bottom, rgba(250, 173, 158, 0.3) 0%, rgba(194, 41, 10, 0.1) 100%); + background: linear-gradient(to top, rgba(250, 173, 158, 0.3) 0%, rgba(194, 41, 10, 0.1) 100%); + border-radius: 40% 40% 60% 60%; + -webkit-transition: opacity 200ms; + transition: opacity 200ms; +} diff --git a/docs/extra/css/sis.css b/docs/extra/css/sis.css new file mode 100644 index 0000000..f6e9e99 --- /dev/null +++ b/docs/extra/css/sis.css @@ -0,0 +1,26 @@ +.corn { + float: left; + background: transparent url('/demo/sis/images/farm.png') no-repeat top left; + background-position: -19px -37px; + width: 19px; + height: 19px; + margin-right: 5px; +} + +.carot { + float: left; + background: transparent url('/demo/sis/images/farm.png') no-repeat top left; + background-position : -38px -37px; + width: 19px; + height: 19px; + margin-right: 5px; +} + +.gun { + float: left; + background: transparent url('/demo/sis/images/farm.png') no-repeat top left; + background-position : -57px -37px; + width: 19px; + height: 19px; + margin-right: 5px; +} diff --git a/docs/extra/js/pacman.js b/docs/extra/js/pacman.js new file mode 100644 index 0000000..e10a4f2 --- /dev/null +++ b/docs/extra/js/pacman.js @@ -0,0 +1,12 @@ +$(document).ready(function() { + $('#startBtn').on('click', function(event) { + for( var i = 1; i < 4; i++) { + $("#life" + i).css('opacity', '100'); + $("#life" + i).show(); + } + SCOREBOARD.score = Game.score = 0; + Game.level = -1; + Game.lives = 3; + Game.init(); + }); +}); \ No newline at end of file diff --git a/docs/extra/js/pyramid.js b/docs/extra/js/pyramid.js new file mode 100644 index 0000000..9934950 --- /dev/null +++ b/docs/extra/js/pyramid.js @@ -0,0 +1,11 @@ +$(document).ready(function() { + $('#startBtn').on('click', function(event) { + for( var i = 0; i < 52; i++ ) { + Deck.cards[i] = i +1; + } + $('img[id^="card"]').remove(); + $("#drawn").removeClass(); + $("#stock").addClass("card").addClass("background"); + Pyramid.init(); + }); +}); \ No newline at end of file diff --git a/docs/extra/js/sis.js b/docs/extra/js/sis.js new file mode 100644 index 0000000..0401fd4 --- /dev/null +++ b/docs/extra/js/sis.js @@ -0,0 +1,23 @@ +$(document).ready(function() { + $('#startBtn').on('click', function(event) { + Game.running = false; + Game.wave_index = -1; + Game.wave = undefined; + Game.aliens = []; + Game.ship = null; + Game.score = 0; + Game.shots = { + total : 0, + lost : 0 + }; + Game.init(); + $.loadCallback(function(percent){ + $("#loadingBar").width(400*percent); + }); + $.playground().startGame( + function() { + $("#welcomeScreen").remove(); + } + ); + }); +}); \ No newline at end of file diff --git a/docs/extra/js/yahtzee.js b/docs/extra/js/yahtzee.js new file mode 100644 index 0000000..afa7456 --- /dev/null +++ b/docs/extra/js/yahtzee.js @@ -0,0 +1,10 @@ +$(document).ready(function() { + $('#startBtn').on('click', function(event) { + Yahtzee.clear(true); + Yahtzee.scoreUp = Yahtzee.scoreDown = 0; + $('span[id$="Score"]').html(' '); + $("#scorePanel").hide(); + $("#launch").html(0); + $("#launchBtn").removeClass("disabled"); + }); +}); \ No newline at end of file diff --git a/docs/games/Space_invaders_stories.md b/docs/games/Space_invaders_stories.md new file mode 100644 index 0000000..39f4259 --- /dev/null +++ b/docs/games/Space_invaders_stories.md @@ -0,0 +1,45 @@ +#Space invaders : Stories + +This is _Space invaders_ implementation currently under construction. + + +##How to + +The goal is to avoid alien invasion. +Use your keyboard arrows to move your hero and the space key to fire. +Warning : your ammo are limited by your weapon rate of fire... + +There are currently 3 different weapons : + + a shotgun + + a carot-machine gun + + a corn-grenade + + + + + + +##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. + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/games/pacman.md b/docs/games/pacman.md new file mode 100644 index 0000000..5a82de3 --- /dev/null +++ b/docs/games/pacman.md @@ -0,0 +1,46 @@ +#Pacman +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. + +##Demo + + + + + +##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) + + + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/games/pyramid.md b/docs/games/pyramid.md new file mode 100644 index 0000000..05ce33a --- /dev/null +++ b/docs/games/pyramid.md @@ -0,0 +1,34 @@ +#Pyramid +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. + +##Demo + + + + + + +##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/) + + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/games/yahtzee.md b/docs/games/yahtzee.md new file mode 100644 index 0000000..dc5d355 --- /dev/null +++ b/docs/games/yahtzee.md @@ -0,0 +1,40 @@ +#Yahtzee + +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. + + + + + + +##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. + + + + + Fork me on GitHub \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..08e493c --- /dev/null +++ b/docs/index.md @@ -0,0 +1,27 @@ +# Welcome + +I made some projects and published them on [GitHub](https://github.com/febbweiss/). +In this space, you will find some of them. Basiclly, these pages are _README_ files but with some adds and demos. + +Different projects for different needs : + +* Development + - Java + + [Springboot / React / Webpack](/development/springboot_react_webpack) + - NodeJS + + [CloudBudget](/development/cloudbudget) (Express) + + [Project deployer](/development/project_deployer) (Meteor) + - Client-side + + [CloudBudget-AngularJS](/development/cloudbudget_angularjs) (Express / AngularJS) + + [Durandal filebrowser widget](/development/filebrowser_durandal_widget) (DurandalJS) +* Docker + - Fullstack servers + + [Log centralizer](/docker/docker_log_centralizer) ELK stack with Kafka + + [GoCD](/docker/docker_gocd) GoCD server and agents + - Utilities + + [Apache log generator](/docker/docker_apache_log_generator) +* Javascript games + - [Space invaders](/games/Space_invaders_stories) + - [Pacman](/games/pacman) + - [Pyramid](/games/pyramid) + - [Yahtzee](/games/yahtzee) \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..c3b300b --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,4 @@ +site_name: Febbweiss +repo_url: https://github.com/febbweiss/ +theme: readthedocs +