腾讯官方绿茶活动的JavaScript(head-4)
腾讯官方绿茶活动--Head(头部)第4段JavaScript代码(带行号)
地址:http://act.qzone.qq.com/uni-greentea/index.html
<script defer="defer" src="act.js" type="text/javascript">
1document.domain = 'qq.com';
2
3CACT = {
4 ACT_ID : 10064
5}
6ACT_PART_COOKIE = 'et_act_' + CACT.ACT_ID;
7
8setInviteCode();
9/***
10 *
11 * 将入库的函数
12 *
13 */
14/**
15 * ptlogin2 登录框调用
16 */
17function qq_login_form(aid)
18{
19 if ( !g_init )
20 {
21 // initialize global variables
22 g_myBodyInstance = document.body;
23 g_myBodyInstanceString = "document.body";
24 isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
25 isMinNS5 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 5) ? 1 : 0;
26 isMinIE4 = (document.all) ? 1 : 0;
27 isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
28 isMacIE = (isMinIE4 && navigator.userAgent.indexOf("Mac") >= 0) ? 1 : 0;
29 getFFVersion = navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
30 //extra height in px to add to iframe in FireFox 1.0+ browsers
31 FFextraHeight = getFFVersion < 1.5 ? 16 : 0;
32 isOpera = (navigator.appName.indexOf("Opera") >= 0) ? 1 : 0;
33
34 if ( document.compatMode != "BackCompat" && !isOpera )
35 {
36 // for looser.dtd
37 g_myBodyInstance = document.documentElement;
38 g_myBodyInstanceString = "document.documentElement";
39 }
40
41 g_init = true;
42 // initialize done
43 }
44
45 var aid_pt = /\d+/;
46
47 // get APPID
48 if ( !aid_pt.test(aid) )
49 {
50 return;
51 }
52
53 // get all arguments
54 var argv = qq_login_form.arguments;
55
56 // get redirect url
57 if ( argv[1] )
58 {
59 redirect_url = argv[1];
60 }
61 else
62 {
63 redirect_url = window.location;
64 }
65
66 // get err_callback url
67 if ( argv[2] )
68 {
69 fp_val = argv[2];
70 }
71 else
72 {
73 fp_val = 'loginerroralert';
74 }
75
76 // get target window
77 if ( argv[3] )
78 {
79 target_win = argv[3];
80 }
81 else
82 {
83 target_win = "_self";
84 }
85
86 // get css url
87 if ( argv[4] )
88 {
89 css_url = argv[4];
90 }
91 else
92 {
93 css_url = dflt_css;
94 }
95
96 if ( !css_obj || (css_rel != css_url) )
97 {
98 css_obj = document.getElementById('login_css');
99
100 if ( !css_obj )
101 {
102 // add login css
103 var login_css = document.createElement('link');
104 login_css.id = 'login_css';
105 login_css.rel = 'stylesheet';
106 login_css.type = 'text/css';
107 login_css.media = 'screen';
108 login_css.href = css_url;
109 document.body.appendChild(login_css);
110
111 css_obj = login_css;
112 }
113 else
114 {
115 css_obj.href = css_url;
116 }
117
118 css_rel = css_url;
119 }
120
121 if ( !login_window )
122 {
123 // add encrypt js
124 var encScript = document.createElement('script');
125 encScript.src = encjs;
126 encScript.type = "text/javascript";
127 document.body.appendChild(encScript);
128
129 // add div element
130 var divE = document.createElement('div');
131 divE.id = 'login_container';
132 //divE.style.display = 'none';
133 divE.style.visibility = 'hidden';
134 //divE.style.filter = 'Alpha(opacity=0)';
135 divE.style.opacity = 0;
136
137 var login_HTML = "";
138 login_HTML += '<div id="login_header">';
139 login_HTML += ' <h4>请您登录</h4>';
140 login_HTML += ' <span id="close" onclick="javascript:setLoginFormVisible(\'hide\');"><span class="none">关闭
</span></span>';
141 login_HTML += '</div>';
142 login_HTML += '<div id="login_form">';
143 login_HTML += ' <iframe width="100%" scrolling="no" height="260" frameborder="0" src="http://ui.ptlogin2.qq.com/cgi-
bin/login?appid=15000103&hide_title_bar=1&s_url='+ encodeURIComponent(redirect_url) +'"/>';
144 login_HTML += "</div>";
145
146 divE.innerHTML = login_HTML;
147
148 document.body.appendChild(divE);
149
150 login_window = document.getElementById('login_container');
151
152 timer = setTimeout("setLoginFormVisible('show')", 500);
153 }
154 else
155 {
156 //_nchangeImg(aid);
157 timer = null;
158 }
159
160 // Miscellaneous Functions ...
161 // get drag flag
162 if ( argv[5] !== undefined )
163 {
164 drag = argv[5];
165 }
166 else
167 {
168 drag = true;
169 }
170
171 // get fix flag
172 if ( argv[6] !== undefined )
173 {
174 fix = argv[6];
175 }
176 else
177 {
178 fix = false;
179 }
180
181 // get module_div flag
182 if ( argv[7] !== undefined )
183 {
184 l_b = argv[7];
185 }
186 else
187 {
188 l_b = false;
189 }
190
191 drag_div = drag;
192 fix_div = fix;
193 module_div = l_b;
194
195 if ( fix || l_b )
196 {
197 if ( l_b )
198 {
199 makeMaskLayer();
200 }
201
202 attachWinAct();
203 }
204
205 //login_window.style.display == 'none';
206 //if (login_window && login_window.style.display == 'none')
207 //{
208 //setLoginFormVisible('show');
209 //}
210
211 if ( !timer )
212 {
213 setLoginFormVisible('show');
214 }
215
216 try {
217 var useruin = getCookie('saveduin');
218
219 if (useruin)
220 {
221 target_win.document.user_login.u.value = useruin;
222 }
223
224 //setFocus('u');
225 } catch(er) {}
226
227 //document.user_login.p.value = '';
228 //document.user_login.verifycode.value = '';
229 //document.user_login.imageField.disabled = false;
230
231 var l_h = document.getElementById("login_header");
232
233 if ( drag_div )
234 {
235 l_h.onmousedown = startMove;
236 }
237 else
238 {
239 l_h.onmousedown = null;
240 }
241}
242
243
244// 分页函数
245function showPageList(curPage,totalPage,pagesPerList,linkFormat,styleObj,delimiter){
246 if(curPage < 1 || totalPage <= 1 || curPage > totalPage)
247 return "";
248 //默认
249 if(!styleObj){
250 styleObj={};
251 styleObj.textClass='pg_having';
252 styleObj.preClass='pgup';
253 styleObj.nextClass='pgdn';
254 styleObj.curPageClass='pg_now';
255 styleObj.otherPageClass='';
256 styleObj.jumpClass='pg_op'
257 styleObj.inputClass='text-input';
258 styleObj.pageClass='page_page';
259 styleObj.submitClass='bt_submit'
260 }
261 if(!delimiter)delimiter=" ";
262
263 var m=[];
264
265 //算出要显示的码列表的范围
266 var startPageNo = curPage - parseInt(pagesPerList/2) < 1?1:curPage - parseInt(pagesPerList/2);
267 var endPageNo = startPageNo + pagesPerList -1 > totalPage ? totalPage : startPageNo +pagesPerList -1;
268 var count=endPageNo-startPageNo+1;
269 startPageNo=count!=pagesPerList?(startPageNo-(pagesPerList-count)):startPageNo;
270 startPageNo=startPageNo<1?1:startPageNo;
271 var prePageNo = curPage > 1 ? curPage-1 : 1;
272 var nextPageNo = curPage < totalPage ? curPage+1 : totalPage;
273 var reg = new RegExp("{no}","g");
274 var url;
275 var i;
276
277
278
279 m[m.length]='<P class="pg_num" style="display:inline">';
280
281 //输出文字描述
282 m[m.length]='<SPAN class="'+styleObj.textClass+'">第<STRONG>'+curPage+'/'+totalPage+'</STRONG>页</SPAN>'
283
284 // 输出上一页
285 if(1==curPage){
286 m[m.length]='<A class="'+styleObj.preClass+'" title="上一页" href="###" onclick="return false">上一页</A>'+delimiter;
287 }else{
288 url = linkFormat.replace(reg,prePageNo);
289 m[m.length]='<A class="'+styleObj.preClass+'" title="上一页" href="'+url+'">上一页</A>'+delimiter;
290 }
291
292 // 输出页列表
293 for(i=startPageNo;i<=endPageNo;i++) {
294 url = linkFormat.replace(reg,i);
295 if(i == curPage){
296 m[m.length]='<SPAN class="'+styleObj.curPageClass+'">'+i+'</SPAN>'+delimiter;
297 }
298 else
299 m[m.length]='<A class="'+styleObj.otherPageClass+'" title="'+i+'" href="'+url+'">'+i+'</A>'+delimiter;
300 }
301
302 // 输出下一页
303 if(totalPage==curPage){
304 m[m.length]='<A class="'+styleObj.nextClass+'" title="下一页" href="#" onclick="return false">下一页</A>';
305 }else{
306 url = linkFormat.replace(reg,nextPageNo);
307 m[m.length]='<A class="'+styleObj.nextClass+'" title="下一页" href="'+url+'">下一页</A>';
308 }
309
310 // 分页结束
311 m[m.length]='</P>';
312
313 var linkstr = linkFormat.replace(/'|"/g,"\\'");
314 //输出跳页
315 m[m.length]='<DIV class="'+styleObj.jumpClass+'" style="display:inline">'+'跳到';
316 m[m.length]='<INPUT class="'+styleObj.inputClass+'" onkeyup="if(event.keyCode==13) goPage('+curPage+',this.value,
'+totalPage+',\''+linkstr+'\');">'
317 m[m.length]='页';
318 m[m.length]='<BUTTON class="'+styleObj.submitClass+'" onclick="goPage('+curPage+',this.parentNode.getElementsByTagName
(\'input\')[0].value, '+totalPage+',\''+linkstr+'\');" type="button" value="GO">GO</BUTTON>'
319 m[m.length]='</DIV>';
320
321 return m.join("");
322}
323
324/**
325 * hltab
326 * @param {string} tabTId
327 * @param {string} tabCtag
328 * @param {string} tabCClass
329*/
330function hltab(tabTId, hlClass, tabCallBack, defTab, tsTag) {
331 // tab 头
332 var tabts = $(tabTId).getElementsByTagName(tsTag ? tsTag : 'a');
333 // tab 内容体
334 var tabcs = new Array();
335 var tlength = tabts.length;
336
337 var dipTab = function(e, ini ,tn){
338 if( tabts.length == 0 ) {
339 window.status = 'do not find any tab head element for ' + tabTId;
340 return;
341 }
342 for(i=0; i<tlength; i++ ) {
343 var tabn = tabts[i];
344 var rp = new RegExp(hlClass + "$");
345 //var rp = CSS.getClassRegEx(hlClass);
346 tabn.className = tabn.className.replace(rp, '');
347 }
348 tabts[tn].className += hlClass;
349 if(tabCallBack && !ini) {
350 tabCallBack(tn);
351 }
352 }
353 defTab = defTab || 0;
354 dipTab(null, true, defTab);
355 for(i=0; i<tlength; i++ ) {
356 Event.observe( tabts[i], 'click', dipTab.bindAsEventListener(null, false, i) );
357 }
358}
359
360
361/**
362 *
363 * 注册函数
364 */
365/**
366 *
367 * 初始化日期选择, 并做合并, 可以有两种情况,有年月日 和 年月
368 */
369function initFDateSel(field, minYear, maxYear) {
370 var reg = /date_(.*)$/
371 var match = field.match(reg);
372 var type = match[1];
373 var yid = 'dateyear_' + type;
374 var mid = 'datemonth_' + type;
375 var did = 'dateday_' + type;
376 initDateSelect( yid, mid, did, minYear, maxYear);
377
378 var fh = document.createElement('input');
379 fh.type = 'hidden';
380 fh.id = field;
381 fh.name = field;
382
383 if($(did)) {
384 $(did).parentNode.appendChild(fh);
385 Event.observe( did, 'change', function() {
386 var m = parseInt($(mid).value).fixDigit(2);
387 var d = parseInt($(did).value).fixDigit(2);
388 fh.value = $(yid).value + '-' + m + '-' + d;
389 FormChecker.chkElement(field);
390 } );
391 } else {
392 $(mid).parentNode.appendChild(fh);
393 Event.observe( mid, 'change', function() {
394 var m = parseInt($(mid).value).fixDigit(2);
395 fh.value = $(yid).value + '-' + m ;
396 FormChecker.chkElement(field);
397 } );
398
399 }
400}
401
402
403/**
404 * 图片切换,设置对应的验证
405 */
406function phototab(phototype, pnum, beNull, tn) {
407 //debugger;
408 var uploadphoto = 'photo' + phototype + '_' + pnum;
409 var albumphoto = 'album' + phototype + '_' + pnum;
410 beNull = !!beNull ? true : false;
411 if(tn == 0) {
412 $('photo' + phototype + '_' + pnum).disabled = true;
413 $('album' + phototype + '_' + pnum).disabled = false;
414 $('album_thum' + phototype + '_' + pnum).disabled = false;
415
416 FormChecker.setExclObj([uploadphoto]);
417 FormChecker.unsetExclObj([albumphoto]);
418 } else {
419 $('photo' + phototype + '_' + pnum).disabled = false;
420 $('album' + phototype + '_' + pnum).disabled = true;
421 $('album_thum' + phototype + '_' + pnum).disabled = true;
422
423 FormChecker.unsetExclObj([uploadphoto]);
424 FormChecker.setExclObj([albumphoto]);
425 }
426}
427
428/**
429 * 添加一张图片
430 *
431 */
432function addPhotoUpload(phototype, limit, notbeNull) {
433 var template = '\
434 <map name="nav_updata">\
435 <div class="tab_title" id="tab_{phototype}_{num}">\
436 <strong class="tab_01"><span>从我的QQ相册上传</span></strong>\
437 <strong class="tab_02"><span>从电脑上传一张图片</span></strong>\
438 </div>\
439 </map>\
440 <div class="tab_upphoto tab_1" id="form_album{phototype}_{num}">\
441 <div class="tab_list">\
442 <input type="text" name="album{phototype}[{num}][o]" id="album{phototype}_{num}" readonly />\
443 <input type="hidden" name="album{phototype}[{num}][t]" id="album_thum{phototype}_{num}" readonly />\
444 <input type="button" class="bt_up" onclick="getAlbumPic(\'album{phototype}_{num}\', \'album_thum{phototype}_{num}\');"
/>\
445 <em class="form_hint">*</em>\
446 </div>\
447 </div>\
448 <div class="tab_upphoto tab_2" id="form_photo{phototype}_{num}">\
449 <div class="tab_list">\
450 <input type="file" class="bt_up" name="photo{phototype}[{num}]" id="photo{phototype}_{num}" />\
451 <em class="form_hint">*</em>\
452 </div>\
453 </div>\
454 ';
455
456 var photoDivId = 'photo' + phototype + '_cont_div';
457 var photoDiv = $(photoDivId);
458 if(!photoDiv) {
459 return;
460 }
461 var pnum = $c('tab_div', photoDiv, 'div').length;
462 if( pnum == limit ) {
463 return;
464 }
465 var pstr = replPlacer(template, 'num', "" + pnum);
466 pstr = replPlacer(pstr, 'phototype', phototype);
467
468 var pdiv = document.createElement("div");
469 pdiv.className = 'tab_div';
470 pdiv.innerHTML = pstr;
471
472 var extradiv = $c('op', photoDiv, 'div')[0];
473 if(!extradiv) extradiv = null;
474 $(photoDiv).insertBefore(pdiv, extradiv);
475 //$(photoDiv).appendChild(pdiv);
476 tab(pdiv, 'tab_' + phototype + '_' + pnum, 'tab_now', 'div', 'tab_upphoto', phototab.bind(null, phototype , pnum,
notbeNull), 0, 'strong');
477
478}
479
480/**
481 * 删除一个图片
482 */
483function removePhoto(phototype) {
484 var pid = 'photo' + phototype + '_cont_div';
485 var pdiv = $(pid);
486 if(!pdiv) {
487 return;
488 }
489
490 var photoeles = $c('tab_div', pdiv, 'div');
491
492 var pnum = photoeles.length;
493 if(pnum == 1 ) {
494 return;
495 }
496
497 pdiv.removeChild(photoeles[pnum - 1]);
498}
499
500/**
501 * 相册图片处理
502 *
503 */
504function getAlbumPic(ori, thum){
505 function callback(data) {
506 if (!data) return;
507 var urlObj = $(ori);
508 if(urlObj) urlObj.value= data.url;
509 var thumObj = $(thum);
510 if(thumObj) thumObj.value= data.pre;
511 }
512 getAlbumDialog2(callback);
513 return;
514}
515
516
517/**
518 * 添加一个视频
519 *
520 */
521function addVideoUpload(videotype, limit) {
522 var template = '\
523 <div class="tab_upphoto tab_1" id="form_video{videotype}_{num}" >\
524 <div class="tab_list">\
525 <input type="text" name="video{videotype}[{num}][v]" id="video{videotype}_{num}" readonly="readonly" class="input-updata"
/>\
526 <button class="bt_scan" onclick="uploadVideo(\'{videotype}\', {num});"><span>浏览...</span></button>\
527 <em class="form_hint">(提示)</em> </div>\
528 </div>\
529 ';
530
531 //debugger;
532 var dataDivId = 'video' + videotype + '_cont_div';
533 var dataDiv = $(dataDivId);
534 if(!dataDiv) {
535 return;
536 }
537 var pnum = $c('tab_div', dataDiv, 'div').length;
538 if( pnum == limit ) {
539 return;
540 }
541
542 var pstr = replPlacer(template, 'num', "" + pnum);
543 pstr = replPlacer(pstr, 'videotype', videotype);
544
545 var pdiv = document.createElement("div");
546 pdiv.className = 'tab_div';
547 pdiv.innerHTML = pstr;
548
549 var extradiv = $c('op', dataDiv, 'div')[0];
550 if(!extradiv) extradiv = null;
551 $(dataDiv).insertBefore(pdiv, extradiv);
552}
553
554/**
555 * 上传video处理, 自动生成视频标题和缩略图的表单节点
556 *
557 */
558function uploadVideo(vtype, index){
559 var val=getVideoDialog();
560 if (!val) return;
561 var preObj= $(vtype + "_videothum_"+index);
562 var urlObj= $( 'video' + vtype + "_" + index);
563 var titleObj= $(vtype + "_videotitle_"+index);
564 var video_url = val[1];
565 var vid_reg = /vid=(.*)$/
566 var match = video_url.match(vid_reg);
567 var vid = match[1];
568 if(urlObj) {
569 if(!preObj) {
570 preObj = document.createElement('input');
571 preObj.type = 'hidden';
572 preObj.id = vtype + "_videothum_"+index;
573 preObj.name = 'video' + vtype + "["+index + "][f]";
574 titleObj = document.createElement('input');
575 titleObj.type = 'hidden';
576 titleObj.id = vtype + "_videotitle_"+index;
577 titleObj.name = 'video' + vtype + "["+index + "][t]";
578
579 urlObj.parentNode.appendChild(preObj);
580 urlObj.parentNode.appendChild(titleObj);
581 }
582 urlObj.value = val[1];
583 titleObj.value = val[4];
584 preObj.value = 'http://vpic.video.qq.com/1/'+vid+'_1.jpg';
585 } else {
586 return;
587 }
588}
589
590/**
591 * 删除一个视频
592 */
593function removeVideo(type) {
594 var pid = 'video' + type + '_cont_div';
595 var pdiv = $(pid);
596 if(!pdiv) {
597 return;
598 }
599
600 var photoeles = $c('tab_div', pdiv, 'div');
601
602 var pnum = photoeles.length;
603 if(pnum == 1 ) {
604 return;
605 }
606
607 pdiv.removeChild(photoeles[pnum - 1]);
608}
609
610
611/**
612 * 添加一个动感影集
613 */
614function addVphotoUpload(type, limit, mid, name) {
615 var template = '\
616 <div class="tab_upphoto tab_1" id="form_vphoto{type}_{num}">\
617 <div class="tab_list">\
618 <input type="text" name="vphoto{type}[{num}][v]" id="vphoto{type}_{num}" readonly="readonly" />\
619 <input type="button" value="浏览..." onclick="javascript:showFlashAlbum(vphotoCallBack.bind(null, \'{type}\', \'{num}\'),
{mid: {mid}, name: \'{name}\'});" />\
620 <em class="form_hint">*</em>\
621 </div>\
622 </div>\
623 ';
624
625 var photoDivId = 'vphoto' + type + '_cont_div';
626 var photoDiv = $(photoDivId);
627 if(!photoDiv) {
628 return;
629 }
630 var pnum = $c('tab_div', photoDiv, 'div').length;
631 if( pnum == limit ) {
632 return;
633 }
634
635 mid = mid || 361;
636 name = name || '洁婷';
637
638 var pstr = replPlacer(template, 'num', "" + pnum);
639 pstr = replPlacer(pstr, 'type', type);
640 pstr = replPlacer(pstr, 'name', name);
641 pstr = replPlacer(pstr, 'mid', mid);
642
643 var pdiv = document.createElement("div");
644 pdiv.className = 'tab_div';
645 pdiv.innerHTML = pstr;
646
647 var extradiv = $c('op', photoDiv, 'div')[0];
648 if(!extradiv) extradiv = null;
649 $(photoDiv).insertBefore(pdiv, extradiv);
650 //$(photoDiv).appendChild(pdiv);
651}
652
653/**
654 * 删除一个动感影集
655 */
656function removeVphotoUpload(type) {
657 var pid = 'vphoto' + type + '_cont_div';
658 var pdiv = $(pid);
659 if(!pdiv) {
660 return;
661 }
662
663 var photoeles = $c('tab_div', pdiv, 'div');
664
665 var pnum = photoeles.length;
666 if(pnum == 1 ) {
667 return;
668 }
669
670 pdiv.removeChild(photoeles[pnum - 1]);
671}
672
673/**
674 * 动感影集回调, 设置数据并添加对应的第一帧和第一帧的缩略图的表单
675 */
676function vphotoCallBack(type, num, data) {
677 if(data){
678
679 var urlId = 'vphoto' + type + '_' + num;
680 var thumbId = 'vphotothumb' + type + '_' + num;
681 var frameId = 'vphotoframe' + type + '_' + num;
682 if(data[3]){
683 $(urlId).value = data[3];
684 if(!$(thumbId)) {
685 var thumb = document.createElement('input');
686 thumb.id = thumbId;
687 thumb.name = 'vphoto' + type + '[' + num+ '][t]';
688 thumb.type = 'hidden';
689
690 var frame = document.createElement('input');
691 frame.id = frameId;
692 frame.name = 'vphoto' + type + '[' + num + '][f]';
693 frame.type = 'hidden';
694
695 $(urlId).parentNode.appendChild(thumb);
696 $(urlId).parentNode.appendChild(frame);
697 }
698 }
699
700 if(data[1]){
701 var frame = data[1];
702 $(frameId).value = frame;
703 $(thumbId).value = frame.replace(/rurl4_b/, 'rurl4_s');
704 }
705 }
706}
707
708
709// 解析用户配置,以及初始化一些选择框,图片视频选择
710function parseUserConf(user_conf, fields, spefileds, acceptlist, exceptlist) {
711 for(var field in user_conf) {
712 if(Object.isArray(acceptlist) && !acceptlist.include(field)) {
713 continue;
714 }
715
716 if(Object.isArray(exceptlist) && exceptlist.include(field)) {
717 continue;
718 }
719
720 var fieldConf = user_conf[field];
721 fields[field] = fieldConf.data_type;
722
723 //debugger;
724 // 表单项显示和排序
725 var field_type = fieldConf.field_type;
726 var row = $('form_' + field);
727 var fele = $(field);
728 var fe = $('fieldset_' + field_type);
729 var fobjele = $(field + '_0');
730 var fobjcont = $(field + '_cont_div');
731
732 // 没有行也没有元素返回
733 if(!row && !fele && !fobjele && !fobjcont) {
734 continue;
735 }
736
737 // 排序字段
738 /*if(row) {
739 continue;
740 row.style.display = '';
741 var fs_app = fe ? fe : $('fieldset_other');
742 if(fs_app) {
743 fs_app.appendChild(row);
744 }
745 }*/
746
747 //debugger;
748 //映射原有的属性
749 //fieldConf['is_null'] = !fieldConf['null'];
750 fieldConf['is_null'] = fieldConf['null'] ? 0 : 1 ;
751 fieldConf['max_value'] = fieldConf['max'];
752 fieldConf['min_value'] = fieldConf['min'];
753 fieldConf['max_length'] = fieldConf['maxlength'];
754 fieldConf['min_length'] = fieldConf['minlength'];
755 fieldConf['length_tip'] = fieldConf['err_tip'];
756 // type属性会覆盖html 的type 去除掉
757 delete fieldConf['type'];
758 spefileds[field] = fieldConf;
759
760 // 初始化用数组初始的选择框
761 if(!!regData[field]) {
762 initSelect(field, regData[field]);
763 continue;
764 }
765
766 // 初始话城市选择框, 命名的规则是 city + 名词
767 var mat = field.match(/city(.*)/);
768 if(mat) {
769 var subfix = mat[1];
770 var cityId = 'province' + subfix;
771 areaSelectInit(cityId, field);
772 continue;
773 }
774
775
776 // 初始化数字选择框, 注意后台配置的时候 min_length == max_length == 20 才是这种类型
777 if(fieldConf['data_type'] == 'select') {
778 //debugger;
779 var min_value = fieldConf['min_value'] || 0;
780 var max_value = fieldConf['max_value'] ;
781 var max_length = fieldConf['maxlength'];
782 var min_length = fieldConf['minlength'];
783 if((max_length == min_length) && (min_length == 20)) {
784 initNumSelect(field, min_value, max_value);
785 continue;
786 }
787 }
788
789 // 初始化年月日选择
790 /*var mat = field.match(/year(.*)/);
791 if(mat) {
792 var minYear = fieldConf['min_value'] || 1982;
793 var maxYear = fieldConf['max_value'] || 2008;
794 var subfix = mat[1];
795 var monthId = 'month' + subfix;
796 var dayId = 'day' + subfix;
797 initDateSelect(field, monthId, dayId, minYear, maxYear);
798 continue;
799 }*/
800
801 // 初始化年月日选择
802 var mat = field.match(/date_(.*)/);
803 if(mat) {
804 var minYear = fieldConf['min_value'] || 1982;
805 var maxYear = fieldConf['max_value'] || 2008;
806 initFDateSel(field, minYear, maxYear);
807 continue;
808 }
809
810
811 // 初始化相框选择 命名规则是 photo + 后缀, 需要在页面上添加id ,id的规则是 字段名 + '_cont_div'
812 var mat = field.match(/^photo(.*)/);
813 if(mat) {
814 //debugger
815 var phototype = mat[1];
816 var isNotNull = fieldConf['is_null'];
817 for(var i=0; i<3; i++){
818 addPhotoUpload(phototype, 3, isNotNull);
819 }
820
821 //var fieldConfOther = spefileds[uploadother + phototype];
822 var array_size = fieldConf['array_size'] || 1;
823 for(var i=0; i<array_size; i++) {
824 fields[ 'photo'+ phototype + '_' + i] = fieldConf.data_type;
825 spefileds[ 'photo'+ phototype + '_' + i] = fieldConf;
826
827 fields[ 'album'+ phototype + '_' + i] = 'string';
828 spefileds[ 'album'+ phototype + '_' + i] = {
829
830 'is_null' : isNotNull,
831 'check_length' : false,
832 'length_tip' : fieldConf.err_tip,
833 'err_tip' : fieldConf.err_tip,
834 'page_tip' : fieldConf.page_tip
835 };
836 }
837 // 多值需要添加id
838 if(array_size > 1) {
839 //debugger
840 // 多值需要添加id, 规则是 字段名 + "_btn_div"
841 //
842 var photoDivId = 'photo' + phototype + '_cont_div';
843 var photoDiv = $(photoDivId);
844 if(!photoDiv) {
845 continue;
846 }
847
848 var opdiv = document.createElement('p');
849 opdiv.className = 'form_tips';
850 opdiv.innerHTML = '请根据主题上传JPG/GIF图片,文件大小500k以内';
851
852 photoDiv.appendChild(opdiv);
853
854 }
855 continue;
856 }
857
858 // 视频选择, 需要在页面内加id, id 的规则是 字段名 + '_cont_div'
859 var mat = field.match(/^video(.*)/);
860 if(mat) {
861 var vtype = mat[1];
862 var isNotNull = fieldConf['is_null'];
863 addVideoUpload(vtype, 3);
864
865 //debugger;
866 var array_size = fieldConf['array_size'] || 1;
867 for(var i=0; i<array_size; i++) {
868 fields[ 'video'+ vtype + '_' + i] = fieldConf.data_type;
869 spefileds[ 'video'+ vtype + '_' + i] = fieldConf;
870 }
871 if(array_size > 1) {
872 var dataDivId = 'video' + vtype + '_cont_div';
873 var dataDiv = $(dataDivId);
874 if(!dataDiv) {
875 continue;
876 }
877
878 var opdiv = document.createElement('div');
879 opdiv.className = 'op';
880 opdiv.innerHTML = '\
881 <button type="button" class="bt_new_upload" onclick="addVideoUpload(\''+ vtype +'\', ' + array_size + ');" >再传一个
</button>\
882 <button type="button" class="bt_del_date" onclick="removeVideo(\''+ vtype+'\');" >删除最后一个</button>\
883 ';
884
885 dataDiv.appendChild(opdiv);
886
887 }
888 continue;
889 }
890
891 // 动感影集选择, 需要在页面内加id, id 的规则是 字段名 + '_cont_div'
892 var mat = field.match(/^vphoto(.*)/);
893 if(mat) {
894 var vtype = mat[1];
895 var isNotNull = fieldConf['is_null'];
896 addVphotoUpload(vtype, 3);
897
898 //debugger;
899 var array_size = fieldConf['array_size'] || 1;
900 for(var i=0; i<array_size; i++) {
901 fields[ 'vphoto'+ vtype + '_' + i] = fieldConf.data_type;
902 spefileds[ 'vphoto'+ vtype + '_' + i] = fieldConf;
903 }
904 if(array_size > 1) {
905 var dataDivId = 'vphoto' + vtype + '_cont_div';
906 var dataDiv = $(dataDivId);
907 if(!dataDiv) {
908 continue;
909 }
910
911 var opdiv = document.createElement('div');
912 opdiv.className = 'op';
913 opdiv.innerHTML = '\
914 <button class="bt_new_upload" type="button" onclick="addVphotoUpload(\''+ vtype +'\', ' + array_size + ');" >上传更多
</button>\
915 <button class="bt_new_upload" type="button" onclick="removeVphotoUpload(\''+ vtype+'\');" >删除最后一个</button>\
916 ';
917 dataDiv.appendChild(opdiv);
918
919 }
920 continue;
921 }
922 }
923}
924
925/**
926 *
927 * 注册函数结束
928 */
929
930/**
931 * 投票函数
932 *
933 */
934/**
935 * 取得剩余的票数
936 * @param{string} limitType 合法值 free_voter free_voting free_player pay_voter pay_voting pay_player
937 * return {myvoteleft, level, ptype}
938 */
939function getVoteLeft(conf, limitType) {
940 var limitConf = conf.limits[limitType];
941 // 我已经投票数
942 var ihavevote = limitConf.voted;
943 // 我可以投票数
944 var icanvote = limitConf.vote_right;
945
946 // 我的剩余票数
947 var myvoteleft = icanvote - ihavevote;
948
949 // 我的优惠权限的级别
950 var level = limitConf.level;
951
952 // 我的优惠权限的类别
953 var ptype = limitConf.ptype;
954 return {
955 'myvoteleft' : myvoteleft,
956 'level': level,
957 'ptype' : ptype
958 } ;
959}
960
961/**
962 * 设置投票页面
963 *
964 */
965function presetVotePage(conf){
966
967 // 检查所有必须的id
968 var reqid = ['type1','type2','type3','type4','unpay1','unpay2','unpay3','unpay4','votecount0','votecount1',
969 'votecount2','votecount3','votecount4','votecost','votetype','voteform', 'paytype', 'player', 'votecount'];
970 reqid.each(
971 function(v) {
972 if(!$(v)) {
973 alert('请检查页面,页面上缺少id ' + v);
974 }
975 }
976 );
977
978 // 收费投票配置
979 var payvoteConf = conf.act_conf.pay;
980 var levelArr = conf.uin;
981
982 // 票数的输入,设置票数和计算用户须付Q币Q点
983 // 对于免费投票的, 也要将票数清零
984 getVoteQB('0', null, null, false, 'votecost', 'votetype', 'Q币');
985 getVoteQB('1', payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q点');
986 getVoteQB('2', payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q币');
987 getVoteQB('3', payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q点');
988 getVoteQB('4', payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q币');
989
990 // radio 类别点击, 取得用户的 paytype
991 Event.observe('type1', 'click', setCheckType.bind(null, 1, payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q点'));
992 Event.observe('type2', 'click', setCheckType.bind(null, 2, payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q币'));
993 Event.observe('type3', 'click', setCheckType.bind(null, 3, payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q点'));
994 Event.observe('type4', 'click', setCheckType.bind(null, 4, payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q币'));
995
996 // 点击不足出另外类型支付,取得用户的paytype
997 Event.observe('unpay1', 'click', setpayType.bind(null, 1, true));
998 Event.observe('unpay2', 'click', setpayType.bind(null, 2, true));
999 Event.observe('unpay3', 'click', setpayType.bind(null, 3, true));
1000 Event.observe('unpay4', 'click', setpayType.bind(null, 4, true));
1001
1002 // 免费投票和收费投票切换
1003 function votetab( tn) {
1004 if(tn == 0) {
1005 // 免费投票
1006 $('voteform').action = '/vote/freevote.php?script&domain&callback=parent.jsonCallBack&act_id=' + CACT.ACT_ID;
1007 $('votecost').innerHTML = 0;
1008 $('votetype').innerHTML = 'Q币';
1009 setVoteQBNum( 0, null, null, false, 'votecost', 'votetype', 'Q币');
1010 } else {
1011 // 收费投票
1012 $('voteform').action = '/vote/payvote.php?script&domain&callback=parent.jsonCallBack&act_id='+ CACT.ACT_ID;
1013 $('votecost').innerHTML = 0;
1014 $('votetype').innerHTML = 'Q点';
1015
1016 var checked = false;
1017 for(var i=1; i<=4; i++) {
1018 var typeEle = $('type' + i);
1019 if(typeEle.checked) {
1020 typeEle.click();
1021 checked = true;
1022 }
1023 }
1024 if(!checked) {
1025 $('type1').click();
1026 }
1027 }
1028 }
1029
1030 /**
1031 *
1032 * act_vote_form
1033 * 1 => 只有免费投票
1034 * 2 => 只有收费投票, 有礼包
1035 * 3 => 只有收费投票, 没有礼包
1036 * 4 => 有免费投票和收费投票, 有礼包
1037 * 5 => 有免费投票和收费投票, 没有礼包
1038 */
1039 switch (window.act_vote_form) {
1040 case 1:
1041 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 0, 'strong');
1042 $('votetabhead').getElementsByTagName('strong')[1].style.display = "none";
1043 break;
1044 case 2:
1045 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1046 $('votetabhead').getElementsByTagName('strong')[0].style.display = "none";
1047 break;
1048 case 3:
1049 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1050 $('votetabhead').getElementsByTagName('strong')[0].style.display = "none";
1051 $('votepack').style.display = 'none';
1052 break;
1053 case 4:
1054 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1055 break;
1056 case 5:
1057 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1058 $('votepack').style.display = 'none';
1059 break;
1060
1061 }
1062}
1063
1064/**
1065 * 根据radio的选择设置投票数,paytype, 以及应付QB
1066 */
1067function setCheckType(index, payvoteConf, levelArr, pack, cid, tid, vtypeText) {
1068 var vsel = $('type' + index);
1069 for(var i =1; i<=4; i++) {
1070 DOM.hide('typediv_' + i);
1071 }
1072 if(vsel.checked) {
1073 DOM.show('typediv_' + index);
1074
1075 setVoteQBNum( index, payvoteConf, levelArr, pack, cid, tid, vtypeText);
1076 setpayType(index, false);
1077 }
1078}
1079
1080/**
1081 * 设置应收Q币Q点数, 已经投票数
1082 */
1083function setVoteQBNum(index, payvoteConf, levelArr, pack, cid, tid, vtypeText) {
1084 //debugger;
1085 var votenum = parseInt($('votecount' + index).value);
1086 if(isNaN(votenum)) {
1087 votenum = 0;
1088 }
1089
1090 if($('type' + index) && !$('type' + index).checked) {
1091 return;
1092 }
1093
1094 var tobj = $(tid);
1095 if(tobj) {
1096 // Q币Q点提示
1097 tobj.innerHTML = vtypeText;
1098 }
1099
1100 // 没有收费配置,那就是免费的
1101 if(!payvoteConf) {
1102 $('votecount').value = votenum;
1103 $(cid).innerHTML = "0";
1104 return;
1105 }
1106
1107 // 原始价格
1108 var cost=0;
1109
1110 var price = 0;
1111 // 是否打包
1112 if(!pack) {
1113 price = payvoteConf.price;
1114 } else {
1115 price = payvoteConf.pkg_price;
1116 }
1117 // Q点
1118 if(index == 1 || index == 3) {
1119 cost = parseInt(votenum) * price/10;
1120 }
1121 else {
1122 cost = parseInt(votenum) * price/100;
1123 }
1124
1125 // 用户输入的票数有误,票数和应收Qb置位0
1126 if(isNaN(cost) || cost==0) {
1127 $(cid).innerHTML = "0";
1128 $('votecount').value = 0;
1129 return;
1130 }
1131
1132 // 优惠配置
1133 var privilege = payvoteConf.privilege;
1134 // 没有优惠配置,用原始价格
1135 if(!privilege) {
1136 // 投票数
1137 $('votecount').value = votenum;
1138 // 应收Q币数
1139 $(cid).innerHTML= cost.toFixed(2);
1140 return;
1141 }
1142
1143 // 遍历优惠的类型
1144 for(var ptype in privilege) {
1145 // 用户的达人或者黄钻级别
1146 var level = levelArr[ptype];
1147 // 用户这个级别的优惠比例
1148 var per = privilege[ptype][level];
1149 if(per) {
1150 // 优惠价格 ,原价格 * 百分比
1151 cost *= parseInt(per)/100;
1152 break;
1153 }
1154 }
1155
1156 // 投票数
1157 $('votecount').value = votenum;
1158 // 应收Q币数
1159 $(cid).innerHTML= cost.toFixed(2);
1160}
1161
1162/**
1163 * 在用户投票数输入框 keyup, keydown, keypress 的时候计算出应收用户的Q币Q点数,以及设置投票数
1164 * @example
1165 */
1166function getVoteQB(index, payvoteConf, levelArr, pack, cid, tid, vtype) {
1167 Event.observe('votecount' + index, 'keyup', setVoteQBNum.bind(null, index, payvoteConf, levelArr, pack, cid, tid,
vtype));
1168 Event.observe('votecount' + index, 'keydown', setVoteQBNum.bind(null, index, payvoteConf, levelArr, pack, cid, tid,
vtype));
1169 Event.observe('votecount' + index, 'keypress', setVoteQBNum.bind(null, index, payvoteConf, levelArr, pack, cid, tid,
vtype));
1170}
1171
1172/**
1173 * checkbox 选择 根据radio 的选择 设置 paytype
1174 * @param index 1 单笔Q点,2 单笔Q币 3。 礼包Q点 4. 礼包Q币
1175 * @isSelf isSelf true为点击事件触发,为点击checkbox时候调用,false 为被被动调用为点击radio时候的调用
1176 *
1177 */
1178function setpayType(index, isSelf) {
1179 //debugger;
1180 // 不足充数的checkbox
1181 var unpay = $('unpay' + index);
1182 var unpaycheck = unpay.checked;
1183
1184 // Q币Q 点的radio
1185 var typecheck = $('type' + index).checked;
1186 //var paytypelist = ['qd', 'qdqb', 'qb', 'qbqd'];
1187
1188 // 传给php 的paytype 列表
1189 var paytypelist = [2, 4, 1, 3];
1190 // 点击checkbox 并且对应的radio是选择的 或者 不是自我调用的时候设置paytype
1191 if((typecheck && isSelf) || (!isSelf) ) {
1192 var paytypeindex = index;
1193 if(paytypeindex >=3 ) {
1194 paytypeindex = paytypeindex - 2;
1195 }
1196 if(unpaycheck) {
1197 paytypeindex = paytypeindex * (paytypeindex - 1) + 1;
1198 $('paytype').value = paytypelist[paytypeindex];
1199 } else {
1200 paytypeindex = paytypeindex * (paytypeindex - 1);
1201 $('paytype').value = paytypelist[paytypeindex];
1202 }
1203 }
1204}
1205
1206/**
1207 * 投票函数结束
1208 *
1209 */
1210
1211
1212/***
1213 *
1214 * 将入库的函数
1215 */
1216
1217////////////////////////////////////////////////////////////// 以上函数请所有都copy 到新活动act.js 里
1218
1219function commFun(){
1220 actTop();
1221 //actHeader();
1222 actFooter();
1223 var speOpt = {
1224 linkClass : 'login',
1225 doLogout : function() {
1226 document.cookie = "uin=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1227 document.cookie = "skey=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1228 document.cookie = "zzpaneluin=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1229 document.cookie = "zzpanelkey=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1230 document.cookie = ACT2.COOKIE_NICKNAME + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
domain="+ACT2_COMM.ACT_COOKIE_DOMAIN;
1231 document.cookie = ACT2.COOKIE_UIN + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
domain="+ACT2_COMM.ACT_COOKIE_DOMAIN;
1232 window.location = 'index.html';
1233 }
1234 };
1235 GJsonDealFun.handlePageData(CACT.ACT_ID, 'status', speOpt);
1236 insertCSSLink('http://imgcache.qq.com/ACT/act_common/css/pop.css');
1237 insertCSSLink("http://imgcache.qq.com/ACT/qzone_090304_tylc/css/dialog.css");
1238}
1239
1240var delFun = {
1241 'index' : function() {
1242 if(getQQNum() != 0){
1243 var speOpt = {
1244 errdeal : false,
1245 dataDeal : function(opt,obj){
1246 if(obj.error && obj.error != 4506 && getParameter('act') == 'showreg'){
1247 getPopUp('reg.html', '', 500, 350);
1248 }
1249 }
1250 }
1251 loadPageData(CACT.ACT_ID, 'profile', speOpt);
1252 }
1253 },
1254 'reg' : function() {
1255 var speOpt = {
1256 onConfirm: function(opt, obj) {
1257 top.location.reload();
1258 },
1259 dataDeal : function(opt, obj){
1260 var msg = opt.getTitle();
1261 var tip = '赶快点击首页转盘,开启你的茶游之旅吧!';
1262 var m1 = MSG2.create(null, msg, tip);
1263 m1.setIcon(1);
1264 m1.setButton([1]);
1265 m1.setTimeout([3000]);
1266 m1.onunload = opt.onConfirm.bind(this, opt, obj);
1267 m1.show();
1268 }
1269 }
1270 loadPageData(CACT.ACT_ID, 'reg', speOpt);
1271 // 注册的cgi
1272 $("reg_form").action = ACT2_COMM.ACT_DOMAIN + "user/freereg.php?domain&script&callback=parent.jsonCallBack&act_id=" +
CACT.ACT_ID;
1273
1274 //此活动的注册为弹出框,所以函数showErr做特殊处理。
1275 window.showErr = function (obj, redrt, onconfirm) {
1276 var m1 = MSG2.create(null, obj.error.msg, null);
1277 if(redrt) {
1278 m1.onunload = function() {
1279 top.location = redrt;
1280 }
1281 }
1282 if(onconfirm) {
1283 m1.onconfirm = onconfirm;
1284 }
1285 m1.setIcon(2);
1286 m1.setButton([1]);
1287 m1.show();
1288 }
1289 },
1290 'user' : function(){
1291 var userQQ = getParameter('qq') || getQQNum();
1292
1293 if(!isOwner()){
1294 $('jiayou').style.display = '';
1295 }else{
1296 $('mode_todo').style.display = '';
1297 $('profileHome').className="now";
1298 }
1299
1300 var speOpt = {
1301 preDeal : function(opt, obj) {
1302 var headType = ['3','2','4','1'];
1303 var facVal = obj.data.faction;
1304 var sexType = ['男', '女'];
1305 var sexVal = obj.data.sex;
1306 if(!!facVal){
1307 obj.data.userhead = 'http://imgcache.qq.com/qzone/qzoneact/greentea_20090316/img/ntx' + headType[facVal - 1] + '.jpg'
1308 }
1309 if(!!sexVal){
1310 obj.data.usersex = sexType[sexVal - 1];
1311 }
1312 },
1313 dataDeal : function(opt, obj){
1314 FillDiv_Ex('userInfo',obj.data);
1315 $('user_info').style.visibility = 'visible';
1316 },
1317 aftDeal:function(opt,obj){
1318 //拉取机会的数据
1319 if(getQQNum()==obj.data.qq)
1320 {
1321 var speOpt = {
1322 request_url: 'http://act.qzone.qq.com/greentea/get_chance.php?act_id=10064&callback',
1323 errdeal: false,
1324 dataDeal : function(opt,obj){
1325 if(!obj.error)
1326 $('chance').innerHTML = obj.data;
1327 }
1328 }
1329 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1330
1331 //可答题的个数
1332 speOpt={
1333 request_url: 'http://act.qzone.qq.com/greentea/get_answer.php?act_id=10064&part=0&callback',
1334 errdeal: false,
1335 dataDeal : function(opt,obj){
1336 if(!obj.error)
1337 {
1338 count=0;
1339 for(var i=1;i<=30;i++)
1340 if(obj.data[i]==2)
1341 count++;
1342 $('queLeft').innerHTML = count;
1343 }
1344 }
1345 }
1346 loadPageData(CACT.ACT_ID,'custom',speOpt);
1347
1348 //复制连接
1349 $('copeinvite').style.display="";
1350
1351 }
1352 }
1353 }
1354 //加载生成数据
1355 loadPageData(CACT.ACT_ID, 'profile', speOpt);
1356
1357 var speOpt = {
1358 request_url: 'http://act.qzone.qq.com/uni-greentea/get_fans.php?callback&page=1&pernum=7&act_id=' + CACT.ACT_ID + '&qq='
+ userQQ,
1359 errdeal: false,
1360 dataDeal : function(opt,obj){
1361 if(!obj.error)
1362 FillDiv_Ex('friendlist1',obj.data.data);
1363 }
1364 }
1365 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1366
1367 var speOpt = {
1368 request_url: 'http://act.qzone.qq.com/uni-greentea/get_msg_list.php?callback&page=1&pernum=7&act_id=' + CACT.ACT_ID +
'&qq=' + userQQ,
1369 errdeal: false,
1370 dataDeal : function(opt,obj){
1371 if(!obj.error)
1372 FillDiv_Ex('feedlist',obj.data.data);
1373 }
1374 }
1375 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1376
1377 var speOpt = {
1378 request_url: 'http://act.qzone.qq.com/uni-greentea/friendlist.php?callback&page=1&pernum=7&act_id=' + CACT.ACT_ID +
'&qq=' + userQQ,
1379 errdeal: false,
1380 dataDeal : function(opt,obj){
1381 if(!obj.error)
1382 FillDiv_Ex('frdMap',obj.data);
1383 }
1384 }
1385 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1386
1387
1388 },
1389 'question' : function() {
1390 //var userQQ = getParameter('qq') || getQQNum();
1391 var speOpt = {
1392 request_url: 'http://act.qzone.qq.com/uni-greentea/get_answer.php?callback&part=0&act_id=' + CACT.ACT_ID,
1393 dataDeal : function(opt,obj){
1394 for(var i=0; i<30; i++){
1395 var ansStatus = obj.data[i + 1];
1396 qlist[i].push(ansStatus);
1397 }
1398 FillDiv_Ex('allQue',qlist);
1399 }
1400 }
1401 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1402
1403 window.jsonCallBack = function(obj) {
1404 var opt = {
1405 errdeal : false,
1406 dataDeal: function(opt, obj) {
1407 if(obj.error){
1408 var msg = obj.error.msg;
1409 simpleMSG(msg);
1410 }else{
1411 if(obj.data.result){
1412 simpleMSG('恭喜,回答正确!','您已获得20茶多酚的奖励');
1413 $('button').disabled = 'disabled';
1414 }else{
1415 simpleMSG('很遗憾,回答错误','您将被扣除20茶多酚');
1416 $('button').disabled = 'disabled';
1417 };
1418 }
1419 }
1420 }
1421 GJsonDealFun.jsonCallBack.bind(null, opt)(obj);
1422 }
1423 },
1424 'fans' : function() {
1425 /**
1426 * 粉丝模块显示函数
1427 * 做法: 将需要显示的类型的粉丝榜的id写在html里,以及写好其对应的模板
1428 * 修改点: 修改fans todo 1 当取粉丝失败时候的处理
1429 */
1430
1431 /**
1432 *
1433 * 获取粉丝列表并填充
1434 */
1435 var speOpt = {
1436 errdeal: false,
1437 // 取得数据之后再取得头像
1438 dataDeal : function(opt, obj) {
1439 /**
1440 *
1441 * 当取数据发生错误时的处理,比如用户没有粉丝 可能会需要做处理
1442 * fans todo 1
1443 */
1444 if(obj.error) {
1445 alert(obj.error.msg);
1446 return;
1447 }
1448
1449 // 将结构绑定到opt
1450 opt.obj = obj;
1451
1452 // 取头像
1453 var fanslist = obj.fans.new_fans;
1454 var len = fanslist.length;
1455 var str_uins = '';
1456 for(var i=0; i<len; i++) {
1457 var fans = fanslist[i]
1458 str_uins += fans.qq + ',';
1459 }
1460 var url="http://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?uins="+str_uins;
1461 // 绑定结果
1462
1463 loadJsonData(url,url,function(obj){ opt.portrait_callback(opt, obj);}, function(){}, true,null, 'portraitCallBack');
1464
1465 },
1466 loadData: function(opt) {
1467 //var player = 231723129;
1468 var qq = getParameter('qq');
1469 var player = getQQNum();
1470 var player = qq || player ;
1471 // 数据url
1472
1473 var url = 'http://act.qzone.qq.com/vote/votefans.php?callback&act_id='+opt.actId+'&player=' + player;
1474 GJsonDealFun.init(url, this.callBack.bind(this, opt), null, false);
1475 },
1476 // 填充数据
1477 portrait_callback: function(opt, arrqq) {
1478 // 取得头像函数
1479 window.getQzoneHead = opt.getQzoneHead.bind(null, arrqq);
1480 // 填充忠实粉丝
1481 try {
1482 FillDiv_Ex("faith_fans_div", opt.obj.fans.faith_fans);
1483 } catch(e) {}
1484 // 填充最新粉丝
1485 try {
1486 FillDiv_Ex("new_fans_div", opt.obj.fans.new_fans);
1487 } catch(e) {}
1488 },
1489 getQzoneHead : function(arr, qq) {
1490 if(arr[qq]) {
1491 return arr[qq][0];
1492 } else {
1493 return '';
1494 }
1495 },
1496 handler_err : {
1497 /**
1498 * 特定的错误码对应的处理函数
1499 * fans todo 2
1500 */
1501 }
1502 }
1503 loadPageData(CACT.ACT_ID, 'fanslist', speOpt );
1504 },
1505 'playerlist' : function() {
1506 var speOpt = {
1507 'ord' : 'sort0',
1508 'direct' : 'desc',
1509 'preRequest' : function(opt) {
1510 var ord = opt.ord;
1511 var direct = opt.direct;
1512 var type = opt.type;
1513
1514
1515 var hntabCallback = function(ordtab, opt, tn){
1516 var link = ACT2.S_PLAYER_LIST_PAGE;
1517 var type = opt.type;
1518 var direct = opt.direct;
1519
1520 ord = ordtab[tn];
1521 link = replPlacer(link, 'ord', ord);
1522 link = replPlacer(link, 'direct', direct);
1523 // page
1524 link = replPlacer(link, 'no', 1);
1525 link = replPlacer(link, '&type', type, true);
1526 window.location = link;
1527 }
1528 },
1529 dataDeal: function(opt, obj) {
1530 //先填充页码
1531
1532 curpage=obj.info.curpage;
1533 totalpage=obj.info.totalpage;
1534 var linkFormat = opt.getLinkFormat(opt);
1535
1536 // 约定页数的id 用page
1537 $("page").innerHTML=showPageList(curpage,totalpage,10,linkFormat,null);
1538 for(i=0;i<obj.data.length;i++)
1539 {
1540 obj.data[i]['index']=(i+1)+(obj.info.curpage-1)*17;
1541 }
1542 var fillFun = function( field, ele){
1543 FillDiv_Ex(ele, obj[field])
1544 };
1545 Object.each(opt.divToFill, fillFun);
1546 }
1547 };
1548 // 载入用户列表数据
1549 loadPageData(CACT.ACT_ID, 'playerlist', speOpt);
1550 }
1551};
1552
1553
1554/**
1555 * 页面加载处理
1556 */
1557function loadfun(){
1558 var curPage = 'index';
1559 var reg = new RegExp("^http:\/\/[^\/]+/[^\/]+\/?(([^\.]+)\.html?)?");
1560 var mat = window.location.href.match(reg);
1561 if(mat[2]) {
1562 curPage = mat[2];
1563 }
1564 if(curPage != 'vote' && curPage != 'fans' && curPage != 'reg'){
1565 commFun();
1566 }
1567
1568 if(delFun[curPage]) {
1569 delFun[curPage]();
1570 }
1571}
1572
1573
1574/**
1575 * 显示选择下拉菜单的值
1576 */
1577function showSelect(data, key) {
1578 if(regData[data][key]) {
1579 return regData[data][key];
1580 } else {
1581 return "";
1582 }
1583}
1584
1585function getAreaName(areacode){
1586 var provname = location_array[Math.floor(areacode/100)];
1587 var cityname= sublocation_array[Math.floor(areacode/100)][areacode];
1588 return provname+'-'+cityname;
1589}
1590
1591/**
1592 * 黄钻图标
1593 *
1594 */
1595function yellStr(isYell) {
1596 if(parseInt(isYell) == 1) {
1597 return '<a href="http://vip.qzone.qq.com/" title="开通黄钻" target="_blank" class="yellow"></a>';
1598 } else {
1599 return "";
1600 }
1601}
1602
1603/**
1604 * 关闭空间里的页面
1605 *
1606 */
1607function close_in_qzone()
1608{
1609 if(top.guide)
1610 {
1611 top.guide(1);
1612 }
1613 else
1614 {
1615 window.close();
1616 }
1617}
1618
1619
1620/**
1621 * 搜索参赛选手
1622 */
1623function searchQQ(ele) {
1624 var qq = $(ele).value;
1625 qq = parseInt(qq);
1626 if(!isNaN(qq)) {
1627 var url = replPlacer(ACT2.S_PROFILE_PAGE, 'qq', qq, true);
1628 window.location = url;
1629 }
1630}
1631
1632
1633var tabArr = {
1634 'index' : 0,
1635 'prizes' : 1,
1636 'prizes_step1' : 1,
1637 'prizes_step2' : 1,
1638 'prizes_step3' : 1,
1639 'prizes_step4' : 1,
1640 'reg' : 2,
1641 'playerlist' : 4,
1642 'user' : 4,
1643 'intro' : 5,
1644 'winner' : 6
1645};
1646
1647
1648
1649/**
1650 * 页顶横栏
1651 */
1652function actTop(){
1653 var topTpl = '\
1654 <div class="gb_logo"><img src="http://imgcache.qq.com/ACT/qzone_080909_dcl/img/lead_logo.png" alt="Qzone Life" /> 统一绿
茶梦想之旅\
1655 <h1 class="none">统一绿茶梦想之旅</h1>\
1656 </div>\
1657 <div class="login_msgbox" id="top">\
1658 <div class="login_msgbox_l"></div>\
1659 <p class="login_msgbox_m">\
1660 <span class="log_status_span" id="log_status"></span> \
1661 <a href="javascript:void(0)" class="brown" title="设为首页" onclick="this.style.behavior=\'url(#default#homepage)
\';this.setHomePage(\'http://act.qzone.qq.com/greentea/\');return false;">设为首页</a>\
1662 <a href="javascript:void(0)" id="user_reg" class="brown" onclick="showLogin();return false;">注册</a>\
1663 <a href="javascript:void(0)" id="user_person" style="display:none" class="brown"
onclick="window.location=\'user.html\';return false;">个人主页</a>\
1664 </p>\
1665 <div class="login_msgbox_r"></div>\
1666 </div>\
1667 '
1668 $('top').innerHTML = topTpl;
1669 if(getQQNum())
1670 {
1671 var speOpt = {
1672 errdeal:false,
1673 dataDeal : function(opt, obj){
1674 if(!obj.error)
1675 {
1676 $('user_reg').style.display="none";
1677 $('user_person').style.display="";;
1678 }
1679 }
1680 }
1681 //加载生成数据
1682 loadPageData(CACT.ACT_ID, 'profile', speOpt);
1683
1684 }
1685}
1686
1687/**
1688 * isOwner 判断是否主人态
1689 * return {Boolean}
1690 */
1691function isOwner(){
1692 var userQQ = getParameter('qq') || getQQNum();
1693 return userQQ == getQQNum();
1694}
1695
1696/**
1697 * 复制链接
1698 */
1699function gen_invitecode(){
1700 var qq = getParameter('qq') || getQQNum();
1701 qq = parseInt(qq);
1702 if(!isNaN(qq)) {
1703 var speOpt = {
1704 request_url: ACT2_COMM.ACT_DOMAIN + "/uni-greentea/copyinvite.php?callback&act_id="+CACT.ACT_ID+"&qq="+qq,
1705 dataDeal :function(opt, obj) {
1706 window.clipboardData.setData("text",obj.data.url);
1707 var m1 = MSG2.create(null,'邀请链接已成功复制到剪贴板', '请发给你的QQ好友,邀请他们来参加活动吧!必须是QQ好友哦,否则无
法赠送您茶多酚哦');
1708 m1.setIcon(1);
1709 m1.setButton([1]);
1710 m1.setModel(true);
1711 m1.show();
1712
1713 /*var intUrl = obj.data.url;
1714 if(intUrl){
1715 function tempcallback()
1716 {
1717 var m1 = MSG2.create(null,'邀请链接已成功复制到剪贴板', '请发给你的QQ好友,邀请他们来参加活动吧!必须是QQ好友哦,否则无
法赠送您茶多酚哦');
1718 m1.setIcon(1);
1719 m1.setButton([1]);
1720 m1.setModel(true);
1721 m1.show();
1722 }
1723 setClipboard(intUrl,tempcallback);
1724 }*/
1725 }
1726 }
1727 }
1728 loadPageData(CACT.ACT_ID, 'custom', speOpt );
1729}
1730
1731/**
1732 * 创建一个浮动层
1733 */
1734function getPopUp(url, t, w ,h){
1735 insertCSSLink("http://imgcache.qq.com/ACT/qzone_090304_tylc/css/dialog.css");
1736 document.domain="qq.com";
1737 var popWidth = w || 450;
1738 var popHeight = h || 300;
1739 var d1 = Window.create(url, popWidth, popHeight);
1740 d1.setProp('opacity', 0);
1741 d1.setModel(true);
1742 d1.setProp('title', t);
1743 d1.show();
1744 window.regDialog = d1;
1745}
1746
1747/**
1748 * 是否显示换钻标识。
1749 */
1750function yellStr(isYell) {
1751 if(parseInt(isYell) == 1) {
1752 return '<a href="http://vip.qzone.qq.com/" target="_blank" class="icon_vip_qzone"><span>黄钻用户</span></a>';
1753 } else {
1754 return "";
1755 }
1756}
1757
1758/**
1759 * 个人页动态 图标状态处理函数
1760 */
1761function iconStatus(val){
1762 switch(val){
1763 case '1' :
1764 return 'start';
1765 break;
1766 case '2' :
1767 return 'add';
1768 break;
1769 case '3' :
1770 return 'reduce';
1771 break;
1772 default :
1773 return 'start';
1774 break;
1775 }
1776}
1777
1778/**
1779 * simpleMSG函数
1780 */
1781function simpleMSG(msg1, msg2){
1782 var msg2 = msg2 || null;
1783 var m1 = MSG2.create(null, msg1, msg2);
1784 m1.setIcon(1);
1785 m1.setButton([1]);
1786 m1.setModel(true);
1787 m1.show();
1788}
1789
1790/**
1791 * showLogin
1792 */
1793function showLogin(){
1794 if(getQQNum() == 0){
1795 var msg1 = '您需要先登陆才能进行游戏,是否现在登陆?';
1796 var m1 = MSG2.create(null, msg1, '');
1797 m1.setIcon(1);
1798 m1.setButton([1,2]);
1799 m1.setModel(true);
1800 m1.onconfirm = function(){
1801 qq_login_form(15000103, ACT2_COMM.ACT_DOMAIN + 'greentea/index.html?act=showreg');
1802 };
1803 m1.show();
1804 return;
1805 }
1806 getPopUp('reg.html', '', 500, 350);
1807}
1808
1809/**
1810 * 在页面html 加载完之后运行页面函数,类似与把所有的js 写到页面的最后面
1811 */
1812if(!document.addEventListener) {
1813 loadfun();
1814} else {
1815 EVENT.addEvent(document, "DOMContentLoaded", loadfun);
1816}
1817
1818function setInviteqq(ele) {
1819 ele = $(ele);
1820 ele.onfocus = checksearch.bind(null, ele, '请输入QQ号码', 1);
1821 ele.onblur = checksearch.bind(null, ele, '请输入QQ号码', 2);
1822 ele.onclick = checksearch.bind(null, ele, '请输入QQ号码', 0);
1823
1824 var keyfun = function(e){
1825 var e = e || window.event;
1826 if(e.keyCode==13) {
1827 gen_invitecode(ele);
1828 }
1829 };
1830 ele.onkeyup = keyfun.bindAsEventListener(null);
1831}
1832
1833
</script>
地址:http://act.qzone.qq.com/uni-greentea/index.html
<script defer="defer" src="act.js" type="text/javascript">
1document.domain = 'qq.com';
2
3CACT = {
4 ACT_ID : 10064
5}
6ACT_PART_COOKIE = 'et_act_' + CACT.ACT_ID;
7
8setInviteCode();
9/***
10 *
11 * 将入库的函数
12 *
13 */
14/**
15 * ptlogin2 登录框调用
16 */
17function qq_login_form(aid)
18{
19 if ( !g_init )
20 {
21 // initialize global variables
22 g_myBodyInstance = document.body;
23 g_myBodyInstanceString = "document.body";
24 isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
25 isMinNS5 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 5) ? 1 : 0;
26 isMinIE4 = (document.all) ? 1 : 0;
27 isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
28 isMacIE = (isMinIE4 && navigator.userAgent.indexOf("Mac") >= 0) ? 1 : 0;
29 getFFVersion = navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
30 //extra height in px to add to iframe in FireFox 1.0+ browsers
31 FFextraHeight = getFFVersion < 1.5 ? 16 : 0;
32 isOpera = (navigator.appName.indexOf("Opera") >= 0) ? 1 : 0;
33
34 if ( document.compatMode != "BackCompat" && !isOpera )
35 {
36 // for looser.dtd
37 g_myBodyInstance = document.documentElement;
38 g_myBodyInstanceString = "document.documentElement";
39 }
40
41 g_init = true;
42 // initialize done
43 }
44
45 var aid_pt = /\d+/;
46
47 // get APPID
48 if ( !aid_pt.test(aid) )
49 {
50 return;
51 }
52
53 // get all arguments
54 var argv = qq_login_form.arguments;
55
56 // get redirect url
57 if ( argv[1] )
58 {
59 redirect_url = argv[1];
60 }
61 else
62 {
63 redirect_url = window.location;
64 }
65
66 // get err_callback url
67 if ( argv[2] )
68 {
69 fp_val = argv[2];
70 }
71 else
72 {
73 fp_val = 'loginerroralert';
74 }
75
76 // get target window
77 if ( argv[3] )
78 {
79 target_win = argv[3];
80 }
81 else
82 {
83 target_win = "_self";
84 }
85
86 // get css url
87 if ( argv[4] )
88 {
89 css_url = argv[4];
90 }
91 else
92 {
93 css_url = dflt_css;
94 }
95
96 if ( !css_obj || (css_rel != css_url) )
97 {
98 css_obj = document.getElementById('login_css');
99
100 if ( !css_obj )
101 {
102 // add login css
103 var login_css = document.createElement('link');
104 login_css.id = 'login_css';
105 login_css.rel = 'stylesheet';
106 login_css.type = 'text/css';
107 login_css.media = 'screen';
108 login_css.href = css_url;
109 document.body.appendChild(login_css);
110
111 css_obj = login_css;
112 }
113 else
114 {
115 css_obj.href = css_url;
116 }
117
118 css_rel = css_url;
119 }
120
121 if ( !login_window )
122 {
123 // add encrypt js
124 var encScript = document.createElement('script');
125 encScript.src = encjs;
126 encScript.type = "text/javascript";
127 document.body.appendChild(encScript);
128
129 // add div element
130 var divE = document.createElement('div');
131 divE.id = 'login_container';
132 //divE.style.display = 'none';
133 divE.style.visibility = 'hidden';
134 //divE.style.filter = 'Alpha(opacity=0)';
135 divE.style.opacity = 0;
136
137 var login_HTML = "";
138 login_HTML += '<div id="login_header">';
139 login_HTML += ' <h4>请您登录</h4>';
140 login_HTML += ' <span id="close" onclick="javascript:setLoginFormVisible(\'hide\');"><span class="none">关闭
</span></span>';
141 login_HTML += '</div>';
142 login_HTML += '<div id="login_form">';
143 login_HTML += ' <iframe width="100%" scrolling="no" height="260" frameborder="0" src="http://ui.ptlogin2.qq.com/cgi-
bin/login?appid=15000103&hide_title_bar=1&s_url='+ encodeURIComponent(redirect_url) +'"/>';
144 login_HTML += "</div>";
145
146 divE.innerHTML = login_HTML;
147
148 document.body.appendChild(divE);
149
150 login_window = document.getElementById('login_container');
151
152 timer = setTimeout("setLoginFormVisible('show')", 500);
153 }
154 else
155 {
156 //_nchangeImg(aid);
157 timer = null;
158 }
159
160 // Miscellaneous Functions ...
161 // get drag flag
162 if ( argv[5] !== undefined )
163 {
164 drag = argv[5];
165 }
166 else
167 {
168 drag = true;
169 }
170
171 // get fix flag
172 if ( argv[6] !== undefined )
173 {
174 fix = argv[6];
175 }
176 else
177 {
178 fix = false;
179 }
180
181 // get module_div flag
182 if ( argv[7] !== undefined )
183 {
184 l_b = argv[7];
185 }
186 else
187 {
188 l_b = false;
189 }
190
191 drag_div = drag;
192 fix_div = fix;
193 module_div = l_b;
194
195 if ( fix || l_b )
196 {
197 if ( l_b )
198 {
199 makeMaskLayer();
200 }
201
202 attachWinAct();
203 }
204
205 //login_window.style.display == 'none';
206 //if (login_window && login_window.style.display == 'none')
207 //{
208 //setLoginFormVisible('show');
209 //}
210
211 if ( !timer )
212 {
213 setLoginFormVisible('show');
214 }
215
216 try {
217 var useruin = getCookie('saveduin');
218
219 if (useruin)
220 {
221 target_win.document.user_login.u.value = useruin;
222 }
223
224 //setFocus('u');
225 } catch(er) {}
226
227 //document.user_login.p.value = '';
228 //document.user_login.verifycode.value = '';
229 //document.user_login.imageField.disabled = false;
230
231 var l_h = document.getElementById("login_header");
232
233 if ( drag_div )
234 {
235 l_h.onmousedown = startMove;
236 }
237 else
238 {
239 l_h.onmousedown = null;
240 }
241}
242
243
244// 分页函数
245function showPageList(curPage,totalPage,pagesPerList,linkFormat,styleObj,delimiter){
246 if(curPage < 1 || totalPage <= 1 || curPage > totalPage)
247 return "";
248 //默认
249 if(!styleObj){
250 styleObj={};
251 styleObj.textClass='pg_having';
252 styleObj.preClass='pgup';
253 styleObj.nextClass='pgdn';
254 styleObj.curPageClass='pg_now';
255 styleObj.otherPageClass='';
256 styleObj.jumpClass='pg_op'
257 styleObj.inputClass='text-input';
258 styleObj.pageClass='page_page';
259 styleObj.submitClass='bt_submit'
260 }
261 if(!delimiter)delimiter=" ";
262
263 var m=[];
264
265 //算出要显示的码列表的范围
266 var startPageNo = curPage - parseInt(pagesPerList/2) < 1?1:curPage - parseInt(pagesPerList/2);
267 var endPageNo = startPageNo + pagesPerList -1 > totalPage ? totalPage : startPageNo +pagesPerList -1;
268 var count=endPageNo-startPageNo+1;
269 startPageNo=count!=pagesPerList?(startPageNo-(pagesPerList-count)):startPageNo;
270 startPageNo=startPageNo<1?1:startPageNo;
271 var prePageNo = curPage > 1 ? curPage-1 : 1;
272 var nextPageNo = curPage < totalPage ? curPage+1 : totalPage;
273 var reg = new RegExp("{no}","g");
274 var url;
275 var i;
276
277
278
279 m[m.length]='<P class="pg_num" style="display:inline">';
280
281 //输出文字描述
282 m[m.length]='<SPAN class="'+styleObj.textClass+'">第<STRONG>'+curPage+'/'+totalPage+'</STRONG>页</SPAN>'
283
284 // 输出上一页
285 if(1==curPage){
286 m[m.length]='<A class="'+styleObj.preClass+'" title="上一页" href="###" onclick="return false">上一页</A>'+delimiter;
287 }else{
288 url = linkFormat.replace(reg,prePageNo);
289 m[m.length]='<A class="'+styleObj.preClass+'" title="上一页" href="'+url+'">上一页</A>'+delimiter;
290 }
291
292 // 输出页列表
293 for(i=startPageNo;i<=endPageNo;i++) {
294 url = linkFormat.replace(reg,i);
295 if(i == curPage){
296 m[m.length]='<SPAN class="'+styleObj.curPageClass+'">'+i+'</SPAN>'+delimiter;
297 }
298 else
299 m[m.length]='<A class="'+styleObj.otherPageClass+'" title="'+i+'" href="'+url+'">'+i+'</A>'+delimiter;
300 }
301
302 // 输出下一页
303 if(totalPage==curPage){
304 m[m.length]='<A class="'+styleObj.nextClass+'" title="下一页" href="#" onclick="return false">下一页</A>';
305 }else{
306 url = linkFormat.replace(reg,nextPageNo);
307 m[m.length]='<A class="'+styleObj.nextClass+'" title="下一页" href="'+url+'">下一页</A>';
308 }
309
310 // 分页结束
311 m[m.length]='</P>';
312
313 var linkstr = linkFormat.replace(/'|"/g,"\\'");
314 //输出跳页
315 m[m.length]='<DIV class="'+styleObj.jumpClass+'" style="display:inline">'+'跳到';
316 m[m.length]='<INPUT class="'+styleObj.inputClass+'" onkeyup="if(event.keyCode==13) goPage('+curPage+',this.value,
'+totalPage+',\''+linkstr+'\');">'
317 m[m.length]='页';
318 m[m.length]='<BUTTON class="'+styleObj.submitClass+'" onclick="goPage('+curPage+',this.parentNode.getElementsByTagName
(\'input\')[0].value, '+totalPage+',\''+linkstr+'\');" type="button" value="GO">GO</BUTTON>'
319 m[m.length]='</DIV>';
320
321 return m.join("");
322}
323
324/**
325 * hltab
326 * @param {string} tabTId
327 * @param {string} tabCtag
328 * @param {string} tabCClass
329*/
330function hltab(tabTId, hlClass, tabCallBack, defTab, tsTag) {
331 // tab 头
332 var tabts = $(tabTId).getElementsByTagName(tsTag ? tsTag : 'a');
333 // tab 内容体
334 var tabcs = new Array();
335 var tlength = tabts.length;
336
337 var dipTab = function(e, ini ,tn){
338 if( tabts.length == 0 ) {
339 window.status = 'do not find any tab head element for ' + tabTId;
340 return;
341 }
342 for(i=0; i<tlength; i++ ) {
343 var tabn = tabts[i];
344 var rp = new RegExp(hlClass + "$");
345 //var rp = CSS.getClassRegEx(hlClass);
346 tabn.className = tabn.className.replace(rp, '');
347 }
348 tabts[tn].className += hlClass;
349 if(tabCallBack && !ini) {
350 tabCallBack(tn);
351 }
352 }
353 defTab = defTab || 0;
354 dipTab(null, true, defTab);
355 for(i=0; i<tlength; i++ ) {
356 Event.observe( tabts[i], 'click', dipTab.bindAsEventListener(null, false, i) );
357 }
358}
359
360
361/**
362 *
363 * 注册函数
364 */
365/**
366 *
367 * 初始化日期选择, 并做合并, 可以有两种情况,有年月日 和 年月
368 */
369function initFDateSel(field, minYear, maxYear) {
370 var reg = /date_(.*)$/
371 var match = field.match(reg);
372 var type = match[1];
373 var yid = 'dateyear_' + type;
374 var mid = 'datemonth_' + type;
375 var did = 'dateday_' + type;
376 initDateSelect( yid, mid, did, minYear, maxYear);
377
378 var fh = document.createElement('input');
379 fh.type = 'hidden';
380 fh.id = field;
381 fh.name = field;
382
383 if($(did)) {
384 $(did).parentNode.appendChild(fh);
385 Event.observe( did, 'change', function() {
386 var m = parseInt($(mid).value).fixDigit(2);
387 var d = parseInt($(did).value).fixDigit(2);
388 fh.value = $(yid).value + '-' + m + '-' + d;
389 FormChecker.chkElement(field);
390 } );
391 } else {
392 $(mid).parentNode.appendChild(fh);
393 Event.observe( mid, 'change', function() {
394 var m = parseInt($(mid).value).fixDigit(2);
395 fh.value = $(yid).value + '-' + m ;
396 FormChecker.chkElement(field);
397 } );
398
399 }
400}
401
402
403/**
404 * 图片切换,设置对应的验证
405 */
406function phototab(phototype, pnum, beNull, tn) {
407 //debugger;
408 var uploadphoto = 'photo' + phototype + '_' + pnum;
409 var albumphoto = 'album' + phototype + '_' + pnum;
410 beNull = !!beNull ? true : false;
411 if(tn == 0) {
412 $('photo' + phototype + '_' + pnum).disabled = true;
413 $('album' + phototype + '_' + pnum).disabled = false;
414 $('album_thum' + phototype + '_' + pnum).disabled = false;
415
416 FormChecker.setExclObj([uploadphoto]);
417 FormChecker.unsetExclObj([albumphoto]);
418 } else {
419 $('photo' + phototype + '_' + pnum).disabled = false;
420 $('album' + phototype + '_' + pnum).disabled = true;
421 $('album_thum' + phototype + '_' + pnum).disabled = true;
422
423 FormChecker.unsetExclObj([uploadphoto]);
424 FormChecker.setExclObj([albumphoto]);
425 }
426}
427
428/**
429 * 添加一张图片
430 *
431 */
432function addPhotoUpload(phototype, limit, notbeNull) {
433 var template = '\
434 <map name="nav_updata">\
435 <div class="tab_title" id="tab_{phototype}_{num}">\
436 <strong class="tab_01"><span>从我的QQ相册上传</span></strong>\
437 <strong class="tab_02"><span>从电脑上传一张图片</span></strong>\
438 </div>\
439 </map>\
440 <div class="tab_upphoto tab_1" id="form_album{phototype}_{num}">\
441 <div class="tab_list">\
442 <input type="text" name="album{phototype}[{num}][o]" id="album{phototype}_{num}" readonly />\
443 <input type="hidden" name="album{phototype}[{num}][t]" id="album_thum{phototype}_{num}" readonly />\
444 <input type="button" class="bt_up" onclick="getAlbumPic(\'album{phototype}_{num}\', \'album_thum{phototype}_{num}\');"
/>\
445 <em class="form_hint">*</em>\
446 </div>\
447 </div>\
448 <div class="tab_upphoto tab_2" id="form_photo{phototype}_{num}">\
449 <div class="tab_list">\
450 <input type="file" class="bt_up" name="photo{phototype}[{num}]" id="photo{phototype}_{num}" />\
451 <em class="form_hint">*</em>\
452 </div>\
453 </div>\
454 ';
455
456 var photoDivId = 'photo' + phototype + '_cont_div';
457 var photoDiv = $(photoDivId);
458 if(!photoDiv) {
459 return;
460 }
461 var pnum = $c('tab_div', photoDiv, 'div').length;
462 if( pnum == limit ) {
463 return;
464 }
465 var pstr = replPlacer(template, 'num', "" + pnum);
466 pstr = replPlacer(pstr, 'phototype', phototype);
467
468 var pdiv = document.createElement("div");
469 pdiv.className = 'tab_div';
470 pdiv.innerHTML = pstr;
471
472 var extradiv = $c('op', photoDiv, 'div')[0];
473 if(!extradiv) extradiv = null;
474 $(photoDiv).insertBefore(pdiv, extradiv);
475 //$(photoDiv).appendChild(pdiv);
476 tab(pdiv, 'tab_' + phototype + '_' + pnum, 'tab_now', 'div', 'tab_upphoto', phototab.bind(null, phototype , pnum,
notbeNull), 0, 'strong');
477
478}
479
480/**
481 * 删除一个图片
482 */
483function removePhoto(phototype) {
484 var pid = 'photo' + phototype + '_cont_div';
485 var pdiv = $(pid);
486 if(!pdiv) {
487 return;
488 }
489
490 var photoeles = $c('tab_div', pdiv, 'div');
491
492 var pnum = photoeles.length;
493 if(pnum == 1 ) {
494 return;
495 }
496
497 pdiv.removeChild(photoeles[pnum - 1]);
498}
499
500/**
501 * 相册图片处理
502 *
503 */
504function getAlbumPic(ori, thum){
505 function callback(data) {
506 if (!data) return;
507 var urlObj = $(ori);
508 if(urlObj) urlObj.value= data.url;
509 var thumObj = $(thum);
510 if(thumObj) thumObj.value= data.pre;
511 }
512 getAlbumDialog2(callback);
513 return;
514}
515
516
517/**
518 * 添加一个视频
519 *
520 */
521function addVideoUpload(videotype, limit) {
522 var template = '\
523 <div class="tab_upphoto tab_1" id="form_video{videotype}_{num}" >\
524 <div class="tab_list">\
525 <input type="text" name="video{videotype}[{num}][v]" id="video{videotype}_{num}" readonly="readonly" class="input-updata"
/>\
526 <button class="bt_scan" onclick="uploadVideo(\'{videotype}\', {num});"><span>浏览...</span></button>\
527 <em class="form_hint">(提示)</em> </div>\
528 </div>\
529 ';
530
531 //debugger;
532 var dataDivId = 'video' + videotype + '_cont_div';
533 var dataDiv = $(dataDivId);
534 if(!dataDiv) {
535 return;
536 }
537 var pnum = $c('tab_div', dataDiv, 'div').length;
538 if( pnum == limit ) {
539 return;
540 }
541
542 var pstr = replPlacer(template, 'num', "" + pnum);
543 pstr = replPlacer(pstr, 'videotype', videotype);
544
545 var pdiv = document.createElement("div");
546 pdiv.className = 'tab_div';
547 pdiv.innerHTML = pstr;
548
549 var extradiv = $c('op', dataDiv, 'div')[0];
550 if(!extradiv) extradiv = null;
551 $(dataDiv).insertBefore(pdiv, extradiv);
552}
553
554/**
555 * 上传video处理, 自动生成视频标题和缩略图的表单节点
556 *
557 */
558function uploadVideo(vtype, index){
559 var val=getVideoDialog();
560 if (!val) return;
561 var preObj= $(vtype + "_videothum_"+index);
562 var urlObj= $( 'video' + vtype + "_" + index);
563 var titleObj= $(vtype + "_videotitle_"+index);
564 var video_url = val[1];
565 var vid_reg = /vid=(.*)$/
566 var match = video_url.match(vid_reg);
567 var vid = match[1];
568 if(urlObj) {
569 if(!preObj) {
570 preObj = document.createElement('input');
571 preObj.type = 'hidden';
572 preObj.id = vtype + "_videothum_"+index;
573 preObj.name = 'video' + vtype + "["+index + "][f]";
574 titleObj = document.createElement('input');
575 titleObj.type = 'hidden';
576 titleObj.id = vtype + "_videotitle_"+index;
577 titleObj.name = 'video' + vtype + "["+index + "][t]";
578
579 urlObj.parentNode.appendChild(preObj);
580 urlObj.parentNode.appendChild(titleObj);
581 }
582 urlObj.value = val[1];
583 titleObj.value = val[4];
584 preObj.value = 'http://vpic.video.qq.com/1/'+vid+'_1.jpg';
585 } else {
586 return;
587 }
588}
589
590/**
591 * 删除一个视频
592 */
593function removeVideo(type) {
594 var pid = 'video' + type + '_cont_div';
595 var pdiv = $(pid);
596 if(!pdiv) {
597 return;
598 }
599
600 var photoeles = $c('tab_div', pdiv, 'div');
601
602 var pnum = photoeles.length;
603 if(pnum == 1 ) {
604 return;
605 }
606
607 pdiv.removeChild(photoeles[pnum - 1]);
608}
609
610
611/**
612 * 添加一个动感影集
613 */
614function addVphotoUpload(type, limit, mid, name) {
615 var template = '\
616 <div class="tab_upphoto tab_1" id="form_vphoto{type}_{num}">\
617 <div class="tab_list">\
618 <input type="text" name="vphoto{type}[{num}][v]" id="vphoto{type}_{num}" readonly="readonly" />\
619 <input type="button" value="浏览..." onclick="javascript:showFlashAlbum(vphotoCallBack.bind(null, \'{type}\', \'{num}\'),
{mid: {mid}, name: \'{name}\'});" />\
620 <em class="form_hint">*</em>\
621 </div>\
622 </div>\
623 ';
624
625 var photoDivId = 'vphoto' + type + '_cont_div';
626 var photoDiv = $(photoDivId);
627 if(!photoDiv) {
628 return;
629 }
630 var pnum = $c('tab_div', photoDiv, 'div').length;
631 if( pnum == limit ) {
632 return;
633 }
634
635 mid = mid || 361;
636 name = name || '洁婷';
637
638 var pstr = replPlacer(template, 'num', "" + pnum);
639 pstr = replPlacer(pstr, 'type', type);
640 pstr = replPlacer(pstr, 'name', name);
641 pstr = replPlacer(pstr, 'mid', mid);
642
643 var pdiv = document.createElement("div");
644 pdiv.className = 'tab_div';
645 pdiv.innerHTML = pstr;
646
647 var extradiv = $c('op', photoDiv, 'div')[0];
648 if(!extradiv) extradiv = null;
649 $(photoDiv).insertBefore(pdiv, extradiv);
650 //$(photoDiv).appendChild(pdiv);
651}
652
653/**
654 * 删除一个动感影集
655 */
656function removeVphotoUpload(type) {
657 var pid = 'vphoto' + type + '_cont_div';
658 var pdiv = $(pid);
659 if(!pdiv) {
660 return;
661 }
662
663 var photoeles = $c('tab_div', pdiv, 'div');
664
665 var pnum = photoeles.length;
666 if(pnum == 1 ) {
667 return;
668 }
669
670 pdiv.removeChild(photoeles[pnum - 1]);
671}
672
673/**
674 * 动感影集回调, 设置数据并添加对应的第一帧和第一帧的缩略图的表单
675 */
676function vphotoCallBack(type, num, data) {
677 if(data){
678
679 var urlId = 'vphoto' + type + '_' + num;
680 var thumbId = 'vphotothumb' + type + '_' + num;
681 var frameId = 'vphotoframe' + type + '_' + num;
682 if(data[3]){
683 $(urlId).value = data[3];
684 if(!$(thumbId)) {
685 var thumb = document.createElement('input');
686 thumb.id = thumbId;
687 thumb.name = 'vphoto' + type + '[' + num+ '][t]';
688 thumb.type = 'hidden';
689
690 var frame = document.createElement('input');
691 frame.id = frameId;
692 frame.name = 'vphoto' + type + '[' + num + '][f]';
693 frame.type = 'hidden';
694
695 $(urlId).parentNode.appendChild(thumb);
696 $(urlId).parentNode.appendChild(frame);
697 }
698 }
699
700 if(data[1]){
701 var frame = data[1];
702 $(frameId).value = frame;
703 $(thumbId).value = frame.replace(/rurl4_b/, 'rurl4_s');
704 }
705 }
706}
707
708
709// 解析用户配置,以及初始化一些选择框,图片视频选择
710function parseUserConf(user_conf, fields, spefileds, acceptlist, exceptlist) {
711 for(var field in user_conf) {
712 if(Object.isArray(acceptlist) && !acceptlist.include(field)) {
713 continue;
714 }
715
716 if(Object.isArray(exceptlist) && exceptlist.include(field)) {
717 continue;
718 }
719
720 var fieldConf = user_conf[field];
721 fields[field] = fieldConf.data_type;
722
723 //debugger;
724 // 表单项显示和排序
725 var field_type = fieldConf.field_type;
726 var row = $('form_' + field);
727 var fele = $(field);
728 var fe = $('fieldset_' + field_type);
729 var fobjele = $(field + '_0');
730 var fobjcont = $(field + '_cont_div');
731
732 // 没有行也没有元素返回
733 if(!row && !fele && !fobjele && !fobjcont) {
734 continue;
735 }
736
737 // 排序字段
738 /*if(row) {
739 continue;
740 row.style.display = '';
741 var fs_app = fe ? fe : $('fieldset_other');
742 if(fs_app) {
743 fs_app.appendChild(row);
744 }
745 }*/
746
747 //debugger;
748 //映射原有的属性
749 //fieldConf['is_null'] = !fieldConf['null'];
750 fieldConf['is_null'] = fieldConf['null'] ? 0 : 1 ;
751 fieldConf['max_value'] = fieldConf['max'];
752 fieldConf['min_value'] = fieldConf['min'];
753 fieldConf['max_length'] = fieldConf['maxlength'];
754 fieldConf['min_length'] = fieldConf['minlength'];
755 fieldConf['length_tip'] = fieldConf['err_tip'];
756 // type属性会覆盖html 的type 去除掉
757 delete fieldConf['type'];
758 spefileds[field] = fieldConf;
759
760 // 初始化用数组初始的选择框
761 if(!!regData[field]) {
762 initSelect(field, regData[field]);
763 continue;
764 }
765
766 // 初始话城市选择框, 命名的规则是 city + 名词
767 var mat = field.match(/city(.*)/);
768 if(mat) {
769 var subfix = mat[1];
770 var cityId = 'province' + subfix;
771 areaSelectInit(cityId, field);
772 continue;
773 }
774
775
776 // 初始化数字选择框, 注意后台配置的时候 min_length == max_length == 20 才是这种类型
777 if(fieldConf['data_type'] == 'select') {
778 //debugger;
779 var min_value = fieldConf['min_value'] || 0;
780 var max_value = fieldConf['max_value'] ;
781 var max_length = fieldConf['maxlength'];
782 var min_length = fieldConf['minlength'];
783 if((max_length == min_length) && (min_length == 20)) {
784 initNumSelect(field, min_value, max_value);
785 continue;
786 }
787 }
788
789 // 初始化年月日选择
790 /*var mat = field.match(/year(.*)/);
791 if(mat) {
792 var minYear = fieldConf['min_value'] || 1982;
793 var maxYear = fieldConf['max_value'] || 2008;
794 var subfix = mat[1];
795 var monthId = 'month' + subfix;
796 var dayId = 'day' + subfix;
797 initDateSelect(field, monthId, dayId, minYear, maxYear);
798 continue;
799 }*/
800
801 // 初始化年月日选择
802 var mat = field.match(/date_(.*)/);
803 if(mat) {
804 var minYear = fieldConf['min_value'] || 1982;
805 var maxYear = fieldConf['max_value'] || 2008;
806 initFDateSel(field, minYear, maxYear);
807 continue;
808 }
809
810
811 // 初始化相框选择 命名规则是 photo + 后缀, 需要在页面上添加id ,id的规则是 字段名 + '_cont_div'
812 var mat = field.match(/^photo(.*)/);
813 if(mat) {
814 //debugger
815 var phototype = mat[1];
816 var isNotNull = fieldConf['is_null'];
817 for(var i=0; i<3; i++){
818 addPhotoUpload(phototype, 3, isNotNull);
819 }
820
821 //var fieldConfOther = spefileds[uploadother + phototype];
822 var array_size = fieldConf['array_size'] || 1;
823 for(var i=0; i<array_size; i++) {
824 fields[ 'photo'+ phototype + '_' + i] = fieldConf.data_type;
825 spefileds[ 'photo'+ phototype + '_' + i] = fieldConf;
826
827 fields[ 'album'+ phototype + '_' + i] = 'string';
828 spefileds[ 'album'+ phototype + '_' + i] = {
829
830 'is_null' : isNotNull,
831 'check_length' : false,
832 'length_tip' : fieldConf.err_tip,
833 'err_tip' : fieldConf.err_tip,
834 'page_tip' : fieldConf.page_tip
835 };
836 }
837 // 多值需要添加id
838 if(array_size > 1) {
839 //debugger
840 // 多值需要添加id, 规则是 字段名 + "_btn_div"
841 //
842 var photoDivId = 'photo' + phototype + '_cont_div';
843 var photoDiv = $(photoDivId);
844 if(!photoDiv) {
845 continue;
846 }
847
848 var opdiv = document.createElement('p');
849 opdiv.className = 'form_tips';
850 opdiv.innerHTML = '请根据主题上传JPG/GIF图片,文件大小500k以内';
851
852 photoDiv.appendChild(opdiv);
853
854 }
855 continue;
856 }
857
858 // 视频选择, 需要在页面内加id, id 的规则是 字段名 + '_cont_div'
859 var mat = field.match(/^video(.*)/);
860 if(mat) {
861 var vtype = mat[1];
862 var isNotNull = fieldConf['is_null'];
863 addVideoUpload(vtype, 3);
864
865 //debugger;
866 var array_size = fieldConf['array_size'] || 1;
867 for(var i=0; i<array_size; i++) {
868 fields[ 'video'+ vtype + '_' + i] = fieldConf.data_type;
869 spefileds[ 'video'+ vtype + '_' + i] = fieldConf;
870 }
871 if(array_size > 1) {
872 var dataDivId = 'video' + vtype + '_cont_div';
873 var dataDiv = $(dataDivId);
874 if(!dataDiv) {
875 continue;
876 }
877
878 var opdiv = document.createElement('div');
879 opdiv.className = 'op';
880 opdiv.innerHTML = '\
881 <button type="button" class="bt_new_upload" onclick="addVideoUpload(\''+ vtype +'\', ' + array_size + ');" >再传一个
</button>\
882 <button type="button" class="bt_del_date" onclick="removeVideo(\''+ vtype+'\');" >删除最后一个</button>\
883 ';
884
885 dataDiv.appendChild(opdiv);
886
887 }
888 continue;
889 }
890
891 // 动感影集选择, 需要在页面内加id, id 的规则是 字段名 + '_cont_div'
892 var mat = field.match(/^vphoto(.*)/);
893 if(mat) {
894 var vtype = mat[1];
895 var isNotNull = fieldConf['is_null'];
896 addVphotoUpload(vtype, 3);
897
898 //debugger;
899 var array_size = fieldConf['array_size'] || 1;
900 for(var i=0; i<array_size; i++) {
901 fields[ 'vphoto'+ vtype + '_' + i] = fieldConf.data_type;
902 spefileds[ 'vphoto'+ vtype + '_' + i] = fieldConf;
903 }
904 if(array_size > 1) {
905 var dataDivId = 'vphoto' + vtype + '_cont_div';
906 var dataDiv = $(dataDivId);
907 if(!dataDiv) {
908 continue;
909 }
910
911 var opdiv = document.createElement('div');
912 opdiv.className = 'op';
913 opdiv.innerHTML = '\
914 <button class="bt_new_upload" type="button" onclick="addVphotoUpload(\''+ vtype +'\', ' + array_size + ');" >上传更多
</button>\
915 <button class="bt_new_upload" type="button" onclick="removeVphotoUpload(\''+ vtype+'\');" >删除最后一个</button>\
916 ';
917 dataDiv.appendChild(opdiv);
918
919 }
920 continue;
921 }
922 }
923}
924
925/**
926 *
927 * 注册函数结束
928 */
929
930/**
931 * 投票函数
932 *
933 */
934/**
935 * 取得剩余的票数
936 * @param{string} limitType 合法值 free_voter free_voting free_player pay_voter pay_voting pay_player
937 * return {myvoteleft, level, ptype}
938 */
939function getVoteLeft(conf, limitType) {
940 var limitConf = conf.limits[limitType];
941 // 我已经投票数
942 var ihavevote = limitConf.voted;
943 // 我可以投票数
944 var icanvote = limitConf.vote_right;
945
946 // 我的剩余票数
947 var myvoteleft = icanvote - ihavevote;
948
949 // 我的优惠权限的级别
950 var level = limitConf.level;
951
952 // 我的优惠权限的类别
953 var ptype = limitConf.ptype;
954 return {
955 'myvoteleft' : myvoteleft,
956 'level': level,
957 'ptype' : ptype
958 } ;
959}
960
961/**
962 * 设置投票页面
963 *
964 */
965function presetVotePage(conf){
966
967 // 检查所有必须的id
968 var reqid = ['type1','type2','type3','type4','unpay1','unpay2','unpay3','unpay4','votecount0','votecount1',
969 'votecount2','votecount3','votecount4','votecost','votetype','voteform', 'paytype', 'player', 'votecount'];
970 reqid.each(
971 function(v) {
972 if(!$(v)) {
973 alert('请检查页面,页面上缺少id ' + v);
974 }
975 }
976 );
977
978 // 收费投票配置
979 var payvoteConf = conf.act_conf.pay;
980 var levelArr = conf.uin;
981
982 // 票数的输入,设置票数和计算用户须付Q币Q点
983 // 对于免费投票的, 也要将票数清零
984 getVoteQB('0', null, null, false, 'votecost', 'votetype', 'Q币');
985 getVoteQB('1', payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q点');
986 getVoteQB('2', payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q币');
987 getVoteQB('3', payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q点');
988 getVoteQB('4', payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q币');
989
990 // radio 类别点击, 取得用户的 paytype
991 Event.observe('type1', 'click', setCheckType.bind(null, 1, payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q点'));
992 Event.observe('type2', 'click', setCheckType.bind(null, 2, payvoteConf, levelArr, false, 'votecost', 'votetype', 'Q币'));
993 Event.observe('type3', 'click', setCheckType.bind(null, 3, payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q点'));
994 Event.observe('type4', 'click', setCheckType.bind(null, 4, payvoteConf, levelArr, true, 'votecost', 'votetype', 'Q币'));
995
996 // 点击不足出另外类型支付,取得用户的paytype
997 Event.observe('unpay1', 'click', setpayType.bind(null, 1, true));
998 Event.observe('unpay2', 'click', setpayType.bind(null, 2, true));
999 Event.observe('unpay3', 'click', setpayType.bind(null, 3, true));
1000 Event.observe('unpay4', 'click', setpayType.bind(null, 4, true));
1001
1002 // 免费投票和收费投票切换
1003 function votetab( tn) {
1004 if(tn == 0) {
1005 // 免费投票
1006 $('voteform').action = '/vote/freevote.php?script&domain&callback=parent.jsonCallBack&act_id=' + CACT.ACT_ID;
1007 $('votecost').innerHTML = 0;
1008 $('votetype').innerHTML = 'Q币';
1009 setVoteQBNum( 0, null, null, false, 'votecost', 'votetype', 'Q币');
1010 } else {
1011 // 收费投票
1012 $('voteform').action = '/vote/payvote.php?script&domain&callback=parent.jsonCallBack&act_id='+ CACT.ACT_ID;
1013 $('votecost').innerHTML = 0;
1014 $('votetype').innerHTML = 'Q点';
1015
1016 var checked = false;
1017 for(var i=1; i<=4; i++) {
1018 var typeEle = $('type' + i);
1019 if(typeEle.checked) {
1020 typeEle.click();
1021 checked = true;
1022 }
1023 }
1024 if(!checked) {
1025 $('type1').click();
1026 }
1027 }
1028 }
1029
1030 /**
1031 *
1032 * act_vote_form
1033 * 1 => 只有免费投票
1034 * 2 => 只有收费投票, 有礼包
1035 * 3 => 只有收费投票, 没有礼包
1036 * 4 => 有免费投票和收费投票, 有礼包
1037 * 5 => 有免费投票和收费投票, 没有礼包
1038 */
1039 switch (window.act_vote_form) {
1040 case 1:
1041 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 0, 'strong');
1042 $('votetabhead').getElementsByTagName('strong')[1].style.display = "none";
1043 break;
1044 case 2:
1045 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1046 $('votetabhead').getElementsByTagName('strong')[0].style.display = "none";
1047 break;
1048 case 3:
1049 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1050 $('votetabhead').getElementsByTagName('strong')[0].style.display = "none";
1051 $('votepack').style.display = 'none';
1052 break;
1053 case 4:
1054 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1055 break;
1056 case 5:
1057 tab('votetab', 'votetabhead', 'h', 'div', 'act_tab_vote', votetab.bind(null), 1, 'strong');
1058 $('votepack').style.display = 'none';
1059 break;
1060
1061 }
1062}
1063
1064/**
1065 * 根据radio的选择设置投票数,paytype, 以及应付QB
1066 */
1067function setCheckType(index, payvoteConf, levelArr, pack, cid, tid, vtypeText) {
1068 var vsel = $('type' + index);
1069 for(var i =1; i<=4; i++) {
1070 DOM.hide('typediv_' + i);
1071 }
1072 if(vsel.checked) {
1073 DOM.show('typediv_' + index);
1074
1075 setVoteQBNum( index, payvoteConf, levelArr, pack, cid, tid, vtypeText);
1076 setpayType(index, false);
1077 }
1078}
1079
1080/**
1081 * 设置应收Q币Q点数, 已经投票数
1082 */
1083function setVoteQBNum(index, payvoteConf, levelArr, pack, cid, tid, vtypeText) {
1084 //debugger;
1085 var votenum = parseInt($('votecount' + index).value);
1086 if(isNaN(votenum)) {
1087 votenum = 0;
1088 }
1089
1090 if($('type' + index) && !$('type' + index).checked) {
1091 return;
1092 }
1093
1094 var tobj = $(tid);
1095 if(tobj) {
1096 // Q币Q点提示
1097 tobj.innerHTML = vtypeText;
1098 }
1099
1100 // 没有收费配置,那就是免费的
1101 if(!payvoteConf) {
1102 $('votecount').value = votenum;
1103 $(cid).innerHTML = "0";
1104 return;
1105 }
1106
1107 // 原始价格
1108 var cost=0;
1109
1110 var price = 0;
1111 // 是否打包
1112 if(!pack) {
1113 price = payvoteConf.price;
1114 } else {
1115 price = payvoteConf.pkg_price;
1116 }
1117 // Q点
1118 if(index == 1 || index == 3) {
1119 cost = parseInt(votenum) * price/10;
1120 }
1121 else {
1122 cost = parseInt(votenum) * price/100;
1123 }
1124
1125 // 用户输入的票数有误,票数和应收Qb置位0
1126 if(isNaN(cost) || cost==0) {
1127 $(cid).innerHTML = "0";
1128 $('votecount').value = 0;
1129 return;
1130 }
1131
1132 // 优惠配置
1133 var privilege = payvoteConf.privilege;
1134 // 没有优惠配置,用原始价格
1135 if(!privilege) {
1136 // 投票数
1137 $('votecount').value = votenum;
1138 // 应收Q币数
1139 $(cid).innerHTML= cost.toFixed(2);
1140 return;
1141 }
1142
1143 // 遍历优惠的类型
1144 for(var ptype in privilege) {
1145 // 用户的达人或者黄钻级别
1146 var level = levelArr[ptype];
1147 // 用户这个级别的优惠比例
1148 var per = privilege[ptype][level];
1149 if(per) {
1150 // 优惠价格 ,原价格 * 百分比
1151 cost *= parseInt(per)/100;
1152 break;
1153 }
1154 }
1155
1156 // 投票数
1157 $('votecount').value = votenum;
1158 // 应收Q币数
1159 $(cid).innerHTML= cost.toFixed(2);
1160}
1161
1162/**
1163 * 在用户投票数输入框 keyup, keydown, keypress 的时候计算出应收用户的Q币Q点数,以及设置投票数
1164 * @example
1165 */
1166function getVoteQB(index, payvoteConf, levelArr, pack, cid, tid, vtype) {
1167 Event.observe('votecount' + index, 'keyup', setVoteQBNum.bind(null, index, payvoteConf, levelArr, pack, cid, tid,
vtype));
1168 Event.observe('votecount' + index, 'keydown', setVoteQBNum.bind(null, index, payvoteConf, levelArr, pack, cid, tid,
vtype));
1169 Event.observe('votecount' + index, 'keypress', setVoteQBNum.bind(null, index, payvoteConf, levelArr, pack, cid, tid,
vtype));
1170}
1171
1172/**
1173 * checkbox 选择 根据radio 的选择 设置 paytype
1174 * @param index 1 单笔Q点,2 单笔Q币 3。 礼包Q点 4. 礼包Q币
1175 * @isSelf isSelf true为点击事件触发,为点击checkbox时候调用,false 为被被动调用为点击radio时候的调用
1176 *
1177 */
1178function setpayType(index, isSelf) {
1179 //debugger;
1180 // 不足充数的checkbox
1181 var unpay = $('unpay' + index);
1182 var unpaycheck = unpay.checked;
1183
1184 // Q币Q 点的radio
1185 var typecheck = $('type' + index).checked;
1186 //var paytypelist = ['qd', 'qdqb', 'qb', 'qbqd'];
1187
1188 // 传给php 的paytype 列表
1189 var paytypelist = [2, 4, 1, 3];
1190 // 点击checkbox 并且对应的radio是选择的 或者 不是自我调用的时候设置paytype
1191 if((typecheck && isSelf) || (!isSelf) ) {
1192 var paytypeindex = index;
1193 if(paytypeindex >=3 ) {
1194 paytypeindex = paytypeindex - 2;
1195 }
1196 if(unpaycheck) {
1197 paytypeindex = paytypeindex * (paytypeindex - 1) + 1;
1198 $('paytype').value = paytypelist[paytypeindex];
1199 } else {
1200 paytypeindex = paytypeindex * (paytypeindex - 1);
1201 $('paytype').value = paytypelist[paytypeindex];
1202 }
1203 }
1204}
1205
1206/**
1207 * 投票函数结束
1208 *
1209 */
1210
1211
1212/***
1213 *
1214 * 将入库的函数
1215 */
1216
1217////////////////////////////////////////////////////////////// 以上函数请所有都copy 到新活动act.js 里
1218
1219function commFun(){
1220 actTop();
1221 //actHeader();
1222 actFooter();
1223 var speOpt = {
1224 linkClass : 'login',
1225 doLogout : function() {
1226 document.cookie = "uin=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1227 document.cookie = "skey=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1228 document.cookie = "zzpaneluin=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1229 document.cookie = "zzpanelkey=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=qq.com";
1230 document.cookie = ACT2.COOKIE_NICKNAME + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
domain="+ACT2_COMM.ACT_COOKIE_DOMAIN;
1231 document.cookie = ACT2.COOKIE_UIN + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
domain="+ACT2_COMM.ACT_COOKIE_DOMAIN;
1232 window.location = 'index.html';
1233 }
1234 };
1235 GJsonDealFun.handlePageData(CACT.ACT_ID, 'status', speOpt);
1236 insertCSSLink('http://imgcache.qq.com/ACT/act_common/css/pop.css');
1237 insertCSSLink("http://imgcache.qq.com/ACT/qzone_090304_tylc/css/dialog.css");
1238}
1239
1240var delFun = {
1241 'index' : function() {
1242 if(getQQNum() != 0){
1243 var speOpt = {
1244 errdeal : false,
1245 dataDeal : function(opt,obj){
1246 if(obj.error && obj.error != 4506 && getParameter('act') == 'showreg'){
1247 getPopUp('reg.html', '', 500, 350);
1248 }
1249 }
1250 }
1251 loadPageData(CACT.ACT_ID, 'profile', speOpt);
1252 }
1253 },
1254 'reg' : function() {
1255 var speOpt = {
1256 onConfirm: function(opt, obj) {
1257 top.location.reload();
1258 },
1259 dataDeal : function(opt, obj){
1260 var msg = opt.getTitle();
1261 var tip = '赶快点击首页转盘,开启你的茶游之旅吧!';
1262 var m1 = MSG2.create(null, msg, tip);
1263 m1.setIcon(1);
1264 m1.setButton([1]);
1265 m1.setTimeout([3000]);
1266 m1.onunload = opt.onConfirm.bind(this, opt, obj);
1267 m1.show();
1268 }
1269 }
1270 loadPageData(CACT.ACT_ID, 'reg', speOpt);
1271 // 注册的cgi
1272 $("reg_form").action = ACT2_COMM.ACT_DOMAIN + "user/freereg.php?domain&script&callback=parent.jsonCallBack&act_id=" +
CACT.ACT_ID;
1273
1274 //此活动的注册为弹出框,所以函数showErr做特殊处理。
1275 window.showErr = function (obj, redrt, onconfirm) {
1276 var m1 = MSG2.create(null, obj.error.msg, null);
1277 if(redrt) {
1278 m1.onunload = function() {
1279 top.location = redrt;
1280 }
1281 }
1282 if(onconfirm) {
1283 m1.onconfirm = onconfirm;
1284 }
1285 m1.setIcon(2);
1286 m1.setButton([1]);
1287 m1.show();
1288 }
1289 },
1290 'user' : function(){
1291 var userQQ = getParameter('qq') || getQQNum();
1292
1293 if(!isOwner()){
1294 $('jiayou').style.display = '';
1295 }else{
1296 $('mode_todo').style.display = '';
1297 $('profileHome').className="now";
1298 }
1299
1300 var speOpt = {
1301 preDeal : function(opt, obj) {
1302 var headType = ['3','2','4','1'];
1303 var facVal = obj.data.faction;
1304 var sexType = ['男', '女'];
1305 var sexVal = obj.data.sex;
1306 if(!!facVal){
1307 obj.data.userhead = 'http://imgcache.qq.com/qzone/qzoneact/greentea_20090316/img/ntx' + headType[facVal - 1] + '.jpg'
1308 }
1309 if(!!sexVal){
1310 obj.data.usersex = sexType[sexVal - 1];
1311 }
1312 },
1313 dataDeal : function(opt, obj){
1314 FillDiv_Ex('userInfo',obj.data);
1315 $('user_info').style.visibility = 'visible';
1316 },
1317 aftDeal:function(opt,obj){
1318 //拉取机会的数据
1319 if(getQQNum()==obj.data.qq)
1320 {
1321 var speOpt = {
1322 request_url: 'http://act.qzone.qq.com/greentea/get_chance.php?act_id=10064&callback',
1323 errdeal: false,
1324 dataDeal : function(opt,obj){
1325 if(!obj.error)
1326 $('chance').innerHTML = obj.data;
1327 }
1328 }
1329 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1330
1331 //可答题的个数
1332 speOpt={
1333 request_url: 'http://act.qzone.qq.com/greentea/get_answer.php?act_id=10064&part=0&callback',
1334 errdeal: false,
1335 dataDeal : function(opt,obj){
1336 if(!obj.error)
1337 {
1338 count=0;
1339 for(var i=1;i<=30;i++)
1340 if(obj.data[i]==2)
1341 count++;
1342 $('queLeft').innerHTML = count;
1343 }
1344 }
1345 }
1346 loadPageData(CACT.ACT_ID,'custom',speOpt);
1347
1348 //复制连接
1349 $('copeinvite').style.display="";
1350
1351 }
1352 }
1353 }
1354 //加载生成数据
1355 loadPageData(CACT.ACT_ID, 'profile', speOpt);
1356
1357 var speOpt = {
1358 request_url: 'http://act.qzone.qq.com/uni-greentea/get_fans.php?callback&page=1&pernum=7&act_id=' + CACT.ACT_ID + '&qq='
+ userQQ,
1359 errdeal: false,
1360 dataDeal : function(opt,obj){
1361 if(!obj.error)
1362 FillDiv_Ex('friendlist1',obj.data.data);
1363 }
1364 }
1365 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1366
1367 var speOpt = {
1368 request_url: 'http://act.qzone.qq.com/uni-greentea/get_msg_list.php?callback&page=1&pernum=7&act_id=' + CACT.ACT_ID +
'&qq=' + userQQ,
1369 errdeal: false,
1370 dataDeal : function(opt,obj){
1371 if(!obj.error)
1372 FillDiv_Ex('feedlist',obj.data.data);
1373 }
1374 }
1375 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1376
1377 var speOpt = {
1378 request_url: 'http://act.qzone.qq.com/uni-greentea/friendlist.php?callback&page=1&pernum=7&act_id=' + CACT.ACT_ID +
'&qq=' + userQQ,
1379 errdeal: false,
1380 dataDeal : function(opt,obj){
1381 if(!obj.error)
1382 FillDiv_Ex('frdMap',obj.data);
1383 }
1384 }
1385 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1386
1387
1388 },
1389 'question' : function() {
1390 //var userQQ = getParameter('qq') || getQQNum();
1391 var speOpt = {
1392 request_url: 'http://act.qzone.qq.com/uni-greentea/get_answer.php?callback&part=0&act_id=' + CACT.ACT_ID,
1393 dataDeal : function(opt,obj){
1394 for(var i=0; i<30; i++){
1395 var ansStatus = obj.data[i + 1];
1396 qlist[i].push(ansStatus);
1397 }
1398 FillDiv_Ex('allQue',qlist);
1399 }
1400 }
1401 loadPageData(CACT.ACT_ID, 'custom', speOpt);
1402
1403 window.jsonCallBack = function(obj) {
1404 var opt = {
1405 errdeal : false,
1406 dataDeal: function(opt, obj) {
1407 if(obj.error){
1408 var msg = obj.error.msg;
1409 simpleMSG(msg);
1410 }else{
1411 if(obj.data.result){
1412 simpleMSG('恭喜,回答正确!','您已获得20茶多酚的奖励');
1413 $('button').disabled = 'disabled';
1414 }else{
1415 simpleMSG('很遗憾,回答错误','您将被扣除20茶多酚');
1416 $('button').disabled = 'disabled';
1417 };
1418 }
1419 }
1420 }
1421 GJsonDealFun.jsonCallBack.bind(null, opt)(obj);
1422 }
1423 },
1424 'fans' : function() {
1425 /**
1426 * 粉丝模块显示函数
1427 * 做法: 将需要显示的类型的粉丝榜的id写在html里,以及写好其对应的模板
1428 * 修改点: 修改fans todo 1 当取粉丝失败时候的处理
1429 */
1430
1431 /**
1432 *
1433 * 获取粉丝列表并填充
1434 */
1435 var speOpt = {
1436 errdeal: false,
1437 // 取得数据之后再取得头像
1438 dataDeal : function(opt, obj) {
1439 /**
1440 *
1441 * 当取数据发生错误时的处理,比如用户没有粉丝 可能会需要做处理
1442 * fans todo 1
1443 */
1444 if(obj.error) {
1445 alert(obj.error.msg);
1446 return;
1447 }
1448
1449 // 将结构绑定到opt
1450 opt.obj = obj;
1451
1452 // 取头像
1453 var fanslist = obj.fans.new_fans;
1454 var len = fanslist.length;
1455 var str_uins = '';
1456 for(var i=0; i<len; i++) {
1457 var fans = fanslist[i]
1458 str_uins += fans.qq + ',';
1459 }
1460 var url="http://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?uins="+str_uins;
1461 // 绑定结果
1462
1463 loadJsonData(url,url,function(obj){ opt.portrait_callback(opt, obj);}, function(){}, true,null, 'portraitCallBack');
1464
1465 },
1466 loadData: function(opt) {
1467 //var player = 231723129;
1468 var qq = getParameter('qq');
1469 var player = getQQNum();
1470 var player = qq || player ;
1471 // 数据url
1472
1473 var url = 'http://act.qzone.qq.com/vote/votefans.php?callback&act_id='+opt.actId+'&player=' + player;
1474 GJsonDealFun.init(url, this.callBack.bind(this, opt), null, false);
1475 },
1476 // 填充数据
1477 portrait_callback: function(opt, arrqq) {
1478 // 取得头像函数
1479 window.getQzoneHead = opt.getQzoneHead.bind(null, arrqq);
1480 // 填充忠实粉丝
1481 try {
1482 FillDiv_Ex("faith_fans_div", opt.obj.fans.faith_fans);
1483 } catch(e) {}
1484 // 填充最新粉丝
1485 try {
1486 FillDiv_Ex("new_fans_div", opt.obj.fans.new_fans);
1487 } catch(e) {}
1488 },
1489 getQzoneHead : function(arr, qq) {
1490 if(arr[qq]) {
1491 return arr[qq][0];
1492 } else {
1493 return '';
1494 }
1495 },
1496 handler_err : {
1497 /**
1498 * 特定的错误码对应的处理函数
1499 * fans todo 2
1500 */
1501 }
1502 }
1503 loadPageData(CACT.ACT_ID, 'fanslist', speOpt );
1504 },
1505 'playerlist' : function() {
1506 var speOpt = {
1507 'ord' : 'sort0',
1508 'direct' : 'desc',
1509 'preRequest' : function(opt) {
1510 var ord = opt.ord;
1511 var direct = opt.direct;
1512 var type = opt.type;
1513
1514
1515 var hntabCallback = function(ordtab, opt, tn){
1516 var link = ACT2.S_PLAYER_LIST_PAGE;
1517 var type = opt.type;
1518 var direct = opt.direct;
1519
1520 ord = ordtab[tn];
1521 link = replPlacer(link, 'ord', ord);
1522 link = replPlacer(link, 'direct', direct);
1523 // page
1524 link = replPlacer(link, 'no', 1);
1525 link = replPlacer(link, '&type', type, true);
1526 window.location = link;
1527 }
1528 },
1529 dataDeal: function(opt, obj) {
1530 //先填充页码
1531
1532 curpage=obj.info.curpage;
1533 totalpage=obj.info.totalpage;
1534 var linkFormat = opt.getLinkFormat(opt);
1535
1536 // 约定页数的id 用page
1537 $("page").innerHTML=showPageList(curpage,totalpage,10,linkFormat,null);
1538 for(i=0;i<obj.data.length;i++)
1539 {
1540 obj.data[i]['index']=(i+1)+(obj.info.curpage-1)*17;
1541 }
1542 var fillFun = function( field, ele){
1543 FillDiv_Ex(ele, obj[field])
1544 };
1545 Object.each(opt.divToFill, fillFun);
1546 }
1547 };
1548 // 载入用户列表数据
1549 loadPageData(CACT.ACT_ID, 'playerlist', speOpt);
1550 }
1551};
1552
1553
1554/**
1555 * 页面加载处理
1556 */
1557function loadfun(){
1558 var curPage = 'index';
1559 var reg = new RegExp("^http:\/\/[^\/]+/[^\/]+\/?(([^\.]+)\.html?)?");
1560 var mat = window.location.href.match(reg);
1561 if(mat[2]) {
1562 curPage = mat[2];
1563 }
1564 if(curPage != 'vote' && curPage != 'fans' && curPage != 'reg'){
1565 commFun();
1566 }
1567
1568 if(delFun[curPage]) {
1569 delFun[curPage]();
1570 }
1571}
1572
1573
1574/**
1575 * 显示选择下拉菜单的值
1576 */
1577function showSelect(data, key) {
1578 if(regData[data][key]) {
1579 return regData[data][key];
1580 } else {
1581 return "";
1582 }
1583}
1584
1585function getAreaName(areacode){
1586 var provname = location_array[Math.floor(areacode/100)];
1587 var cityname= sublocation_array[Math.floor(areacode/100)][areacode];
1588 return provname+'-'+cityname;
1589}
1590
1591/**
1592 * 黄钻图标
1593 *
1594 */
1595function yellStr(isYell) {
1596 if(parseInt(isYell) == 1) {
1597 return '<a href="http://vip.qzone.qq.com/" title="开通黄钻" target="_blank" class="yellow"></a>';
1598 } else {
1599 return "";
1600 }
1601}
1602
1603/**
1604 * 关闭空间里的页面
1605 *
1606 */
1607function close_in_qzone()
1608{
1609 if(top.guide)
1610 {
1611 top.guide(1);
1612 }
1613 else
1614 {
1615 window.close();
1616 }
1617}
1618
1619
1620/**
1621 * 搜索参赛选手
1622 */
1623function searchQQ(ele) {
1624 var qq = $(ele).value;
1625 qq = parseInt(qq);
1626 if(!isNaN(qq)) {
1627 var url = replPlacer(ACT2.S_PROFILE_PAGE, 'qq', qq, true);
1628 window.location = url;
1629 }
1630}
1631
1632
1633var tabArr = {
1634 'index' : 0,
1635 'prizes' : 1,
1636 'prizes_step1' : 1,
1637 'prizes_step2' : 1,
1638 'prizes_step3' : 1,
1639 'prizes_step4' : 1,
1640 'reg' : 2,
1641 'playerlist' : 4,
1642 'user' : 4,
1643 'intro' : 5,
1644 'winner' : 6
1645};
1646
1647
1648
1649/**
1650 * 页顶横栏
1651 */
1652function actTop(){
1653 var topTpl = '\
1654 <div class="gb_logo"><img src="http://imgcache.qq.com/ACT/qzone_080909_dcl/img/lead_logo.png" alt="Qzone Life" /> 统一绿
茶梦想之旅\
1655 <h1 class="none">统一绿茶梦想之旅</h1>\
1656 </div>\
1657 <div class="login_msgbox" id="top">\
1658 <div class="login_msgbox_l"></div>\
1659 <p class="login_msgbox_m">\
1660 <span class="log_status_span" id="log_status"></span> \
1661 <a href="javascript:void(0)" class="brown" title="设为首页" onclick="this.style.behavior=\'url(#default#homepage)
\';this.setHomePage(\'http://act.qzone.qq.com/greentea/\');return false;">设为首页</a>\
1662 <a href="javascript:void(0)" id="user_reg" class="brown" onclick="showLogin();return false;">注册</a>\
1663 <a href="javascript:void(0)" id="user_person" style="display:none" class="brown"
onclick="window.location=\'user.html\';return false;">个人主页</a>\
1664 </p>\
1665 <div class="login_msgbox_r"></div>\
1666 </div>\
1667 '
1668 $('top').innerHTML = topTpl;
1669 if(getQQNum())
1670 {
1671 var speOpt = {
1672 errdeal:false,
1673 dataDeal : function(opt, obj){
1674 if(!obj.error)
1675 {
1676 $('user_reg').style.display="none";
1677 $('user_person').style.display="";;
1678 }
1679 }
1680 }
1681 //加载生成数据
1682 loadPageData(CACT.ACT_ID, 'profile', speOpt);
1683
1684 }
1685}
1686
1687/**
1688 * isOwner 判断是否主人态
1689 * return {Boolean}
1690 */
1691function isOwner(){
1692 var userQQ = getParameter('qq') || getQQNum();
1693 return userQQ == getQQNum();
1694}
1695
1696/**
1697 * 复制链接
1698 */
1699function gen_invitecode(){
1700 var qq = getParameter('qq') || getQQNum();
1701 qq = parseInt(qq);
1702 if(!isNaN(qq)) {
1703 var speOpt = {
1704 request_url: ACT2_COMM.ACT_DOMAIN + "/uni-greentea/copyinvite.php?callback&act_id="+CACT.ACT_ID+"&qq="+qq,
1705 dataDeal :function(opt, obj) {
1706 window.clipboardData.setData("text",obj.data.url);
1707 var m1 = MSG2.create(null,'邀请链接已成功复制到剪贴板', '请发给你的QQ好友,邀请他们来参加活动吧!必须是QQ好友哦,否则无
法赠送您茶多酚哦');
1708 m1.setIcon(1);
1709 m1.setButton([1]);
1710 m1.setModel(true);
1711 m1.show();
1712
1713 /*var intUrl = obj.data.url;
1714 if(intUrl){
1715 function tempcallback()
1716 {
1717 var m1 = MSG2.create(null,'邀请链接已成功复制到剪贴板', '请发给你的QQ好友,邀请他们来参加活动吧!必须是QQ好友哦,否则无
法赠送您茶多酚哦');
1718 m1.setIcon(1);
1719 m1.setButton([1]);
1720 m1.setModel(true);
1721 m1.show();
1722 }
1723 setClipboard(intUrl,tempcallback);
1724 }*/
1725 }
1726 }
1727 }
1728 loadPageData(CACT.ACT_ID, 'custom', speOpt );
1729}
1730
1731/**
1732 * 创建一个浮动层
1733 */
1734function getPopUp(url, t, w ,h){
1735 insertCSSLink("http://imgcache.qq.com/ACT/qzone_090304_tylc/css/dialog.css");
1736 document.domain="qq.com";
1737 var popWidth = w || 450;
1738 var popHeight = h || 300;
1739 var d1 = Window.create(url, popWidth, popHeight);
1740 d1.setProp('opacity', 0);
1741 d1.setModel(true);
1742 d1.setProp('title', t);
1743 d1.show();
1744 window.regDialog = d1;
1745}
1746
1747/**
1748 * 是否显示换钻标识。
1749 */
1750function yellStr(isYell) {
1751 if(parseInt(isYell) == 1) {
1752 return '<a href="http://vip.qzone.qq.com/" target="_blank" class="icon_vip_qzone"><span>黄钻用户</span></a>';
1753 } else {
1754 return "";
1755 }
1756}
1757
1758/**
1759 * 个人页动态 图标状态处理函数
1760 */
1761function iconStatus(val){
1762 switch(val){
1763 case '1' :
1764 return 'start';
1765 break;
1766 case '2' :
1767 return 'add';
1768 break;
1769 case '3' :
1770 return 'reduce';
1771 break;
1772 default :
1773 return 'start';
1774 break;
1775 }
1776}
1777
1778/**
1779 * simpleMSG函数
1780 */
1781function simpleMSG(msg1, msg2){
1782 var msg2 = msg2 || null;
1783 var m1 = MSG2.create(null, msg1, msg2);
1784 m1.setIcon(1);
1785 m1.setButton([1]);
1786 m1.setModel(true);
1787 m1.show();
1788}
1789
1790/**
1791 * showLogin
1792 */
1793function showLogin(){
1794 if(getQQNum() == 0){
1795 var msg1 = '您需要先登陆才能进行游戏,是否现在登陆?';
1796 var m1 = MSG2.create(null, msg1, '');
1797 m1.setIcon(1);
1798 m1.setButton([1,2]);
1799 m1.setModel(true);
1800 m1.onconfirm = function(){
1801 qq_login_form(15000103, ACT2_COMM.ACT_DOMAIN + 'greentea/index.html?act=showreg');
1802 };
1803 m1.show();
1804 return;
1805 }
1806 getPopUp('reg.html', '', 500, 350);
1807}
1808
1809/**
1810 * 在页面html 加载完之后运行页面函数,类似与把所有的js 写到页面的最后面
1811 */
1812if(!document.addEventListener) {
1813 loadfun();
1814} else {
1815 EVENT.addEvent(document, "DOMContentLoaded", loadfun);
1816}
1817
1818function setInviteqq(ele) {
1819 ele = $(ele);
1820 ele.onfocus = checksearch.bind(null, ele, '请输入QQ号码', 1);
1821 ele.onblur = checksearch.bind(null, ele, '请输入QQ号码', 2);
1822 ele.onclick = checksearch.bind(null, ele, '请输入QQ号码', 0);
1823
1824 var keyfun = function(e){
1825 var e = e || window.event;
1826 if(e.keyCode==13) {
1827 gen_invitecode(ele);
1828 }
1829 };
1830 ele.onkeyup = keyfun.bindAsEventListener(null);
1831}
1832
1833
</script>
浙公网安备 33010602011771号