fanstest.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. function shuffle(e) {
  2. return e.sort(function() {
  3. return.5 - Math.random()
  4. })
  5. }
  6. audio_folder = "http://121.40.137.155/StephenChow/audio/"
  7. function get_audio_url(file) {
  8. return audio_folder+file
  9. }
  10. var questions = [{
  11. au: ["breakup_cantanese.mp3","breakup_mandarin.mp3"],
  12. op: ["赌侠", "逃学威龙2", "整蛊专家"],
  13. as: "逃学威龙2",
  14. },{
  15. au: ["dream_cantanese.mp3","dream_mandarin.mp3"],
  16. op: ["少林足球","功夫","百变星君"],
  17. as: "少林足球",
  18. },{
  19. au: ["howtochaseagirl_cantanese.mp3","howtochaseagirl_mandarin.mp3"],
  20. op: ["功夫","行运一条龙","百变星君"],
  21. as: "行运一条龙",
  22. },{
  23. au: ["lostahand_cantanese.mp3","lostahand_mandarin.mp3"],
  24. op: ["大话西游","唐伯虎点秋香","鹿鼎记"],
  25. as: "唐伯虎点秋香",
  26. },{
  27. au: ["nothandsome_cantanese.mp3","nothandsome_mandarin.mp3"],
  28. op: [,"百变星君","喜剧之王","赌侠"],
  29. as: "百变星君",
  30. },{
  31. au: ["prostitution_cantanese.mp3","prostitution_mandarin.mp3"],
  32. op: ["喜剧之王","赌侠","国产凌凌漆"],
  33. as: "国产凌凌漆",
  34. },{
  35. au: ["robbed_cantanese.mp3","robbed_mandarin.mp3"],
  36. op: ["少林足球","破坏之王","赌侠"],
  37. as: "破坏之王",
  38. },{
  39. au: ["thereason_cantanese.mp3","thereason_mandarin.mp3"],
  40. op: ["唐伯虎点秋香","武状元苏乞儿","鹿鼎记"],
  41. as: "武状元苏乞儿",
  42. },{
  43. au: ["vowel_cantanese.mp3","vowel_mandarin.mp3"],
  44. op: ["唐伯虎点秋香","赌侠","鹿鼎记"],
  45. as: "唐伯虎点秋香",
  46. },
  47. {
  48. au: ["dongfang_cantanese.mp3","dongfang_mandarin.mp3"],
  49. op: ["整蛊专家","破坏之王", "逃学威龙2" ],
  50. as: "整蛊专家"
  51. }]
  52. player = $("#audio_player")
  53. pe =player.get(0)
  54. ca = $("#cantonese_audio")
  55. ma = $("#mandarin_audio")
  56. choose_audio = ""
  57. function fill_content(question,currentRate){
  58. cantonese = get_audio_url(question.au[0])
  59. mandarin = get_audio_url(question.au[1])
  60. ca.unbind("click")
  61. ca.click(function (){
  62. choose_audio = "c"
  63. playing = !pe.paused && !pe.ended
  64. src = player.attr("src")
  65. if (playing) {
  66. if (src == cantonese){
  67. pe.pause()
  68. } else {
  69. player.attr("src",cantonese)
  70. pe.play()
  71. }
  72. } else {
  73. if (src != cantonese){
  74. player.attr("src",cantonese)
  75. }
  76. pe.play()
  77. }
  78. }),
  79. ma.unbind("click")
  80. ma.click(function (){
  81. choose_audio = "m"
  82. playing = !pe.paused && !pe.ended
  83. src = player.attr("src")
  84. if (playing) {
  85. if (src == mandarin){
  86. pe.pause()
  87. } else {
  88. player.attr("src",mandarin)
  89. pe.play()
  90. }
  91. } else {
  92. if (src != mandarin){
  93. player.attr("src",cantonese)
  94. }
  95. pe.play()
  96. }
  97. })
  98. if (choose_audio == "c") {
  99. player.attr("src",cantonese)
  100. pe.play()
  101. } else if (choose_audio == "m") {
  102. player.attr("src",mandarin)
  103. pe.play()
  104. }
  105. $("#answer").html(question.op[0]),
  106. $("#answer0").html(question.op[0]),
  107. $("#answerValue0").attr("value", 0),
  108. $("#answerValue0").attr("listOrder", 0),
  109. $("#answer1").html(question.op[1]),
  110. $("#answerValue1").attr("value", 1),
  111. $("#answerValue1").attr("listOrder", 1),
  112. $("#answer2").html(question.op[2]),
  113. $("#answerValue2").attr("value", 2),
  114. $("#answerValue2").attr("listOrder", 2),
  115. $("#currentRate").html(currentRate + "%"),
  116. $("#answerValue0").attr("checked", "checked"),
  117. $("#answerValue1").removeAttr("checked"),
  118. $("#answerValue2").removeAttr("checked")
  119. }
  120. function get_title(score){
  121. if (score >= 100) {
  122. return "铁杆粉丝"
  123. } else if (score >= 90) {
  124. return "铁杆粉丝"
  125. } else if (score >= 80) {
  126. return "资深粉丝"
  127. } else if (score >= 70) {
  128. return "忠实粉丝"
  129. } else if (score >= 60) {
  130. return "鸭血粉丝"
  131. } else if (score >= 50) {
  132. return "猪肝粉丝"
  133. } else if (score >= 40) {
  134. return "大肠粉丝"
  135. } else if (score >= 30) {
  136. return "清汤粉丝"
  137. } else if (score >= 20) {
  138. return "路人甲"
  139. } else if (score >= 10) {
  140. return "呵呵呵"
  141. } else {
  142. return "高端黑"
  143. }
  144. }
  145. score = 0,
  146. $(document).ready(function() {
  147. questions = shuffle(questions);
  148. var questionsNums = questions.length;
  149. var index = 0
  150. var currentRate = 0
  151. fill_content(questions[index],currentRate)
  152. $(".next").click(function() {
  153. player.attr("src","#"),
  154. player.attr("preload","none"),
  155. player.attr("autoplay","false")
  156. pe.pause()
  157. var as = $("#answer").text();
  158. if (as == questions[index].as) {
  159. score++
  160. }
  161. if (index + 1 >= questionsNums) {
  162. var realScore = (100 * score / questionsNums).toFixed(0)
  163. var title = get_title(realScore)
  164. var r = "<h1>你在星爷粉丝大考验中答对了<em>" + score + "</em>题,得到了"+ realScore +"分</h1>";
  165. r += "<p>获得称号:<em>"+title+"</em></p>",
  166. r += "<div class='bottom'></div>",
  167. $("#showPannel").slideToggle(1e3,
  168. function() {
  169. $(".text").hide(),
  170. $(".progress").hide(),
  171. $(".next").hide(),
  172. $("#result").fadeIn(),
  173. $(".content").css({
  174. background: '#ffffff url("./riddle_files/img/shadow2.png") repeat-x'
  175. }),
  176. $("#showPannel").html(r),
  177. $("#showPannel").slideToggle(2e3),
  178. $("#playAgain").show()
  179. });
  180. var t = "我在星爷粉丝大考验中答对" + score + "题,获得" + title + "称号,快来超越我!";
  181. return void $(document).attr("title", t)
  182. } else {
  183. index++,
  184. currentRate = (100 * index / questionsNums).toFixed(0),
  185. fill_content(questions[index],currentRate);
  186. if (index + 1 >= questionsNums) {
  187. $(".next").html("交卷看成绩!")
  188. }
  189. $(".rate").animate({
  190. width: currentRate + "%"
  191. }),
  192. $("#currentRate").animate({
  193. left: currentRate - 7 + "%"
  194. }),
  195. $(".trangle").animate({
  196. left: currentRate - 4 + "%"
  197. })
  198. }
  199. }),
  200. $("input:radio").change(function() {
  201. var e = $(":radio:checked").attr("listOrder");
  202. newAnswer = $("#answer" + e).html(),
  203. $("#answer").html(newAnswer)
  204. }),
  205. $(".reset").click(function() {
  206. window.location.reload()
  207. }),
  208. $(".share").click(function() {
  209. $("#share").show()
  210. }),
  211. $("#share").click(function() {
  212. $("#share").hide()
  213. })
  214. });