Commits

Luke Plant  committed ff1550b

Implemented hiding of verses that have already been memorised

  • Participants
  • Parent commits d845012

Comments (0)

Files changed (3)

File lukeplant_me_uk/bibleverses/templates/scheme.html

 <ul class="verselist">
 
 {% for item in scheme.items %}
-<li>
-  <a class="biblelink" href="{{ item.verse.verse|esvlink }}">{{ item.verse.verse }}</a>
-  {% if item.entries %}
-  <ul>
-    {% for entry in item.entries %}
-     <li class="topicentry"><span class="topicheading">{{ entry.topic }}</span>
-       {% if entry.comment %} :: {{ entry.comment }}{% endif %}
-     </li>
-    {% endfor %}
-  </ul>
-  {% endif %}
-  <blockquote class="bible"><p>{{ item.verse.texts.ESV|linebreaksbr }}</p></blockquote>
+<li class="verseref">
+  <div class="versetopline"><a class="biblelink" href="{{ item.verse.verse|esvlink }}">{{ item.verse.verse }}</a></div>
+  <div class="versebottom">
+    {% if item.entries %}
+    <ul>
+      {% for entry in item.entries %}
+      <li class="topicentry"><span class="topicheading">{{ entry.topic }}</span>
+	{% if entry.comment %} :: {{ entry.comment }}{% endif %}
+      </li>
+      {% endfor %}
+    </ul>
+    {% endif %}
+    <blockquote class="bible"><p>{{ item.verse.texts.ESV|linebreaksbr }}</p></blockquote>
+  </div>
 </li>
 {% endfor %}
 </ul>

File lukeplant_me_uk/bibleverses/web/css/style.css

     border: 2px solid #ccddcc;
     background: #eeffee;
     padding: 3px;
-
+    margin-left: 1em;
 }
 
 .intro { 
 
 blockquote.bible {
     margin-top: 1em;
-    margin-bottom: 1em;
+    margin-bottom: 0em;
 }
 
 .hidden {
     font-size: x-small;
     font-style: italic;
     margin-top: -2px;
+}
+
+ul.verselist {
+    list-style-type: none;
+    margin-left: 0;
+    padding-left: 0;
+}
+
+li.verseref {
+    padding: 3px;
+}
+
+.memorised {
+    background-color: #d0d0d0;
+}
+
+.memorised .versebottom {
+    display: none;
+    
 }

File lukeplant_me_uk/bibleverses/web/js/bibleverses.js

         return null;
 }
 
+
+function setCookie(name, value, days) {
+    if (days) {
+        var date = new Date();
+        date.setTime(date.getTime()+(days*24*60*60*1000));
+        var expires = "; expires="+date.toGMTString();
+    }
+    else var expires = "";
+    document.cookie = name+"="+value+expires + "; path=" + rootUrl ;
+}
+
 function eraseCookie(name) {
-    setCookie(name, "", new Date(2000,1,1,0,0,0,0))
+    setCookie(name, "", -1);
 }
 
 function encodeObj(obj) {
 	  });
     return d;
 }
-       
+
+function doGetRequest(method) {
+    var d = doXHR(cgiRoot + method + "/",
+	{
+	    method: 'GET',
+	});
+    return d;
+}
+
 function standardErrorHandler(err) {
     logError(err);
 }
 
-function setCookie(name, val, expires) {
-    document.cookie = name + "=" + encodeURIComponent(val) + "; expires=" + expires.toGMTString() + "; path=" + rootUrl;
-}
-
 function setLoginCookie(email, password) {
     // Security is very low (just put password in cookie).
     // But the data being protected has minimal security requirements.
-    var d = new Date();
-    d.setFullYear(d.getFullYear()+100);
-    setCookie("email", email, d);
-    setCookie("password", password, d);
+    setCookie("email", email, 100000);
+    setCookie("password", password, 100000);
     showCorrectUserBar();
 }
 
     hideElement($('loginblock'));
 }
 
+function doLogout() {
+    eraseCookie('email');
+    eraseCookie('password');
+    showCorrectUserBar();
+}
+
 function onLogout(ev) {
-    eraseCookie('email');
-    addUserBar1();
+    doLogout();
 }
 
 function showUserBar(bar) {
 	addUserBar1();
     }
 }
+
 function get_email() {
     var email = readCookie('email');
     if (email == null) {
     }
 }
 
+verselist = new Array();
+
+function indicateFinishedVerses() {
+    var verselinks = getElementsByTagAndClassName("a", "biblelink");
+    logDebug(verselinks.length);
+    for(var i = 0; i < verselinks.length; i++) {
+	var ref = verselinks[i].innerHTML;
+	logDebug(ref);
+	if (findValue(verselist, ref) != -1) {
+	    addElementClass(verselinks[i].parentNode.parentNode, "memorised");
+	}
+    }
+}
+
+
+function verseListArrived(req) {
+    var json = evalJSONRequest(req);
+    logDebug(req.responseText);
+    if (json.success) {
+	verselist = json.verselist;
+	indicateFinishedVerses();
+    } else {
+	// login details wrong.
+	//doLogout();
+	// (or, TODO, network error)
+    }
+}
+
+function loadVerses() {
+    var d = doGetRequest("verses");
+    d.addCallbacks(verseListArrived, standardErrorHandler);
+}
+
 connect(window, 'onload',
         function(ev) {
 	    showCorrectUserBar();
 	    connect($('cancellogin'), 'onclick', onCancelLogin);
 	    connect($('closelogin'), 'onclick', onCloseLogin);
 	    connect($('logout'), 'onclick', onLogout);
+	    loadVerses();
         }
        );