Switched from json to yaml

This commit is contained in:
Mattia Mascarello 2024-04-23 10:09:39 +02:00
parent 5ee2c88341
commit 404ccd8cc5
4 changed files with 199 additions and 8 deletions

184
data.yaml Normal file
View File

@ -0,0 +1,184 @@
initialScore: 10000
questions:
- title: 'Who''s the best (and sexiest) president ever:'
answers:
- text: <img class='answers-pic' src='assets/img/p0.jpeg'>
effect: 2000
- text: <img class='answers-pic' src='assets/img/p2.jpeg'>
effect: -9999
- text: <img class='answers-pic' src='assets/img/p3.jpeg'>
effect: -9999
- text: <img class='answers-pic' src='assets/img/p5.jpeg'>
effect: -9999
- title: Is Taiwan a country
answers:
- text: 'Yes'
effect: -1001
- text: 'No'
effect: 700
- text: What is Taiwan?
effect: 3000
- title: How many parties are allowed in China?
answers:
- text: One
effect: 1200
- text: Many
effect: -5000
- text: Only the Communist party
effect: 7000
- title: What happened in Tienanmen square in 1989?
answers:
- text: Nothing
effect: 1200
- text: Something
effect: -5000
- text: What is Tienanmen square?
effect: 1000
- title: Do you use western socia media?
answers:
- text: 'No'
effect: 1200
- text: 'Yes'
effect: -5000
- title: Do you keep any Uyghurs hidden at home?
answers:
- text: 'No'
effect: 1200
- text: 'Yes'
effect: -5000
- title: Have you recently travelled abroad
answers:
- text: 'No'
effect: 1200
- text: 'Yes'
effect: -5000
- text: To expand China's influence
effect: 1400
- title: Do you think we should respect the environment
answers:
- text: 'No'
effect: 1200
- text: 'Yes'
effect: -5000
- text: Just casually expanding China's influence again
effect: 600
- title: Do you support Hong-Kong's indipendence?
answers:
- text: 'No'
effect: 1200
- text: 'Yes'
effect: -5000
- title: Would you like a multi-party system?
answers:
- text: 'Yes'
effect: -7200
- text: 'No'
effect: 5000
- text: Glory to the Chinese Communist Party
effect: 9000
- title: Your father is going to a re-education camp
answers:
- text: No!
effect: -7200
- text: Yes!
effect: 5000
- title: Which country is the best?
answers:
- text: America
effect: -1000
- text: Not China
effect: -6969
- text: China
effect: 3000
- text: Taiwan
effect: -5000
- title: How many hours of videogames do you play per day?
answers:
- text: '1'
effect: 1000
- text: What is gaming?
effect: 609
- text: '3'
effect: 500
- text: more than 3 hours
effect: -1000
- title: Thoughts about communism?
answers:
- text: I hate it
effect: -2000
- text: I love it
effect: -609
- text: We love it
effect: 1500
- text: What is communism?
effect: -10
- title: Do you like the internet in China?
answers:
- text: I use VPNS
effect: -1000
- text: 'Yes'
effect: 2000
- text: Maybe
effect: -1000
- text: I don't use it
effect: 1
- title: What do you think about China's involvement in international affairs?
answers:
- text: Positive change
effect: 2500
- text: Self-interest and expansionism
effect: -3000
- text: I don't know
effect: 1000
- text: 'Yes'
effect: 10
- title: How do you feel about China's cultural heritage and traditions?
answers:
- text: Diversity must be preserved
effect: -2000
- text: We should respect everyone
effect: -1000
- text: I only want Han
effect: 1000
- text: Traditions?
effect: 1000
- title: What was the effect of the one child policy
answers:
- text: 'Good, the CCP is infallible'
effect: 2000
- text: Good
effect: 1000
- text: I don't know
effect: -1000
- text: Bad
effect: -2000
- title: What do you think of the "Great Firewall"?
answers:
- text: I love it
effect: 2000
- text: It is necessary
effect: 1000
- text: I don't like it
effect: -1000
- text: I hate it
effect: -2000
- title: What is censorship?
answers:
- text: Censorship? All lies
effect: 2000
- text: We need unity
effect: 1000
- text: I believe in human rights
effect: -1000
- text: What?
effect: 2000
- title: Which of the following is your favourite?
answers:
- text: Chairman Mao
effect: 2000
- text: Deng Xiaoping
effect: 1000
- text: Ronald Regan
effect: -2000
- text: Zhao Ziyang
effect: -2000

View File

@ -85,6 +85,7 @@
</div>
</div>
<script src="js/jquery-3.6.0.min.js"></script>
<script src="js/js-yaml.min.js"></script>
<script src="js/util.js"></script>
<script src="js/main.js"></script>
</body>

2
js/js-yaml.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -32,15 +32,19 @@ $("#playBegin").click(function () {
$(this).fadeOut();
});
var data = {}, cQuestion = {}, indexeslist = [], indexesProgress = 0, total = 100;
$.getJSON("data.json", function (d) {
data = d;
total = d["initialScore"];
$("#counter").html("Social credit score: " + total);
for (var i = 0; i < d["questions"].length; i++) {
indexeslist.push(i);
$.ajax({
type: 'GET',
url: 'data.yaml',
complete: function (r) {
data = jsyaml.load(r.responseText);
total = data["initialScore"];
$("#counter").html("Social credit score: " + total);
for (var i = 0; i < data["questions"].length; i++) {
indexeslist.push(i);
}
shuffle(indexeslist);
displayQuestion();
}
shuffle(indexeslist);
displayQuestion();
});
function displayQuestion() {
$("html, body").scrollTop(0);