Commits

Lars Yencken committed 2b9ab19

Fixes error messages and avoids help text timeout.

Comments (0)

Files changed (3)

simsearch/media/css/lookup.css

     margin-bottom: 0px;
 }
 
-.error {
+.searchError {
     position: absolute; 
     color: black;
     width: 400px;
     text-align: center;
-    font: 300 .9em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif;
+    font: 300 1.2em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif;
 }

simsearch/media/js/search.js

  * drawError()
  *      Draws an error message to the screen.
  */
-function drawError(messageEn, messageJp) {
-    drawSeedingInput(false);
+function drawError(messageEn, messageJp, timeout) {
+   // drawSeedingInput(false);
     // Render it, but still hidden, so we can check its size.
     setOpacity('errorMessage', 0.01);
     showElement('errorMessage');
     setElementPosition('errorMessage', errorLoc);
 
     appear('errorMessage');
-    callLater(5, function(){ fade('errorMessage'); });
     drawSeedingInput(false);
+    if (timeout > 0) {
+        callLater(timeout, function(){ fade('errorMessage'); });
+        drawSeedingInput(false);
+    }
 }
 
 /*
 
     if (value.length != 1) {
         drawError('Please enter a single kanji only.',
-        '漢字を一つ書いてください。');
+        '漢字を一つ書いてください。', 6);
     } else {
         // Check that the input is a kanji.
         logDebug("Ok value: " + value);
         var valueOrd = ord(value);
         if (valueOrd < 12353 || valueOrd > 40869) {
             drawError('Please enter a single kanji only.',
-            '漢字を一つ書いてください。');
+            '漢字を一つ書いてください。', 6);
         } else {
             // Valid!
             switchState("lookup", value);
     var failure = function(err) {
         logDebug("Couldn't load data: " + err);
         switchState('seeding', null);
-        drawError('No data found for the kanji ' + pivotKanjiVal + '.', '');
+        drawError('No data found for the kanji ' + pivotKanjiVal + '.', '',
+                6);
     }
 
     newDoc.addCallbacks(success, failure);
     callLater(4, function() { 
             if (emptyInput()) {
                 drawError('Enter a kanji similar to',
-                        'to the one you want to find.');
-
-                callLater(10, function() {
-                    if (emptyInput()) {
-                    drawError('Still confused?', 'Try searching with 閉.');
-                    callLater(5, function() {
-                            if (emptyInput()) {
-                                document['seedForm'].seedKanji.value = '閉';
-                            }
-                        });
-                    }
-                });
+                        'to the one you want to find.', 0);
             }
         });
 }

simsearch/search/templates/search/index.html

     </div>
   </form>
 
-  <div class="error" id="errorMessage" style="opacity:0.00"></div>
+  <div class="searchError" id="errorMessage" style="opacity:0.00"></div>
 
 {% endblock %}