1717< script src ="https://unpkg.com/i18next@8.0.0/i18next.min.js "> </ script >
1818< script src ="https://unpkg.com/i18next-browser-languagedetector@1.0.1/i18nextBrowserLanguageDetector.min.js "> </ script >
1919< script src ="https://unpkg.com/i18next-xhr-backend@1.4.1/i18nextXHRBackend.min.js "> </ script >
20- < script type ="application/javascript "
21- src ="questions .js ">
22- </ script >
20+ < script type ="application/javascript " src =" questions.js " > </ script >
21+ < script type =" application/javascript " src ="i18n .js "> </ script >
22+
2323< h1 > 8values</ h1 >
2424< hr >
25- < h2 style ="text-align:center; " id ="question-number "> Loading...</ h2 >
26- < p class ="question " id ="question-text "> </ p >
27- < button class ="button " onclick ="next_question( 1.0) " style ="background-color: #1b5e20; " id ="strongly_agree "> </ button > < br >
28- < button class ="button " onclick ="next_question( 0.5) " style ="background-color: #4caf50; " id ="agree "> </ button > < br >
29- < button class ="button " onclick ="next_question( 0.0) " style ="background-color: #bbbbbb; " id ="neutral "> </ button > < br >
30- < button class ="button " onclick ="next_question(-0.5) " style ="background-color: #f44336; " id ="disagree "> </ button > < br >
31- < button class ="button " onclick ="next_question(-1.0) " style ="background-color: #b71c1c; " id ="strongly_disagree "> </ button > < br >
25+ < h2 style ="text-align:center; " id ="question-number " data-i18n =" question_no " data-ns =" quiz " > Loading...</ h2 >
26+ < p class ="question " id ="question-text " data-ns =" questions " > </ p >
27+ < button class ="button " onclick ="next_question( 1.0) " style ="background-color: #1b5e20; " data-i18n ="strongly_agree " data-ns =" quiz "> </ button > < br >
28+ < button class ="button " onclick ="next_question( 0.5) " style ="background-color: #4caf50; " data-i18n ="agree " data-ns =" quiz "> </ button > < br >
29+ < button class ="button " onclick ="next_question( 0.0) " style ="background-color: #bbbbbb; " data-i18n ="neutral " data-ns =" quiz "> </ button > < br >
30+ < button class ="button " onclick ="next_question(-0.5) " style ="background-color: #f44336; " data-i18n ="disagree " data-ns =" quiz "> </ button > < br >
31+ < button class ="button " onclick ="next_question(-1.0) " style ="background-color: #b71c1c; " data-i18n ="strongly_disagree " data-ns =" quiz "> </ button > < br >
3232< button class ="small_button " onclick ="prev_question() " id ="back_button "> Back</ button >
3333< button class ="small_button_off " id ="back_button_off "> Back</ button > < br >
3434
@@ -50,15 +50,10 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
5050stats "> </ a > </ div > </ noscript >
5151
5252< script >
53- window . i18next
54- . use ( window . i18nextBrowserLanguageDetector )
55- . use ( window . i18nextXHRBackend )
56- . init ( {
57- "fallbackLng" : "en" ,
58- "ns" : [ "questions" , "quiz" ]
59- } , ready )
53+ i18n_load_ns ( [ "questions" , "quiz" ] , function ( ) {
54+ display_progress ( )
55+ } )
6056
61- var qs , qz ;
6257 var max_econ , max_dipl , max_govt , max_scty ; // Max possible scores
6358 max_econ = max_dipl = max_govt = max_scty = 0 ;
6459 var econ , dipl , govt , scty ; // User's scores
@@ -72,18 +67,14 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
7267 max_govt += Math . abs ( questions [ i ] . effect . govt )
7368 max_scty += Math . abs ( questions [ i ] . effect . scty )
7469 }
75- function ready ( ) {
76- qs = i18next . getFixedT ( null , 'questions' )
77- qz = i18next . getFixedT ( null , 'quiz' )
7870
79- for ( i of [ "strongly_agree" , "agree" , "neutral" , "disagree" , "strongly_disagree" ] ) {
80- document . getElementById ( i ) . innerHTML = qz ( i )
81- }
82- display_progress ( )
83- }
8471 function display_progress ( ) {
85- document . getElementById ( "question-text" ) . innerHTML = qs ( questions [ qn ] . question )
86- document . getElementById ( "question-number" ) . innerHTML = qz ( "question_no" , { current : qn + 1 , total : questions . length } )
72+ document . getElementById ( "question-text" ) . dataset . i18n = questions [ qn ] . question
73+ document . getElementById ( "question-number" ) . dataset . current = qn + 1
74+ document . getElementById ( "question-number" ) . dataset . total = questions . length
75+
76+ i18n_ready ( )
77+
8778 if ( prev_answer == null ) {
8879 document . getElementById ( "back_button" ) . style . display = 'none' ;
8980 document . getElementById ( "back_button_off" ) . style . display = 'block' ;
@@ -92,7 +83,6 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
9283 document . getElementById ( "back_button_off" ) . style . display = 'none' ;
9384 }
9485 }
95-
9686 function next_question ( mult ) {
9787 econ += mult * questions [ qn ] . effect . econ
9888 dipl += mult * questions [ qn ] . effect . dipl
@@ -101,9 +91,9 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
10191 qn ++ ;
10292 prev_answer = mult ;
10393 if ( qn < questions . length ) {
104- display_progress ( ) ;
94+ display_progress ( )
10595 } else {
106- results ( ) ;
96+ results ( )
10797 }
10898 }
10999 function prev_question ( ) {
0 commit comments