17
17
< script src ="
https://unpkg.com/[email protected] /i18next.min.js "
> </ script >
18
18
< script src ="
https://unpkg.com/[email protected] /i18nextBrowserLanguageDetector.min.js "
> </ script >
19
19
< script src ="
https://unpkg.com/[email protected] /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
+
23
23
< h1 > 8values</ h1 >
24
24
< 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 >
32
32
< button class ="small_button " onclick ="prev_question() " id ="back_button "> Back</ button >
33
33
< button class ="small_button_off " id ="back_button_off "> Back</ button > < br >
34
34
@@ -50,15 +50,10 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
50
50
stats "> </ a > </ div > </ noscript >
51
51
52
52
< 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
+ } )
60
56
61
- var qs , qz ;
62
57
var max_econ , max_dipl , max_govt , max_scty ; // Max possible scores
63
58
max_econ = max_dipl = max_govt = max_scty = 0 ;
64
59
var econ , dipl , govt , scty ; // User's scores
@@ -72,18 +67,14 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
72
67
max_govt += Math . abs ( questions [ i ] . effect . govt )
73
68
max_scty += Math . abs ( questions [ i ] . effect . scty )
74
69
}
75
- function ready ( ) {
76
- qs = i18next . getFixedT ( null , 'questions' )
77
- qz = i18next . getFixedT ( null , 'quiz' )
78
70
79
- for ( i of [ "strongly_agree" , "agree" , "neutral" , "disagree" , "strongly_disagree" ] ) {
80
- document . getElementById ( i ) . innerHTML = qz ( i )
81
- }
82
- display_progress ( )
83
- }
84
71
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
+
87
78
if ( prev_answer == null ) {
88
79
document . getElementById ( "back_button" ) . style . display = 'none' ;
89
80
document . getElementById ( "back_button_off" ) . style . display = 'block' ;
@@ -92,7 +83,6 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
92
83
document . getElementById ( "back_button_off" ) . style . display = 'none' ;
93
84
}
94
85
}
95
-
96
86
function next_question ( mult ) {
97
87
econ += mult * questions [ qn ] . effect . econ
98
88
dipl += mult * questions [ qn ] . effect . dipl
@@ -101,9 +91,9 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
101
91
qn ++ ;
102
92
prev_answer = mult ;
103
93
if ( qn < questions . length ) {
104
- display_progress ( ) ;
94
+ display_progress ( )
105
95
} else {
106
- results ( ) ;
96
+ results ( )
107
97
}
108
98
}
109
99
function prev_question ( ) {
0 commit comments