Skip to content

Instantly share code, notes, and snippets.

@marsen
Created August 29, 2020 05:46
Show Gist options
  • Save marsen/2c7cd6824bf6795cc4a9f5dc53c2cd66 to your computer and use it in GitHub Desktop.
Save marsen/2c7cd6824bf6795cc4a9f5dc53c2cd66 to your computer and use it in GitHub Desktop.
純靠北工程師 5087
/* 91APP Inc.遊戲產生器91APP All rights reserved. */
$(function(){
var url = window.location.href;
var share_fb = 'http://www.facebook.com/sharer.php';
$('.share_fb').attr('href',share_fb+'?u='+url);
var share_line = 'http://line.naver.jp/R/msg/text/';
$('.share_line').attr('href',share_line+'?'+url);
});
$(function(){
var GAME = new Array();
GAME[0] = "game00";
// ↑無意義_只是方便記順序
GAME[1] = "game01";
// ↑獎項_01
GAME[2] = "game02";
// ↑獎項_02
GAME[3] = "game03";
// ↑獎項_03
GAME[4] = "game04";
// ↑獎項_04
GAME[5] = "game05";
// ↑獎項_05
GAME[6] = "game06";
// ↑獎項_06
GAME[7] = "game07";
// ↑獎項_07
GAME[8] = "game08";
// ↑獎項_08
var PRIZE = new Array();
PRIZE[0] = "";
// ↑無意義_只是方便記順序
PRIZE[1] = ".rwd_outer .prize_outer.prize_num";
// ↑獎項彈跳視窗_序號式
PRIZE[2] = ".rwd_outer .prize_outer.prize_link";
// ↑獎項彈跳視窗_連結式
PRIZE[3] = ".rwd_outer .prize_outer.prize_none";
// ↑獎項彈跳視窗_銘謝惠顧
var ERRO = new Array();
ERRO[0] = "";
// ↑可玩
ERRO[1] = ".rwd_outer .prize_outer.prize_pop1";
// ↑不可玩_活動結束
ERRO[2] = ".rwd_outer .prize_outer.prize_pop2";
// ↑不可玩_今日已玩三次
// ↓點START後 遊戲結果控制
$(".game_outer ul li:nth-child(4)").click(function(){
var gift = do_lottery();
var id = gift.id;
var type = 0;
if(gift.type == 'code'){
type = 1;
}else if(gift.type == 'link'){
type = 2;
}
show_result(gift);
$(".game_outer ul li:nth-child(1) img").addClass(GAME[id]);
// ↑後端依機率餵 獎項 陣列號碼
$(".game_outer ul li:nth-child(2)").addClass('gameshine');
// ↑得獎後閃爍
$(PRIZE[type]).delay(3500).fadeIn(300);
// ↑後端依機率餵 獎項彈跳視窗 陣列號碼
});
// 複製序號
$(".copybtn").click(function() {
var name = $(this).attr('name');
var el = document.getElementById(name);
var range = document.createRange();
range.selectNodeContents(el);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
document.execCommand('copy');
//alert("已複製序號");
$(".copyouter").fadeIn(300).delay(800).fadeOut(300);
return false;
});
// 點擊X關閉提醒視窗
$(".prize_pop2 i a").click(function(e){
e.preventDefault();
$(".prize_pop2").hide();
$(".game_outer ul").append("<li></li>");
$(".game_outer ul li:nth-child(5)").css({
"width":"100%",
"height":"100%",
});
});
// 點擊X與再玩一次後_刷新頁面
$(".prize_num i a, .prize_link i a, .prize_outer div div a:nth-child(2)").click(function(e){
e.preventDefault();
location.reload();
});
if(time_check()){
$(ERRO[2]).fadeOut(0);
$(ERRO[1]).fadeIn(300);
}
var remaining = count_check();
if(remaining<=0){
// ↓每日超出次數_就顯示提醒視窗
$(ERRO[2]).fadeIn(300);
}else {
$(ERRO[0]).fadeIn(300);
}
if((remaining-1)>0){
$(".playcount").html("還剩"+ (remaining-1) + "次機會");
}else{
$(".playcount").html('每日限玩'+total_of_day+'次,下次請早喔');
}
$(".today_played").html('每日限玩'+total_of_day+'次<br/>下次請早喔');
});
/**
* Cookie 到期日,次日00:00:00
*/
var currentDate = new Date();
var expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);
function set_count(){
var _count = get_count();
_count++;
$.cookie("count_"+path, _count ,{ expires: expirationDate } );
}
function get_count(){
var _count = $.cookie("count_"+path);
if( !_count){
$.cookie("count_"+path, 0 ,{ expires: expirationDate });
}
return _count;
}
function time_check(){
var NOWYEAR = moment().format('YYYY');
var NOWMONTH = moment().format('MM');
var NOWDATE = moment().format('DD');
var NOWHOUR = moment().format('HH');
var NOWMIN = moment().format('mm');
var AAA = moment([NOWYEAR, NOWMONTH, NOWDATE, NOWHOUR, NOWMIN]);
var NOW = moment();
var BBB = moment(end_date); //遊戲截止_年,月,日,時,分
//var FINALCOUNT = AAA.diff(BBB, 'minutes');
var FINALCOUNT = parseInt(NOW-BBB);
if( FINALCOUNT > 0 ){
return true;
}else{
return false;
}
}
function count_check(){
var _count = get_count();
var remaining = total_of_day - _count;
if(remaining>0){
return remaining;
}else {
return 0;
}
} var start_date = "";
var end_date = "2020-09-13";
var total_of_day = 3;
var gift = {"1":{"type":"code","chance":"1","title":"550\u5143\u6298\u50f9\u5238","code":"SDN3B8QY","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"},"2":{"type":"code","chance":"30","title":"50\u5143\u73fe\u91d1\u5238","code":"4D4HQDWE","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"},"3":{"type":"code","chance":"15","title":"200\u5143\u6298\u50f9\u5238","code":"SFUKA6PY","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"},"4":{"type":"code","chance":"4","title":"300\u5143\u6298\u50f9\u5238","code":"ZMFHPRZD","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"},"5":{"type":"code","chance":"1","title":"550\u5143\u6298\u50f9\u5238","code":"UHYJSSDK","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"},"6":{"type":"code","chance":"30","title":"50\u5143\u73fe\u91d1\u5238","code":"ZXFKHJRE","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"},"7":{"type":"code","chance":"15","title":"200\u5143\u6298\u50f9\u5238","code":"HWZETHYF","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"},"8":{"type":"code","chance":"4","title":"300\u5143\u6298\u50f9\u5238","code":"ZMFHPRZD","link":"http:\/\/shop.timberland.com.tw\/ref\/1257\/ecouponlist"}};
var lottery = {"1":1,"2":2,"3":2,"4":2,"5":2,"6":2,"7":2,"8":2,"9":2,"10":2,"11":2,"12":2,"13":2,"14":2,"15":2,"16":2,"17":2,"18":2,"19":2,"20":2,"21":2,"22":2,"23":2,"24":2,"25":2,"26":2,"27":2,"28":2,"29":2,"30":2,"31":2,"32":3,"33":3,"34":3,"35":3,"36":3,"37":3,"38":3,"39":3,"40":3,"41":3,"42":3,"43":3,"44":3,"45":3,"46":3,"47":4,"48":4,"49":4,"50":4,"51":5,"52":6,"53":6,"54":6,"55":6,"56":6,"57":6,"58":6,"59":6,"60":6,"61":6,"62":6,"63":6,"64":6,"65":6,"66":6,"67":6,"68":6,"69":6,"70":6,"71":6,"72":6,"73":6,"74":6,"75":6,"76":6,"77":6,"78":6,"79":6,"80":6,"81":6,"82":7,"83":7,"84":7,"85":7,"86":7,"87":7,"88":7,"89":7,"90":7,"91":7,"92":7,"93":7,"94":7,"95":7,"96":7,"97":8,"98":8,"99":8,"100":8};
var path = "20200818001257";
function get_random(){
return Math.floor((Math.random()*100) + 1);
}
function do_lottery(){
var num = get_random();
var key = lottery[num];
var now_gift = gift[key];
now_gift.id = key;
return now_gift;
}
function show_result(gift){
$('.gift_title').text(gift.title);
$('.gift_code').text(gift.code);
$('.gift_link').attr('href',gift.link);
set_count();
//console.log(gift);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment