index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <!DOCTYPE html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <meta name="viewport" content="width=100%; initial-scale=1; maximum-scale=1; minimum-scale=1; user-scalable=no;">
  5. <title>Playing Twins Match-Up</title>
  6. <script type="text/javascript" src="http://game.ikongzhong.cn/games/qw/jquery.min.js"></script>
  7. <script type="text/javascript">
  8. var dataForWeixin = {
  9. appId: "gh_ff79a97cd7f3",
  10. TLImg: "http://game.ikongzhong.cn/games/ddb/logo.jpg",
  11. url: "http://game.ikongzhong.cn/games/ddb/",
  12. title: "Classic game <Twins Match>, please share your friends! Circle friends wechat!",
  13. desc: "please share your friends! Circle friends wechat!"
  14. };
  15. var onBridgeReady = function(){
  16. WeixinJSBridge.on('menu:share:appmessage', function(argv){
  17. var infos = $("#infos").text();
  18. WeixinJSBridge.invoke('sendAppMessage', {
  19. "appid": dataForWeixin.appId,
  20. "img_url": dataForWeixin.TLImg,
  21. "img_width": "120",
  22. "img_height": "120",
  23. "link": dataForWeixin.url + '?f=wx_hy_bb',
  24. "title": infos + dataForWeixin.title,
  25. "desc": dataForWeixin.desc
  26. });
  27. setTimeout(function () {location.href = "http://game.ikongzhong.cn/games/ddb/";}, 1500);
  28. });
  29. WeixinJSBridge.on('menu:share:timeline', function(argv){
  30. var infos = $("#infos").text();
  31. WeixinJSBridge.invoke('shareTimeline', {
  32. "appid": dataForWeixin.appId,
  33. "img_url":dataForWeixin.TLImg,
  34. "img_width": "120",
  35. "img_height": "120",
  36. "link": dataForWeixin.url + '?f=wx_pyq_bb',
  37. "title": infos + dataForWeixin.title,
  38. "desc": dataForWeixin.desc
  39. });
  40. setTimeout(function () {location.href = "http://game.ikongzhong.cn/games/ddb/";}, 1500);
  41. });
  42. };
  43. if(document.addEventListener){
  44. document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  45. }else if(document.attachEvent){
  46. document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  47. document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  48. }
  49. </script>
  50. <link href='http://game.ikongzhong.cn/css' rel='stylesheet' type='text/css'>
  51. <style>
  52. body {
  53. text-align: center;
  54. background: #FFEDD9 url(images/bg.jpg) repeat 0 0;
  55. font-family: 'Luckiest Guy', cursive;
  56. color: #48321D;
  57. }
  58. h2 {
  59. color: #E61D25;
  60. font-size: 36px;
  61. margin: 15px 0;
  62. }
  63. p {
  64. display: block;
  65. font-size: 16px;
  66. margin: 0 0 15px;
  67. }
  68. #game {
  69. background: #FFCEB8;
  70. width: 300px;
  71. height: 320px;
  72. margin: 0 auto 10px;
  73. padding: 10px;
  74. display: -webkit-box;
  75. -webkit-border-radius: 10px;
  76. -moz-border-radius: 10px;
  77. border-radius: 10px;
  78. box-shadow: 0 0 4px #CC1220;
  79. -webkit-box-shadow: 0 0 4px #CC1220;
  80. -moz-box-shadow: 0 0 4px #CC1220;
  81. }
  82. #time {
  83. clear: both;
  84. position: relative;
  85. }
  86. #cards {
  87. position: relative;
  88. width: 300px;
  89. height: 345px;
  90. }
  91. .card {
  92. -webkit-perspective: 600;
  93. width: 60px;
  94. height: 90px;
  95. position: absolute;
  96. -moz-transition: all .3s;
  97. -webkit-transition: all .3s;
  98. transition: all .3s;
  99. }
  100. .face {
  101. border-radius: 10px;
  102. width: 100%;
  103. height: 100%;
  104. position: absolute;
  105. -webkit-transition-property: opacity, transform, box-shadow;
  106. -webkit-transition-duration: .3s;
  107. -webkit-backface-visibility: hidden;
  108. }
  109. .front {
  110. background: #999 url(images/deck.png) 0 -180px;
  111. z-index: 10;
  112. }
  113. .back {
  114. background: #efefef url(images/deck.png) 0 -180px;
  115. -webkit-transform: rotate3d(0,1,0,-180deg);
  116. z-index: 8;
  117. }
  118. .card:hover .face, .card-flipped .face {
  119. -webkit-box-shadow: 0 0 10px #CC1220;
  120. }
  121. .card-flipped .front {
  122. -webkit-transform: rotate3d(0,1,0,180deg);
  123. z-index: 8;
  124. }
  125. .card-flipped .back {
  126. -webkit-transform: rotate3d(0,1,0,0deg);
  127. z-index: 10;
  128. }
  129. .card-removed {
  130. opacity: 0;
  131. }
  132. .cardAQ {background-position: 0 0;}
  133. .cardAK {background-position: -60px 0;}
  134. .cardCK {background-position: -120px 0;}
  135. .cardBQ {background-position: -180px 0;}
  136. .cardCQ {background-position: 0 -90px;}
  137. .cardBK {background-position: -60px -90px;}
  138. .cardDQ {background-position: -120px -90px;}
  139. .cardDK {background-position: -180px -90px;}
  140. #game_wrapper {
  141. position: relative;
  142. margin: 0 auto;
  143. width: 320px;
  144. }
  145. #timer {
  146. background: url(images/message.png) no-repeat left top;
  147. height: 95px;
  148. width: 300px;
  149. position: relative;
  150. }
  151. #timer p {
  152. margin: 0 0 10px;
  153. left: 137px;
  154. top: 47px;
  155. position: absolute;
  156. }
  157. .button a {
  158. background: url(images/btn.png) no-repeat 0 0;
  159. color: #fff;
  160. display: block;
  161. margin: 0 auto;
  162. height: 30px;
  163. padding: 3px;
  164. text-align: center;
  165. text-decoration: none;
  166. width: 145px;
  167. }
  168. .button a:hover {
  169. color: #fff;
  170. text-decoration: none;
  171. }
  172. #popup {
  173. margin: 0 auto;
  174. position:absolute;
  175. top: 180px;
  176. width: 100%;
  177. z-index: 10;
  178. }
  179. #popup.hide {
  180. display: none;
  181. }
  182. #popup.show {
  183. display: block;
  184. }
  185. #popup p {
  186. font-size: 18px;
  187. margin: 0 0 15px;
  188. }
  189. #popup .score {
  190. color: #52B910;
  191. font-size: 24px;
  192. }
  193. #notice {
  194. background: none repeat scroll 0 0 #F9E48F;
  195. border: 1px solid #F0D567;
  196. color: #A26C0D;
  197. font-size: 1.2em;
  198. line-height: 1.64;
  199. margin: 10px 0 0;
  200. padding: 10px;
  201. display: none;
  202. -webkit-border-radius: 10px;
  203. -moz-border-radius: 10px;
  204. border-radius: 10px;
  205. box-shadow: 0 0 4px #CC1220;
  206. -webkit-box-shadow: 0 0 4px #CC1220;
  207. -moz-box-shadow: 0 0 4px #CC1220;
  208. }
  209. #notice p {
  210. margin: 0;
  211. }
  212. .other_game {
  213. background: #28AAA9;
  214. margin: 0 auto;
  215. overflow: hidden;
  216. padding: 10px;
  217. text-align: left;
  218. width: 300px;
  219. -webkit-border-radius: 5px;
  220. -moz-border-radius: 5px;
  221. border-radius: 5px;
  222. }
  223. .other_game p {
  224. color: #fff;
  225. font-family: Arial, Helvetica, sans-serif;
  226. font-weight: normal;
  227. font-size: 14px;
  228. margin: 0 0 10px;
  229. }
  230. .other_game ul {
  231. list-style-type: none;
  232. margin: 0;
  233. padding: 0;
  234. }
  235. .other_game ul li {
  236. margin-top: 10px;
  237. }
  238. .other_game ul li:first-child {
  239. margin: 0;
  240. }
  241. .other_game ul li img {
  242. float: left;
  243. margin-right: 10px;
  244. }
  245. .other_game a {
  246. display:block;
  247. color: #fff;
  248. font-family: Arial, Helvetica, sans-serif;
  249. font-size: 14px;
  250. overflow: hidden;
  251. text-decoration: none;
  252. }
  253. .other_game a span {
  254. font-size: 12px;
  255. font-family: Arial, Helvetica, sans-serif;
  256. color: #fff;
  257. }
  258. </style>
  259. <!-- Google analytics, ignore this -->
  260. <script type="text/javascript">
  261. var _gaq = _gaq || [];
  262. _gaq.push(['_setAccount', 'UA-18035087-2']);
  263. _gaq.push(['_trackPageview']);
  264. (function() {
  265. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  266. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  267. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  268. })();
  269. </script>
  270. <script src="http://game.ikongzhong.cn/games/qw/jquery.min.js"></script>
  271. <script>
  272. window.addEventListener("load",function() {
  273. // Set a timeout...
  274. setTimeout(function(){
  275. // Hide the address bar!
  276. window.scrollTo(0, 65);
  277. }, 0);
  278. });
  279. //logic
  280. var matchingGame = {};
  281. matchingGame.deck = [
  282. 'cardAK', 'cardAK',
  283. 'cardAQ', 'cardAQ',
  284. 'cardCQ', 'cardCQ',
  285. 'cardBK', 'cardBK',
  286. 'cardBQ', 'cardBQ',
  287. 'cardDK', 'cardDK',
  288. ];
  289. $(function(){
  290. if (!$.browser.webkit) {
  291. alert( "Your current browser doesn't support this game. Please play this game on either Safari or Google Chrome!" );
  292. $("#game_wrapper").html('<div class"notice"><p>Your current browser does not support this game</p></div>');
  293. }
  294. //reset elapsed time
  295. matchingGame.elapsedTime = 0;
  296. //start the timer
  297. matchingGame.timer = setInterval(countTimer, 1000);
  298. matchingGame.deck.sort(shuffle);
  299. // clone 12 copies of the card
  300. for(var i=0;i<11;i++){
  301. $(".card:first-child").clone().appendTo("#cards");
  302. }
  303. // initialize each card's position
  304. $("#cards").children().each(function(index) {
  305. // align the cards to be 4x3 ourselves.
  306. $(this).css({
  307. "left" : ($(this).width() + 20) * (index % 4),
  308. "top" : ($(this).height() + 20) * Math.floor(index / 4)
  309. });
  310. //get pattern from shuffled deck
  311. var pattern = matchingGame.deck.pop();
  312. //visually apply the pattern on the card's back side
  313. $(this).find('.back').addClass(pattern);
  314. //embed the pattern data into DOM
  315. $(this).attr('data-pattern',pattern);
  316. //listen the click event on each card
  317. $(this).click(selectCard);
  318. });
  319. });
  320. function shuffle() {
  321. return 0.5 - Math.random();
  322. }
  323. function selectCard() {
  324. //we do nothing if there are already two card flipped.
  325. if($('.card-flipped').size() > 1) {
  326. return;
  327. }
  328. $(this).addClass('card-flipped');
  329. //check the pattern of both flipped card 0.7s latter
  330. if($('.card-flipped').size() == 2) {
  331. setTimeout(checkPattern, 700);
  332. }
  333. }
  334. function checkPattern() {
  335. if(isMatchPattern()) {
  336. $('.card-flipped').removeClass('card-flipped').addClass('card-removed');
  337. $('.card-removed').bind("webkitTransitionEnd",removeTookCards);
  338. //checkWinStatus();
  339. } else {
  340. $('.card-flipped').removeClass('card-flipped');
  341. }
  342. }
  343. function isMatchPattern() {
  344. var cards = $('.card-flipped');
  345. var pattern = $(cards[0]).data('pattern');
  346. var anotherPattern = $(cards[1]).data('pattern');
  347. return (pattern == anotherPattern);
  348. }
  349. function removeTookCards() {
  350. $('.card-removed').remove();
  351. //check if all cards are removed and show game over
  352. if($('.card').length == 0) {
  353. gameover();
  354. }
  355. }
  356. function gameover() {
  357. //stop the timer
  358. clearInterval(matchingGame.timer);
  359. //set the score in the game over popup
  360. $('.score').html($('#elapsed-time').html());
  361. //load the saved last score from local storage
  362. var lastElapsedTime = localStorage.getItem('last-elapsed-time');
  363. //convert the elapsed time into minute:second format
  364. var minute = Math.floor(lastElapsedTime / 60);
  365. var second = lastElapsedTime % 60;
  366. //add 0 if minute and sec less than 10
  367. if(minute<10) minute = "0" + minute;
  368. if(second<10) second = "0" + second;
  369. //display the last elapsed time
  370. $('.last-score').html(minute+":"+second);
  371. // save the score into local storage
  372. localStorage.setItem("last-elapsed-time", matchingGame.elapsedTime);
  373. //show the game over popup
  374. $('#popup').removeClass('hide');
  375. $('#popup').addClass('show');
  376. }
  377. function countTimer() {
  378. matchingGame.elapsedTime++;
  379. //calculate
  380. var minute = Math.floor(matchingGame.elapsedTime / 60);
  381. var second = matchingGame.elapsedTime % 60;
  382. //add 0 if minute and sec less than 10
  383. if(minute<10) minute = "0" + minute;
  384. if(second<10) second = "0" + second;
  385. //display the elapsed time
  386. $('#elapsed-time').html(minute+":"+second);
  387. }
  388. </script>
  389. </head>
  390. <body>
  391. <div id="game_wrapper">
  392. <div id="ads">
  393. </div>
  394. <div id="timer">
  395. <p>Elapsed time: <span id="elapsed-time">00:00</span></p>
  396. </div>
  397. <section id="game">
  398. <div id="cards">
  399. <div class="card">
  400. <div class="face front"></div>
  401. <div class="face back"></div>
  402. </div> <!-- .card -->
  403. </div> <!-- #cards -->
  404. </section> <!-- #game -->
  405. <section id="popup" class="hide">
  406. <div id="popup-bg"></div><!-- END popup-bg -->
  407. <div id="popup-box">
  408. <div id="popup-box-content">
  409. <h2>You Won</h2>
  410. <p>Your Score:</p>
  411. <p><span class="score"></span></p>
  412. <p>Last Score: <span class='last-score'></span></p>
  413. <p class="button"><a href="index.html">Retry</a></p>
  414. </div><!-- END popup-box-content -->
  415. </div><!-- END popup-box -->
  416. </section>
  417. <footer>
  418. <p>Copyright &copy; <script>var year = new Date().getFullYear(); document.write(year);</script> YT Low</p>
  419. </footer>
  420. </div><!-- END game_wrapper -->
  421. <div class="other_game">
  422. <ul><li>
  423. <div align="center">Twins Match-Up</div>
  424. </li>
  425. <li>
  426. <p>There are a group of snow monsters looking for their long lost twin!</p>
  427. <p>To reunited them, you have to search and find out the twins that look exactly alike</p>
  428. <p><img src="http://img.tongji.linezing.com/3455448/tongji.gif"/></p>
  429. </li>
  430. </ul>
  431. </div><!-- END other game -->
  432. </body>
  433. </html>