summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2014-11-13 23:28:20 +0100
committerMatěj Cepl <mcepl@redhat.com>2014-11-13 23:28:20 +0100
commit8459c8ad8ac035a82b778fa460f75b20e8c10fae (patch)
treeb69c31759b72bc64f6f14ced3d6b778a0497ca18
parentbadcf6cb1dbe15e4d200e255ac3aa37e99664578 (diff)
downloadzalmy-8459c8ad8ac035a82b778fa460f75b20e8c10fae.tar.gz
Add a better comments and ignore generated files.
-rw-r--r--.gitignore4
-rw-r--r--activePage.js100
-rw-r--r--activePage.js.map1
-rw-r--r--activePage.ts10
-rw-r--r--config.js7
-rw-r--r--config.js.map1
-rw-r--r--zalmy.js92
-rw-r--r--zalmy.ts4
8 files changed, 12 insertions, 207 deletions
diff --git a/.gitignore b/.gitignore
index 51947e7..d9db49a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
*~
-zalmy.js.map
+*.js
+*.js.map
+!require.js
diff --git a/activePage.js b/activePage.js
deleted file mode 100644
index 62b4b4d..0000000
--- a/activePage.js
+++ /dev/null
@@ -1,100 +0,0 @@
-/// <reference path='touchEvent.d.ts' />
-define(["require", "exports"], function(require, exports) {
- var ActivePage = (function () {
- function ActivePage() {
- var _this = this;
- this.cur_section = null;
- this.swipe_pos_x = 0;
- this.swipe_pos_y = 0;
- // Swipe event handlers
- document.body.addEventListener("dblclick", function () {
- console.log("dblclick");
- _this.display();
- }, false);
-
- document.body.addEventListener("mousedown", function (evt) {
- _this.swipe_pos_x = evt.screenX;
- _this.swipe_pos_y = evt.screenY;
- console.log("mousedown; pos = " + _this.swipe_pos_x + " / " + _this.swipe_pos_y);
- }, false);
-
- document.body.addEventListener("mouseup", function (evt) {
- console.log("mouseup; end_pos = " + evt.screenX + " / " + evt.screenY);
- _this.handle_move(_this.swipe_pos_x - evt.screenX, _this.swipe_pos_y - evt.screenY);
- }, false);
-
- document.body.addEventListener("touchstart", function (evt) {
- _this.swipe_pos_x = evt.changedTouches[0].screenX;
- _this.swipe_pos_y = evt.changedTouches[0].screenY;
- console.log("touchstart; pos = " + _this.swipe_pos_x + " / " + _this.swipe_pos_y);
- }, false);
-
- document.body.addEventListener("touchend", function (evt) {
- var end_pos = evt.changedTouches[evt.changedTouches.length - 1];
- console.log("touchend; end_pos = " + end_pos.screenX + " / " + end_pos.screenY);
-
- // We want't opposite direction to Mouse gestures here
- // so the difference should be opposite
- _this.handle_move(end_pos.screenX - _this.swipe_pos_x, end_pos.screenY - _this.swipe_pos_y);
- }, false);
-
- document.body.addEventListener("touchcancel", function () {
- console.log("touchcancel");
- _this.swipe_pos_x = 0;
- _this.swipe_pos_y = 0;
- }, false);
-
- applicationCache.addEventListener("updateready", function () {
- location.reload();
- });
-
- this.display();
- }
- ActivePage.prototype.display = function (disp_no) {
- if (typeof disp_no === "undefined") { disp_no = 0; }
- };
-
- ActivePage.prototype.hide = function () {
- };
-
- /**
- * react to the discovered distance of swipe
- *
- * @param distX Number distance in points in direction X
- * @param distY Number distance in points in direction Y
- *
- * There is a preference for the horizontal swipe; if that doesn't
- * happen (i.e., the distance travelled horizontally is less than
- * negligible), then the vertical swipe (in either direction) means
- * jump to today.
- */
- ActivePage.prototype.handle_move = function (distX, distY) {
- var negligible = 100;
- console.log('distX = ' + distX);
- console.log('distY = ' + distY);
-
- if (distX < -negligible) {
- console.log("swipe left");
- this.next();
- } else if (distX > negligible) {
- console.log("swipe right");
- this.prev();
- }
- };
-
- ActivePage.prototype.next = function () {
- console.log("Next!");
- this.cur_section += 1;
- this.display(this.cur_section);
- };
-
- ActivePage.prototype.prev = function () {
- console.log("Previous!");
- this.cur_section -= 1;
- this.display(this.cur_section);
- };
- return ActivePage;
- })();
- exports.ActivePage = ActivePage;
-});
-//# sourceMappingURL=activePage.js.map
diff --git a/activePage.js.map b/activePage.js.map
deleted file mode 100644
index 3992ac7..0000000
--- a/activePage.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"activePage.js","sourceRoot":"","sources":["activePage.ts"],"names":["ActivePage","ActivePage.constructor","ActivePage.display","ActivePage.hide","ActivePage.handle_move","ActivePage.next","ActivePage.prev"],"mappings":"AAAA,wCAAwC;AAAxC;IAEA;QAKEA;YAAAC,iBAuDCA;YA3DDA,KAAOA,WAAWA,GAAGA,IAAIA,CAACA;YAC1BA,KAAQA,WAAWA,GAAGA,CAACA,CAACA;YACxBA,KAAQA,WAAWA,GAAGA,CAACA,CAACA;YAGtBA,uBAAuBA;YACvBA,QAAQA,CAACA,IAAIA,CAACA,gBAAgBA,CAACA,UAAUA,EACvCA;gBACEA,OAAOA,CAACA,GAAGA,CAACA,UAAUA,CAACA;gBACvBA,KAAIA,CAACA,OAAOA,CAACA,CAACA;YAChBA,CAACA,EAAEA,KAAKA,CAACA;;YAEXA,QAAQA,CAACA,IAAIA,CAACA,gBAAgBA,CAACA,WAAWA,EACxCA,UAACA,GAAeA;gBACdA,KAAIA,CAACA,WAAWA,GAAGA,GAAGA,CAACA,OAAOA;gBAC9BA,KAAIA,CAACA,WAAWA,GAAGA,GAAGA,CAACA,OAAOA;gBAC9BA,OAAOA,CAACA,GAAGA,CAACA,mBAAmBA,GAAGA,KAAIA,CAACA,WAAWA,GAChDA,KAAKA,GAAGA,KAAIA,CAACA,WAAWA,CAACA;YAC7BA,CAACA,EAAEA,KAAKA,CAACA;;YAEXA,QAAQA,CAACA,IAAIA,CAACA,gBAAgBA,CAACA,SAASA,EACtCA,UAACA,GAAeA;gBACdA,OAAOA,CAACA,GAAGA,CAACA,qBAAqBA,GAAGA,GAAGA,CAACA,OAAOA,GAC7CA,KAAKA,GAAGA,GAAGA,CAACA,OAAOA,CAACA;gBACtBA,KAAIA,CAACA,WAAWA,CAACA,KAAIA,CAACA,WAAWA,GAAGA,GAAGA,CAACA,OAAOA,EAC7CA,KAAIA,CAACA,WAAWA,GAAGA,GAAGA,CAACA,OAAOA,CAACA;YACnCA,CAACA,EAAEA,KAAKA,CAACA;;YAEXA,QA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AAMA,CAACA,CAACA;YAAEA,CAACA,CAC3BA;;YAEHA,IAAIA,CAACA,OAAOA,CAACA,CAACA;QAChBA,CAACA;QAEDD,+BAAAA,UAAQA,OAAmBA;YAAnBE,sCAAAA,OAAOA,GAAWA,CAACA;AAAAA,QAC3BA,CAACA;;QAEDF,4BAAAA;QACAG,CAACA;;QAaDH;;;;;;;;;;UADGA;2CACHA,UAAYA,KAAaA,EAAEA,KAAaA;YACtCI,IAAIA,UAAUA,GAAGA,GAAGA;YACpBA,OAAOA,CAACA,GAAGA,CAACA,UAAUA,GAAGA,KAAKA,CAACA;YAC/BA,OAAOA,CAACA,GAAGA,CAACA,UAAUA,GAAGA,KAAKA,CAACA;;YAE/BA,IAAIA,KAAKA,GAAGA,CAACA,UAAUA,CACvBA;gBACEA,OAAOA,CAACA,GAAGA,CAACA,YAAYA,CAACA;gBACzBA,IAAIA,CAACA,IAAIA,CAACA,CAACA;aACZA,MACIA,IAAIA,KAAKA,GAAGA,UAAUA,CAC3BA;gBACEA,OAAOA,CAACA,GAAGA,CAACA,aAAaA,CAACA;gBAC1BA,IAAIA,CAACA,IAAIA,CAACA,CAACA;aACZA;QACHA,CAACA;;QAEDJ,4BAAAA;YACEK,OAAOA,CAACA,GAAGA,CAACA,OAAOA,CAACA;YACpBA,IAAIA,CAACA,WAAWA,IAAIA,CAACA;YACrBA,IAAIA,CAACA,OAAOA,CAACA,IAAIA,CAACA,WAAWA,CAACA;QAChCA,CAACA;;QAEDL,4BAAAA;YACEM,OAAOA,CAACA,GAAGA,CAACA,WAAWA,CAACA;YACxBA,IAAIA,CAACA,WAAWA,IAAIA,CAACA;YACrBA,IAAIA,CAACA,OAAOA,CAACA,IAAIA,CAACA,WAAWA,CAACA;QAChCA,CAACA;QAEHN,kBAACA;IAADA,CAACA,IAAA;IA5GD,gCA4GC;GAAA"} \ No newline at end of file
diff --git a/activePage.ts b/activePage.ts
index 516e32e..2a3e87a 100644
--- a/activePage.ts
+++ b/activePage.ts
@@ -1,6 +1,10 @@
/// <reference path='touchEvent.d.ts' />
export class ActivePage {
+ // The idea behind this property that it could basically anything, but
+ // whoever inherits this class must override next(), prev(), and display() methods,
+ // if necessary; just in the end, its value probably corresponds to the IDs of the
+ // individual elements in the page.
public cur_section = null;
private swipe_pos_x = 0;
private swipe_pos_y = 0;
@@ -84,13 +88,11 @@ export class ActivePage {
console.log('distX = ' + distX);
console.log('distY = ' + distY);
- if (distX < -negligible)
- {
+ if (distX < -negligible) {
console.log("swipe left");
this.next();
}
- else if (distX > negligible)
- {
+ else if (distX > negligible) {
console.log("swipe right");
this.prev();
}
diff --git a/config.js b/config.js
deleted file mode 100644
index 80134d7..0000000
--- a/config.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/// <reference path="require.d.ts" />
-define(["require", "exports", "zalmy"], function(require, exports, zl) {
- require([], function () {
- var thisPsalm = new zl.Psalm();
- });
-});
-//# sourceMappingURL=config.js.map
diff --git a/config.js.map b/config.js.map
deleted file mode 100644
index 1651d70..0000000
--- a/config.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"config.js","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAArC;IAIA,OAAO,CAAC,EAAE,EAAE;QACR,IAAI,SAAS,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC,CAAC;GAAC"} \ No newline at end of file
diff --git a/zalmy.js b/zalmy.js
deleted file mode 100644
index a31aba1..0000000
--- a/zalmy.js
+++ /dev/null
@@ -1,92 +0,0 @@
-var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
-};
-define(["require", "exports", "activePage"], function(require, exports, ap) {
- var Psalm = (function (_super) {
- __extends(Psalm, _super);
- function Psalm() {
- _super.call(this);
- }
- Object.defineProperty(Psalm.prototype, "cur_psalm", {
- get: function () {
- // If this.cur_section has not been initialized yet, do it
- if (this.cur_section === null) {
- var storedStr = localStorage.getItem("curPsalm");
- var stored = JSON.parse(storedStr);
- if ((stored === null) || (stored < 1) || (stored > 150)) {
- this.cur_section = 1;
- localStorage.setItem("curPsalm", JSON.stringify(this.cur_section));
- } else {
- this.cur_section = stored;
- }
- }
-
- return this.cur_section;
- },
- set: function (value) {
- // Remove 'visible' style from the currently displayed psalm, if
- // there is any
- this.hide();
-
- if (value < 1) {
- this.cur_section = 150;
- } else if (value > 150) {
- this.cur_section = 1;
- } else {
- this.cur_section = value;
- }
- localStorage.setItem("curPsalm", JSON.stringify(this.cur_section));
-
- // set the parameter directly to avoid call to getter.
- this.display(this.cur_section);
- },
- enumerable: true,
- configurable: true
- });
-
-
- // Methods
- /**
- * Display the current Psalm
- *
- * @param number Number of the psalm to be displayed (optional)
- *
- * Displays the particular Psalm
- */
- Psalm.prototype.display = function (disp_no) {
- if (typeof disp_no === "undefined") { disp_no = this.cur_psalm; }
- console.log("cur_psalm = " + disp_no);
-
- // first scroll then switch to avoid blinking of the page
- window.scroll(0, 0);
- document.getElementById("Ps." + disp_no).parentElement.classList.add('visible');
- };
-
- /**
- * Hides the current Psalm
- */
- Psalm.prototype.hide = function () {
- document.getElementById("Ps." + this.cur_psalm).parentElement.classList.remove('visible');
- };
-
- // We have to override activePage’s next() and prev() methods to call
- // this.cur_psalm setter whcih does actual refresh of the page.
- Psalm.prototype.next = function () {
- console.log("Next!");
- this.cur_psalm += 1;
- };
-
- Psalm.prototype.prev = function () {
- console.log("Previous!");
- this.cur_psalm -= 1;
- };
- return Psalm;
- })(ap.ActivePage);
- exports.Psalm = Psalm;
-
- var thisPsalm = new Psalm();
-});
-//# sourceMappingURL=zalmy.js.map
diff --git a/zalmy.ts b/zalmy.ts
index 3bfc5f6..2548e99 100644
--- a/zalmy.ts
+++ b/zalmy.ts
@@ -1,11 +1,13 @@
/// <reference path='touchEvent.d.ts' />
-import ap = require("activePage");
+import ap = require("./activePage");
export class Psalm extends ap.ActivePage {
constructor() {
super();
}
+ // cur_psalm is actually just a virtual property, which is not stored anywhere and its
+ // accessor methods change the value of the cur_section property instead.
public get cur_psalm(): number {
// If this.cur_section has not been initialized yet, do it
if (this.cur_section === null)