1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
| var smjq = jQuery; var _typei = 0; var weichuncai_text = ''; smjq(document).ready(function(){ var getwidth = getCookie("historywidth"); var getheight = getCookie("historyheight"); if(getwidth != null && getheight != null){ var width = getwidth; var height = getheight; }else{ var width = document.documentElement.clientWidth- 200 - imagewidth; var height = document.documentElement.clientHeight- 180 - imageheight; }
var cwidth = document.documentElement.clientWidth-100; var cheight = document.documentElement.clientHeight-20; var moveX = 0; var moveY = 0; var moveTop = 0; var moveLeft = 0; var moveable = false; var docMouseMoveEvent = document.onmousemove; var docMouseUpEvent = document.onmouseup;
smjq("body").append('<div id="smchuncai" onfocus="this.blur();" style="color:#626262;z-index:999;"><div id="chuncaiface"></div><div id="dialog_chat"><div id="chat_top"></div><div id="dialog_chat_contents"><div id="dialog_chat_loading"></div><div id="tempsaying"></div><div id="showchuncaimenu"><ul class="wcc_mlist" id="shownotice">显示公告</ul><ul class="wcc_mlist" id="chatTochuncai">聊 天</ul><ul class="wcc_mlist" id="foods">吃 零 食</ul><ul class="wcc_mlist" id="aboutmanage">关 于</ul><ul class="wcc_mlist" id="lifetimechuncai">生存时间</ul><ul class="wcc_mlist" id="closechuncai">关闭春菜</ul></div><div><ul id="chuncaisaying"></ul></div><div id="getmenu"> </div></div><div id="chat_bottom"></div></div></div>'); smjq("#smchuncai").append('<div id="addinput"><div id="inp_l"><input id="talk" type="text" name="mastersay" value="" /> <input id="talkto" type="button" value=" " /></div><div id="inp_r"> X </div></div>'); smjq("body").append('<div id="callchuncai">召唤春菜</div>'); var is_closechuncai = getCookie("is_closechuncai"); if(is_closechuncai == 'close'){ closechuncai_init(); } getdata("getnotice"); setFace(1);
smjq("#smchuncai").css('left', width+'px'); smjq("#smchuncai").css('top', height+'px'); smjq("#smchuncai").css('width', imagewidth+'px'); smjq("#smchuncai").css('height', imageheight+'px'); smjq("#callchuncai").attr("style", "top:"+cheight+"px; left:"+cwidth+"px; text-align:center;");
smcc = document.getElementById("smchuncai"); smcc.onmousedown = function(){ var ent = getEvent(); moveable = true; moveX = ent.clientX; moveY = ent.clientY; var obj = document.getElementById("smchuncai"); moveTop = parseInt(obj.style.top); moveLeft = parseInt(obj.style.left); if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ window.getSelection().removeAllRanges(); } document.onmousemove = function(){ if(moveable){ var ent = getEvent(); var x = moveLeft + ent.clientX - moveX; var y = moveTop + ent.clientY - moveY; var w = 200; var h = 200; obj.style.left = x + "px"; obj.style.top = y + "px"; } }; document.onmouseup = function(){ if(moveable){ var historywidth = obj.style.left; var historyheight = obj.style.top; historywidth = historywidth.replace('px', ''); historyheight = historyheight.replace('px', ''); setCookie("historywidth", historywidth, 60*60*24*30*1000); setCookie("historyheight", historyheight, 60*60*24*30*1000); document.onmousemove = docMouseMoveEvent; document.onmouseup = docMouseUpEvent; moveable = false; moveX = 0; moveY = 0; moveTop = 0; moveLeft = 0; } } }; smjq("#getmenu").click(function(){ chuncaiMenu(); setFace(1); }); smjq("#shownotice").click(function(){ getdata("getnotice"); setFace(1); }); smjq("#closechuncai").click(function(){ setFace(3); closechuncai(); }); smjq("#callchuncai").click(function(){ setFace(2); callchuncai(); setCookie("is_closechuncai", '', 60*60*24*30*1000); }); smjq("#shownotice").click(function(){ setFace(1); closeChuncaiMenu(); }); smjq("#lifetimechuncai").click(function(){ closeChuncaiMenu(); closeNotice(); setFace(2); getdata('showlifetime'); }); smjq("#chatTochuncai").click(function(){ showInput(); }); smjq("#inp_r").click(function(){ closeInput(); chuncaiSay('不聊天了吗?(→_→)'); setFace(3); }); smjq("#talkto").click(function(){ getdata("talking"); }); smjq("#aboutmanage").click(function(){ closeChuncaiMenu(); closeNotice(); smjq("#getmenu").css("display", "none"); chuncaiSay("你想了解我主人?跟我来吧~~~"); setFace(2); setTimeout(function(){ window.location.href = _about_path ; }, 2000); }); smjq("#foods").click(function(){ closeChuncaiMenu(); closeNotice(); getdata("foods"); });
document.onmousemove = function(){ stoptime(); tol = 0; setTime(); } talkSelf(talktime); document.getElementById("smchuncai").onmouseover = function(){ if(talkobj){ clearTimeout(talkobj); } talktime = 0; talkSelf(talktime); } });
function getEvent() { return window.event || arguments.callee.caller.arguments[0]; }
var eattimes = 0; function eatfood(obj){ var gettimes = getCookie("eattimes"); if(parseInt(gettimes) > parseInt(9)){ chuncaiSay("主人是个大混蛋!!"); setFace(3); closechuncai_evil(); }else if(parseInt(gettimes) > parseInt(7)){ chuncaiSay(".....................肚子要炸了,死也不要再吃了~~!!!TAT"); setFace(3); }else if(parseInt(gettimes) == parseInt(5)){ chuncaiSay("我已经吃饱了,不要再吃啦......"); setFace(3); }else if(parseInt(gettimes) == parseInt(3)){ chuncaiSay("多谢款待,我吃饱啦~~~ ╰( ̄▽ ̄)╭"); setFace(2); }else{ var id = obj.replace("f",''); getdata('eatsay', id); } eattimes++; setCookie("eattimes", eattimes, 60*10*1000); } function chuncaiMenu(){ clearChuncaiSay(); closeInput(); chuncaiSay("准备做什么呢?"); smjq("#showchuncaimenu").css("display", "block"); smjq("#getmenu").css("display", "none"); smjq("#chuncaisaying").css("display", "none"); } function closeChuncaiMenu(){ clearChuncaiSay(); smjq("#showchuncaimenu").css("display", "none"); showNotice(); smjq("#getmenu").css("display", "block"); } function showNotice(){ smjq("#chuncaisaying").css("display", "block"); } function closechuncai(){ stopTalkSelf(); chuncaiSay("记得再叫我出来哦..."); smjq("#showchuncaimenu").css("display", "none"); setTimeout(function(){ smjq("#smchuncai").fadeOut(1200); smjq("#callchuncai").css("display", "block");}, 2000); setCookie("is_closechuncai", 'close', 60*60*24*30*1000); } function closechuncai_evil(){ stopTalkSelf(); smjq("#showchuncaimenu").css("display", "none"); setTimeout(function(){ smjq("#smchuncai").fadeOut(1200); smjq("#callchuncai").css("display", "block");}, 2000); } function closechuncai_init(){ stopTalkSelf(); smjq("#showchuncaimenu").css("display", "none"); setTimeout(function(){ smjq("#smchuncai").css("display", "none"); smjq("#callchuncai").css("display", "block");}, 30); } function callchuncai(){ talkSelf(talktime); smjq("#smchuncai").fadeIn('normal'); smjq("#callchuncai").css("display", "none"); closeChuncaiMenu(); closeNotice(); chuncaiSay("我回来啦~"); setCookie("is_closechuncai", '', 60*60*24*30*1000); }
function chuncaiSay(s){ clearChuncaiSay(); smjq("#tempsaying").append(s); smjq("#tempsaying").css("display", "block"); weichuncai_text = s; typeWords(); } function clearChuncaiSay(){ document.getElementById("tempsaying").innerHTML = ''; } function closeNotice(){ smjq("#chuncaisaying").css("display", "none"); } function showInput(){ closeChuncaiMenu(); closeNotice(); chuncaiSay("............?"); smjq("#addinput").css("display", "block"); } function closeInput(){ setFace(3); smjq("#addinput").css("display", "none"); } function clearInput(){ document.getElementById("talk").value = ''; } function createFace(a, b, c){ smjq("head").append('<div id="hiddenfaces"><img id="hf1" src="'+a+'" /><img id="hf2" src="'+b+'" /><img id="hf3" src="'+c+'" /></div>'); setFace(1); } function setFace(num){ obj = document.getElementById("hf"+num).src; smjq("#chuncaiface").attr("style", "background:url("+obj+") no-repeat scroll 50% 0% transparent; width:"+imagewidth+"px;height:"+imageheight+"px;"); } function getdata(el, id){ smjq.ajax({ type: 'GET', url: _weichuncai_jsonpath, cache: 'false', dataType: 'html', contentType: 'application/json; charset=utf8', beforeSend: function(){ smjq("#tempsaying").css('display', "none"); smjq("#dialog_chat_loading").fadeIn("normal"); }, success: function(data){ smjq("#dialog_chat_loading").css('display', "none"); smjq("#tempsaying").css('display', ""); var dat = eval("("+data+")"); if(el == 'getnotice'){ chuncaiSay(dat.notice); setFace(1); }else if(el == 'showlifetime'){ BirthDay=new Date(dat.showlifetime); today=new Date(); timeold=(today.getTime()-BirthDay.getTime()); sectimeold=timeold/1000 secondsold=Math.floor(sectimeold); msPerDay=24*60*60*1000 e_daysold=timeold/msPerDay daysold=Math.floor(e_daysold); e_hrsold=(daysold-e_daysold)*-24; hrsold=Math.floor(e_hrsold); e_minsold=(hrsold-e_hrsold)*-60; minsold=Math.floor((hrsold-e_hrsold)*-60); seconds=Math.floor((minsold-e_minsold)*-60); chuncaiSay("我已经与主人 一起生存了 "+daysold+" 天 "+hrsold+" 小时 "+minsold+" 分钟 "+seconds+" 秒的快乐时光啦~*^_^*"); }else if(el == 'talking'){ var talkcon = smjq("#talk").val(); var i = in_array(talkcon, dat.ques); var types = typeof(i); if(types != 'boolean'){ chuncaiSay(dat.ans[i]); setFace(2); }else{ chuncaiSay('.......................嗯?'); setFace(3); } clearInput(); }else if(el == 'foods'){ var str=''; var arr = dat.foods; var preg = /function/; for(var i in arr){ if(arr[i] != '' && !preg.test(arr[i]) ){ str +='<ul id="f'+i+'" class="eatfood" onclick="eatfood(this.id)">'+arr[i]+'</ul>'; } } chuncaiSay(str); }else if(el = "eatsay"){ var str = dat.eatsay[id]; chuncaiSay(str); setFace(2); }else if(el = "talkself"){ var arr = dat.talkself; return arr; } }, error: function(){ chuncaiSay('好像出错了,是什么错误呢...请联系管理猿'); } }); }
function in_array(str, arr){ for(var i in arr){ if(arr[i] == str){ return i; } } return false; }
var timenum; var tol=0;
var goal = 10*60; function setTime(){ tol++; timenum = window.setTimeout("setTime('"+tol+"')", 1000); if(parseInt(tol) == parseInt(goal)){ stopTalkSelf(); closeChuncaiMenu(); closeNotice(); closeInput(); chuncaiSay("主人跑到哪里去了呢...."); setFace(3); stoptime(); } } function stoptime(){ if(timenum){ clearTimeout(timenum); } } var talktime = 0;
var talkself = 60; var talkobj; var tsi = 0; var talkself_arr = [ ["白日依山尽,黄河入海流,欲穷千里目,更上.....一层楼?", "1"], ["我看见主人熊猫眼又加重了!", "3"], ["我是不是很厉害呀~~?", "2"], ["5555...昨天有个小孩子跟我抢棒棒糖吃.....", "3"], ["昨天我好像看见主人又在众人之前卖萌了哦~", "2"] ];
function talkSelf(talktime){ talktime++; var yushu = talktime%talkself; if(parseInt(yushu) == parseInt(9)){ closeChuncaiMenu(); closeNotice(); closeInput(); tsi = Math.floor(Math.random() * talkself_arr.length + 1)-1; chuncaiSay(talkself_arr[tsi][0]); setFace(talkself_arr[tsi][1]); } talkobj = window.setTimeout("talkSelf("+talktime+")", 1000); } function stopTalkSelf(){ if(talkobj){ clearTimeout(talkobj); } } function arrayShuffle(arr){ var result = [], len = arr.length; while(len--){ result[result.length] = arr.splice(Math.floor(Math.random()*(len+1)),1); } return result; }
function typeWords() { var p = 1; var str = weichuncai_text.substr(0,_typei); var w = weichuncai_text.substr(_typei,1); if(w=="<"){ str += weichuncai_text.substr(_typei,weichuncai_text.substr(_typei).indexOf(">")+1); p= weichuncai_text.substr(_typei).indexOf(">")+1; } _typei+=p; document.getElementById("tempsaying").innerHTML = str; txtst = setTimeout("typeWords()",20); if (_typei> weichuncai_text.length){ clearTimeout(txtst); _typei = 0; } }
function setCookie(name, val, ex){ var times = new Date(); times.setTime(times.getTime() + ex); if(ex == 0){ document.cookie = name+"="+val+";"; }else{ document.cookie = name+"="+val+"; expires="+times.toGMTString(); } }
function getCookie(name){ var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return null; }
|
评论