new-words

diff misc/memo.js @ 68:846240941452

added -C key: compress to lines; fixed bug with #90-line
author Igor Chubin <igor@chub.in>
date Sun Sep 23 16:07:29 2012 +0300 (2012-09-23)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/misc/memo.js	Sun Sep 23 16:07:29 2012 +0300
     1.3 @@ -0,0 +1,42 @@
     1.4 +var memo_state = {
     1.5 +        'initialized' : 0,
     1.6 +        'answers' : {},
     1.7 +    };
     1.8 +
     1.9 +function memo_init() {
    1.10 +    memo_state.initialized = 1;
    1.11 +}
    1.12 +function memo_saveState() {
    1.13 +    if (memo_state.initialized == 1) {
    1.14 +        $.post("http://xgu.ru/memo/post/state/"+memo_subdir, memo_state.answers);
    1.15 +    }
    1.16 +}
    1.17 +function memo_saveAnswer(key, value) {
    1.18 +    if (memo_state.initialized == 1) {
    1.19 +        var entry = {};
    1.20 +        entry[key] = value;
    1.21 +        $.post("http://xgu.ru/memo/post/state/"+memo_subdir, entry);
    1.22 +    }
    1.23 +}
    1.24 +function myAlert(name, dropdown, correct_answer) {
    1.25 +    var myindex  = dropdown.selectedIndex;
    1.26 +    var SelValue = dropdown.options[myindex].value;
    1.27 +    memo_state.answers[name] = SelValue;
    1.28 +    if (SelValue == correct_answer) {
    1.29 +        dropdown.style.backgroundColor = '#ffffff';
    1.30 +        dropdown.disabled = true;
    1.31 +
    1.32 +        var x = $("#correct_answers").html();
    1.33 +        $("#correct_answers").html(parseInt(x) + 1);
    1.34 +
    1.35 +        x = $("#yet_to_answer").html();
    1.36 +        $("#yet_to_answer").html(parseInt(x) - 1);
    1.37 +    }
    1.38 +    else {
    1.39 +        var x = $("#wrong_answers").html();
    1.40 +        $("#wrong_answers").html(parseInt(x) + 1);
    1.41 +    }
    1.42 +    //memo_saveState();
    1.43 +    memo_saveAnswer(name, SelValue);
    1.44 +    return true;
    1.45 +}