new-words
annotate misc/memo.js @ 66:53ba2847501f
added misc scripts
author | Igor Chubin <igor@chub.in> |
---|---|
date | Tue Mar 27 14:16:46 2012 +0200 (2012-03-27) |
parents | |
children |
rev | line source |
---|---|
igor@66 | 1 var memo_state = { |
igor@66 | 2 'initialized' : 0, |
igor@66 | 3 'answers' : {}, |
igor@66 | 4 }; |
igor@66 | 5 |
igor@66 | 6 function memo_init() { |
igor@66 | 7 memo_state.initialized = 1; |
igor@66 | 8 } |
igor@66 | 9 function memo_saveState() { |
igor@66 | 10 if (memo_state.initialized == 1) { |
igor@66 | 11 $.post("http://xgu.ru/memo/post/state/"+memo_subdir, memo_state.answers); |
igor@66 | 12 } |
igor@66 | 13 } |
igor@66 | 14 function memo_saveAnswer(key, value) { |
igor@66 | 15 if (memo_state.initialized == 1) { |
igor@66 | 16 var entry = {}; |
igor@66 | 17 entry[key] = value; |
igor@66 | 18 $.post("http://xgu.ru/memo/post/state/"+memo_subdir, entry); |
igor@66 | 19 } |
igor@66 | 20 } |
igor@66 | 21 function myAlert(name, dropdown, correct_answer) { |
igor@66 | 22 var myindex = dropdown.selectedIndex; |
igor@66 | 23 var SelValue = dropdown.options[myindex].value; |
igor@66 | 24 memo_state.answers[name] = SelValue; |
igor@66 | 25 if (SelValue == correct_answer) { |
igor@66 | 26 dropdown.style.backgroundColor = '#ffffff'; |
igor@66 | 27 dropdown.disabled = true; |
igor@66 | 28 |
igor@66 | 29 var x = $("#correct_answers").html(); |
igor@66 | 30 $("#correct_answers").html(parseInt(x) + 1); |
igor@66 | 31 |
igor@66 | 32 x = $("#yet_to_answer").html(); |
igor@66 | 33 $("#yet_to_answer").html(parseInt(x) - 1); |
igor@66 | 34 } |
igor@66 | 35 else { |
igor@66 | 36 var x = $("#wrong_answers").html(); |
igor@66 | 37 $("#wrong_answers").html(parseInt(x) + 1); |
igor@66 | 38 } |
igor@66 | 39 //memo_saveState(); |
igor@66 | 40 memo_saveAnswer(name, SelValue); |
igor@66 | 41 return true; |
igor@66 | 42 } |