diff options
Diffstat (limited to 'zalmy.js')
-rw-r--r-- | zalmy.js | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -49,8 +49,9 @@ var Psalm = (function () { get: function () { // If this._cur_psalm has not been initialized yet, do it if (this._cur_psalm === null) { - var stored = JSON.parse(localStorage.getItem("curPsalm")); - if (stored === null) { + var storedStr = localStorage.getItem("curPsalm"); + var stored = JSON.parse(storedStr); + if ((stored === null) || (stored < 1) || (stored > 150)) { this._cur_psalm = 1; localStorage.setItem("curPsalm", JSON.stringify(this._cur_psalm)); } else { @@ -65,10 +66,14 @@ var Psalm = (function () { // there is any this.hide(); - if ((value > 0) && (value <= 150)) { + if (value < 1) { + this._cur_psalm = 150; + } else if (value > 150) { + this._cur_psalm = 1; + } else { this._cur_psalm = value; - localStorage.setItem("curPsalm", JSON.stringify(this._cur_psalm)); } + localStorage.setItem("curPsalm", JSON.stringify(this._cur_psalm)); // set the parameter directly to avoid call to getter. this.display(this._cur_psalm); @@ -114,10 +119,10 @@ var Psalm = (function () { * * Displays the particular Psalm */ - Psalm.prototype.display = function (new_date) { - if (typeof new_date === "undefined") { new_date = this.cur_psalm; } - console.log("cur_psalm = " + new_date); - document.getElementById("Ps." + new_date).parentElement.classList.add('visible'); + Psalm.prototype.display = function (disp_no) { + if (typeof disp_no === "undefined") { disp_no = this.cur_psalm; } + console.log("cur_psalm = " + disp_no); + document.getElementById("Ps." + disp_no).parentElement.classList.add('visible'); }; /** |