From 86a20798d3725142de33cf97d10372d29c448c11 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 18 Jul 2016 18:12:33 +0200 Subject: [PATCH 1/4] Adding comments --- Animation/Animation.js | 10 ++++ Animation/Canvas/Particle.js | 68 +++++++++++++++++++++++++++ Animation/Canvas/ParticleAnimation.js | 50 +++++++++++++++++++- 3 files changed, 127 insertions(+), 1 deletion(-) diff --git a/Animation/Animation.js b/Animation/Animation.js index dc5c5f6..0e83320 100644 --- a/Animation/Animation.js +++ b/Animation/Animation.js @@ -14,6 +14,16 @@ /** @namespace jsOMS.Animation.Animation */ jsOMS.Autoloader.defineNamespace('jsOMS.Animation.Animation'); + /** + * requestAnimationFrame wrapper + * + * @return {function} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Animation.requestAnimationFrame = (function () { return window.requestAnimationFrame || diff --git a/Animation/Canvas/Particle.js b/Animation/Canvas/Particle.js index 911275f..2b714f9 100644 --- a/Animation/Canvas/Particle.js +++ b/Animation/Canvas/Particle.js @@ -32,33 +32,101 @@ this.color = {r: 255, g: 255, b: 255, a: 0.5}; }; + /** + * Get particle radius + * + * @return {int} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.getRadius = function () { return this.radius; }; + /** + * Set particle position + * + * @param {int} posX Position x + * @param {int} posY Position y + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.setPosition = function (posX, posY) { this.posX = posX; this.posY = posY; }; + /** + * Get position + * + * @return {Object} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.getPosition = function () { return {x: this.posX, y: this.posY}; }; + /** + * Set particle velocity + * + * @param {float} velX Velocity x + * @param {float} velY Velocity y + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.setVelocity = function (velX, velY) { this.velX = velX; this.velY = velY; }; + /** + * Get velocity + * + * @return {Object} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.getVelocity = function () { return {x: this.velX, y: this.velY}; }; + /** + * Draw particle to canvas + * + * @param {object} ctx Canvas + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.Particle.prototype.draw = function (ctx) { ctx.fillStyle = 'rgba(' + this.color.r + ', ' + this.color.g + ', ' + this.color.b + ', ' + this.color.a + ')'; diff --git a/Animation/Canvas/ParticleAnimation.js b/Animation/Canvas/ParticleAnimation.js index 3234ae9..d3f54a9 100644 --- a/Animation/Canvas/ParticleAnimation.js +++ b/Animation/Canvas/ParticleAnimation.js @@ -1,5 +1,5 @@ /** - * Particle class. + * Particle animation class. * * @author OMS Development Team * @author Dennis Eichhorn @@ -15,6 +15,9 @@ jsOMS.Autoloader.defineNamespace('jsOMS.Animation.Canvas'); /** + * + * @param {object} canvas Canvas + * * @constructor * * @since 1.0.0 @@ -45,6 +48,18 @@ } }; + /** + * Draw everything + * + * @param {object} self Object reference for self invoke + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.draw = function (self) { self = typeof self !== 'undefined' ? self : this; @@ -63,11 +78,31 @@ }); }; + /** + * Invalidate/clean canvas + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.invalidate = function () { this.ctx.clearRect(0, 0, this.width, this.height); }; + /** + * Update particle + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.updateParticles = function () { let particle, @@ -107,6 +142,19 @@ } }; + /** + * Handle distance between particles + * + * @param {Particle} p1 Particle + * @param {Particle} p2 Particle + * + * @return {void} + * + * @method + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ jsOMS.Animation.Canvas.ParticleAnimation.prototype.updateDistance = function (p1, p2) { let pos1 = p1.getPosition(), From 58c96cfeb92de7b3b27040c88e1995bc7e1f606d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 28 Jul 2016 18:54:26 +0200 Subject: [PATCH 2/4] Binding element --- UI/Input.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/UI/Input.js b/UI/Input.js index 3229214..8e79345 100644 --- a/UI/Input.js +++ b/UI/Input.js @@ -36,8 +36,12 @@ * @since 1.0.0 * @author Dennis Eichhorn */ - jsOMS.UI.Input.bind = function (input) + jsOMS.UI.Input.bindElement = function (input) { + if(typeof input === 'undefined') { + throw 'Input element required' + } + let self = this; input.addEventListener('change', function changeBind(event) From 10886f01781d3036f9267700aa74ffe24e794576 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 2 Aug 2016 09:16:36 +0200 Subject: [PATCH 3/4] Spreadsheet skeleton --- Spreadsheet/Formatting.js | 0 Spreadsheet/Functions.js | 0 Spreadsheet/Sheet.js | 0 Spreadsheet/Spreadsheet.js | 23 +++++++++++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 Spreadsheet/Formatting.js create mode 100644 Spreadsheet/Functions.js create mode 100644 Spreadsheet/Sheet.js create mode 100644 Spreadsheet/Spreadsheet.js diff --git a/Spreadsheet/Formatting.js b/Spreadsheet/Formatting.js new file mode 100644 index 0000000..e69de29 diff --git a/Spreadsheet/Functions.js b/Spreadsheet/Functions.js new file mode 100644 index 0000000..e69de29 diff --git a/Spreadsheet/Sheet.js b/Spreadsheet/Sheet.js new file mode 100644 index 0000000..e69de29 diff --git a/Spreadsheet/Spreadsheet.js b/Spreadsheet/Spreadsheet.js new file mode 100644 index 0000000..7af6daa --- /dev/null +++ b/Spreadsheet/Spreadsheet.js @@ -0,0 +1,23 @@ +/** + * Form view. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 * @since 1.0.0 + */ +(function (jsOMS) +{ + "use strict"; + /** @namespace jsOMS.Spreadsheet */ + jsOMS.Autoloader.defineNamespace('jsOMS.Spreadsheet'); + + jsOMS.Spreadsheet.Spreadsheet = function(id, options) + { + this.title = ''; + this.sheets = []; + this.columns = true; + this.rows = true; + }; +}(window.jsOMS = window.jsOMS || {})); \ No newline at end of file From afcc8a6646830467e483198f48b3953d17e257da Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 2 Aug 2016 15:34:57 +0200 Subject: [PATCH 4/4] Update spreadsheet cell --- Spreadsheet/Cell.js | 22 ++++++++++++++++++++++ Spreadsheet/Spreadsheet.js | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 Spreadsheet/Cell.js diff --git a/Spreadsheet/Cell.js b/Spreadsheet/Cell.js new file mode 100644 index 0000000..d6314d0 --- /dev/null +++ b/Spreadsheet/Cell.js @@ -0,0 +1,22 @@ +/** + * Cell. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 * @since 1.0.0 + */ +(function (jsOMS) +{ + "use strict"; + /** @namespace jsOMS.Spreadsheet */ + jsOMS.Autoloader.defineNamespace('jsOMS.Spreadsheet'); + + jsOMS.Spreadsheet.Cell = function(id, raw) + { + this.id = id; + this.raw = raw; + this.formatting = raw.formatting; + }; +}(window.jsOMS = window.jsOMS || {})); \ No newline at end of file diff --git a/Spreadsheet/Spreadsheet.js b/Spreadsheet/Spreadsheet.js index 7af6daa..7b6afc9 100644 --- a/Spreadsheet/Spreadsheet.js +++ b/Spreadsheet/Spreadsheet.js @@ -1,5 +1,5 @@ /** - * Form view. + * Spreadsheet view. * * @author OMS Development Team * @author Dennis Eichhorn @@ -13,11 +13,39 @@ /** @namespace jsOMS.Spreadsheet */ jsOMS.Autoloader.defineNamespace('jsOMS.Spreadsheet'); - jsOMS.Spreadsheet.Spreadsheet = function(id, options) + jsOMS.Spreadsheet.Spreadsheet = function(id, dataset, options) { + this.spreadsheet = document.getElementById(id); this.title = ''; this.sheets = []; this.columns = true; this.rows = true; + this.dataset = []; + this.compiledData = []; + this.scroll = {h: false, v: false}; + }; + + jsOMS.SpreadSheet.prototype.draw = function() + { + let col = 0, + row = 0, + cRows = this.dataset.length(), + cCols = 0; + j = 0, + this.compiledData = this.dataset; + + for(let i = 0; i < cRows; i++) { + cCols = this.compiledData[i].length(); + + for(j = 0; j < cCols; j++) { + this.compiledData[i][j] = Functions.evaluate(this.compiledData[i][j], compiledData); + + this.drawCell(this.compiledData[i][j]); + } + } + }; + + jsOMS.SpreadSheet.prototype.drawCell = function() + { }; }(window.jsOMS = window.jsOMS || {})); \ No newline at end of file