├── .gitignore
├── README.md
├── img
├── btn.png
├── b_che.png
├── b_ma.png
├── b_pao.png
├── b_shi.png
├── b_zu.png
├── guide1.png
├── guide2.png
├── guide3.png
├── guide4.png
├── r_che.png
├── r_ma.png
├── r_pao.png
├── r_shi.png
├── r_zu.png
├── ready.png
├── xinju.png
├── b_jiang.png
├── b_xiang.png
├── bg_cont.png
├── newgame.png
├── r_jiang.png
├── r_xiang.png
├── zhunbei.png
├── chesspanel.png
└── ���� - ����.png
├── HTML5���ν���SDK˵���ĵ�.doc
├── HTML5���νӿڵ���demo�����ܽ�.doc
├── css
├── public.css
└── chinesechess.css
├── index.html
├── js
├── ResourceManager.js
├── utils.js
├── canvascomponent.js
├── loadres.js
├── html5gamedemo.js
├── component.js
├── MicrorapidNetGameSDK.js
├── canvaswrapper.js
├── canvaschesspanel.js
├── chinesechess.js
└── jquery-1.4.2.js
└── index.jsp
/.gitignore:
--------------------------------------------------------------------------------
1 | .svn
2 | build
3 | .settings
4 | *~
5 | .project
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ChineseChess
2 | ============
3 |
4 | HTML5版中国象棋对战游戏
--------------------------------------------------------------------------------
/img/btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/btn.png
--------------------------------------------------------------------------------
/img/b_che.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/b_che.png
--------------------------------------------------------------------------------
/img/b_ma.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/b_ma.png
--------------------------------------------------------------------------------
/img/b_pao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/b_pao.png
--------------------------------------------------------------------------------
/img/b_shi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/b_shi.png
--------------------------------------------------------------------------------
/img/b_zu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/b_zu.png
--------------------------------------------------------------------------------
/img/guide1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/guide1.png
--------------------------------------------------------------------------------
/img/guide2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/guide2.png
--------------------------------------------------------------------------------
/img/guide3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/guide3.png
--------------------------------------------------------------------------------
/img/guide4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/guide4.png
--------------------------------------------------------------------------------
/img/r_che.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/r_che.png
--------------------------------------------------------------------------------
/img/r_ma.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/r_ma.png
--------------------------------------------------------------------------------
/img/r_pao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/r_pao.png
--------------------------------------------------------------------------------
/img/r_shi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/r_shi.png
--------------------------------------------------------------------------------
/img/r_zu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/r_zu.png
--------------------------------------------------------------------------------
/img/ready.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/ready.png
--------------------------------------------------------------------------------
/img/xinju.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/xinju.png
--------------------------------------------------------------------------------
/img/b_jiang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/b_jiang.png
--------------------------------------------------------------------------------
/img/b_xiang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/b_xiang.png
--------------------------------------------------------------------------------
/img/bg_cont.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/bg_cont.png
--------------------------------------------------------------------------------
/img/newgame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/newgame.png
--------------------------------------------------------------------------------
/img/r_jiang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/r_jiang.png
--------------------------------------------------------------------------------
/img/r_xiang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/r_xiang.png
--------------------------------------------------------------------------------
/img/zhunbei.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/zhunbei.png
--------------------------------------------------------------------------------
/img/chesspanel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/chesspanel.png
--------------------------------------------------------------------------------
/img/���� - ����.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/img/���� - ����.png
--------------------------------------------------------------------------------
/HTML5���ν���SDK˵���ĵ�.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/HTML5���ν���SDK˵���ĵ�.doc
--------------------------------------------------------------------------------
/HTML5���νӿڵ���demo�����ܽ�.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p-jasonchen/ChineseChess/HEAD/HTML5���νӿڵ���demo�����ܽ�.doc
--------------------------------------------------------------------------------
/css/public.css:
--------------------------------------------------------------------------------
1 | body, div, p, ul, li, table, tbody, tr, td, textarea, form, input, h1, h2, h3, h4, h5, dl, dt, dd, img, iframe
2 | {
3 | border: 0 none;
4 | list-style: none outside none;
5 | font-size: 14px;
6 | font-family: "Microsoft YaHei",Helvetica;
7 | margin: 0;
8 | padding: 0;
9 |
10 | }
11 | body{-webkit-user-select:none;-webkit-text-size-adjust:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-touch-callout:none;}
12 | a
13 | {
14 | text-decoration: none;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/css/chinesechess.css:
--------------------------------------------------------------------------------
1 | #chess_frame, #chess_panel {
2 | width: 100%;
3 | height: 100%;
4 | min-height: 400px;
5 | }
6 |
7 | #players{
8 | width : 100px;
9 | height : 100%;
10 | min-height: 400px;
11 | float: left;
12 | text-align: right;
13 | padding-right: 10px;
14 | }
15 |
16 | #players ul{
17 | height: 100%;
18 | }
19 |
20 | #players ul li:first-child{
21 | color: red;
22 | }
23 |
24 | #tips{
25 | text-align: left;
26 | }
27 | #piece_type{
28 | color: red;
29 | font-size: 20px;
30 | font-style: bold;
31 | text-align: center;
32 | }
33 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 | 中国象棋
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
41 |
43 |
44 |
48 |
49 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/js/ResourceManager.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 资源管理器
3 | */
4 |
5 | var ResourceManager={};
6 | (function(manager){
7 | var ResourceDownloader=function(){
8 | this.resources = [];
9 | this.callbackObj = [];
10 | this.countLoaded=0;
11 |
12 | ResourceDownloader.prototype.init = function(jRes){
13 |
14 | };
15 |
16 | ResourceDownloader.prototype.loadRes = function(jRes){
17 | if(jRes){
18 | var type = jRes.type;
19 | //相对路径
20 | var path = (jRes.path == undefined) ? './' : jRes.path;
21 | var resArray = jRes.resArray;
22 |
23 | var that=this;
24 | for(var i=0;i
2 | <%@ page import="java.net.InetAddress,java.net.UnknownHostException" %>
3 |
4 |
5 |
6 |
7 |
8 |
10 |
11 |
12 | 中国象棋
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
42 |
44 |
45 | <%
46 | {
47 | InetAddress addr;
48 | String SERVER_IP="", PROXY_SERVER_IP="";
49 | try {
50 | addr = InetAddress.getLocalHost();
51 | PROXY_SERVER_IP = addr.getHostAddress().toString();
52 | SERVER_IP = PROXY_SERVER_IP;
53 | String hostname = addr.getHostName().toString();//获得本机名称
54 | System.out.println("PROXY_SERVER_IP:\t" + PROXY_SERVER_IP + "\tPROXY_NAME:\t" + hostname);
55 | } catch (UnknownHostException e) {
56 | // TODO Auto-generated catch block
57 | e.printStackTrace();
58 | }
59 | %>
60 |
61 | <%}%>
62 |
63 |
66 |
67 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/js/utils.js:
--------------------------------------------------------------------------------
1 | var Utils={};
2 | (function(util){
3 |
4 | function _re_mask() {
5 | /*
6 | 更改遮罩层的大小,确保在滚动以及窗口大小改变时还可以覆盖所有的内容
7 | */
8 | var mask = document.getElementById("mask");
9 | if(null == mask)
10 | return;
11 | mask.style.width = util.getVisualWidth() + "px";
12 | mask.style.height = util.getVisualHeight() + "px";
13 | }
14 |
15 | function _re_pos(id) {
16 | /*
17 | 更改弹出对话框层的位置,确保在滚动以及窗口大小改变时一直保持在网页的最中间
18 | */
19 | var box = document.getElementById(id);
20 | if(null != box) {
21 | var w = box.clientWidth;
22 | var h = box.clientHeight;
23 | box.style.left = util.getLeft(w) + "px";
24 | box.style.top = util.getTop(h) + "px";
25 | }
26 | }
27 |
28 |
29 | util.getVisualWidth = function(){
30 | var w1 = document.body.clientWidth;
31 | var w2 = window.innerWidth;
32 | return (w1 > w2) ? w1 : w2;
33 | //return w1;
34 | }
35 | util.getVisualHeight = function(){
36 | var h1 = document.body.clientHeight;
37 | var h2 = window.innerHeight;
38 | return (h1 > h2) ? h1 : h2;
39 | //return h1;
40 | }
41 |
42 | util.getLeft = function(w) {
43 | var bw = document.body.clientWidth;
44 | var bh = document.body.clientHeight;
45 | w = parseFloat(w);
46 | return (bw / 2 - w / 2 + document.body.scrollLeft);
47 | }
48 |
49 | util.getTop = function(h) {
50 | var bw = document.body.clientWidth;
51 | var bh = document.body.clientHeight;
52 | h = parseFloat(h);
53 | return (document.body.scrollTop + h / 2);
54 | }
55 |
56 | util.createMask = function(){//创建遮罩层的函数
57 | if(this.mask) return this.mask;
58 | var mask=document.createElement("div");
59 | mask.id="mask";
60 | mask.style.position="absolute";
61 | //mask.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=25)";//IE的不透明设置
62 | mask.style.opacity=0.3;//Mozilla的不透明设置
63 | mask.style.background=" rgba(0, 0, 0, 0.3)";
64 | mask.style.top="0px";
65 | mask.style.left="0px";
66 | mask.style.width=this.getVisualWidth()+'px';
67 | mask.style.height=this.getVisualHeight()+'px';
68 | mask.style.zIndex=1000;
69 | document.body.appendChild(mask);
70 | this.mask = mask;
71 | }
72 |
73 | var Guide = function(guideArray){
74 | if(!guideArray || guideArray.length == 0) return;
75 | if(!this.guideArray){
76 | util.createMask();
77 |
78 | var box=document.createElement("img");
79 | box.src="img/" + guideArray[0];
80 | box.id="guide";
81 | box.style.position="absolute";
82 |
83 | box.style.top="0px";
84 | box.style.left="0px";
85 | box.style.opacity=0.7;
86 |
87 | box.style.width=util.getVisualWidth()+'px';
88 |
89 | box.style.height=util.getVisualHeight()+'px';
90 | box.style.overflow="visible";
91 | //box.style.border="1px solid black";
92 | //box.style.borderRadius = "6px";
93 |
94 | box.style.zIndex=1001;
95 | document.body.appendChild(box);
96 | //_re_pos(box.id);
97 | var that = this;
98 | box.onclick = function(){
99 | var array = that.guideArray;
100 | var guide = array.shift();
101 | array.push(guide);
102 | box.src="img/" + guide;
103 | if(that.count++ == array.length) box.style.display='none';
104 | }
105 | }
106 | this.guideArray = guideArray;
107 | this.count = 0;
108 |
109 | }
110 |
111 |
112 | util.Guide = Guide;
113 |
114 | })(Utils);
115 |
--------------------------------------------------------------------------------
/js/canvascomponent.js:
--------------------------------------------------------------------------------
1 | ( function(window) {"use strict";
2 |
3 | function absoluteCenter(canvas, span, offset){
4 | var left = (document.body.clientWidth - canvas.width)/2;
5 | var top = (document.body.clientHeight - canvas.height)/2;
6 | var css = {
7 | position: 'absolute',
8 | left : left + 'px',
9 | top : top + 'px',
10 |
11 | }
12 | css['text-align'] = 'center';
13 | $(canvas).css(css);
14 |
15 | if(span){
16 | css.width = canvas.width;
17 | css.height = canvas.heigth;
18 | var _offset = offset;
19 | if(!_offset)
20 | _offset = 0;
21 | css.top = top + _offset + 'px';
22 | $(span).css(css);
23 | }
24 |
25 | }
26 |
27 | /*
28 | * CanvasProgressbar
29 | */
30 | var CanvasProgressbar = function(id, opt) {
31 | var progressbar = new CanvasWrapper(id, opt);
32 |
33 | progressbar.width = 200;
34 | progressbar.height = 20;
35 | progressbar.progress = 0;
36 |
37 |
38 | var span = progressbar.addEl('span', document.getElementById(opt.id));
39 | if(span){
40 | span.id = 'loadingres_span';
41 | span.innerHTML = '0%';
42 | span.width = progressbar.width;
43 | span.height = progressbar.height;
44 | }
45 |
46 |
47 | progressbar.setProgress = function(progress) {
48 | span.innerHTML = (progress * 100).toFixed(0) + '%';
49 | // console.log(span.innerHTML);
50 | this.progress = progress;
51 | this.redraw();
52 | }
53 |
54 | progressbar.Config = function(){
55 | this.setAttr(this.can, {
56 | width : this.width,
57 | height : this.height
58 | });
59 | this.setAttr(this.cCan, {
60 | width : this.width,
61 | height : this.height
62 | });
63 |
64 | absoluteCenter(this.can, span);
65 | }
66 |
67 | progressbar.draw = function () {
68 | var c = this.con, d = 1000;
69 | c.clearRect(0, 0, d, d);
70 |
71 | c.fillStyle = "rgb(" + this.cRGB.r + "," + this.cRGB.g + "," + this.cRGB.b + ")";
72 | c.fillRect(0,0, this.width * this.progress,this.height);
73 | };
74 |
75 | progressbar.Config();
76 |
77 | return progressbar;
78 |
79 | };
80 |
81 | window.CanvasProgressbar = CanvasProgressbar;
82 | /*
83 | * CanvasProgressbar
84 | */
85 |
86 |
87 | /*
88 | * CanvasLoader
89 | */
90 | var CanvasLoader = function(id, opt) {
91 |
92 | var canvasloader = new CanvasWrapper(id, opt);
93 | canvasloader.width = 100;
94 | canvasloader.height = 100;
95 |
96 | var span = canvasloader.addEl('span', document.getElementById(opt.id));
97 | if(span){
98 | span.id = 'loading_span';
99 | span.innerHTML = '加载中...';
100 | span.width = canvasloader.width;
101 | span.height = canvasloader.height;
102 | }
103 |
104 | canvasloader.draw = function () {
105 | var c = this.con, d = 1000;
106 | c.clearRect(0, 0, d, d);
107 | var image = new Image();
108 | image.src = '../img/loading.png';
109 | var that = this;
110 | image.onload = function(){
111 | var xScale = (that.width / image.naturalWidth);
112 | var yScale = (that.height / image.naturalHeight);
113 | c.scale(xScale,yScale);
114 | c.drawImage(image, 0, 0);
115 | }
116 | };
117 |
118 | canvasloader.Config = function(){
119 | this.setAttr(this.can, {
120 | width : this.width,
121 | height : this.height
122 | });
123 | this.setAttr(this.cCan, {
124 | width : this.width,
125 | height : this.height
126 | });
127 |
128 | absoluteCenter(this.can, span, 0.5 * this.height);
129 |
130 | }
131 |
132 | canvasloader.Config();
133 | return canvasloader;
134 | };
135 |
136 |
137 | window.CanvasLoader = CanvasLoader;
138 | /*
139 | * CanvasLoader
140 | */
141 |
142 |
143 |
144 | }(window));
145 |
--------------------------------------------------------------------------------
/js/loadres.js:
--------------------------------------------------------------------------------
1 | var DownloadControler={};
2 | (function(controler){
3 |
4 | var DownloaderCtx = function(_states, _progressBar){
5 | this.states = _states;
6 | this.state = this.states[0];
7 | this.progressBar = _progressBar;
8 |
9 | this.total = 0;
10 | for(var i=0; i< this.states.length; i++){
11 | this.total += this.states[i].jRes.resArray.length;
12 | }
13 |
14 | DownloaderCtx.prototype.load = function(){
15 | var that = this;
16 | if(that.state)
17 | that.state.load(that);
18 | }
19 | }
20 |
21 | var State = function(_order){
22 | this.order = _order;
23 | this.jRes = {};
24 |
25 | State.prototype.setProgress = function(jData){
26 | var ctx = this.ctx;
27 | if(jData){
28 | var current = jData.args[0];
29 | for(var i = 0; i < this.order; i++){
30 | current += ctx.states[i].jRes.resArray.length;
31 | }
32 | if(ctx){
33 | if(ctx.progressBar)
34 | ctx.progressBar.setProgress(current / ctx.total);
35 | if(jData.args[0] == jData.args[1]){
36 | ctx.state = ctx.states[this.order + 1];
37 | ctx.load();
38 | if(this.onFinish)
39 | this.onFinish();
40 | }
41 | }
42 | }
43 | };
44 |
45 |
46 | State.prototype.load = function(ctx){
47 | var rm = new ResourceManager.ResourceDownloader();
48 | this.ctx = ctx;
49 | rm.bind(this);
50 | rm.loadRes(this.jRes);
51 |
52 | };
53 | }
54 |
55 |
56 |
57 |
58 | var ImgState = function(_order){
59 | var img = new State(_order);
60 | img.jRes = {
61 | type:'img',
62 | path:'img/',
63 | resArray:[
64 | 'chesspanel.png', 'r_jiang.png', 'r_shi.png',
65 | 'r_xiang.png', 'r_che.png', 'r_ma.png',
66 | 'r_pao.png', 'r_zu.png', 'b_zu.png',
67 | 'b_pao.png', 'b_jiang.png', 'b_ma.png',
68 | 'b_shi.png', 'b_xiang.png', 'b_che.png',
69 | 'ready.png', 'newgame.png', 'guide1.png',
70 | 'guide2.png', 'guide3.png', 'guide4.png',
71 | ]
72 | };
73 |
74 | img.onFinish = function(){
75 | var opt = {
76 | id : 'canvasChessPanel',
77 | };
78 | var guideImgs = ['guide1.png','guide2.png', 'guide3.png', 'guide4.png',];
79 | var guides = new Utils.Guide(guideImgs);
80 | var chessPanel = new CanvasChessPanel('chess_frame', opt);
81 | chessPanel.pieces = ChineseChess.pieces,
82 | window.chessPanel = chessPanel;
83 |
84 | }
85 |
86 | return img;
87 | }
88 |
89 | var CommonJsState = function(_order){
90 | var js = new State(_order);
91 | js.jRes = {
92 | type:'script',
93 | path:'../javascript/',
94 | resArray:[
95 | 'nc.js',
96 | 'zepto.js',
97 | 'common.js',
98 | 'iscroll4.js',
99 | ]
100 | };
101 |
102 |
103 | js.onFinish = function(){
104 | NC.pages.config({switchStyle:NC.SwitchStyleEnum.CUBE,defaultPage:'index'});
105 | }
106 |
107 | return js;
108 | }
109 |
110 | var WorkJsState = function(_order){
111 | var js = new State(_order);
112 | js.jRes = {
113 | type:'script',
114 | resArray:[
115 | 'index.js',
116 | 'index_new.js',
117 | 'pintu.js',
118 | 'favorite.js',
119 | 'gameend.js',
120 | 'selectpic.js',
121 | 'selectdif.js',
122 | 'gamelist.js',
123 | 'roominfo.js',
124 | 'roundinfo.js',
125 | 'pcomment.js',
126 | 'guide.js'
127 | ]
128 | };
129 |
130 | return js;
131 | }
132 |
133 |
134 |
135 | var doDownload = function(){
136 | var states = [];
137 | states.push(new ImgState(states.length));
138 | //states.push(new CommonJsState(states.length));
139 | //states.push(new WorkJsState(states.length));
140 |
141 |
142 |
143 | var opt = {};
144 | opt.id = 'canvasProgressbar';
145 | var pb = Component.CanvasProgressbar.init('info-loading', opt);
146 |
147 | var ctx = new DownloaderCtx(states,pb);
148 | ctx.load();
149 | };
150 |
151 |
152 | controler.doDownload = doDownload;
153 |
154 |
155 |
156 | })(DownloadControler);
--------------------------------------------------------------------------------
/js/html5gamedemo.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {
2 | var proxy = new MicrorapidNetGameSDK.Proxy();
3 |
4 | function createFriendListHtml (jsonFriends) {
5 | var array = [];
6 |
7 | array.push('');
8 |
9 | for(i = 0; i < jsonFriends.length&& i < 10; i++){
10 | friend = jsonFriends[i];
11 | array.push('openid:'
12 | + friend.openid + ' 昵称:'
13 | + friend.nickname + ' ');
14 | }
15 | array.push(' ');
16 | return array.join('');
17 |
18 | }
19 |
20 | function showFriendList(jsonData){
21 | /*
22 | jsonData = window.JSON.parse(data);
23 | stringData = jsonData.data;
24 | last = stringData.lastIndexOf('}');
25 | stringData = stringData.substring(0,last+1);
26 | ////window.log('stringData:' + stringData);
27 | jsonData = window.JSON.parse(stringData);
28 | */
29 |
30 | //正常获取好友列表
31 | if(jsonData){
32 | //frienListString = jsonData.list;
33 | //jsonFriends = window.JSON.parse(frienListString);
34 | html = createFriendListHtml(jsonData);
35 | $("#container").html(html);
36 | }else{
37 | var array = [];
38 | array.push('');
39 | array.push('' + jsonData.desc + ' ');
40 | array.push(' ');
41 | html = array.join('');
42 | $("#container").html(html);
43 | }
44 |
45 | }
46 |
47 | function showBuyPropResult(jsonData){
48 | /*
49 | jsonData = window.JSON.parse(data);
50 | stringData = jsonData.data;
51 | last = stringData.lastIndexOf('}');
52 | stringData = stringData.substring(0,last+1);
53 | //window.log('stringData:' + stringData);
54 | jsonData = window.JSON.parse(stringData);
55 | */
56 |
57 | $(".result").show();
58 | if(jsonData){
59 | $(".result .desc").html('单号:');
60 | $(".result .orderid").html(jsonData.orderid);
61 | }else{
62 | $(".result .desc").html(jsonData.code);
63 | $(".result .orderid").html(jsonData.desc);
64 | }
65 |
66 | }
67 |
68 | function showQueryMoneyResult(jsonData){
69 | /*
70 | jsonData = window.JSON.parse(data);
71 | stringData = jsonData.data;
72 | last = stringData.lastIndexOf('}');
73 | stringData = stringData.substring(0,last+1);
74 | //window.log('stringData:' + stringData);
75 | jsonData = window.JSON.parse(stringData);
76 | */
77 |
78 | var array = [];
79 | array.push('');
80 | array.push(' ');
81 | array.push(' ');
82 | html = array.join('');
83 | $("#container").html(html);
84 |
85 | if(jsonData.code == '0'){
86 | $(".result .desc").html('余额:');
87 | $(".result .balance").html(jsonData.balance);
88 | }else{
89 | $(".result .desc").html(jsonData.code);
90 | $(".result .balance").html(jsonData.desc);
91 | }
92 | }
93 |
94 | function resetContainer () {
95 | $("#container").html('');
96 | }
97 |
98 | chongzhi = function (){
99 | proxy.go2ReCharge();
100 | }
101 |
102 |
103 | doBuyProp = function (btn){
104 | div = $(btn).parent().parent();
105 | propid = div.children(".propid").val();
106 | price = div.children('.prop_price_div').children('.prop_price').html();
107 | num = div.children('.prop_num').children('select').val();
108 | var goods = new MicrorapidNetGameSDK.Goods(propid, price, num);
109 | proxy.payMoney(goods, showBuyPropResult);
110 | }
111 |
112 |
113 |
114 |
115 |
116 | var getFriendsBtn = $("#get_friend_list_fgdev");
117 | getFriendsBtn.click(function(){
118 | resetContainer();
119 | //doPost(getCookie(),fgdevurl, 'cmd=getFriendList' ,showFriendList);
120 | proxy.getFriendList(showFriendList);
121 | });
122 |
123 | $('#query_money').click(function(){
124 | resetContainer();
125 | //doPost(getCookie(),fgdevurl, 'cmd=qcoins', showQueryMoneyResult);
126 | proxy.queryAccountBalance(showQueryMoneyResult);
127 | });
128 |
129 | $('#buy_prop').click(function(){
130 | resetContainer();
131 | $("#container").load('ppay.html');
132 | // $("#container").load('ppay');
133 |
134 | });
135 |
136 | });
137 |
--------------------------------------------------------------------------------
/js/component.js:
--------------------------------------------------------------------------------
1 | var Component={};
2 | (function(comp){
3 |
4 | /*
5 | 功能:自定义窗口标题,自定义窗口内容,是否显示取消按钮,焦点位置设定
6 | */
7 | function _getWidth(){
8 | return (document.body.clientWidth+document.body.scrollLeft);
9 | }
10 | function _getHeight(){
11 | return (document.body.clientHeight+document.body.scrollTop);
12 | }
13 | function _getLeft(w){
14 | var bw=document.body.clientWidth;
15 | var bh=document.body.clientHeight;
16 | w=parseFloat(w);
17 | return (bw/2-w/2+document.body.scrollLeft);
18 | }
19 | function _getTop(h){
20 | var bw=document.body.clientWidth;
21 | var bh=document.body.clientHeight;
22 | h=parseFloat(h);
23 | return (bh/2-h/2+document.body.scrollTop);
24 | }
25 |
26 | function _createMask(){//创建遮罩层的函数
27 | var mask=document.createElement("div");
28 | mask.id="mask";
29 | mask.style.position="absolute";
30 | //mask.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=25)";//IE的不透明设置
31 | mask.style.opacity=0.3;//Mozilla的不透明设置
32 | mask.style.background=" rgba(0, 0, 0, 0.3)";
33 | mask.style.top="0px";
34 | mask.style.left="0px";
35 | mask.style.width=_getWidth();
36 | mask.style.height=_getHeight();
37 | mask.style.zIndex=1000;
38 | document.body.appendChild(mask);
39 | }
40 | function _createMsgbox(w,h,t){//创建弹出对话框的函数
41 | var box=document.createElement("div") ;
42 | box.id="msgbox";
43 | box.style.opacity=0.7;
44 | box.style.position="absolute";
45 | box.style.background="black";
46 | box.style.width=w;
47 |
48 | box.style.height=h*0.8;
49 | box.style.overflow="visible";
50 | box.style.border="1px solid black";
51 | box.style.borderRadius = "6px";
52 | box.innerHTML=t;
53 | box.style.zIndex=1001;
54 | document.body.appendChild(box);
55 | _re_pos();
56 | }
57 | function _re_mask(){
58 | /*
59 | 更改遮罩层的大小,确保在滚动以及窗口大小改变时还可以覆盖所有的内容
60 | */
61 | var mask=document.getElementById("mask") ;
62 | if(null==mask)return;
63 | mask.style.width=_getWidth()+"px";
64 | mask.style.height=_getHeight()+"px";
65 | }
66 | function _re_pos(){
67 | /*
68 | 更改弹出对话框层的位置,确保在滚动以及窗口大小改变时一直保持在网页的最中间
69 | */
70 | var box=document.getElementById("msgbox");
71 | if(null!=box){
72 | var w=box.clientWidth;//style.width;
73 | var h=box.clientHeight;//style.height;
74 | box.style.left=_getLeft(w)+"px";
75 | box.style.top=_getTop(h)+"px";
76 | }
77 | }
78 | function _remove(){
79 | /*
80 | 清除遮罩层以及弹出的对话框
81 | */
82 | var mask=document.getElementById("mask");
83 | var msgbox=document.getElementById("msgbox");
84 | if(null==mask&&null==msgbox)return;
85 | document.body.removeChild(mask);
86 | document.body.removeChild(msgbox);
87 | }
88 | function _re_show(){
89 | /*
90 | 重新显示遮罩层以及弹出窗口元素
91 | */
92 | _re_pos();
93 | _re_mask();
94 | }
95 | function _set_url(url)
96 | {
97 | window.location.href=goUrl(url);
98 | }
99 |
100 | comp.MsgDialog={
101 | msgbox:function (option){
102 | var mstitle =option.title||null;
103 | var mstext =option.content||null;
104 | var callbackone =option.callbackone||null;
105 | var callbacktwo =option.callbacktwo||null;
106 | var buttonone =option.buttonone||null;
107 | var buttontwo =option.buttontwo||null;
108 | var isfocus =option.focus||null;
109 | _createMask();
110 |
111 | //if(typeof callbacktwo == 'string')callbacktwo="set_url('"+callbacktwo+"')";
112 | var temp="";
113 | if(mstitle)temp+=""+mstitle+" ";
114 | temp+=""+mstext+" ";
115 | temp+="";
116 | if(buttonone){temp+=""+buttonone+" ";}
117 | if(buttontwo){temp+=" "+buttontwo+" ";}
118 | if(!buttonone&&!buttontwo){temp+=""+"关闭 ";}
119 | temp+="
";
120 | _createMsgbox(400,200,temp);
121 | if(buttonone)
122 | document.getElementById('buttonone').onclick =function(){
123 | _remove();
124 | (typeof callbackone == 'string') ?_set_url(callbackone):callbackone();
125 | };
126 | if(buttontwo)
127 | document.getElementById('buttontwo').onclick =function(){
128 | _remove();
129 | (typeof callbacktwo == 'string') ?_set_url(callbacktwo):callbacktwo();
130 | };
131 | if(focus==0||focus=="0"||null==focus){document.getElementById("buttonone").focus();}
132 | else if(focus==1||focus=="1"){document.getElementById("buttontwo").focus();}
133 | _re_show();
134 | }
135 | };
136 |
137 |
138 |
139 | comp.CanvasLoader={
140 | show:function(id, opt){
141 | if (!this.cl) {
142 | cl = new CanvasLoader(id, opt);
143 | cl.setColor('#a8a5a8'); // default is '#000000'
144 | /*
145 | cl.setColor('#a8a5a8'); // default is '#000000'
146 | cl.setShape('spiral'); // default is 'oval'
147 | cl.setDiameter(50); // default is 40
148 | cl.setDensity(45); // default is 40
149 | cl.setRange(1); // default is 1.3
150 | this.cl = cl;
151 | */
152 | this.cl = cl;
153 |
154 | }
155 | $("#canvasLoader").css("margin-top", ($(window).height() / 2 - 20) + "px");
156 | $("#canvasLoader").css("margin-left", ($(window).width() / 2 - 20) + "px");
157 | $('#info-loading').css('display', 'block');
158 | this.cl.show();
159 | },
160 |
161 | hide:function(){
162 | if (this.cl) {
163 | this.cl.hide();
164 | }
165 | $('#info-loading').css('display', 'none');
166 | },
167 |
168 | };
169 |
170 | comp.CanvasProgressbar={
171 | init : function(id, opt) {
172 | if(!this.cpb) {
173 | var cpb = new CanvasProgressbar(id, opt);
174 | cpb.setColor('#a8a5a8');
175 | // default is '#000000'
176 | this.cpb = cpb;
177 |
178 | }
179 | $("#canvasProgressbar").css("margin-top", ($(window).height() / 2 - 20) + "px");
180 | $("#canvasProgressbar").css("margin-left", ($(window).width() / 2 - 20) + "px");
181 | $('#info-loading').css('display', 'block');
182 | this.cpb.show();
183 | return this;
184 | },
185 |
186 | setProgress : function(progress) {
187 | if(this.cpb) {
188 | this.cpb.setProgress(progress);
189 | if(progress == 1){
190 | this.cpb.hide();
191 | $('#info-loading').css('display', 'none')
192 | }
193 |
194 | }
195 | },
196 | };
197 |
198 | })(Component);
199 |
--------------------------------------------------------------------------------
/js/MicrorapidNetGameSDK.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Administrator
3 | */
4 |
5 |
6 | //todo: 参考jquery的noConflict 机制,可以对SDK重命名,防止和开发商的类冲突
7 | var MicrorapidNetGameSDK = {};
8 | (function(sdk) {
9 |
10 | var Utils = function(){};
11 | Utils.prototype.cleanString2Json = function(rspTxt){
12 | var jsonData = window.JSON.parse(rspTxt);
13 | var stringData = jsonData.data;
14 | var last = stringData.lastIndexOf('}');
15 | stringData = stringData.substring(0,last+1);
16 | jsonData = window.JSON.parse(stringData);
17 | return jsonData;
18 | }
19 | Utils.prototype.getFriends = function(rspTxt){
20 |
21 | var jsonData = this.cleanString2Json(rspTxt);
22 | //正常获取好友列表
23 | if(jsonData.code == '1'){
24 | frienListString = jsonData.list;
25 | jsonFriends = window.JSON.parse(frienListString);
26 | return jsonFriends;
27 | }
28 | }
29 |
30 | Utils.prototype.getPayMoneyResult = function(rspTxt){
31 | var jsonData = this.cleanString2Json(rspTxt);
32 | return jsonData;
33 | }
34 |
35 | Utils.prototype.getQueryMoneyResult = function(rspTxt){
36 | var jsonData = this.cleanString2Json(rspTxt);
37 | return jsonData;
38 | }
39 |
40 | Utils.prototype.isObject = function(param){
41 | var b = (parma || typeof param == 'object');
42 | return b;
43 | }
44 |
45 | Utils.prototype.isFunction = function(param){
46 | var b = (param || typeof param == 'function');
47 | return b;
48 | }
49 |
50 | Utils.prototype.getKeyValueReg = function(str) {
51 | var res = [];
52 | var reg = /(\w+)=([^&]+)/g;
53 | while ((a = reg.exec(str))) {
54 | res.push(a[0]);
55 | }
56 | return res;
57 | }
58 |
59 | var helper = new Utils();
60 |
61 | var AjaxType = {
62 | getFriendList : 1,
63 | qcoins : 2,
64 | ppay : 3,
65 | }
66 |
67 | var Ajax = function(opt, ajaxType) {
68 | if(window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
69 | this.xmlhttp = new XMLHttpRequest();
70 | } else {// code for IE6, IE5
71 | this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
72 | }
73 |
74 | var xmlhttp = this.xmlhttp, opt = opt || {};
75 | xmlhttp.onreadystatechange = function() {
76 | if(xmlhttp.readyState == 4) {
77 | switch(xmlhttp.status) {
78 | case 0:
79 | //window.log('ajaxType:' + ajaxType);
80 | helper.isFunction(opt.error) && opt.error(xmlhttp);break;
81 | case 200:{
82 | var jsonData;
83 | //window.log(xmlhttp.responseText);
84 | switch(ajaxType){
85 | case AjaxType.getFriendList:
86 | jsonData = helper.getFriends(xmlhttp.responseText);break;
87 | case AjaxType.qcoins:
88 | jsonData = helper.getQueryMoneyResult(xmlhttp.responseText);break;
89 | case AjaxType.ppay:
90 | jsonData = helper.getPayMoneyResult(xmlhttp.responseText);break;
91 | }
92 | helper.isFunction(opt.success) && opt.success(jsonData);
93 | break;
94 | }
95 | }
96 | }
97 | }
98 | var method, url, async = true;
99 |
100 | helper.isFunction(opt.beforeSend) && opt.beforeSend(xmlhttp);
101 | opt.data && typeof opt.data == 'string' && ( method = 'POST');
102 | if(!method) {
103 | var type;
104 | opt.type && typeof opt.type == 'string' && ( type = opt.type.toLocaleUpperCase());
105 | (type == 'GET' || type == 'POST') ? ( method = type) : ( method = 'GET');
106 | }
107 |
108 | opt.async && typeof opt.async == 'boolean' && ( async = opt.async);
109 | opt.url && typeof opt.url == 'string' && ( url = opt.url);
110 | //window.log('method :' + method);
111 | xmlhttp.open(method, url, async);
112 |
113 | if(opt.data){
114 | var data = opt.data;
115 | //发送post数据的关键设置代码
116 | xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8");
117 | xmlhttp.send(data);
118 | }else
119 | xmlhttp.send();
120 |
121 |
122 |
123 | }
124 | var Proxy = function() {
125 | this.postUrl = "http://221.130.15.185:18000/json"; //dev
126 | this.cookie = this.getCookie();
127 | }
128 |
129 | Proxy.prototype.doPost = function(cmd, ajaxType ,successFunc, errorFunc) {
130 | var jsonData = {
131 | data : cmd,
132 | url : '1379/MLibok/main.swf',
133 | //md5 : 'a5cea1eac184bb7f2bee9e99e79b8961',
134 | md5 : 'c6e7c6a1b86042745fc64766b16bbe62',
135 | cookie : this.cookie,
136 | };
137 |
138 | var stringData = window.JSON.stringify(jsonData);
139 | //window.log(stringData);
140 |
141 | var success,error;
142 | helper.isFunction(successFunc)? success = successFunc : success = function(jsonData) {
143 | window.log('success' + jsonData);
144 |
145 | };
146 |
147 | helper.isFunction(errorFunc) ? error = errorFunc : error = function(xhr) {
148 | window.log('error' + xhr);
149 | };
150 | var opt = {
151 | url : this.postUrl,
152 | type : 'POST',
153 | data : "data=" + stringData,
154 | // data : stringData,
155 | async : true,
156 | success : success,
157 | error : error,
158 | beforeSend : function(xhr) {
159 | //window.log('beforeSend' + xhr);
160 | }
161 | };
162 | new Ajax(opt, ajaxType);
163 | }
164 |
165 |
166 |
167 |
168 | Proxy.prototype.getCookie = function() {
169 | var chromecookiefgdev = "token=PCDZ7QfsdDoHIiF1GkArgCesWJTthFT4zpkAAdbAFKIPa0fnyVtr0/BlpkyZ89WfDIotlb9dsUKyGK9ATvH5L2iENA/Z1ysFI9jv/GYqAL7LnkVLiyQlaconSB2CzGUo;appid=10002;gameid=1379;g_ut=3;PK=0;sid=AcWfxRIXEpKAmSjI_QqFhtc3;JumpURLExtraData=0|0|0|newwap|0|0;"
170 | var host = window.location.host, token;
171 | //必须使用dev 环境的cookie才能在fgnew 环境调试
172 | if(host.indexOf('dev') == -1)
173 | token = chromecookiefgdev;
174 | else {
175 | paras = window.location.search;
176 | ret = helper.getKeyValueReg(paras);
177 | token = ret.join(';');
178 | }
179 | return token;
180 | }
181 |
182 | /**
183 | * 获取好友列表
184 | * @param successFunc 获取好友列表成功的回调
185 | * @param errorFunc 获取好友列表失败的回调
186 | */
187 | Proxy.prototype.getFriendList = function(successFunc, errorFunc) {
188 | window.log('getFriendList');
189 | this.doPost('cmd=getFriendList', AjaxType.getFriendList, successFunc, errorFunc);
190 | }
191 |
192 | /**
193 | * 获取账户余额
194 | * @param successFunc 获取账户余额成功的回调
195 | * @param errorFunc 获取账户余额失败的回调
196 | */
197 | Proxy.prototype.queryAccountBalance = function(successFunc, errorFunc) {
198 | window.log('queryAccountBalance');
199 | this.doPost('cmd=qcoins', AjaxType.qcoins, successFunc, errorFunc);
200 | }
201 |
202 | /**
203 | * 购买商品请求支付接口
204 | * @param successFunc 支付成功的回调
205 | * @param errorFunc 支付失败的回调
206 | */
207 | Proxy.prototype.payMoney = function(goods, successFunc, errorFunc) {
208 | window.log('payMoney');
209 | this.doPost('cmd=ppay&' + goods.toString(), AjaxType.ppay, successFunc, errorFunc);
210 | }
211 |
212 | /**
213 | * 跳转到充值页面的请求
214 | */
215 | Proxy.prototype.go2ReCharge = function() {
216 | window.log('go2ReCharge');
217 | var key = 'gameid=';
218 | var params = window.location.search;
219 | var start = params.indexOf(key), end, gameid;
220 | if(start > -1) {
221 | end = params.indexOf('&', start);
222 | start += key.length;
223 | if(end == -1)
224 | gameid = params.substring(start);
225 | else
226 | gameid = params.substring(start, end);
227 | } else {
228 | window.log('gameid not exist, use default for test');
229 | gameid = 1225;
230 | }
231 | window.log(gameid);
232 | window.location = 'http://flash' + gameid + '.mbdev.3g.qq.com';
233 | }
234 |
235 | /**
236 | * 对游戏中购买的商品的封装类
237 | * @param id 所购买商品的id
238 | * @param price 所购买商品的单价
239 | * @param num 所购买商品的数量
240 | */
241 | var Goods = function(id, price, num) {
242 | this.id = id;
243 | this.price = price, this.num = num;
244 |
245 | Goods.prototype.toString = function() {
246 | var s = ['propid=', this.id, "&price=", this.price, '&num=', this.num];
247 | return s.join('');
248 | }
249 | }
250 |
251 |
252 |
253 | sdk.Proxy = Proxy;
254 | sdk.Goods = Goods;
255 | /*
256 | sdk.getKeyValueRegTest = function(){
257 | var a='?name=zhiyelee&blog=www.tsnrose.com&name=zhiyelee&blog=www.tsnrose.com&name=zhiyelee&blog=www.tsnrose.com';
258 | return helper.getKeyValueReg(a);
259 | }
260 | */
261 |
262 | window.debug = true;
263 | window.log = function(b) {
264 | if(window.debug) {
265 | window.console && window.console.log(b);
266 | }
267 | }
268 |
269 | })(MicrorapidNetGameSDK);
270 |
--------------------------------------------------------------------------------
/js/canvaswrapper.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Róbert Pataki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | *
22 | * ----------------------------------------------------------------------------------------
23 | *
24 | * Check out my GitHub: http://github.com/heartcode/
25 | * Send me an email: heartcode@robertpataki.com
26 | * Follow me on Twitter: http://twitter.com/#iHeartcode
27 | * Blog: http://heartcode.robertpataki.com
28 | */
29 |
30 | /**
31 | * CanvasWrapper uses the HTML5 canvas element in modern browsers and VML in IE6/7/8 to create and animate the most popular preloader shapes (oval, spiral, rectangle, square and rounded rectangle).
32 | * It is important to note that CanvasWrapper doesn't show up and starts rendering automatically on instantiation. To start rendering and display the loader use the show() method.
33 | * @module CanvasWrapper
34 | **/
35 | ( function(window) {"use strict";
36 | /**
37 | * CanvasWrapper is a JavaScript UI library that draws and animates circular preloaders using the Canvas HTML object.
38 | * A CanvasWrapper instance creates two canvas elements which are placed into a placeholder div (the id of the div has to be passed in the constructor). The second canvas is invisible and used for caching purposes only.
39 | * If no id is passed in the constructor, the canvas objects are paced in the document directly.
40 | * @class CanvasWrapper
41 | * @constructor
42 | * @param id {String} The id of the placeholder div
43 | * @param opt {Object} Optional parameters
44 | * Possible values of optional parameters:
45 | *
46 | * id (String): The id of the CanvasWrapper instance
47 | * safeVML (Boolean): If set to true, the amount of CanvasWrapper shapes are limited in VML mode. It prevents CPU overkilling when rendering loaders with high density. The default value is true.
48 | **/
49 | var CanvasWrapper = function(id, opt) {
50 | if( typeof (opt) == "undefined") {
51 | opt = {};
52 | }
53 | if(typeof (id) !== "undefined")
54 | this.init(id, opt);
55 | }, p = CanvasWrapper.prototype, engine, engines = ["canvas", "vml"], cRX = /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, ie8 = navigator.appVersion.indexOf("MSIE") !== -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) === 8 ? true : false, canSup = !!document.createElement('canvas').getContext;
56 |
57 |
58 |
59 | /**
60 | * Creates a new element with the tag and applies the passed properties on it
61 | * @method addEl
62 | * @protected
63 | * @param tag {String} The tag to be created
64 | * @param par {String} The DOM element the new element will be appended to
65 | * @param opt {Object} Additional properties passed to the new DOM element
66 | * @return {Object} The DOM element
67 | */
68 | p.addEl = function(tag, par, opt) {
69 | var el = document.createElement(tag), n;
70 | for(n in opt) {
71 | el[n] = opt[n];
72 | }
73 | if( typeof (par) !== "undefined") {
74 | par.appendChild(el);
75 | }
76 | return el;
77 | };
78 | /**
79 | * Initialization method
80 | * @method init
81 | * @protected
82 | * @param id {String} The id of the placeholder div, where the loader will be nested into
83 | * @param opt {Object} Optional parameters
84 | * Possible values of optional parameters:
85 | *
86 | * id (String): The id of the CanvasWrapper instance
87 | * safeVML (Boolean): If set to true, the amount of CanvasWrapper shapes are limited in VML mode. It prevents CPU overkilling when rendering loaders with high density. The default value is true.
88 | **/
89 | p.init = function(pId, opt) {
90 | /*
91 | * Find the containing div by id
92 | * If the container element cannot be found we use the document body itself
93 | */
94 | try {
95 | // Look for the parent element
96 | if(document.getElementById(pId) !== undefined) {
97 | this.mum = document.getElementById(pId);
98 | } else {
99 | this.mum = document.body;
100 | }
101 | } catch (error) {
102 | this.mum = document.body;
103 | }
104 | // Creates the parent div of the loader instance
105 | opt.id = typeof (opt.id) !== "undefined" ? opt.id : "canvasLoader";
106 | this.cont = this.addEl("div", this.mum, {
107 | id : opt.id
108 | });
109 | if(canSup) {
110 | // For browsers with Canvas support...
111 | engine = engines[0];
112 | // Create the canvas element
113 | this.can = this.addEl("canvas", this.cont);
114 | this.con = this.can.getContext("2d");
115 | // Create the cache canvas element
116 | this.cCan = this.setCSS(this.addEl("canvas", this.cont), {
117 | display : "none"
118 | });
119 | this.cCon = this.cCan.getContext("2d");
120 | }
121 | // Set the RGB color object
122 | this.setColor(this.color);
123 | // Draws the shapes on the canvas
124 | this.draw();
125 | //Hides the preloader
126 | this.setCSS(this.cont, {
127 | display : "none"
128 | });
129 | };
130 |
131 | /**
132 | * Transforms the cache canvas before drawing
133 | * @method transCon
134 | * @protected
135 | * @param c {Object} The canvas context to be transformed
136 | * @param x {Number} x translation
137 | * @param y {Number} y translation
138 | * @param r {Number} Rotation radians
139 | */
140 | p.transCon = function(c, x, y, r) {
141 | c.save();
142 | c.translate(x, y);
143 | c.rotate(r);
144 | c.translate(-x, -y);
145 | c.beginPath();
146 | };
147 |
148 | /**
149 | * Sets the css properties on the element
150 | * @method setCSS
151 | * @protected
152 | * @param el {Object} The DOM element to be styled
153 | * @param opt {Object} The style properties
154 | * @return {Object} The DOM element
155 | */
156 | p.setCSS = function(el, opt) {
157 | for(var n in opt) {
158 | el.style[n] = opt[n];
159 | }
160 | return el;
161 | };
162 | /**
163 | * Sets the attributes on the element
164 | * @method setAttr
165 | * @protected
166 | * @param el {Object} The DOM element to add the attributes to
167 | * @param opt {Object} The attributes
168 | * @return {Object} The DOM element
169 | */
170 | p.setAttr = function(el, opt) {
171 | for(var n in opt) {
172 | el.setAttribute(n, opt[n]);
173 | }
174 | return el;
175 | };
176 | /////////////////////////////////////////////////////////////////////////////////////////////
177 | // Property declarations
178 | /**
179 | * The div we place the canvas object into
180 | * @property cont
181 | * @protected
182 | * @type Object
183 | **/
184 | p.cont = {};
185 | /**
186 | * The div we draw the shapes into
187 | * @property can
188 | * @protected
189 | * @type Object
190 | **/
191 | p.can = {};
192 | /**
193 | * The canvas context
194 | * @property con
195 | * @protected
196 | * @type Object
197 | **/
198 | p.con = {};
199 | /**
200 | * The canvas we use for caching
201 | * @property cCan
202 | * @protected
203 | * @type Object
204 | **/
205 | p.cCan = {};
206 | /**
207 | * The context of the cache canvas
208 | * @property cCon
209 | * @protected
210 | * @type Object
211 | **/
212 | p.cCon = {};
213 |
214 | /**
215 | * The color of the loader shapes in RGB
216 | * @property cRGB
217 | * @protected
218 | * @type Object
219 | **/
220 | p.cRGB = {};
221 | /**
222 | * The color of the loader shapes in HEX
223 | * @property color
224 | * @protected
225 | * @type String
226 | * @default "#000000"
227 | **/
228 | p.color = "#000000";
229 | /**
230 | * Sets hexadecimal color of the loader
231 | * @method setColor
232 | * @public
233 | * @param color {String} The default value is '#000000'
234 | **/
235 | p.setColor = function(color) {
236 | this.color = cRX.test(color) ? color : "#000000";
237 | this.cRGB = this.getRGB(this.color);
238 | this.redraw();
239 | };
240 | /**
241 | * Returns the loader color in a hexadecimal form
242 | * @method getColor
243 | * @public
244 | * @return {String}
245 | **/
246 | p.getColor = function() {
247 | return this.color;
248 | };
249 |
250 | // End of Property declarations
251 | /////////////////////////////////////////////////////////////////////////////////////////////
252 | /**
253 | * Return the RGB values of the passed color
254 | * @method getRGB
255 | * @protected
256 | * @param color {String} The HEX color value to be converted to RGB
257 | */
258 | p.getRGB = function(c) {
259 | c = c.charAt(0) === "#" ? c.substring(1, 7) : c;
260 | return {
261 | r : parseInt(c.substring(0, 2), 16),
262 | g : parseInt(c.substring(2, 4), 16),
263 | b : parseInt(c.substring(4, 6), 16)
264 | };
265 | };
266 | /**
267 | * Draw the shapes on the canvas
268 | * @method draw
269 | * @protected
270 | */
271 | p.draw = function() {
272 | };
273 | /**
274 | * Cleans the canvas
275 | * @method clean
276 | * @protected
277 | */
278 | p.clean = function() {
279 | if(engine === engines[0]) {
280 | this.con.clearRect(0, 0, 1000, 1000);
281 | }
282 | };
283 | /**
284 | * Redraws the canvas
285 | * @method redraw
286 | * @protected
287 | */
288 | p.redraw = function() {
289 | this.clean();
290 | this.draw();
291 | };
292 |
293 | /**
294 | * Shows the rendering of the loader animation
295 | * @method show
296 | * @public
297 | */
298 | p.show = function() {
299 | this.setCSS(this.cont, {
300 | display : "block"
301 | });
302 | };
303 | /**
304 | * Stops the rendering of the loader animation and hides the loader
305 | * @method hide
306 | * @public
307 | */
308 | p.hide = function() {
309 | this.setCSS(this.cont, {
310 | display : "none"
311 | });
312 | };
313 |
314 | /**
315 | * Removes the CanvasWrapper instance and all its references
316 | * @method kill
317 | * @public
318 | */
319 | p.kill = function() {
320 | var c = this.cont;
321 |
322 | if(engine === engines[0]) {
323 | c.removeChild(this.can);
324 | c.removeChild(this.cCan);
325 | }
326 | var n;
327 | for(n in this) {
328 | delete this[n];
329 | }
330 | };
331 | window.CanvasWrapper = CanvasWrapper;
332 | }(window));
333 |
--------------------------------------------------------------------------------
/js/canvaschesspanel.js:
--------------------------------------------------------------------------------
1 | ( function(window) {"use strict";
2 |
3 | window.log = function(data){
4 | window.console.log && window.console.log(data);
5 | }
6 |
7 | function absoluteCenter(canvas, span, offset){
8 | var left = (document.body.clientWidth - canvas.width)/2;
9 | var top = (document.body.clientHeight - canvas.height)/2;
10 | var css = {
11 | position: 'absolute',
12 | left : left + 'px',
13 | top : top + 'px',
14 |
15 | }
16 | css['text-align'] = 'center';
17 | $(canvas).css(css);
18 |
19 | if(span){
20 | css.width = canvas.width;
21 | css.height = canvas.heigth;
22 | var _offset = offset;
23 | if(!_offset)
24 | _offset = 0;
25 | css.top = top + _offset + 'px';
26 | $(span).css(css);
27 | }
28 |
29 | }
30 |
31 | var ChessProtocal = {
32 | HEART_BEAT : 0,
33 | SET_PLAYER_ID :1,
34 | MOVE_PIECE : 2,
35 | PLAYER_IN : 3,
36 | PLAYER_OUT : 4,
37 | GAME_REQUEST : 5,
38 | GAME_RESPONSE:6,
39 | }
40 |
41 | var GameStatus = {
42 | waiting: 0,
43 | playing: 1,
44 | over: 2,
45 | myturn:3,
46 | }
47 |
48 | window.heart = function(){
49 | var heart = {cmd: ChessProtocal.HEART_BEAT};
50 | window.window.chessPanel.wsocket.send(window.JSON.stringify(heart));
51 | window.t=setTimeout('heart()',4000);
52 | }
53 |
54 | window.doGameRequest = function(anchor){
55 | var playerId = anchor.innerHTML;
56 | var req = {
57 | cmd: ChessProtocal.GAME_REQUEST,
58 | playerId : playerId,
59 | }
60 | window.chessPanel.wsocket.send(window.JSON.stringify(req));
61 | }
62 |
63 | var GameResponse = function(result, reqId){
64 | var rsp = {
65 | cmd: ChessProtocal.GAME_RESPONSE,
66 | result: result,
67 | playerId: reqId,
68 | }
69 | if(result == 1){
70 | $('#tips').html('等待对方先走棋...');
71 | $('#piece_type').html('红方');
72 | }
73 | window.chessPanel.pieceType = ChineseChess.RED;
74 | window.chessPanel.wsocket.send(window.JSON.stringify(rsp));
75 | }
76 |
77 | var ChessSocket = function(chessPanel){
78 | var proxyServerIp = $('#PROXY_SERVER_IP').val();
79 | if(proxyServerIp)
80 | var url = 'ws://' + proxyServerIp + ':33601/demo';
81 | else
82 | var url = "ws://124.73.15.139:33601/demo";
83 | try {
84 | var ws = new WebSocket(url);
85 | ws.onopen = this.onOpen;
86 | ws.onmessage = this.onMessage;
87 | ws.onclose = this.onClose;
88 | ws.onerror = this.onError;
89 | ws.chessPanel = chessPanel;
90 | this.ws = ws;
91 | } catch (ex) {
92 | $('#tips').html('您的浏览器暂不支持websocket哦...');
93 | }
94 |
95 | }
96 |
97 |
98 |
99 |
100 | ChessSocket.prototype.onOpen = function(Event){
101 | window.log('ChessSocket.prototype.onOpen');
102 | window.heart();
103 | }
104 |
105 | ChessSocket.prototype.onMessage = function(MessageEvent){
106 | var data = MessageEvent.data;
107 | var jsonMsg = window.JSON.parse(data);
108 | var cmd = parseInt(jsonMsg.cmd);
109 | switch(cmd){
110 | //获取自己的playerID
111 | case ChessProtocal.SET_PLAYER_ID :{
112 | if(jsonMsg.playerId){
113 | var player = '昵称:'+ jsonMsg.playerId +' ';
114 | $('#players ul').prepend(player);
115 | }else{
116 | $('#tips').html('抱歉,服务器拒绝请求,请稍后再试...');
117 | }
118 | break;
119 | }
120 | case ChessProtocal.MOVE_PIECE:{
121 | window.chessPanel.moveEnemyPiece(jsonMsg);
122 | $('#tips').html('对方走子完毕,请您走棋');
123 | break;
124 |
125 | }
126 | //player in
127 | case ChessProtocal.PLAYER_IN:{
128 | var player = ''+ jsonMsg.playerId +' ';
129 | $('#players ul').append(player);break;
130 | }
131 | //player out
132 | case ChessProtocal.PLAYER_OUT:{
133 | var selector = '#players ul li[value ="' + jsonMsg.playerId + '"]';
134 | $(selector).remove();break;
135 | }
136 | case ChessProtocal.GAME_REQUEST:{
137 | var reqId = jsonMsg.playerId;
138 | var dialog = {
139 | title:'游戏请求',
140 | content:reqId + '发来游戏请求,是否同意?',
141 | callbackone:function(){GameResponse(1, reqId)},
142 | callbacktwo:function(){GameResponse(0, reqId)},
143 | buttonone:'开始',
144 | buttontwo:'拒绝',
145 | }
146 |
147 | Component.MsgDialog.msgbox(dialog);break;
148 | }
149 | case ChessProtocal.GAME_RESPONSE:{
150 | if(jsonMsg.result == 1){
151 | this.chessPanel.gameStatus = GameStatus.myturn;
152 | this.chessPanel.pieceType = ChineseChess.BLACK;
153 | $('#tips').html('对方接受邀请.您为黑方,请先走棋');
154 | $('#piece_type').html('黑方');
155 | }
156 | break;
157 | }
158 | }
159 | window.log('ChessSocket.prototype.onMessage');
160 | }
161 |
162 | ChessSocket.prototype.onClose = function(Event){
163 | clearTimeout(window.t);
164 | $('#tips').html('抱歉,与服务器失去连接,请稍后再试...');
165 | window.log('ChessSocket.prototype.onClose');
166 | }
167 |
168 | ChessSocket.prototype.onError = function(){
169 | $('#tips').html('抱歉,出错啦,请稍后再试...');
170 | window.log('ChessSocket.prototype.onError');
171 | }
172 |
173 | ChessSocket.prototype.send = function(msg){
174 | this.ws && this.ws.send(msg);
175 | }
176 |
177 | /*
178 | * CanvasChessPanel
179 | */
180 | var CanvasChessPanel = function(id, opt) {
181 | var CanvasChessPanel = new CanvasWrapper(id, opt);
182 | var wsocket = new ChessSocket(CanvasChessPanel);
183 | CanvasChessPanel.wsocket = wsocket;
184 | CanvasChessPanel.width = 320;
185 | CanvasChessPanel.height = 480;
186 | CanvasChessPanel.gameStatus = GameStatus.waiting;
187 |
188 | CanvasChessPanel.moveEnemyPiece = function(jsonData){
189 | var oldX = jsonData.oldX;
190 | var oldY = jsonData.oldY;
191 | var newX = jsonData.newX;
192 | var newY = jsonData.newY;
193 | var beat = jsonData.beat;
194 | var pieces = this.pieces;
195 | if(beat && beat == 1){
196 | for(var i = 0; i < pieces.length; i++) {
197 | var cur = pieces[i];
198 | if(cur.alive) {
199 | if(cur.xCoor == newX && cur.yCoor == newY){
200 | cur.alive = false;break;
201 | }
202 | }
203 | }
204 | }
205 |
206 | for(var i = 0; i < pieces.length; i++) {
207 | var cur = pieces[i];
208 | if(cur.alive) {
209 | if(cur.xCoor == oldX && cur.yCoor == oldY){
210 | cur.xCoor = newX;
211 | cur.yCoor = newY;
212 | break;
213 | }
214 | }
215 | }
216 | this.gameStatus = GameStatus.myturn;
217 | this.draw();
218 | }
219 |
220 | CanvasChessPanel.draw = function () {
221 | var c = this.con;
222 | if(this.chessPanelImg){
223 | c.drawImage(this.chessPanelImg, 0, 0);
224 | }
225 | var that = this;
226 | var pieces = that.pieces;
227 | var xCenter, yCenter;
228 | if(pieces){
229 | c.translate(- that.trans.x , -that.trans.y);
230 | for(var i = 0; i < pieces.length; i++){
231 | var cur = pieces[i];
232 | if(cur.alive){
233 | xCenter = ChineseChess.vOffset[cur.xCoor];
234 | yCenter = ChineseChess.hOffset[cur.yCoor];
235 | c.drawImage(cur.image, xCenter, yCenter);
236 | }
237 | }
238 |
239 | var selected = that.selected;
240 | if(selected){
241 | xCenter = ChineseChess.vOffset[selected.xCoor];
242 | yCenter = ChineseChess.hOffset[selected.yCoor];
243 | var border = {
244 | xPos : xCenter,
245 | yPos : yCenter,
246 | borderWidth : 2 * that.trans.x,
247 | borderHeight : 2 * that.trans.y,
248 | };
249 | that.con.strokeStyle = "rgb(255,0,0)";
250 | //之前设置的translate依然有效
251 | that.con.strokeRect(border.xPos, border.yPos, border.borderWidth, border.borderHeight);
252 | }
253 | c.translate( that.trans.x , that.trans.y);
254 |
255 | }
256 | };
257 |
258 |
259 | CanvasChessPanel.preDraw = function(){
260 | var image = new Image();
261 | image.src = 'img/chesspanel.png';
262 | var that = this;
263 | var c = this.con;
264 | image.onload = function(){
265 | //棋盘缩放系数
266 | var xScale = (that.width / image.naturalWidth);
267 | var yScale = (that.height / image.naturalHeight);
268 | c.scale(xScale,yScale);
269 | that.chessPanelImg = image;
270 | var pieces = that.pieces;
271 | if(pieces){
272 | var cur = pieces[0];
273 | image = new Image();
274 | image.src = 'img/' + cur.src;
275 | var trans = {
276 | x : image.naturalWidth /2,
277 | y : image.naturalHeight / 2,
278 | };
279 | that.trans = trans;
280 | ChineseChess.trans = trans;
281 |
282 | for(var i = 0; i < pieces.length; i++){
283 | cur = pieces[i];
284 | image = new Image();
285 | image.src = 'img/' + cur.src;
286 | cur.image = image;
287 | }
288 | }
289 | that.draw();
290 | }
291 |
292 | };
293 |
294 | CanvasChessPanel.setMousedownCallBack = function(){
295 | var that = this;
296 | $(window).mousedown(function(e) {
297 | var canvasX = Math.floor(e.pageX-that.can.offsetLeft);
298 | var canvasY = Math.floor(e.pageY-that.can.offsetTop);
299 | });
300 | };
301 |
302 | CanvasChessPanel.setClickCallBack = function(){
303 | var that = this;
304 | $(window).click(function(e) {
305 | if(that.gameStatus != GameStatus.myturn)
306 | return;
307 | var canvasX = Math.floor(e.pageX-that.can.offsetLeft);
308 | var canvasY = Math.floor(e.pageY-that.can.offsetTop);
309 | if(that.selected){
310 | var objPos = that.selected.getCenterXY({posX : canvasX, posY : canvasY});
311 | if(that.selected.xCoor == objPos.xCoor && that.selected.yCoor == objPos.yCoor)
312 | that.selected = null;
313 | else{
314 | if(that.selected.type != that.pieceType){
315 | that.selected = null;return;
316 | }
317 | var ret = that.selected.go({posX : canvasX, posY : canvasY});
318 |
319 | if(ret.reachable){
320 | var cur = that.selected;
321 | var go = {
322 | cmd : ChessProtocal.MOVE_PIECE,
323 | oldX : cur.savedX,
324 | oldY : cur.saveY,
325 | newX : cur.xCoor,
326 | newY : cur.yCoor,
327 | beat : ret.beat,
328 | }
329 | wsocket.send(window.JSON.stringify(go));
330 | that.gameStatus = GameStatus.playing;
331 | $('#tips').html('等待对方走棋...');
332 | }else{
333 | alert('illegal go');
334 | }
335 | that.selected = null;
336 | }
337 | that.redraw();
338 | return;
339 | }
340 |
341 | var cur, xCenter, yCenter;
342 |
343 | for(var i = 0; i < that.pieces.length; i++){
344 | cur = that.pieces[i];
345 | if(!cur.alive) continue;
346 | xCenter = ChineseChess.vOffset[cur.xCoor];
347 | yCenter = ChineseChess.hOffset[cur.yCoor];
348 | if(Math.abs(xCenter - canvasX) < that.trans.x && Math.abs(yCenter - canvasY) < that.trans.y){
349 | that.selected = cur;
350 | that.redraw();
351 | return;
352 | }
353 | }
354 | });
355 | };
356 | CanvasChessPanel.Config = function(){
357 | this.setAttr(this.can, {
358 | width : this.width,
359 | height : this.height
360 | });
361 | this.setAttr(this.cCan, {
362 | width : this.width,
363 | height : this.height
364 | });
365 |
366 | this.preDraw();
367 | //this.setMousedownCallBack();
368 | this.setClickCallBack();
369 | //absoluteCenter(this.can);
370 | //this.setColor('#a8a5a8');
371 | this.show();
372 |
373 | }
374 |
375 | CanvasChessPanel.Config();
376 |
377 |
378 |
379 |
380 |
381 |
382 | return CanvasChessPanel;
383 | };
384 |
385 |
386 | window.CanvasChessPanel = CanvasChessPanel;
387 | /*
388 | * CanvasChessPanel
389 | */
390 |
391 |
392 |
393 | }(window));
394 |
395 |
396 |
397 |
--------------------------------------------------------------------------------
/js/chinesechess.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Administrator
3 | */
4 |
5 | var ChineseChess={};
6 | (function(chess){
7 |
8 | //棋盘横线偏移
9 | var hOffset = [80,116,152,186,222,257,292,327,362,398];
10 | //棋盘纵线偏移
11 | var vOffset = [20,55,90,125,160,195,230,265,300];
12 |
13 |
14 | var RED = 0, BLACK = 1;
15 | var GO = 0, BEAT = 1;
16 |
17 | var redPieces = [], blackPieces = [];
18 | var redJiang,blackJiang;
19 |
20 | var Piece = function(xCoor,yCoor,type){
21 | this.xCoor = xCoor;
22 | this.yCoor = yCoor;
23 | this.type = type;
24 | this.alive = true;
25 |
26 | this.toeat = null;
27 | this.savedX = this.xCoor;
28 | this.saveY = this.yCoor;
29 | }
30 |
31 | Piece.prototype.hasPieceBetweenJiang = function(){
32 | if(redJiang.xCoor != blackJiang.xCoor) return true;
33 | var cur, all = chess.pieces, interval = 0;
34 | for(var i = 0; i < all.length; i++){
35 | cur = all[i];
36 | if(!cur.alive || cur.xCoor != redJiang.xCoor) continue;
37 | var diff1 = cur.yCoor - redJiang.yCoor;
38 | var diff2 = cur.yCoor - blackJiang.yCoor;
39 | var mark = diff1 * diff2;
40 | if(mark < 0){
41 | if(interval++ > 0)
42 | return true;
43 | }
44 | }
45 | return (interval > 0);
46 | }
47 |
48 | Piece.prototype.getCenterXY = function(opt){
49 | var posX = opt.posX, posY = opt.posY;
50 | var xCoor = vOffset[0], yCoor = hOffset[0];
51 | var i,j;
52 | for(i = 0; i < vOffset.length; i++){
53 | if(Math.abs(vOffset[i] - posX) <= ChineseChess.trans.x){
54 | break;
55 | }
56 | }
57 | if(i == vOffset.length)
58 | i--;
59 |
60 | for(j = 0; j < hOffset.length; j++){
61 | if(Math.abs(hOffset[j] - posY) <= ChineseChess.trans.y){
62 | break;
63 | }
64 | }
65 | if(j == hOffset.length)
66 | j--;
67 |
68 | return {
69 | xCoor :i,
70 | yCoor :j,
71 | }
72 |
73 | }
74 |
75 | Piece.prototype.objInRightBorder = function(objPos){return true;};
76 | Piece.prototype.objReachable = function(objPos){return true;};
77 |
78 | Piece.prototype.go = function(opt){
79 | var objPos = this.getCenterXY(opt);
80 | var right = this.objInRightBorder(objPos);
81 | var ret = {reachable: right};
82 | if(right){
83 | var reachable = this.objReachable(objPos);
84 | if(reachable){
85 | this.savedX = this.xCoor;
86 | this.saveY = this.yCoor;
87 |
88 | this.xCoor = objPos.xCoor;
89 | this.yCoor = objPos.yCoor;
90 | if(this.hasPieceBetweenJiang()){
91 | if(this.toeat){
92 | ret.beat = 1;
93 | this.toeat.alive = false;
94 | this.toeat = null;
95 | }
96 | }else{
97 | this.xCoor = this.savedX;
98 | this.yCoor = this.saveY;
99 | this.toeat = null;
100 | reachable = false;
101 | }
102 | }
103 | ret.reachable = reachable;
104 | return ret;
105 | }else
106 | return ret;
107 | };
108 |
109 |
110 |
111 | var Che = function(xCoor,yCoor,type){
112 | Piece.call(this,xCoor,yCoor,type);
113 | this.type == RED ? this.src = 'r_che.png' :this.src = 'b_che.png';
114 | }
115 | Che.prototype = new Piece();
116 | Che.prototype.objInRightBorder = function(objPos){
117 | return (objPos.xCoor == this.xCoor || objPos.yCoor == this.yCoor);
118 | }
119 | Che.prototype.objReachable = function(objPos){
120 | var p , all = chess.pieces;
121 | var reachable = true;
122 | //纵向走子
123 | if(objPos.xCoor == this.xCoor){
124 | for(var i = 0; reachable && i < all.length; i++){
125 | p = all[i];
126 | if(!p.alive || p === this || p.xCoor != this.xCoor) continue;
127 | //判断p是否在this,和objPos之间
128 | var diff1 = p.yCoor - this.yCoor;
129 | var diff2 = p.yCoor - objPos.yCoor;
130 | var mark = diff1 * diff2;
131 | //不在中间
132 | if(mark > 0){
133 | reachable = true;
134 | }else if(mark == 0){
135 | if(p.type == this.type) reachable = false;
136 | else{
137 | //待吃子
138 | reachable = true;
139 | this.toeat = p;
140 | }
141 | }else{
142 | reachable = false;
143 | }
144 | }
145 | }else{
146 | for(var i = 0; reachable && i < all.length; i++){
147 | p = all[i];
148 | if(!p.alive || p === this || p.yCoor != this.yCoor) continue;
149 | var diff1 = p.xCoor - this.xCoor;
150 | var diff2 = p.xCoor - objPos.xCoor;
151 | var mark = diff1 * diff2;
152 | if(mark > 0){
153 | reachable = true;
154 | }else if(mark == 0){
155 | if(p.type == this.type) reachable = false;
156 | else{
157 | //待吃子
158 | reachable = true;
159 | this.toeat = p;
160 | }
161 | }else{
162 | reachable = false;
163 | }
164 |
165 | }
166 | }
167 | return reachable;
168 | }
169 |
170 | var Ma = function(xCoor,yCoor,type){
171 | Piece.call(this,xCoor,yCoor,type);
172 | this.type == RED ? this.src = 'r_ma.png' : this.src = 'b_ma.png';
173 | }
174 | Ma.prototype = new Piece();
175 | Ma.prototype.objInRightBorder = function(objPos){
176 | var diffX = Math.abs(objPos.xCoor - this.xCoor);
177 | var diffY = Math.abs(objPos.yCoor - this.yCoor);
178 | var bigger, smaller;
179 | if(diffX > diffY){
180 | bigger = diffX; smaller = diffY;
181 | }else{
182 | bigger = diffY; smaller = diffX;
183 | }
184 | var right = (bigger == 2 && bigger/smaller == 2);
185 | if(right){
186 | var tripX, triY;
187 | if(bigger == diffX){
188 | tripY = this.yCoor;
189 | if(objPos.xCoor > this.xCoor)
190 | tripX = this.xCoor + 1;
191 | else
192 | tripX = this.xCoor -1;
193 | }else{
194 | tripX = this.xCoor;
195 | if(objPos.yCoor > this.yCoor)
196 | tripY = this.yCoor + 1;
197 | else
198 | tripY = this.yCoor -1;
199 | }
200 |
201 | var p , all = chess.pieces;
202 | for(var i = 0; i < all.length; i++){
203 | p = all[i];
204 | if(p.xCoor == tripX && p.yCoor == tripY)
205 | return false;
206 | }
207 | }else
208 | return false;
209 | return true;
210 | }
211 | Ma.prototype.objReachable = function(objPos){
212 | var p , all = chess.pieces, reachable = true;
213 | for(var i = 0; i < all.length; i++){
214 | p = all[i];
215 | if(!p.alive || p === this || p.xCoor != objPos.xCoor || p.yCoor != objPos.yCoor) continue;
216 | if(p.type == this.type) reachable = false;
217 | else{
218 | //吃子
219 | reachable = true;
220 | this.toeat = p;
221 | }
222 | return reachable;
223 | }
224 | return reachable;
225 | }
226 |
227 | var Xiang = function(xCoor,yCoor,type){
228 | Piece.call(this,xCoor,yCoor,type);
229 | this.type == RED ? this.src = 'r_xiang.png' : this.src = 'b_xiang.png';
230 | }
231 | Xiang.prototype = new Piece();
232 | Xiang.prototype.objInRightBorder = function(objPos){
233 | var right = Math.abs(objPos.xCoor - this.xCoor) == 2 && Math.abs(objPos.yCoor - this.yCoor) == 2;
234 | if(right && (objPos.xCoor % 2 == 0)){
235 | if(this.type == RED){
236 | return (objPos.yCoor % 2 == 0 && objPos.yCoor <= 4);
237 | }else{
238 | return (objPos.yCoor % 2 == 1 && objPos.yCoor >= 5);
239 | }
240 | }
241 | return false;
242 | }
243 | Xiang.prototype.objReachable = function(objPos){
244 | var p , all = chess.pieces;
245 | var reachable = true;
246 | //先判断中心位置是否有障碍
247 | for(var i = 0; i < all.length; i++){
248 | p = all[i];
249 | var diffY1 = p.yCoor - this.yCoor;
250 | var diffY2 = p.yCoor - objPos.yCoor;
251 | var markY = diffY1 + diffY2;
252 |
253 | var diffX1 = p.xCoor - this.xCoor;
254 | var diffX2 = p.xCoor - objPos.xCoor;
255 | var markX = diffX1 + diffX2;
256 | if(markX == 0 && markY == 0){
257 | reachable = false;
258 | }
259 | }
260 | if(reachable){
261 | for(var i = 0; i < all.length; i++){
262 | p = all[i];
263 | if(!p.alive || p === this || p.xCoor != objPos.xCoor || p.yCoor != objPos.yCoor) continue;
264 | if(p.type == this.type) reachable = false;
265 | else{
266 | //吃子
267 | reachable = true;
268 | this.toeat = p;
269 | }
270 | return reachable;
271 | }
272 | }
273 | return reachable;
274 | }
275 |
276 | var Shi = function(xCoor,yCoor,type){
277 | Piece.call(this,xCoor,yCoor,type);
278 | this.type == RED ? this.src = 'r_shi.png' : this.src = 'b_shi.png';
279 | }
280 | Shi.prototype = new Piece();
281 | Shi.prototype.objInRightBorder = function(objPos){
282 | var right = Math.abs(objPos.xCoor - this.xCoor) == 1 && Math.abs(objPos.yCoor - this.yCoor) == 1;
283 | if(right && (objPos.xCoor >=3 && objPos.xCoor <= 5)){
284 | if(this.type == RED){
285 | return (objPos.yCoor >=0 && objPos.yCoor <= 2);
286 | }else{
287 | return (objPos.yCoor >= hOffset.length -3 && objPos.yCoor <= hOffset.length - 1);
288 | }
289 | }
290 | return false;
291 | }
292 | Shi.prototype.objReachable = function(objPos){
293 | var p , all = chess.pieces;
294 | var reachable = true;
295 | for(var i = 0; i < all.length; i++){
296 | p = all[i];
297 | if(!p.alive || p === this || p.xCoor != objPos.xCoor || p.yCoor != objPos.yCoor) continue;
298 | if(p.type == this.type) reachable = false;
299 | else{
300 | //吃子
301 | reachable = true;
302 | this.toeat = p;
303 | }
304 | return reachable;
305 | }
306 | return reachable;
307 | }
308 |
309 | var Jiang = function(xCoor,yCoor,type){
310 | Piece.call(this,xCoor,yCoor,type);
311 | this.type == RED ? this.src = 'r_jiang.png' : this.src = 'b_jiang.png';
312 | }
313 | Jiang.prototype = new Piece();
314 | Jiang.prototype.objInRightBorder = function(objPos){
315 | var diffX = objPos.xCoor - this.xCoor;
316 | var diffY = objPos.yCoor - this.yCoor;
317 | if(Math.abs(diffX + diffY) == 1 && diffX * diffY == 0 ){
318 | if((objPos.xCoor >=3 && objPos.xCoor <= 5)){
319 | if(this.type == RED){
320 | return (objPos.yCoor >=0 && objPos.yCoor <= 2);
321 | }else{
322 | return (objPos.yCoor >= hOffset.length -3 && objPos.yCoor <= hOffset.length - 1);
323 | }
324 | }
325 | return false;
326 | }
327 | return false;
328 | }
329 | Jiang.prototype.objReachable = function(objPos){
330 | var p , all = chess.pieces;
331 | var reachable = true;
332 | for(var i = 0; i < all.length; i++){
333 | p = all[i];
334 | if(!p.alive || p === this || p.xCoor != objPos.xCoor || p.yCoor != objPos.yCoor) continue;
335 | if(p.type == this.type) reachable = false;
336 | else{
337 | //吃子
338 | reachable = true;
339 | this.toeat = p;
340 | }
341 | return reachable;
342 | }
343 | return reachable;
344 | }
345 |
346 | var Pao = function(xCoor,yCoor,type){
347 | Piece.call(this,xCoor,yCoor,type);
348 | this.type == RED ? this.src = 'r_pao.png' : this.src = 'b_pao.png';
349 | }
350 | Pao.prototype = new Piece();
351 |
352 | Pao.prototype.objInRightBorder = function(objPos){
353 | return (objPos.xCoor == this.xCoor || objPos.yCoor == this.yCoor);
354 | }
355 |
356 | Pao.prototype.objReachable = function(objPos){
357 | var p , all = chess.pieces, interval = 0;
358 | var reachable = true;
359 | //纵向走子
360 | if(objPos.xCoor == this.xCoor){
361 | for(var i = 0; reachable && i < all.length; i++){
362 | p = all[i];
363 | if(!p.alive || p === this || p.xCoor != this.xCoor) continue;
364 | //判断p是否在this,和objPos之间
365 | var diff1 = p.yCoor - this.yCoor;
366 | var diff2 = p.yCoor - objPos.yCoor;
367 | var mark = diff1 * diff2;
368 | //不在中间
369 | if(mark > 0){
370 | reachable = true;
371 | }else if(mark == 0){
372 | if(p.type == this.type) reachable = false;
373 | else{
374 | //待吃子
375 | reachable = true;
376 | this.toeat = p;
377 | }
378 | }else{
379 | if(interval++ > 1)
380 | reachable = false;
381 | }
382 | }
383 | }else{
384 | for(var i = 0; reachable && i < all.length; i++){
385 | p = all[i];
386 | if(!p.alive || p === this || p.yCoor != this.yCoor) continue;
387 | var diff1 = p.xCoor - this.xCoor;
388 | var diff2 = p.xCoor - objPos.xCoor;
389 | var mark = diff1 * diff2;
390 | if(mark > 0){
391 | reachable = true;
392 | }else if(mark == 0){
393 | if(p.type == this.type) reachable = false;
394 | else{
395 | //待吃子
396 | reachable = true;
397 | this.toeat = p;
398 | }
399 | }else{
400 | if(interval++ > 1)
401 | reachable = false;
402 | }
403 |
404 | }
405 | }
406 | if(interval == 1 && !this.toeat) reachable = false;
407 | return reachable;
408 | }
409 |
410 | var Zu = function(xCoor,yCoor,type){
411 | Piece.call(this,xCoor,yCoor,type);
412 | this.type == RED ? this.src = 'r_zu.png' : this.src = 'b_zu.png';
413 | }
414 | Zu.prototype = new Piece();
415 |
416 | Zu.prototype.objInRightBorder = function(objPos){
417 | var right = false;
418 | if(objPos.xCoor == this.xCoor){
419 | this.type == RED && (objPos.yCoor - this.yCoor == 1) && (right = true);
420 | this.type == BLACK && (objPos.yCoor - this.yCoor == -1) && (right = true);
421 | return right;
422 | }else if(objPos.yCoor == this.yCoor){
423 | this.type == RED && this.yCoor >= 5 && Math.abs(objPos.xCoor - this.xCoor) == 1 && (right = true);
424 | this.type == BLACK && this.yCoor <= 4 && Math.abs(objPos.xCoor - this.xCoor) == 1 && (right = true);
425 | return right;
426 | }
427 | return false;
428 | }
429 | Zu.prototype.objReachable = function(objPos){
430 | var p , all = chess.pieces;
431 | var reachable = true;
432 | for(var i = 0; i < all.length; i++){
433 | p = all[i];
434 | if(!p.alive || p === this || p.xCoor != objPos.xCoor || p.yCoor != objPos.yCoor) continue;
435 | if(p.type == this.type) reachable = false;
436 | else{
437 | //吃子
438 | reachable = true;
439 | this.toeat = p;
440 | }
441 | return reachable;
442 | }
443 | return reachable;
444 | }
445 |
446 | var i, xCoor, yCoor,piece;
447 | var func = [Che, Ma, Xiang, Shi, Jiang, Shi, Xiang, Ma, Che];
448 | //车马象士帅
449 | for(i = 0; i < vOffset.length; i++){
450 | xCoor = i, yCoor = 0;
451 |
452 | piece = new func[xCoor](xCoor,yCoor,RED);
453 | redPieces.push(piece);
454 |
455 | yCoor = hOffset.length - 1;
456 | piece = new func[xCoor](xCoor,yCoor,BLACK);
457 | blackPieces.push(piece);
458 | }
459 | redJiang = redPieces[4]; blackJiang = blackPieces[4];
460 | //炮
461 | for(i = 1; i < vOffset.length; i = i + 6){
462 | xCoor = i, yCoor = 2;
463 |
464 | piece = new Pao(xCoor,yCoor,RED);
465 | redPieces.push(piece);
466 |
467 | yCoor = hOffset.length - 3;
468 | piece = new Pao(xCoor,yCoor,BLACK);
469 | blackPieces.push(piece);
470 | }
471 |
472 | //卒
473 | for(i = 0; i < vOffset.length; i = i + 2){
474 | xCoor = i, yCoor = 3;
475 |
476 | piece = new Zu(xCoor,yCoor,RED);
477 | redPieces.push(piece);
478 |
479 | yCoor = hOffset.length - 4;
480 | piece = new Zu(xCoor,yCoor,BLACK);
481 |
482 | blackPieces.push(piece);
483 | }
484 |
485 | chess.pieces = redPieces.concat(blackPieces);
486 | chess.hOffset = hOffset;
487 | chess.vOffset = vOffset;
488 | chess.RED = RED;
489 | chess.BLACK = BLACK;
490 |
491 | chess.debug = function(log){
492 | console.log(log);
493 | }
494 |
495 | })(ChineseChess);
--------------------------------------------------------------------------------
/js/jquery-1.4.2.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v1.7.2 jquery.com | jquery.org/license */
2 | (function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;ca ",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q=""+"",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="
",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(
3 | a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c ",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML=" ",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="
";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/ ]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*",""],legend:[1,""," "],thead:[1,""],tr:[2,""],td:[3,""],col:[2,""],area:[1,""," "],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div","
"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f
4 | .clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>$2>");try{for(;d1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1>$2>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]===""&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/