Best JavaScript code snippet using puppeteer
js.js
Source:js.js  
1let bClassList = ['bknight','bking','bqueen','bbishop','bpawn','brook']2let wClassList = ['wknight','wking','wqueen','wbishop','wpawn','wrook']3let classes = ['brook', 'bknight', 'bbishop', 'bqueen', 'bking','bpawn','wpawn','wrook','wknight','wbishop','wking','wqueen']4let others = true;5let bturn = false;6let wturn = true;7$(document).ready(function() {8  function run() {9    jQuery.removeData("table");10    if(wturn) {11      for(xi in wClassList){12        x = wClassList[xi];13        x = '.' + x;14        pawn_id = [];15        $(x).map(function() {16          pawn_id.push(this.id);17        });18        if(x == '.wpawn' && $(x).length > 0){19          times1 = $(".wpawn").length;20          while(times1 > 0){21            move(x, pawn_id);22            times1 -= 1;23          }24        }25        else if($(x).length > 0) {26          times1 = $(x).length;27          while(times1 > 0){28            move(x, pawn_id);29            times1 -= 1;30          }31        }32      }33    }34    if(bturn){35      for(xi in bClassList){36        x = bClassList[xi];37        x = '.' + x;38        pawn_id = [];39        $(x).map(function() {40          pawn_id.push(this.id);41        });42        if(x == '.bpawn' && $(x).length > 0){43          times1 = $(".bpawn").length;44          while(times1 > 0){45            move(x, pawn_id);46            times1 -= 1;47          }48        }49        else if(x != '.bking' && x != '.bqueen' && $(x).length > 0) {50          times1 = $(x).length;51          while(times1 > 0){52            move(x, pawn_id);53            times1 -= 1;54          }55        }56        else if($(x).length > 0) {57          move(x, pawn_id)58        }59      }60    }61    function move(x, pawn_id) {62      times = pawn_id.length - 1;63      if(x == '.bking') {64        x = pawn_id[times];65        pawn_id.pop();66        xcopy = x;67        var i = x;68        var a = '';69        d = i[0];70        a += i[2];71        a += i[3];72        a = parseInt(a);73        if(d == 'b'){74          d = 'w';75        }76        else if(d == 'w'){77          d = 'b';78        }79        a += 10;80        c = d + 'a' + a;81        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){82          f = document.getElementById(c);83          ret = true;84          for(xi in bClassList){85            x = bClassList[xi];86            y = wClassList[xi];87            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){88              rerun_bRook = false;89              ret = false;90            }91            else if(y == f.getAttribute('class')){92              rerun_bRook = false;93            }94          }95          if(ret){96            $(f).addClass('moveable');97          }98        }99        else {100          rerun_bRook = false;101        }102        var a = '';103        d = i[0];104        a += i[2];105        a += i[3];106        a = parseInt(a);107        if(d == 'b'){108          d = 'w';109        }110        else if(d == 'w'){111          d = 'b';112        }113        a += 1;114        c = d + 'a' + a;115        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){116          f = document.getElementById(c);117          ret = true;118          for(xi in bClassList){119            x = bClassList[xi];120            y = wClassList[xi];121            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){122              rerun_bRook = false;123              ret = false;124            }125            else if(y == f.getAttribute('class')){126              rerun_bRook = false;127            }128          }129          if(ret){130            $(f).addClass('moveable');131          }132        }133        else {134          rerun_bRook = false;135        }136        var a = '';137        d = i[0];138        a += i[2];139        a += i[3];140        a = parseInt(a);141        if(d == 'b'){142          d = 'w';143        }144        else if(d == 'w'){145          d = 'b';146        }147        a -= 10;148        c = d + 'a' + a;149        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){150          f = document.getElementById(c);151          ret = true;152          for(xi in bClassList){153            x = bClassList[xi];154            y = wClassList[xi];155            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){156              rerun_bRook = false;157              ret = false;158            }159            else if(y == f.getAttribute('class')){160              rerun_bRook = false;161            }162          }163          if(ret){164            $(f).addClass('moveable');165          }166        }167        else {168          rerun_bRook = false;169        }170        var a = '';171        d = i[0];172        a += i[2];173        a += i[3];174        a = parseInt(a);175        if(d == 'b'){176          d = 'w';177        }178        else if(d == 'w'){179          d = 'b';180        }181        a -= 1;182        c = d + 'a' + a;183        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){184          f = document.getElementById(c);185          ret = true;186          for(xi in bClassList){187            x = bClassList[xi];188            y = wClassList[xi];189            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){190              rerun_bRook = false;191              ret = false;192            }193            else if(y == f.getAttribute('class')){194              rerun_bRook = false;195            }196          }197          if(ret){198            $(f).addClass('moveable');199          }200        }201        else {202          rerun_bRook = false;203        }204        var a = '';205        d = i[0];206        a += i[2];207        a += i[3];208        a = parseInt(a);209        a += 9;210        c = d + 'a' + a;211        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){212          f = document.getElementById(c);213          ret = true;214          for(xi in bClassList){215            x = bClassList[xi];216            y = wClassList[xi];217            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){218              rerun_bRook = false;219              ret = false;220            }221            else if(y == f.getAttribute('class')){222              rerun_bRook = false;223            }224          }225          if(ret){226            $(f).addClass('moveable');227          }228        }229        else {230          rerun_bRook = false;231        }232        var a = '';233        d = i[0];234        a += i[2];235        a += i[3];236        a = parseInt(a);237        a += 11;238        c = d + 'a' + a;239        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){240          f = document.getElementById(c);241          ret = true;242          for(xi in bClassList){243            x = bClassList[xi];244            y = wClassList[xi];245            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){246              rerun_bRook = false;247              ret = false;248            }249            else if(y == f.getAttribute('class')){250              rerun_bRook = false;251            }252          }253          if(ret){254            $(f).addClass('moveable');255          }256        }257        else {258          rerun_bRook = false;259        }260        var a = '';261        d = i[0];262        a += i[2];263        a += i[3];264        a = parseInt(a);265        a -= 9;266        c = d + 'a' + a;267        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){268          f = document.getElementById(c);269          ret = true;270          for(xi in bClassList){271            x = bClassList[xi];272            y = wClassList[xi];273            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){274              rerun_bRook = false;275              ret = false;276            }277            else if(y == f.getAttribute('class')){278              rerun_bRook = false;279            }280          }281          if(ret){282            $(f).addClass('moveable');283          }284        }285        else {286          rerun_bRook = false;287        }288        var a = '';289        d = i[0];290        a += i[2];291        a += i[3];292        a = parseInt(a);293        a -= 11;294        c = d + 'a' + a;295        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){296          f = document.getElementById(c);297          ret = true;298          for(xi in bClassList){299            x = bClassList[xi];300            y = wClassList[xi];301            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){302              rerun_bRook = false;303              ret = false;304            }305            else if(y == f.getAttribute('class')){306              rerun_bRook = false;307            }308          }309          if(ret){310            $(f).addClass('moveable');311          }312        }313        else {314          rerun_bRook = false;315        }316        if($('.moveable').length > 0){317          $('#' + xcopy).addClass('moveable2')318        }319        $('.moveable').removeClass('moveable');320      }321      else if(x == '.wking') {322        x = pawn_id[times];323        pawn_id.pop();324        xcopy = x;325        var i = x;326        var a = '';327        d = i[0];328        a += i[2];329        a += i[3];330        a = parseInt(a);331        if(d == 'b'){332          d = 'w';333        }334        else if(d == 'w'){335          d = 'b';336        }337        a += 10;338        c = d + 'a' + a;339        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){340          f = document.getElementById(c);341          ret = true;342          for(xi in wClassList){343            x = wClassList[xi];344            y = bClassList[xi];345            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){346              rerun_bRook = false;347              ret = false;348            }349            else if(y == f.getAttribute('class')){350              rerun_bRook = false;351            }352          }353          if(ret){354            $(f).addClass('moveable');355          }356        }357        else {358          rerun_bRook = false;359        }360        var a = '';361        d = i[0];362        a += i[2];363        a += i[3];364        a = parseInt(a);365        if(d == 'b'){366          d = 'w';367        }368        else if(d == 'w'){369          d = 'b';370        }371        a += 1;372        c = d + 'a' + a;373        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){374          f = document.getElementById(c);375          ret = true;376          for(xi in wClassList){377            x = wClassList[xi];378            y = bClassList[xi];379            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){380              rerun_bRook = false;381              ret = false;382            }383            else if(y == f.getAttribute('class')){384              rerun_bRook = false;385            }386          }387          if(ret){388            $(f).addClass('moveable');389          }390        }391        else {392          rerun_bRook = false;393        }394        var a = '';395        d = i[0];396        a += i[2];397        a += i[3];398        a = parseInt(a);399        if(d == 'b'){400          d = 'w';401        }402        else if(d == 'w'){403          d = 'b';404        }405        a -= 10;406        c = d + 'a' + a;407        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){408          f = document.getElementById(c);409          ret = true;410          for(xi in wClassList){411            x = wClassList[xi];412            y = bClassList[xi];413            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){414              rerun_bRook = false;415              ret = false;416            }417            else if(y == f.getAttribute('class')){418              rerun_bRook = false;419            }420          }421          if(ret){422            $(f).addClass('moveable');423          }424        }425        else {426          rerun_bRook = false;427        }428        var a = '';429        d = i[0];430        a += i[2];431        a += i[3];432        a = parseInt(a);433        if(d == 'b'){434          d = 'w';435        }436        else if(d == 'w'){437          d = 'b';438        }439        a -= 1;440        c = d + 'a' + a;441        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){442          f = document.getElementById(c);443          ret = true;444          for(xi in wClassList){445            x = wClassList[xi];446            y = bClassList[xi];447            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){448              rerun_bRook = false;449              ret = false;450            }451            else if(y == f.getAttribute('class')){452              rerun_bRook = false;453            }454          }455          if(ret){456            $(f).addClass('moveable');457          }458        }459        else {460          rerun_bRook = false;461        }462        var a = '';463        d = i[0];464        a += i[2];465        a += i[3];466        a = parseInt(a);467        a += 9;468        c = d + 'a' + a;469        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){470          f = document.getElementById(c);471          ret = true;472          for(xi in wClassList){473            x = wClassList[xi];474            y = bClassList[xi];475            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){476              rerun_bRook = false;477              ret = false;478            }479            else if(y == f.getAttribute('class')){480              rerun_bRook = false;481            }482          }483          if(ret){484            $(f).addClass('moveable');485          }486        }487        else {488          rerun_bRook = false;489        }490        var a = '';491        d = i[0];492        a += i[2];493        a += i[3];494        a = parseInt(a);495        a += 11;496        c = d + 'a' + a;497        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){498          f = document.getElementById(c);499          ret = true;500          for(xi in wClassList){501            x = wClassList[xi];502            y = bClassList[xi];503            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){504              rerun_bRook = false;505              ret = false;506            }507            else if(y == f.getAttribute('class')){508              rerun_bRook = false;509            }510          }511          if(ret){512            $(f).addClass('moveable');513          }514        }515        else {516          rerun_bRook = false;517        }518        var a = '';519        d = i[0];520        a += i[2];521        a += i[3];522        a = parseInt(a);523        a -= 9;524        c = d + 'a' + a;525        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){526          f = document.getElementById(c);527          ret = true;528          for(xi in wClassList){529            x = wClassList[xi];530            y = bClassList[xi];531            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){532              rerun_bRook = false;533              ret = false;534            }535            else if(y == f.getAttribute('class')){536              rerun_bRook = false;537            }538          }539          if(ret){540            $(f).addClass('moveable');541          }542        }543        else {544          rerun_bRook = false;545        }546        var a = '';547        d = i[0];548        a += i[2];549        a += i[3];550        a = parseInt(a);551        a -= 11;552        c = d + 'a' + a;553        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){554          f = document.getElementById(c);555          ret = true;556          for(xi in wClassList){557            x = wClassList[xi];558            y = bClassList[xi];559            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){560              rerun_bRook = false;561              ret = false;562            }563            else if(y == f.getAttribute('class')){564              rerun_bRook = false;565            }566          }567          if(ret){568            $(f).addClass('moveable');569          }570        }571        else {572          rerun_bRook = false;573        }574        if($('.moveable').length > 0){575          $('#' + xcopy).addClass('moveable2')576        }577        $('.moveable').removeClass('moveable');578      }579      else if(x == '.bqueen') {580        x = pawn_id[times];581        pawn_id.pop();582        xcopy = x;583        var i = x;584        var a = '';585        d = i[0];586        a += i[2];587        a += i[3];588        a = parseInt(a);589        rerun_bRook = true;590        while(rerun_bRook){591          if(d == 'b'){592            d = 'w';593          }594          else if(d == 'w'){595            d = 'b';596          }597          a += 10;598          c = d + 'a' + a;599          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){600            f = document.getElementById(c);601            ret = true;602            for(xi in bClassList){603              x = bClassList[xi];604              y = wClassList[xi];605              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){606                rerun_bRook = false;607                ret = false;608              }609              else if(y == f.getAttribute('class')){610                rerun_bRook = false;611              }612            }613            if(ret){614              $(f).addClass('moveable');615            }616          }617          else {618            rerun_bRook = false;619          }620        }621        var a = '';622        d = i[0];623        a += i[2];624        a += i[3];625        a = parseInt(a);626        rerun_bRook = true;627        while(rerun_bRook){628          if(d == 'b'){629            d = 'w';630          }631          else if(d == 'w'){632            d = 'b';633          }634          a += 1;635          c = d + 'a' + a;636          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){637            f = document.getElementById(c);638            ret = true;639            for(xi in bClassList){640              x = bClassList[xi];641              y = wClassList[xi];642              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){643                rerun_bRook = false;644                ret = false;645              }646              else if(y == f.getAttribute('class')){647                rerun_bRook = false;648              }649            }650            if(ret){651              $(f).addClass('moveable');652            }653          }654          else {655            rerun_bRook = false;656          }657        }658        var a = '';659        d = i[0];660        a += i[2];661        a += i[3];662        a = parseInt(a);663        rerun_bRook = true;664        while(rerun_bRook){665          if(d == 'b'){666            d = 'w';667          }668          else if(d == 'w'){669            d = 'b';670          }671          a -= 10;672          c = d + 'a' + a;673          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){674            f = document.getElementById(c);675            ret = true;676            for(xi in bClassList){677              x = bClassList[xi];678              y = wClassList[xi];679              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){680                rerun_bRook = false;681                ret = false;682              }683              else if(y == f.getAttribute('class')){684                rerun_bRook = false;685              }686            }687            if(ret){688              $(f).addClass('moveable');689            }690          }691          else {692            rerun_bRook = false;693          }694        }695        var a = '';696        d = i[0];697        a += i[2];698        a += i[3];699        a = parseInt(a);700        rerun_bRook = true;701        while(rerun_bRook){702          if(d == 'b'){703            d = 'w';704          }705          else if(d == 'w'){706            d = 'b';707          }708          a -= 1;709          c = d + 'a' + a;710          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){711            f = document.getElementById(c);712            ret = true;713            for(xi in bClassList){714              x = bClassList[xi];715              y = wClassList[xi];716              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){717                rerun_bRook = false;718                ret = false;719              }720              else if(y == f.getAttribute('class')){721                rerun_bRook = false;722              }723            }724            if(ret){725              $(f).addClass('moveable');726            }727          }728          else {729            rerun_bRook = false;730          }731        }732        var a = '';733        d = i[0];734        a += i[2];735        a += i[3];736        a = parseInt(a);737        rerun_bRook = true;738        while(rerun_bRook){739          a += 9;740          c = d + 'a' + a;741          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){742            f = document.getElementById(c);743            ret = true;744            for(xi in bClassList){745              x = bClassList[xi];746              y = wClassList[xi];747              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){748                rerun_bRook = false;749                ret = false;750              }751              else if(y == f.getAttribute('class')){752                rerun_bRook = false;753              }754            }755            if(ret){756              $(f).addClass('moveable');757            }758          }759          else {760            rerun_bRook = false;761          }762        }763        var a = '';764        d = i[0];765        a += i[2];766        a += i[3];767        a = parseInt(a);768        rerun_bRook = true;769        while(rerun_bRook){770          a += 11;771          c = d + 'a' + a;772          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){773            f = document.getElementById(c);774            ret = true;775            for(xi in bClassList){776              x = bClassList[xi];777              y = wClassList[xi];778              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){779                rerun_bRook = false;780                ret = false;781              }782              else if(y == f.getAttribute('class')){783                rerun_bRook = false;784              }785            }786            if(ret){787              $(f).addClass('moveable');788            }789          }790          else {791            rerun_bRook = false;792          }793        }794        var a = '';795        d = i[0];796        a += i[2];797        a += i[3];798        a = parseInt(a);799        rerun_bRook = true;800        while(rerun_bRook){801          a -= 9;802          c = d + 'a' + a;803          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){804            f = document.getElementById(c);805            ret = true;806            for(xi in bClassList){807              x = bClassList[xi];808              y = wClassList[xi];809              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){810                rerun_bRook = false;811                ret = false;812              }813              else if(y == f.getAttribute('class')){814                rerun_bRook = false;815              }816            }817            if(ret){818              $(f).addClass('moveable');819            }820          }821          else {822            rerun_bRook = false;823          }824        }825        var a = '';826        d = i[0];827        a += i[2];828        a += i[3];829        a = parseInt(a);830        rerun_bRook = true;831        while(rerun_bRook){832          a -= 11;833          c = d + 'a' + a;834          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){835            f = document.getElementById(c);836            ret = true;837            for(xi in bClassList){838              x = bClassList[xi];839              y = wClassList[xi];840              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){841                rerun_bRook = false;842                ret = false;843              }844              else if(y == f.getAttribute('class')){845                rerun_bRook = false;846              }847            }848            if(ret){849              $(f).addClass('moveable');850            }851          }852          else {853            rerun_bRook = false;854          }855        }856        if($('.moveable').length > 0){857          $('#' + xcopy).addClass('moveable2')858        }859        $('.moveable').removeClass('moveable');860      }861      else if(x == '.wqueen') {862        x = pawn_id[times];863        pawn_id.pop();864        xcopy = x;865        var i = x;866        var a = '';867        d = i[0];868        a += i[2];869        a += i[3];870        a = parseInt(a);871        rerun_bRook = true;872        while(rerun_bRook){873          if(d == 'b'){874            d = 'w';875          }876          else if(d == 'w'){877            d = 'b';878          }879          a += 10;880          c = d + 'a' + a;881          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){882            f = document.getElementById(c);883            ret = true;884            for(xi in wClassList){885              x = wClassList[xi];886              y = bClassList[xi];887              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){888                rerun_bRook = false;889                ret = false;890              }891              else if(y == f.getAttribute('class')){892                rerun_bRook = false;893              }894            }895            if(ret){896              $(f).addClass('moveable');897            }898          }899          else {900            rerun_bRook = false;901          }902        }903        var a = '';904        d = i[0];905        a += i[2];906        a += i[3];907        a = parseInt(a);908        rerun_bRook = true;909        while(rerun_bRook){910          if(d == 'b'){911            d = 'w';912          }913          else if(d == 'w'){914            d = 'b';915          }916          a += 1;917          c = d + 'a' + a;918          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){919            f = document.getElementById(c);920            ret = true;921            for(xi in wClassList){922              x = wClassList[xi];923              y = bClassList[xi];924              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){925                rerun_bRook = false;926                ret = false;927              }928              else if(y == f.getAttribute('class')){929                rerun_bRook = false;930              }931            }932            if(ret){933              $(f).addClass('moveable');934            }935          }936          else {937            rerun_bRook = false;938          }939        }940        var a = '';941        d = i[0];942        a += i[2];943        a += i[3];944        a = parseInt(a);945        rerun_bRook = true;946        while(rerun_bRook){947          if(d == 'b'){948            d = 'w';949          }950          else if(d == 'w'){951            d = 'b';952          }953          a -= 10;954          c = d + 'a' + a;955          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){956            f = document.getElementById(c);957            ret = true;958            for(xi in wClassList){959              x = wClassList[xi];960              y = bClassList[xi];961              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){962                rerun_bRook = false;963                ret = false;964              }965              else if(y == f.getAttribute('class')){966                rerun_bRook = false;967              }968            }969            if(ret){970              $(f).addClass('moveable');971            }972          }973          else {974            rerun_bRook = false;975          }976        }977        var a = '';978        d = i[0];979        a += i[2];980        a += i[3];981        a = parseInt(a);982        rerun_bRook = true;983        while(rerun_bRook){984          if(d == 'b'){985            d = 'w';986          }987          else if(d == 'w'){988            d = 'b';989          }990          a -= 1;991          c = d + 'a' + a;992          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){993            f = document.getElementById(c);994            ret = true;995            for(xi in wClassList){996              x = wClassList[xi];997              y = bClassList[xi];998              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){999                rerun_bRook = false;1000                ret = false;1001              }1002              else if(y == f.getAttribute('class')){1003                rerun_bRook = false;1004              }1005            }1006            if(ret){1007              $(f).addClass('moveable');1008            }1009          }1010          else {1011            rerun_bRook = false;1012          }1013        }1014        var a = '';1015        d = i[0];1016        a += i[2];1017        a += i[3];1018        a = parseInt(a);1019        rerun_bRook = true;1020        while(rerun_bRook){1021          a += 9;1022          c = d + 'a' + a;1023          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1024            f = document.getElementById(c);1025            ret = true;1026            for(xi in wClassList){1027              x = wClassList[xi];1028              y = bClassList[xi];1029              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1030                rerun_bRook = false;1031                ret = false;1032              }1033              else if(y == f.getAttribute('class')){1034                rerun_bRook = false;1035              }1036            }1037            if(ret){1038              $(f).addClass('moveable');1039            }1040          }1041          else {1042            rerun_bRook = false;1043          }1044        }1045        var a = '';1046        d = i[0];1047        a += i[2];1048        a += i[3];1049        a = parseInt(a);1050        rerun_bRook = true;1051        while(rerun_bRook){1052          a += 11;1053          c = d + 'a' + a;1054          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1055            f = document.getElementById(c);1056            ret = true;1057            for(xi in wClassList){1058              x = wClassList[xi];1059              y = bClassList[xi];1060              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1061                rerun_bRook = false;1062                ret = false;1063              }1064              else if(y == f.getAttribute('class')){1065                rerun_bRook = false;1066              }1067            }1068            if(ret){1069              $(f).addClass('moveable');1070            }1071          }1072          else {1073            rerun_bRook = false;1074          }1075        }1076        var a = '';1077        d = i[0];1078        a += i[2];1079        a += i[3];1080        a = parseInt(a);1081        rerun_bRook = true;1082        while(rerun_bRook){1083          a -= 9;1084          c = d + 'a' + a;1085          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1086            f = document.getElementById(c);1087            ret = true;1088            for(xi in wClassList){1089              x = wClassList[xi];1090              y = bClassList[xi];1091              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1092                rerun_bRook = false;1093                ret = false;1094              }1095              else if(y == f.getAttribute('class')){1096                rerun_bRook = false;1097              }1098            }1099            if(ret){1100              $(f).addClass('moveable');1101            }1102          }1103          else {1104            rerun_bRook = false;1105          }1106        }1107        var a = '';1108        d = i[0];1109        a += i[2];1110        a += i[3];1111        a = parseInt(a);1112        rerun_bRook = true;1113        while(rerun_bRook){1114          a -= 11;1115          c = d + 'a' + a;1116          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1117            f = document.getElementById(c);1118            ret = true;1119            for(xi in wClassList){1120              x = wClassList[xi];1121              y = bClassList[xi];1122              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1123                rerun_bRook = false;1124                ret = false;1125              }1126              else if(y == f.getAttribute('class')){1127                rerun_bRook = false;1128              }1129            }1130            if(ret){1131              $(f).addClass('moveable');1132            }1133          }1134          else {1135            rerun_bRook = false;1136          }1137        }1138        if($('.moveable').length > 0){1139          $('#' + xcopy).addClass('moveable2')1140        }1141        $('.moveable').removeClass('moveable');1142      }1143      else if(x == '.bbishop') {1144        x = pawn_id[times];1145        pawn_id.pop();1146        xcopy = x;1147        var i = x;1148        var a = '';1149        d = i[0];1150        a += i[2];1151        a += i[3];1152        a = parseInt(a);1153        rerun_bRook = true;1154        while(rerun_bRook){1155          a += 9;1156          c = d + 'a' + a;1157          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1158            f = document.getElementById(c);1159            ret = true;1160            for(xi in bClassList){1161              x = bClassList[xi];1162              y = wClassList[xi];1163              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1164                rerun_bRook = false;1165                ret = false;1166              }1167              else if(y == f.getAttribute('class')){1168                rerun_bRook = false;1169              }1170            }1171            if(ret){1172              $(f).addClass('moveable');1173            }1174          }1175          else {1176            rerun_bRook = false;1177          }1178        }1179        var a = '';1180        d = i[0];1181        a += i[2];1182        a += i[3];1183        a = parseInt(a);1184        rerun_bRook = true;1185        while(rerun_bRook){1186          a += 11;1187          c = d + 'a' + a;1188          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1189            f = document.getElementById(c);1190            ret = true;1191            for(xi in bClassList){1192              x = bClassList[xi];1193              y = wClassList[xi];1194              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1195                rerun_bRook = false;1196                ret = false;1197              }1198              else if(y == f.getAttribute('class')){1199                rerun_bRook = false;1200              }1201            }1202            if(ret){1203              $(f).addClass('moveable');1204            }1205          }1206          else {1207            rerun_bRook = false;1208          }1209        }1210        var a = '';1211        d = i[0];1212        a += i[2];1213        a += i[3];1214        a = parseInt(a);1215        rerun_bRook = true;1216        while(rerun_bRook){1217          a -= 9;1218          c = d + 'a' + a;1219          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1220            f = document.getElementById(c);1221            ret = true;1222            for(xi in bClassList){1223              x = bClassList[xi];1224              y = wClassList[xi];1225              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1226                rerun_bRook = false;1227                ret = false;1228              }1229              else if(y == f.getAttribute('class')){1230                rerun_bRook = false;1231              }1232            }1233            if(ret){1234              $(f).addClass('moveable');1235            }1236          }1237          else {1238            rerun_bRook = false;1239          }1240        }1241        var a = '';1242        d = i[0];1243        a += i[2];1244        a += i[3];1245        a = parseInt(a);1246        rerun_bRook = true;1247        while(rerun_bRook){1248          a -= 11;1249          c = d + 'a' + a;1250          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1251            f = document.getElementById(c);1252            ret = true;1253            for(xi in bClassList){1254              x = bClassList[xi];1255              y = wClassList[xi];1256              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1257                rerun_bRook = false;1258                ret = false;1259              }1260              else if(y == f.getAttribute('class')){1261                rerun_bRook = false;1262              }1263            }1264            if(ret){1265              $(f).addClass('moveable');1266            }1267          }1268          else {1269            rerun_bRook = false;1270          }1271        }1272        if($('.moveable').length > 0){1273          $('#' + xcopy).addClass('moveable2')1274        }1275        $('.moveable').removeClass('moveable');1276      }1277      else if(x == '.wbishop') {1278        x = pawn_id[times];1279        pawn_id.pop();1280        xcopy = x;1281        var i = x;1282        var a = '';1283        d = i[0];1284        a += i[2];1285        a += i[3];1286        a = parseInt(a);1287        rerun_bRook = true;1288        while(rerun_bRook){1289          a += 9;1290          c = d + 'a' + a;1291          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1292            f = document.getElementById(c);1293            ret = true;1294            for(xi in wClassList){1295              x = wClassList[xi];1296              y = bClassList[xi];1297              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1298                rerun_bRook = false;1299                ret = false;1300              }1301              else if(y == f.getAttribute('class')){1302                rerun_bRook = false;1303              }1304            }1305            if(ret){1306              $(f).addClass('moveable');1307            }1308          }1309          else {1310            rerun_bRook = false;1311          }1312        }1313        var a = '';1314        d = i[0];1315        a += i[2];1316        a += i[3];1317        a = parseInt(a);1318        rerun_bRook = true;1319        while(rerun_bRook){1320          a += 11;1321          c = d + 'a' + a;1322          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1323            f = document.getElementById(c);1324            ret = true;1325            for(xi in wClassList){1326              x = wClassList[xi];1327              y = bClassList[xi];1328              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1329                rerun_bRook = false;1330                ret = false;1331              }1332              else if(y == f.getAttribute('class')){1333                rerun_bRook = false;1334              }1335            }1336            if(ret){1337              $(f).addClass('moveable');1338            }1339          }1340          else {1341            rerun_bRook = false;1342          }1343        }1344        var a = '';1345        d = i[0];1346        a += i[2];1347        a += i[3];1348        a = parseInt(a);1349        rerun_bRook = true;1350        while(rerun_bRook){1351          a -= 9;1352          c = d + 'a' + a;1353          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1354            f = document.getElementById(c);1355            ret = true;1356            for(xi in wClassList){1357              x = wClassList[xi];1358              y = bClassList[xi];1359              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1360                rerun_bRook = false;1361                ret = false;1362              }1363              else if(y == f.getAttribute('class')){1364                rerun_bRook = false;1365              }1366            }1367            if(ret){1368              $(f).addClass('moveable');1369            }1370          }1371          else {1372            rerun_bRook = false;1373          }1374        }1375        var a = '';1376        d = i[0];1377        a += i[2];1378        a += i[3];1379        a = parseInt(a);1380        rerun_bRook = true;1381        while(rerun_bRook){1382          a -= 11;1383          c = d + 'a' + a;1384          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1385            f = document.getElementById(c);1386            ret = true;1387            for(xi in wClassList){1388              x = wClassList[xi];1389              y = bClassList[xi];1390              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1391                rerun_bRook = false;1392                ret = false;1393              }1394              else if(y == f.getAttribute('class')){1395                rerun_bRook = false;1396              }1397            }1398            if(ret){1399              $(f).addClass('moveable');1400            }1401          }1402          else {1403            rerun_bRook = false;1404          }1405        }1406        if($('.moveable').length > 0){1407          $('#' + xcopy).addClass('moveable2')1408        }1409        $('.moveable').removeClass('moveable');1410      }1411      else if(x == '.brook') {1412        x = pawn_id[times];1413        pawn_id.pop();1414        xcopy = x;1415        var i = x;1416        var a = '';1417        d = i[0];1418        a += i[2];1419        a += i[3];1420        a = parseInt(a);1421        rerun_bRook = true;1422        while(rerun_bRook){1423          if(d == 'b'){1424            d = 'w';1425          }1426          else if(d == 'w'){1427            d = 'b';1428          }1429          a += 10;1430          c = d + 'a' + a;1431          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1432            f = document.getElementById(c);1433            ret = true;1434            for(xi in bClassList){1435              x = bClassList[xi];1436              y = wClassList[xi];1437              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1438                rerun_bRook = false;1439                ret = false;1440              }1441              else if(y == f.getAttribute('class')){1442                rerun_bRook = false;1443              }1444            }1445            if(ret){1446              $(f).addClass('moveable');1447            }1448          }1449          else {1450            rerun_bRook = false;1451          }1452        }1453        var a = '';1454        d = i[0];1455        a += i[2];1456        a += i[3];1457        a = parseInt(a);1458        rerun_bRook = true;1459        while(rerun_bRook){1460          if(d == 'b'){1461            d = 'w';1462          }1463          else if(d == 'w'){1464            d = 'b';1465          }1466          a += 1;1467          c = d + 'a' + a;1468          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1469            f = document.getElementById(c);1470            ret = true;1471            for(xi in bClassList){1472              x = bClassList[xi];1473              y = wClassList[xi];1474              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1475                rerun_bRook = false;1476                ret = false;1477              }1478              else if(y == f.getAttribute('class')){1479                rerun_bRook = false;1480              }1481            }1482            if(ret){1483              $(f).addClass('moveable');1484            }1485          }1486          else {1487            rerun_bRook = false;1488          }1489        }1490        var a = '';1491        d = i[0];1492        a += i[2];1493        a += i[3];1494        a = parseInt(a);1495        rerun_bRook = true;1496        while(rerun_bRook){1497          if(d == 'b'){1498            d = 'w';1499          }1500          else if(d == 'w'){1501            d = 'b';1502          }1503          a -= 10;1504          c = d + 'a' + a;1505          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1506            f = document.getElementById(c);1507            ret = true;1508            for(xi in bClassList){1509              x = bClassList[xi];1510              y = wClassList[xi];1511              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1512                rerun_bRook = false;1513                ret = false;1514              }1515              else if(y == f.getAttribute('class')){1516                rerun_bRook = false;1517              }1518            }1519            if(ret){1520              $(f).addClass('moveable');1521            }1522          }1523          else {1524            rerun_bRook = false;1525          }1526        }1527        var a = '';1528        d = i[0];1529        a += i[2];1530        a += i[3];1531        a = parseInt(a);1532        rerun_bRook = true;1533        while(rerun_bRook){1534          if(d == 'b'){1535            d = 'w';1536          }1537          else if(d == 'w'){1538            d = 'b';1539          }1540          a -= 1;1541          c = d + 'a' + a;1542          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1543            f = document.getElementById(c);1544            ret = true;1545            for(xi in bClassList){1546              x = bClassList[xi];1547              y = wClassList[xi];1548              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1549                rerun_bRook = false;1550                ret = false;1551              }1552              else if(y == f.getAttribute('class')){1553                rerun_bRook = false;1554              }1555            }1556            if(ret){1557              $(f).addClass('moveable');1558            }1559          }1560          else {1561            rerun_bRook = false;1562          }1563        }1564        if($('.moveable').length > 0){1565          $('#' + xcopy).addClass('moveable2')1566        }1567        $('.moveable').removeClass('moveable');1568      }1569      else if(x == '.wrook') {1570        x = pawn_id[times];1571        pawn_id.pop();1572        xcopy = x;1573        var i = x;1574        var a = '';1575        d = i[0];1576        a += i[2];1577        a += i[3];1578        a = parseInt(a);1579        rerun_wRook = true;1580        while(rerun_wRook){1581          if(d == 'b'){1582            d = 'w';1583          }1584          else if(d == 'w'){1585            d = 'b';1586          }1587          a += 10;1588          c = d + 'a' + a;1589          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1590            f = document.getElementById(c);1591            ret = true;1592            for(xi in wClassList){1593              x = wClassList[xi];1594              y = bClassList[xi];1595              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1596                rerun_wRook = false;1597                ret = false;1598              }1599              else if(y == f.getAttribute('class')){1600                rerun_wRook = false;1601              }1602            }1603            if(ret){1604              $(f).addClass('moveable');1605            }1606          }1607          else {1608            rerun_wRook = false;1609          }1610        }1611        var a = '';1612        d = i[0];1613        a += i[2];1614        a += i[3];1615        a = parseInt(a);1616        rerun_wRook = true;1617        while(rerun_wRook){1618          if(d == 'b'){1619            d = 'w';1620          }1621          else if(d == 'w'){1622            d = 'b';1623          }1624          a += 1;1625          c = d + 'a' + a;1626          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1627            f = document.getElementById(c);1628            ret = true;1629            for(xi in wClassList){1630              x = wClassList[xi];1631              y = bClassList[xi];1632              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1633                rerun_wRook = false;1634                ret = false;1635              }1636              else if(y == f.getAttribute('class')){1637                rerun_wRook = false;1638              }1639            }1640            if(ret){1641              $(f).addClass('moveable');1642            }1643          }1644          else {1645            rerun_wRook = false;1646          }1647        }1648        var a = '';1649        d = i[0];1650        a += i[2];1651        a += i[3];1652        a = parseInt(a);1653        rerun_wRook = true;1654        while(rerun_wRook){1655          if(d == 'b'){1656            d = 'w';1657          }1658          else if(d == 'w'){1659            d = 'b';1660          }1661          a -= 10;1662          c = d + 'a' + a;1663          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1664            f = document.getElementById(c);1665            ret = true;1666            for(xi in wClassList){1667              x = wClassList[xi];1668              y = bClassList[xi];1669              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1670                rerun_wRook = false;1671                ret = false;1672              }1673              else if(y == f.getAttribute('class')){1674                rerun_wRook = false;1675              }1676            }1677            if(ret){1678              $(f).addClass('moveable');1679            }1680          }1681          else {1682            rerun_wRook = false;1683          }1684        }1685        var a = '';1686        d = i[0];1687        a += i[2];1688        a += i[3];1689        a = parseInt(a);1690        rerun_wRook = true;1691        while(rerun_wRook){1692          if(d == 'b'){1693            d = 'w';1694          }1695          else if(d == 'w'){1696            d = 'b';1697          }1698          a -= 1;1699          c = d + 'a' + a;1700          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){1701            f = document.getElementById(c);1702            ret = true;1703            for(xi in wClassList){1704              x = wClassList[xi];1705              y = bClassList[xi];1706              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){1707                rerun_wRook = false;1708                ret = false;1709              }1710              else if(y == f.getAttribute('class')){1711                rerun_wRook = false;1712              }1713            }1714            if(ret){1715              $(f).addClass('moveable');1716            }1717          }1718          else {1719            rerun_wRook = false;1720          }1721        }1722        if($('.moveable').length > 0) {1723          $('#' + xcopy).addClass('moveable2')1724        }1725        $('.moveable').removeClass('moveable');1726      }1727      else if(x == '.bknight') {1728        x = pawn_id[times];1729        pawn_id.pop();1730        xcopy = x;1731        var i = x;1732        var a = '';1733        a += i[2];1734        a += i[3];1735        a = parseInt(a);1736        a += 21;1737        if(i[0] == 'b'){1738          d = 'w'1739        }1740        else if(i[0] == 'w'){1741          d = 'b'1742        }1743        c = d + 'a' + a;1744        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1745          ret = true;1746          for(xi in bClassList){1747            x = bClassList[xi]1748            if(x == document.getElementById(c).getAttribute('class')){1749              1750              ret = false;1751            }1752          }1753          if(ret) {1754            f = document.getElementById(c);1755            $(f).addClass('moveable');1756          }1757        }1758        a = a - 2;1759        c = d + 'a' + a;1760        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1761          ret = true;1762          for(xi in bClassList){1763            x = bClassList[xi]1764            if(x == document.getElementById(c).getAttribute('class')){1765              1766              ret = false;1767            }1768          }1769          if(ret) {1770            f = document.getElementById(c);1771            $(f).addClass('moveable');1772          }1773        }1774        a = a - 11;1775        c = d + 'a' + a;1776        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1777          ret = true;1778          for(xi in bClassList){ 1779            x = bClassList[xi]1780            if(x == document.getElementById(c).getAttribute('class')){1781              1782              ret = false;1783            }1784          }1785          if(ret) {1786            f = document.getElementById(c);1787            $(f).addClass('moveable');1788          }1789        }1790        a = a - 20;1791        c = d + 'a' + a;1792        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1793          ret = true;1794          for(xi in bClassList){ 1795            x = bClassList[xi]1796            if(x == document.getElementById(c).getAttribute('class')){1797              1798              ret = false;1799            }1800          }1801          if(ret) {1802            f = document.getElementById(c);1803            $(f).addClass('moveable');1804          }1805        }1806        a = a - 9;1807        c = d + 'a' + a;1808        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1809          ret = true;1810          for(xi in bClassList){ 1811            x = bClassList[xi]1812            if(x == document.getElementById(c).getAttribute('class')){1813              ret = false;1814              1815            }1816          }1817          if(ret) {1818            f = document.getElementById(c);1819            $(f).addClass('moveable');1820          }1821        }1822        a = a + 2;1823        c = d + 'a' + a;1824        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1825          ret = true;1826          for(xi in bClassList){1827            x = bClassList[xi]1828            if(x == document.getElementById(c).getAttribute('class')){1829              ret = false;1830              1831            }1832          }1833          if(ret) {1834            f = document.getElementById(c);1835            $(f).addClass('moveable');1836          }1837        }1838        a = a + 11;1839        c = d + 'a' + a;1840        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1841          ret = true;1842          for(xi in bClassList){ 1843            x = bClassList[xi]1844            if(x == document.getElementById(c).getAttribute('class')){1845              ret = false;1846              1847            }1848          }1849          if(ret) {1850            f = document.getElementById(c);1851            $(f).addClass('moveable');1852          }1853        }1854        a = a + 20;1855        c = d + 'a' + a;1856        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1857          ret = true;1858          for(xi in bClassList){ 1859            x = bClassList[xi]1860            if(x == document.getElementById(c).getAttribute('class')){1861              ret = false;1862            }1863          }1864          if(ret) {1865            f = document.getElementById(c);1866            $(f).addClass('moveable');1867          }1868        }1869        if($('.moveable').length > 0){1870          $('#' + xcopy).addClass('moveable2')1871        }1872        $('.moveable').removeClass('moveable');1873      }1874      else if(x == '.wknight') {1875        x = pawn_id[times];1876        pawn_id.pop();1877        xcopy = x;1878        var i = x;1879        var a = '';1880        a += i[2];1881        a += i[3];1882        a = parseInt(a);1883        a += 21;1884        if(i[0] == 'b'){1885          d = 'w'1886        }1887        else if(i[0] == 'w'){1888          d = 'b'1889        }1890        c = d + 'a' + a;1891        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1892          ret = true;1893          for(xi in wClassList){1894            x = wClassList[xi]1895            if(x == document.getElementById(c).getAttribute('class')){1896              1897              ret = false;1898            }1899          }1900          if(ret) {1901            f = document.getElementById(c);1902            $(f).addClass('moveable');1903          }1904        }1905        a = a - 2;1906        c = d + 'a' + a;1907        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1908          ret = true;1909          for(xi in wClassList){1910            x = wClassList[xi]1911            if(x == document.getElementById(c).getAttribute('class')){1912              1913              ret = false;1914            }1915          }1916          if(ret) {1917            f = document.getElementById(c);1918            $(f).addClass('moveable');1919          }1920        }1921        a = a - 11;1922        c = d + 'a' + a;1923        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1924          ret = true;1925          for(xi in wClassList){ 1926            x = wClassList[xi]1927            if(x == document.getElementById(c).getAttribute('class')){1928              1929              ret = false;1930            }1931          }1932          if(ret) {1933            f = document.getElementById(c);1934            $(f).addClass('moveable');1935          }1936        }1937        a = a - 20;1938        c = d + 'a' + a;1939        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1940          ret = true;1941          for(xi in wClassList){ 1942            x = wClassList[xi]1943            if(x == document.getElementById(c).getAttribute('class')){1944              1945              ret = false;1946            }1947          }1948          if(ret) {1949            f = document.getElementById(c);1950            $(f).addClass('moveable');1951          }1952        }1953        a = a - 9;1954        c = d + 'a' + a;1955        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1956          ret = true;1957          for(xi in wClassList){ 1958            x = wClassList[xi]1959            if(x == document.getElementById(c).getAttribute('class')){1960              ret = false;1961              1962            }1963          }1964          if(ret) {1965            f = document.getElementById(c);1966            $(f).addClass('moveable');1967          }1968        }1969        a = a + 2;1970        c = d + 'a' + a;1971        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1972          ret = true;1973          for(xi in wClassList){1974            x = wClassList[xi]1975            if(x == document.getElementById(c).getAttribute('class')){1976              ret = false;1977              1978            }1979          }1980          if(ret) {1981            f = document.getElementById(c);1982            $(f).addClass('moveable');1983          }1984        }1985        a = a + 11;1986        c = d + 'a' + a;1987        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {1988          ret = true;1989          for(xi in wClassList){ 1990            x = wClassList[xi]1991            if(x == document.getElementById(c).getAttribute('class')){1992              ret = false;1993              1994            }1995          }1996          if(ret) {1997            f = document.getElementById(c);1998            $(f).addClass('moveable');1999          }2000        }2001        a = a + 20;2002        c = d + 'a' + a;2003        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2004          ret = true;2005          for(xi in wClassList){ 2006            x = wClassList[xi]2007            if(x == document.getElementById(c).getAttribute('class')){2008              ret = false;2009            }2010          }2011          if(ret) {2012            f = document.getElementById(c);2013            $(f).addClass('moveable');2014          }2015        }2016        if($('.moveable').length > 0){2017          $('#' + xcopy).addClass('moveable2')2018        }2019        $('.moveable').removeClass('moveable');2020      }2021      else if(x == '.bpawn') {2022        x = pawn_id[times];2023        pawn_id.pop();2024        xcopy = x;2025        var i = x;2026        var a = '';2027        a += i[2];2028        a += i[3];2029        a = parseInt(a);2030        if(i[0] == 'b'){2031          d = 'w';2032        }2033        else if(i[0] == 'w'){2034          d = 'b';2035        }2036        a += 10;2037        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2038          c = d + 'a' + a;2039          c1 = d + 'a' + a;2040          c2 = d + 'a' + a;2041          if(d == 'b'){2042            d = 'w';2043          }2044          else if(d == 'w'){2045            d = 'b';2046          }2047          if(a-1 > 10 && a-1 < 89 && (a-1) % 10 != 9 && (a-1) % 10 != 0){2048            c1 = d + 'a' + (a - 1);2049          }2050          if(a+1 > 10 && a+1 < 89 && (a+1) % 10 != 9 && (a+1) % 10 != 0){2051            c2 = d + 'a' + (a + 1);2052          }2053          if(d == 'b'){2054            d = 'w';2055          }2056          else if(d == 'w'){2057            d = 'b';2058          }2059          f = document.getElementById(c);2060          if(c1 != c){2061            f1 = document.getElementById(c1);2062          }2063          if(c2 != c){2064            f2 = document.getElementById(c2);2065          }2066          ret = true;2067          ret1 = false;2068          ret2 = false;2069          for(xi in wClassList){2070            x = wClassList[xi];2071            y = bClassList[xi];2072            if(f.getAttribute('class') == y || f.getAttribute('class') == y + ' moveable2'){2073              ret = false;2074            }2075            if(f.getAttribute('class') == x || f.getAttribute('class') == x + ' moveable2'){2076              ret = false;2077            }2078            if(c1 != c){2079              if(x == f1.getAttribute('class')){2080                ret1 = true;2081              }2082            }2083            if(c2 != c){2084              if(x == f2.getAttribute('class')){2085                ret2 = true;2086              }2087            }2088          }2089          if(ret){2090            $(f).addClass('moveable');2091          }2092          if(ret1){2093            $(f1).addClass('moveable');2094          }2095          if(ret2){2096            $(f2).addClass('moveable');2097          }2098        }2099        if($('.moveable').length > 0){2100          $('#' + xcopy).addClass('moveable2')2101        }2102        $('.moveable').removeClass('moveable');2103      }2104      else if(x == '.wpawn') {2105        x = pawn_id[times];2106        pawn_id.pop();2107        xcopy = x;2108        var i = x;2109        var a = '';2110        a += i[2];2111        a += i[3];2112        a = parseInt(a);2113        if(i[0] == 'b'){2114          d = 'w';2115        }2116        else if(i[0] == 'w'){2117          d = 'b';2118        }2119        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2120          a -= 10;2121          c = d + 'a' + a;2122          c1 = d + 'a' + a;2123          c2 = d + 'a' + a;2124          if(d == 'b'){2125            d = 'w';2126          }2127          else if(d == 'w'){2128            d = 'b';2129          }2130          if(a-1 > 10 && a-1 < 89 && (a-1) % 10 != 9 && (a-1) % 10 != 0){2131            c1 = d + 'a' + (a - 1);2132          }2133          if(a+1 > 10 && a+1 < 89 && (a+1) % 10 != 9 && (a+1) % 10 != 0){2134            c2 = d + 'a' + (a + 1);2135          }2136          if(d == 'b'){2137            d = 'w';2138          }2139          else if(d == 'w'){2140            d = 'b';2141          }2142          f = document.getElementById(c);2143          if(c1 != c){2144            f1 = document.getElementById(c1);2145          }2146          if(c2 != c){2147            f2 = document.getElementById(c2);2148          }2149          ret = true;2150          ret1 = false;2151          ret2 = false;2152          for(xi in bClassList){2153            x = bClassList[xi];2154            y = wClassList[xi];2155            if(f.getAttribute('class') == y || f.getAttribute('class') == y + ' moveable2'){2156              ret = false;2157            }2158            if(f.getAttribute('class') == x || f.getAttribute('class') == x + ' moveable2'){2159              ret = false;2160            }2161            if(c1 != c){2162              if(x == f1.getAttribute('class')){2163                ret1 = true;2164              }2165            }2166            if(c2 != c){2167              if(x == f2.getAttribute('class')){2168                ret2 = true;2169              }2170            }2171          }2172          if(ret){2173            $(f).addClass('moveable');2174          }2175          if(ret1){2176            $(f1).addClass('moveable');2177          }2178          if(ret2){2179            $(f2).addClass('moveable');2180          }2181        }2182        if($('.moveable').length > 0){2183          $('#' + xcopy).addClass('moveable2');2184        }2185        $('.moveable').removeClass('moveable');2186      }2187    }2188    function refresh() {2189      location.replace('../chessGame');2190    }2191    if($('.bking').length < 1) {2192      alert('WHITE WINS!!!!!!');2193      refresh();2194    }2195    else if($('.wking').length < 1) {2196      alert('BLACK WINS!!!!!!');2197      refresh();2198    }2199    $('.bknight').on('click', function() {2200      if(others && bturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2201        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});2202        others = false;2203        $(this).off('click');2204        var i = this.id;2205        var b = this;2206        var a = '';2207        a += i[2];2208        a += i[3];2209        a = parseInt(a);2210        a += 21;2211        if(i[0] == 'b'){2212          d = 'w'2213        }2214        else if(i[0] == 'w'){2215          d = 'b'2216        }2217        c = d + 'a' + a;2218        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2219          ret = true;2220          for(xi in bClassList){2221            x = bClassList[xi]2222            if(x == document.getElementById(c).getAttribute('class')){2223              ret = false;2224            }2225          }2226          if(ret) {2227            f = document.getElementById(c);2228            $(f).addClass('moveable');2229          }2230        }2231        a = a - 2;2232        c = d + 'a' + a;2233        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2234          ret = true;2235          for(xi in bClassList){2236            x = bClassList[xi]2237            if(x == document.getElementById(c).getAttribute('class')){2238              2239              ret = false;2240            }2241          }2242          if(ret) {2243            f = document.getElementById(c);2244            $(f).addClass('moveable');2245          }2246        }2247        a = a - 11;2248        c = d + 'a' + a;2249        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2250          ret = true;2251          for(xi in bClassList){ 2252            x = bClassList[xi]2253            if(x == document.getElementById(c).getAttribute('class')){2254              2255              ret = false;2256            }2257          }2258          if(ret) {2259            f = document.getElementById(c);2260            $(f).addClass('moveable');2261          }2262        }2263        a = a - 20;2264        c = d + 'a' + a;2265        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2266          ret = true;2267          for(xi in bClassList){ 2268            x = bClassList[xi]2269            if(x == document.getElementById(c).getAttribute('class')){2270              2271              ret = false;2272            }2273          }2274          if(ret) {2275            f = document.getElementById(c);2276            $(f).addClass('moveable');2277          }2278        }2279        a = a - 9;2280        c = d + 'a' + a;2281        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2282          ret = true;2283          for(xi in bClassList){ 2284            x = bClassList[xi]2285            if(x == document.getElementById(c).getAttribute('class')){2286              ret = false;2287              2288            }2289          }2290          if(ret) {2291            f = document.getElementById(c);2292            $(f).addClass('moveable');2293          }2294        }2295        a = a + 2;2296        c = d + 'a' + a;2297        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2298          ret = true;2299          for(xi in bClassList){2300            x = bClassList[xi]2301            if(x == document.getElementById(c).getAttribute('class')){2302              ret = false;2303              2304            }2305          }2306          if(ret) {2307            f = document.getElementById(c);2308            $(f).addClass('moveable');2309          }2310        }2311        a = a + 11;2312        c = d + 'a' + a;2313        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2314          ret = true;2315          for(xi in bClassList){ 2316            x = bClassList[xi]2317            if(x == document.getElementById(c).getAttribute('class')){2318              ret = false;2319              2320            }2321          }2322          if(ret) {2323            f = document.getElementById(c);2324            $(f).addClass('moveable');2325          }2326        }2327        a = a + 20;2328        c = d + 'a' + a;2329        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {2330          ret = true;2331          for(xi in bClassList){ 2332            x = bClassList[xi]2333            if(x == document.getElementById(c).getAttribute('class')){2334              ret = false;2335              2336            }2337          }2338          if(ret) {2339            f = document.getElementById(c);2340            $(f).addClass('moveable');2341          }2342        }2343        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});2344        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2345          add = true;2346          $(b).removeClass('bknight');2347          for(xi in wClassList){2348            x = wClassList[xi]2349            if(x == 'wking') {2350              idd = this.id;2351              f = document.getElementById(idd);2352              if(f.getAttribute('class') == 'wking') {2353                add = false;2354              }2355            }2356            $(this).removeClass(x);2357          }2358          if(add){2359            $(this).addClass('bknight');2360          }2361          $('.moveable').off('click');2362          $('.moveable').removeClass('moveable');2363          others = true;2364          bturn = false;2365          wturn = true;2366          run();2367        });2368      }2369    });2370    $('.bpawn').on('click', function() {2371      if(others && bturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2372        others = false;2373        $(this).off('click');2374        var i = this.id;2375        var b = this;2376        var a = '';2377        a += i[2];2378        a += i[3];2379        a = parseInt(a)2380        if(i[0] == 'b'){2381          d = 'w'2382        }2383        else if(i[0] == 'w'){2384          d = 'b'2385        }2386        if(a > 20 && a < 29 ){2387          a += 10;2388          var c = d + 'a' + a;2389          c1 = d + 'a' + a;2390          c2 = d + 'a' + a;2391          if(d == 'b'){2392            d = 'w'2393          }2394          else if(d == 'w'){2395            d = 'b'2396          }2397          if(a-1 > 10 && a-1 < 89 && (a-1) % 10 != 9 && (a-1) % 10 != 0){2398            c1 = d + 'a' + (a - 1);2399          }2400          if(a+1 > 10 && a+1 < 89 && (a+1) % 10 != 9 && (a+1) % 10 != 0){2401            c2 = d + 'a' + (a + 1);2402          }2403          if(d == 'b'){2404            d = 'w'2405          }2406          else if(d == 'w'){2407            d = 'b'2408          }2409          f = document.getElementById(c);2410          if(c1 != c){2411            f1 = document.getElementById(c1);2412          }2413          if(c2 != c){2414            f2 = document.getElementById(c2);2415          }2416          ret = true;2417          ret1 = false;2418          ret2 = false;2419          for(xi in wClassList){2420            x = wClassList[xi];2421            y = bClassList[xi];2422            if(f.getAttribute('class') == y || f.getAttribute('class') == y + ' moveable2'){2423              ret = false;2424            }2425            if(f.getAttribute('class') == x || f.getAttribute('class') == x + ' moveable2'){2426              ret = false;2427            }2428            if(c1 != c){2429              if(x == f1.getAttribute('class')){2430                ret1 = true;2431              }2432            }2433            if(c2 != c){2434              if(x == f2.getAttribute('class')){2435                ret2 = true;2436              }2437            }2438          }2439          if(ret){2440            $(f).addClass('moveable');2441          }2442          if(ret1){2443            $(f1).addClass('moveable');2444          }2445          if(ret2){2446            $(f2).addClass('moveable');2447          }2448          if(d == 'b'){2449            d = 'w'2450          }2451          else if(d == 'w'){2452            d = 'b'2453          }2454          a += 10;2455          c = d + 'a' + a;2456          f = document.getElementById(c);2457          for(xi in bClassList){2458            x = bClassList[xi];2459            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2460              ret = false;2461            }2462          }2463          if(ret){2464            $(f).addClass('moveable');2465          }2466        }2467        else if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2468          a += 10;2469          c = d + 'a' + a;2470          c1 = d + 'a' + a;2471          c2 = d + 'a' + a;2472          if(d == 'b'){2473            d = 'w'2474          }2475          else if(d == 'w'){2476            d = 'b'2477          }2478          if(a-1 > 10 && a-1 < 89 && (a-1) % 10 != 9 && (a-1) % 10 != 0){2479            c1 = d + 'a' + (a - 1);2480          }2481          if(a+1 > 10 && a+1 < 89 && (a+1) % 10 != 9 && (a+1) % 10 != 0){2482            c2 = d + 'a' + (a + 1);2483          }2484          if(d == 'b'){2485            d = 'w'2486          }2487          else if(d == 'w'){2488            d = 'b'2489          }2490          f = document.getElementById(c);2491          if(c1 != c){2492            f1 = document.getElementById(c1);2493          }2494          if(c2 != c){2495            f2 = document.getElementById(c2);2496          }2497          ret = true;2498          ret1 = false;2499          ret2 = false;2500          for(xi in wClassList){2501            x = wClassList[xi];2502            y = bClassList[xi];2503            if(f.getAttribute('class') == y || f.getAttribute('class') == y + ' moveable2'){2504              ret = false;2505            }2506            if(f.getAttribute('class') == x || f.getAttribute('class') == x + ' moveable2'){2507              ret = false;2508            }2509            if(c1 != c){2510              if(x == f1.getAttribute('class')){2511                ret1 = true;2512              }2513            }2514            if(c2 != c){2515              if(x == f2.getAttribute('class')){2516                ret2 = true;2517              }2518            }2519          }2520          if(ret){2521            $(f).addClass('moveable');2522          }2523          if(ret1){2524            $(f1).addClass('moveable');2525          }2526          if(ret2){2527            $(f2).addClass('moveable');2528          }2529        }2530        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});2531        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2532          $(this).off('click');2533          $(b).removeClass('bpawn');2534          $('.moveable').off('click');2535          a = '';2536          i = this.id;2537          a += i[2];2538          a += i[3];2539          add = true;2540          for(xi in wClassList){2541            x = wClassList[xi]2542            if(x == 'wking') {2543              idd = this.id;2544              f = document.getElementById(idd);2545              if(f.getAttribute('class') == 'wking') {2546                add = false;2547              }2548            }2549            $(this).removeClass(x);2550          }2551          if(a > 80 && a < 89 && add) {2552            $(this).addClass('bqueen');2553          }2554          else if(add){2555            $(this).addClass('bpawn');2556          }2557          $('.moveable').removeClass('moveable');2558          others = true;2559          bturn = false;2560          wturn = true;2561          run();2562        });2563      }2564    });2565    $('.brook').on('click', function() {2566      if(others && bturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2567        others = false;2568        $(this).off('click');2569        var i = this.id;2570        var b = this;2571        var a = '';2572        d = i[0];2573        a += i[2];2574        a += i[3];2575        a = parseInt(a);2576        rerun_bRook = true;2577        while(rerun_bRook){2578          if(d == 'b'){2579            d = 'w';2580          }2581          else if(d == 'w'){2582            d = 'b';2583          }2584          a += 10;2585          c = d + 'a' + a;2586          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2587            f = document.getElementById(c);2588            ret = true;2589            for(xi in bClassList){2590              x = bClassList[xi];2591              y = wClassList[xi];2592              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2593                rerun_bRook = false;2594                ret = false;2595              }2596              else if(y == f.getAttribute('class')){2597                rerun_bRook = false;2598              }2599            }2600            if(ret){2601              $(f).addClass('moveable');2602            }2603          }2604          else {2605            rerun_bRook = false;2606          }2607        }2608        var a = '';2609        d = i[0];2610        a += i[2];2611        a += i[3];2612        a = parseInt(a);2613        rerun_bRook = true;2614        while(rerun_bRook){2615          if(d == 'b'){2616            d = 'w';2617          }2618          else if(d == 'w'){2619            d = 'b';2620          }2621          a += 1;2622          c = d + 'a' + a;2623          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2624            f = document.getElementById(c);2625            ret = true;2626            for(xi in bClassList){2627              x = bClassList[xi];2628              y = wClassList[xi];2629              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2630                rerun_bRook = false;2631                ret = false;2632              }2633              else if(y == f.getAttribute('class')){2634                rerun_bRook = false;2635              }2636            }2637            if(ret){2638              $(f).addClass('moveable');2639            }2640          }2641          else {2642            rerun_bRook = false;2643          }2644        }2645        var a = '';2646        d = i[0];2647        a += i[2];2648        a += i[3];2649        a = parseInt(a);2650        rerun_bRook = true;2651        while(rerun_bRook){2652          if(d == 'b'){2653            d = 'w';2654          }2655          else if(d == 'w'){2656            d = 'b';2657          }2658          a -= 10;2659          c = d + 'a' + a;2660          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2661            f = document.getElementById(c);2662            ret = true;2663            for(xi in bClassList){2664              x = bClassList[xi];2665              y = wClassList[xi];2666              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2667                rerun_bRook = false;2668                ret = false;2669              }2670              else if(y == f.getAttribute('class')){2671                rerun_bRook = false;2672              }2673            }2674            if(ret){2675              $(f).addClass('moveable');2676            }2677          }2678          else {2679            rerun_bRook = false;2680          }2681        }2682        var a = '';2683        d = i[0];2684        a += i[2];2685        a += i[3];2686        a = parseInt(a);2687        rerun_bRook = true;2688        while(rerun_bRook){2689          if(d == 'b'){2690            d = 'w';2691          }2692          else if(d == 'w'){2693            d = 'b';2694          }2695          a -= 1;2696          c = d + 'a' + a;2697          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2698            f = document.getElementById(c);2699            ret = true;2700            for(xi in bClassList){2701              x = bClassList[xi];2702              y = wClassList[xi];2703              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2704                rerun_bRook = false;2705                ret = false;2706              }2707              else if(y == f.getAttribute('class')){2708                rerun_bRook = false;2709              }2710            }2711            if(ret){2712              $(f).addClass('moveable');2713            }2714          }2715          else {2716            rerun_bRook = false;2717          }2718        }2719        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});2720        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2721          $(this).off('click');2722          $(b).removeClass('brook');2723          $('.moveable').off('click');2724          a = '';2725          i = this.id;2726          a += i[2];2727          a += i[3];2728          f = document.getElementsByClassName('bking')[0];2729          if(a == '13' && f.getAttribute('id') == 'wa14'){2730            mking = true;2731          }2732          else {2733            mking = false;2734          }2735          add = true;2736          for(xi in wClassList){2737            x = wClassList[xi];2738            if(x == 'wking') {2739              idd = this.id;2740              f = document.getElementById(idd);2741              if(f.getAttribute('class') == 'wking') {2742                add = false;2743              }2744            }2745            $(this).removeClass(x);2746          }2747          if(add){2748            $(this).addClass('brook');2749          }2750          $(this).addClass('brook');2751          if(mking) {2752            $('#wa12').addClass('bking');2753            $('#wa14').removeClass('bking');2754          }2755          $('.moveable').removeClass('moveable');2756          others = true;2757          bturn = false;2758          wturn = true;2759          run();2760        });2761      }2762    });2763    $('.bbishop').on('click', function() {2764      if(others && bturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2765        others = false;2766        $(this).off('click');2767        var i = this.id;2768        var b = this;2769        var a = '';2770        d = i[0];2771        a += i[2];2772        a += i[3];2773        a = parseInt(a);2774        rerun_bRook = true;2775        while(rerun_bRook){2776          a += 9;2777          c = d + 'a' + a;2778          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2779            f = document.getElementById(c);2780            ret = true;2781            for(xi in bClassList){2782              x = bClassList[xi];2783              y = wClassList[xi];2784              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2785                rerun_bRook = false;2786                ret = false;2787              }2788              else if(y == f.getAttribute('class')){2789                rerun_bRook = false;2790              }2791            }2792            if(ret){2793              $(f).addClass('moveable');2794            }2795          }2796          else {2797            rerun_bRook = false;2798          }2799        }2800        var a = '';2801        d = i[0];2802        a += i[2];2803        a += i[3];2804        a = parseInt(a);2805        rerun_bRook = true;2806        while(rerun_bRook){2807          a += 11;2808          c = d + 'a' + a;2809          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2810            f = document.getElementById(c);2811            ret = true;2812            for(xi in bClassList){2813              x = bClassList[xi];2814              y = wClassList[xi];2815              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2816                rerun_bRook = false;2817                ret = false;2818              }2819              else if(y == f.getAttribute('class')){2820                rerun_bRook = false;2821              }2822            }2823            if(ret){2824              $(f).addClass('moveable');2825            }2826          }2827          else {2828            rerun_bRook = false;2829          }2830        }2831        var a = '';2832        d = i[0];2833        a += i[2];2834        a += i[3];2835        a = parseInt(a);2836        rerun_bRook = true;2837        while(rerun_bRook){2838          a -= 9;2839          c = d + 'a' + a;2840          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2841            f = document.getElementById(c);2842            ret = true;2843            for(xi in bClassList){2844              x = bClassList[xi];2845              y = wClassList[xi];2846              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2847                rerun_bRook = false;2848                ret = false;2849              }2850              else if(y == f.getAttribute('class')){2851                rerun_bRook = false;2852              }2853            }2854            if(ret){2855              $(f).addClass('moveable');2856            }2857          }2858          else {2859            rerun_bRook = false;2860          }2861        }2862        var a = '';2863        d = i[0];2864        a += i[2];2865        a += i[3];2866        a = parseInt(a);2867        rerun_bRook = true;2868        while(rerun_bRook){2869          a -= 11;2870          c = d + 'a' + a;2871          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2872            f = document.getElementById(c);2873            ret = true;2874            for(xi in bClassList){2875              x = bClassList[xi];2876              y = wClassList[xi];2877              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2878                rerun_bRook = false;2879                ret = false;2880              }2881              else if(y == f.getAttribute('class')){2882                rerun_bRook = false;2883              }2884            }2885            if(ret){2886              $(f).addClass('moveable');2887            }2888          }2889          else {2890            rerun_bRook = false;2891          }2892        }2893        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});2894        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2895          $(this).off('click');2896          $(b).removeClass('bbishop');2897          $('.moveable').off('click');2898          a = '';2899          i = this.id;2900          a += i[2];2901          a += i[3];2902          add = true;2903          for(xi in wClassList){2904            x = wClassList[xi];2905            if(x == 'wking') {2906              idd = this.id;2907              f = document.getElementById(idd);2908              if(f.getAttribute('class') == 'wking') {2909                add = false;2910              }2911            }2912            $(this).removeClass(x);2913          }2914          if(add){2915            $(this).addClass('bbishop');2916          }2917          $(this).addClass('bbishop');2918          $('.moveable').removeClass('moveable');2919          others = true;2920          bturn = false;2921          wturn = true;2922          run();2923        });2924      }2925    });2926    $('.bqueen').on('click', function() {2927      if(others && bturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');2928        others = false;2929        $(this).off('click');2930        var i = this.id;2931        var b = this;2932        var a = '';2933        d = i[0];2934        a += i[2];2935        a += i[3];2936        a = parseInt(a);2937        rerun_bRook = true;2938        while(rerun_bRook){2939          if(d == 'b'){2940            d = 'w';2941          }2942          else if(d == 'w'){2943            d = 'b';2944          }2945          a += 10;2946          c = d + 'a' + a;2947          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2948            f = document.getElementById(c);2949            ret = true;2950            for(xi in bClassList){2951              x = bClassList[xi];2952              y = wClassList[xi];2953              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2954                rerun_bRook = false;2955                ret = false;2956              }2957              else if(y == f.getAttribute('class')){2958                rerun_bRook = false;2959              }2960            }2961            if(ret){2962              $(f).addClass('moveable');2963            }2964          }2965          else {2966            rerun_bRook = false;2967          }2968        }2969        var a = '';2970        d = i[0];2971        a += i[2];2972        a += i[3];2973        a = parseInt(a);2974        rerun_bRook = true;2975        while(rerun_bRook){2976          if(d == 'b'){2977            d = 'w';2978          }2979          else if(d == 'w'){2980            d = 'b';2981          }2982          a += 1;2983          c = d + 'a' + a;2984          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){2985            f = document.getElementById(c);2986            ret = true;2987            for(xi in bClassList){2988              x = bClassList[xi];2989              y = wClassList[xi];2990              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){2991                rerun_bRook = false;2992                ret = false;2993              }2994              else if(y == f.getAttribute('class')){2995                rerun_bRook = false;2996              }2997            }2998            if(ret){2999              $(f).addClass('moveable');3000            }3001          }3002          else {3003            rerun_bRook = false;3004          }3005        }3006        var a = '';3007        d = i[0];3008        a += i[2];3009        a += i[3];3010        a = parseInt(a);3011        rerun_bRook = true;3012        while(rerun_bRook){3013          if(d == 'b'){3014            d = 'w';3015          }3016          else if(d == 'w'){3017            d = 'b';3018          }3019          a -= 10;3020          c = d + 'a' + a;3021          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3022            f = document.getElementById(c);3023            ret = true;3024            for(xi in bClassList){3025              x = bClassList[xi];3026              y = wClassList[xi];3027              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3028                rerun_bRook = false;3029                ret = false;3030              }3031              else if(y == f.getAttribute('class')){3032                rerun_bRook = false;3033              }3034            }3035            if(ret){3036              $(f).addClass('moveable');3037            }3038          }3039          else {3040            rerun_bRook = false;3041          }3042        }3043        var a = '';3044        d = i[0];3045        a += i[2];3046        a += i[3];3047        a = parseInt(a);3048        rerun_bRook = true;3049        while(rerun_bRook){3050          if(d == 'b'){3051            d = 'w';3052          }3053          else if(d == 'w'){3054            d = 'b';3055          }3056          a -= 1;3057          c = d + 'a' + a;3058          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3059            f = document.getElementById(c);3060            ret = true;3061            for(xi in bClassList){3062              x = bClassList[xi];3063              y = wClassList[xi];3064              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3065                rerun_bRook = false;3066                ret = false;3067              }3068              else if(y == f.getAttribute('class')){3069                rerun_bRook = false;3070              }3071            }3072            if(ret){3073              $(f).addClass('moveable');3074            }3075          }3076          else {3077            rerun_bRook = false;3078          }3079        }3080        var i = this.id;3081        var b = this;3082        var a = '';3083        d = i[0];3084        a += i[2];3085        a += i[3];3086        a = parseInt(a);3087        rerun_bRook = true;3088        while(rerun_bRook){3089          a += 9;3090          c = d + 'a' + a;3091          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3092            f = document.getElementById(c);3093            ret = true;3094            for(xi in bClassList){3095              x = bClassList[xi];3096              y = wClassList[xi];3097              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3098                rerun_bRook = false;3099                ret = false;3100              }3101              else if(y == f.getAttribute('class')){3102                rerun_bRook = false;3103              }3104            }3105            if(ret){3106              $(f).addClass('moveable');3107            }3108          }3109          else {3110            rerun_bRook = false;3111          }3112        }3113        var a = '';3114        d = i[0];3115        a += i[2];3116        a += i[3];3117        a = parseInt(a);3118        rerun_bRook = true;3119        while(rerun_bRook){3120          a += 11;3121          c = d + 'a' + a;3122          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3123            f = document.getElementById(c);3124            ret = true;3125            for(xi in bClassList){3126              x = bClassList[xi];3127              y = wClassList[xi];3128              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3129                rerun_bRook = false;3130                ret = false;3131              }3132              else if(y == f.getAttribute('class')){3133                rerun_bRook = false;3134              }3135            }3136            if(ret){3137              $(f).addClass('moveable');3138            }3139          }3140          else {3141            rerun_bRook = false;3142          }3143        }3144        var a = '';3145        d = i[0];3146        a += i[2];3147        a += i[3];3148        a = parseInt(a);3149        rerun_bRook = true;3150        while(rerun_bRook){3151          a -= 9;3152          c = d + 'a' + a;3153          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3154            f = document.getElementById(c);3155            ret = true;3156            for(xi in bClassList){3157              x = bClassList[xi];3158              y = wClassList[xi];3159              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3160                rerun_bRook = false;3161                ret = false;3162              }3163              else if(y == f.getAttribute('class')){3164                rerun_bRook = false;3165              }3166            }3167            if(ret){3168              $(f).addClass('moveable');3169            }3170          }3171          else {3172            rerun_bRook = false;3173          }3174        }3175        var a = '';3176        d = i[0];3177        a += i[2];3178        a += i[3];3179        a = parseInt(a);3180        rerun_bRook = true;3181        while(rerun_bRook){3182          a -= 11;3183          c = d + 'a' + a;3184          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3185            f = document.getElementById(c);3186            ret = true;3187            for(xi in bClassList){3188              x = bClassList[xi];3189              y = wClassList[xi];3190              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3191                rerun_bRook = false;3192                ret = false;3193              }3194              else if(y == f.getAttribute('class')){3195                rerun_bRook = false;3196              }3197            }3198            if(ret){3199              $(f).addClass('moveable');3200            }3201          }3202          else {3203            rerun_bRook = false;3204          }3205        }3206        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});3207        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');3208          $(this).off('click');3209          $(b).removeClass('bqueen');3210          $('.moveable').off('click');3211          a = '';3212          i = this.id;3213          a += i[2];3214          a += i[3];3215          add = true;3216          for(xi in wClassList){3217            x = wClassList[xi];3218            $(this).removeClass(x);3219          }3220          $(this).addClass('bqueen');3221          $('.moveable').removeClass('moveable');3222          others = true;3223          bturn = false;3224          wturn = true;3225          run();3226        });3227      }3228    });3229    $('.bking').on('click', function() {3230      if(others && bturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');3231        others = false;3232        $(this).off('click');3233        var i = this.id;3234        var b = this;3235        var a = '';3236        d = i[0];3237        a += i[2];3238        a += i[3];3239        a = parseInt(a);3240        if(d == 'b'){3241          d = 'w';3242        }3243        else if(d == 'w'){3244          d = 'b';3245        }3246        a += 10;3247        c = d + 'a' + a;3248        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3249          f = document.getElementById(c);3250          ret = true;3251          for(xi in bClassList){3252            x = bClassList[xi];3253            y = wClassList[xi];3254            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3255              rerun_bRook = false;3256              ret = false;3257            }3258            else if(y == f.getAttribute('class')){3259              rerun_bRook = false;3260            }3261          }3262          if(ret){3263            $(f).addClass('moveable');3264          }3265        }3266        else {3267          rerun_bRook = false;3268        }3269        var a = '';3270        d = i[0];3271        a += i[2];3272        a += i[3];3273        a = parseInt(a);3274        if(d == 'b'){3275          d = 'w';3276        }3277        else if(d == 'w'){3278          d = 'b';3279        }3280        a += 1;3281        c = d + 'a' + a;3282        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3283          f = document.getElementById(c);3284          ret = true;3285          for(xi in bClassList){3286            x = bClassList[xi];3287            y = wClassList[xi];3288            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3289              rerun_bRook = false;3290              ret = false;3291            }3292            else if(y == f.getAttribute('class')){3293              rerun_bRook = false;3294            }3295          }3296          if(ret){3297            $(f).addClass('moveable');3298          }3299        }3300        else {3301          rerun_bRook = false;3302        }3303        var a = '';3304        d = i[0];3305        a += i[2];3306        a += i[3];3307        a = parseInt(a);3308        if(d == 'b'){3309          d = 'w';3310        }3311        else if(d == 'w'){3312          d = 'b';3313        }3314        a -= 10;3315        c = d + 'a' + a;3316        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3317          f = document.getElementById(c);3318          ret = true;3319          for(xi in bClassList){3320            x = bClassList[xi];3321            y = wClassList[xi];3322            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3323              rerun_bRook = false;3324              ret = false;3325            }3326            else if(y == f.getAttribute('class')){3327              rerun_bRook = false;3328            }3329          }3330          if(ret){3331            $(f).addClass('moveable');3332          }3333        }3334        else {3335          rerun_bRook = false;3336        }3337        var a = '';3338        d = i[0];3339        a += i[2];3340        a += i[3];3341        a = parseInt(a);3342        if(d == 'b'){3343          d = 'w';3344        }3345        else if(d == 'w'){3346          d = 'b';3347        }3348        a -= 1;3349        c = d + 'a' + a;3350        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3351          f = document.getElementById(c);3352          ret = true;3353          for(xi in bClassList){3354            x = bClassList[xi];3355            y = wClassList[xi];3356            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3357              rerun_bRook = false;3358              ret = false;3359            }3360            else if(y == f.getAttribute('class')){3361              rerun_bRook = false;3362            }3363          }3364          if(ret){3365            $(f).addClass('moveable');3366          }3367        }3368        else {3369          rerun_bRook = false;3370        }3371        var i = this.id;3372        var b = this;3373        var a = '';3374        d = i[0];3375        a += i[2];3376        a += i[3];3377        a = parseInt(a);3378        a += 9;3379        c = d + 'a' + a;3380        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3381          f = document.getElementById(c);3382          ret = true;3383          for(xi in bClassList){3384            x = bClassList[xi];3385            y = wClassList[xi];3386            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3387              rerun_bRook = false;3388              ret = false;3389            }3390            else if(y == f.getAttribute('class')){3391              rerun_bRook = false;3392            }3393          }3394          if(ret){3395            $(f).addClass('moveable');3396          }3397        }3398        else {3399          rerun_bRook = false;3400        }3401        var a = '';3402        d = i[0];3403        a += i[2];3404        a += i[3];3405        a = parseInt(a);3406        a += 11;3407        c = d + 'a' + a;3408        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3409          f = document.getElementById(c);3410          ret = true;3411          for(xi in bClassList){3412            x = bClassList[xi];3413            y = wClassList[xi];3414            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3415              rerun_bRook = false;3416              ret = false;3417            }3418            else if(y == f.getAttribute('class')){3419              rerun_bRook = false;3420            }3421          }3422          if(ret){3423            $(f).addClass('moveable');3424          }3425        }3426        else {3427          rerun_bRook = false;3428        }3429        var a = '';3430        d = i[0];3431        a += i[2];3432        a += i[3];3433        a = parseInt(a);3434        a -= 9;3435        c = d + 'a' + a;3436        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3437          f = document.getElementById(c);3438          ret = true;3439          for(xi in bClassList){3440            x = bClassList[xi];3441            y = wClassList[xi];3442            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3443              rerun_bRook = false;3444              ret = false;3445            }3446            else if(y == f.getAttribute('class')){3447              rerun_bRook = false;3448            }3449          }3450          if(ret){3451            $(f).addClass('moveable');3452          }3453        }3454        else {3455          rerun_bRook = false;3456        }3457        var a = '';3458        d = i[0];3459        a += i[2];3460        a += i[3];3461        a = parseInt(a);3462        a -= 11;3463        c = d + 'a' + a;3464        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3465          f = document.getElementById(c);3466          ret = true;3467          for(xi in bClassList){3468            x = bClassList[xi];3469            y = wClassList[xi];3470            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3471              rerun_bRook = false;3472              ret = false;3473            }3474            else if(y == f.getAttribute('class')){3475              rerun_bRook = false;3476            }3477          }3478          if(ret){3479            $(f).addClass('moveable');3480          }3481        }3482        else {3483          rerun_bRook = false;3484        }3485        $(this).addClass('moveable2');3486        $('.moveable2').on('click', function() {3487          $('.moveable').off('click');3488          $('.moveable').removeClass('moveable');3489          others = true;3490          $('.moveable2').off('click');3491          $('.moveable2').removeClass('moveable2');3492          run();3493        });3494        $('.moveable').on('click', function() {3495          $('.moveable2').off('click');3496          $('.moveable2').removeClass('moveable2');3497          $(this).off('click');3498          $(b).removeClass('bking');3499          $('.moveable').off('click');3500          a = '';3501          i = this.id;3502          a += i[2];3503          a += i[3];3504          add = true;3505          for(xi in wClassList){3506            x = wClassList[xi];3507            $(this).removeClass(x);3508          }3509          $(this).addClass('bking');3510          $('.moveable').removeClass('moveable');3511          others = true;3512          bturn = false;3513          wturn = true;3514          run();3515        });3516      }3517    })3518    $('.wknight').on('click', function() {3519      if(others && wturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');3520        others = false;3521        $(this).off('click');3522        var i = this.id;3523        var b = this;3524        var a = '';3525        a += i[2];3526        a += i[3];3527        a = parseInt(a);3528        a += 21;3529        if(i[0] == 'b'){3530          d = 'w'3531        }3532        else if(i[0] == 'w'){3533          d = 'b'3534        }3535        c = d + 'a' + a;3536        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3537          ret = true;3538          for(xi in wClassList){3539            x = wClassList[xi]3540            if(x == document.getElementById(c).getAttribute('class')){3541              3542              ret = false;3543            }3544          }3545          if(ret) {3546            f = document.getElementById(c);3547            $(f).addClass('moveable');3548          }3549        }3550        a = a - 2;3551        c = d + 'a' + a;3552        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3553          ret = true;3554          for(xi in wClassList){3555            x = wClassList[xi]3556            if(x == document.getElementById(c).getAttribute('class')){3557              3558              ret = false;3559            }3560          }3561          if(ret) {3562            f = document.getElementById(c);3563            $(f).addClass('moveable');3564          }3565        }3566        a = a - 11;3567        c = d + 'a' + a;3568        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3569          ret = true;3570          for(xi in wClassList){ 3571            x = wClassList[xi]3572            if(x == document.getElementById(c).getAttribute('class')){3573              3574              ret = false;3575            }3576          }3577          if(ret) {3578            f = document.getElementById(c);3579            $(f).addClass('moveable');3580          }3581        }3582        a = a - 20;3583        c = d + 'a' + a;3584        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3585          ret = true;3586          for(xi in wClassList){ 3587            x = wClassList[xi]3588            if(x == document.getElementById(c).getAttribute('class')){3589              3590              ret = false;3591            }3592          }3593          if(ret) {3594            f = document.getElementById(c);3595            $(f).addClass('moveable');3596          }3597        }3598        a = a - 9;3599        c = d + 'a' + a;3600        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3601          ret = true;3602          for(xi in wClassList){ 3603            x = wClassList[xi]3604            if(x == document.getElementById(c).getAttribute('class')){3605              ret = false;3606              3607            }3608          }3609          if(ret) {3610            f = document.getElementById(c);3611            $(f).addClass('moveable');3612          }3613        }3614        a = a + 2;3615        c = d + 'a' + a;3616        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3617          ret = true;3618          for(xi in wClassList){3619            x = wClassList[xi]3620            if(x == document.getElementById(c).getAttribute('class')){3621              ret = false;3622              3623            }3624          }3625          if(ret) {3626            f = document.getElementById(c);3627            $(f).addClass('moveable');3628          }3629        }3630        a = a + 11;3631        c = d + 'a' + a;3632        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3633          ret = true;3634          for(xi in wClassList){ 3635            x = wClassList[xi]3636            if(x == document.getElementById(c).getAttribute('class')){3637              ret = false;3638              3639            }3640          }3641          if(ret) {3642            f = document.getElementById(c);3643            $(f).addClass('moveable');3644          }3645        }3646        a = a + 20;3647        c = d + 'a' + a;3648        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0) {3649          ret = true;3650          for(xi in wClassList){ 3651            x = wClassList[xi]3652            if(x == document.getElementById(c).getAttribute('class')){3653              ret = false;3654              3655            }3656          }3657          if(ret) {3658            f = document.getElementById(c);3659            $(f).addClass('moveable');3660          }3661        }3662        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});3663        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');3664          $(this).off('click');3665          $(b).removeClass('wknight');3666          add = true;3667          for(xi in bClassList){3668            x = bClassList[xi]3669            if(x == 'bking') {3670              idd = this.id;3671              f = document.getElementById(idd);3672              if(f.getAttribute('class') == 'bking') {3673                add = false;3674              }3675            }3676            $(this).removeClass(x);3677          }3678          if(add){3679            $(this).addClass('wknight');3680          }3681          $('.moveable').off('click');3682          $(this).addClass('wknight');3683          $('.moveable').removeClass('moveable');3684          others = true;3685          wturn = false;3686          bturn = true;3687          run();3688        });3689      }3690    });3691    $('.wpawn').on('click', function() {3692      if(others && wturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');3693        others = false;3694        $(this).off('click');3695        var i = this.id;3696        var b = this;3697        var a = '';3698        a += i[2];3699        a += i[3];3700        a = parseInt(a)3701        if(i[0] == 'b'){3702          d = 'w'3703        }3704        else if(i[0] == 'w'){3705          d = 'b'3706        }3707        if(a > 70 && a < 79 ){3708          a -= 10;3709          var c = d + 'a' + a;3710          c1 = d + 'a' + a;3711          c2 = d + 'a' + a;3712          if(d == 'b'){3713            d = 'w'3714          }3715          else if(d == 'w'){3716            d = 'b'3717          }3718          if(a-1 > 10 && a-1 < 89 && (a-1) % 10 != 9 && (a-1) % 10 != 0){3719            c1 = d + 'a' + (a - 1);3720          }3721          if(a+1 > 10 && a+1 < 89 && (a+1) % 10 != 9 && (a+1) % 10 != 0){3722            c2 = d + 'a' + (a + 1);3723          }3724          if(d == 'b'){3725            d = 'w'3726          }3727          else if(d == 'w'){3728            d = 'b'3729          }3730          f = document.getElementById(c);3731          if(c1 != c){3732            f1 = document.getElementById(c1);3733          }3734          if(c2 != c){3735            f2 = document.getElementById(c2);3736          }3737          ret = true;3738          ret1 = false;3739          ret2 = false;3740          for(xi in wClassList){3741            x = bClassList[xi];3742            y = wClassList[xi];3743            if(f.getAttribute('class') == y || f.getAttribute('class') == y + ' moveable2'){3744              ret = false;3745            }3746            if(f.getAttribute('class') == x || f.getAttribute('class') == x + ' moveable2'){3747              ret = false;3748            }3749            if(c1 != c){3750              if(x == f1.getAttribute('class')){3751                ret1 = true;3752              }3753            }3754            if(c2 != c){3755              if(x == f2.getAttribute('class')){3756                ret2 = true;3757              }3758            }3759          }3760          if(ret){3761            $(f).addClass('moveable');3762          }3763          if(ret1){3764            $(f1).addClass('moveable');3765          }3766          if(ret2){3767            $(f2).addClass('moveable');3768          }3769          if(d == 'b'){3770            d = 'w'3771          }3772          else if(d == 'w'){3773            d = 'b'3774          }3775          a -= 10;3776          c = d + 'a' + a;3777          f = document.getElementById(c);3778          for(xi in bClassList){3779            x = wClassList[xi];3780            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3781              ret = false;3782            }3783          }3784          if(ret){3785            $(f).addClass('moveable');3786          }3787        }3788        else if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3789          a -= 10;3790          c = d + 'a' + a;3791          c1 = d + 'a' + a;3792          c2 = d + 'a' + a;3793          if(d == 'b'){3794            d = 'w'3795          }3796          else if(d == 'w'){3797            d = 'b'3798          }3799          if(a-1 > 10 && a-1 < 89 && (a-1) % 10 != 9 && (a-1) % 10 != 0){3800            c1 = d + 'a' + (a - 1);3801          }3802          if(a+1 > 10 && a+1 < 89 && (a+1) % 10 != 9 && (a+1) % 10 != 0){3803            c2 = d + 'a' + (a + 1);3804          }3805          if(d == 'b'){3806            d = 'w'3807          }3808          else if(d == 'w'){3809            d = 'b'3810          }3811          f = document.getElementById(c);3812          if(c1 != c){3813            f1 = document.getElementById(c1);3814          }3815          if(c2 != c){3816            f2 = document.getElementById(c2);3817          }3818          ret = true;3819          ret1 = false;3820          ret2 = false;3821          for(xi in bClassList){3822            x = bClassList[xi];3823            if(f.getAttribute('class') == x || f.getAttribute('class') == x + ' moveable2'){3824              ret = false;3825            }3826            if(c1 != c){3827              if(x == f1.getAttribute('class')){3828                ret1 = true;3829              }3830            }3831            if(c2 != c){3832              if(x == f2.getAttribute('class')){3833                ret2 = true;3834              }3835            }3836          }3837          if(ret){3838            $(f).addClass('moveable');3839          }3840          if(ret1){3841            $(f1).addClass('moveable');3842          }3843          if(ret2){3844            $(f2).addClass('moveable');3845          }3846        }3847        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});3848        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');3849          $(this).off('click');3850          $(b).removeClass('wpawn');3851          $('.moveable').off('click');3852          a = '';3853          i = this.id;3854          a += i[2];3855          a += i[3];3856          add = true;3857          for(xi in bClassList){3858            x = bClassList[xi]3859            if(x == 'bking') {3860              idd = this.id;3861              f = document.getElementById(idd);3862              if(f.getAttribute('class') == 'bking') {3863                add = false;3864              }3865            }3866            $(this).removeClass(x);3867          }3868          if(a > 10 && a < 19 && add) {3869            $(this).addClass('wqueen');3870          }3871          else if(add){3872            $(this).addClass('wpawn');3873          }3874          $('.moveable').removeClass('moveable');3875          others = true;3876          wturn = false;3877          bturn = true;3878          run();3879        });3880      }3881    });3882    $('.wrook').on('click', function() {3883      if(others && wturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');3884        others = false;3885        $(this).off('click');3886        var i = this.id;3887        var b = this;3888        var a = '';3889        d = i[0];3890        a += i[2];3891        a += i[3];3892        a = parseInt(a);3893        rerun_wRook = true;3894        while(rerun_wRook){3895          if(d == 'b'){3896            d = 'w';3897          }3898          else if(d == 'w'){3899            d = 'b';3900          }3901          a += 10;3902          c = d + 'a' + a;3903          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3904            f = document.getElementById(c);3905            ret = true;3906            for(xi in wClassList){3907              x = wClassList[xi];3908              y = bClassList[xi];3909              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3910                rerun_wRook = false;3911                ret = false;3912              }3913              else if(y == f.getAttribute('class')){3914                rerun_wRook = false;3915              }3916            }3917            if(ret){3918              $(f).addClass('moveable');3919            }3920          }3921          else {3922            rerun_wRook = false;3923          }3924        }3925        var a = '';3926        d = i[0];3927        a += i[2];3928        a += i[3];3929        a = parseInt(a);3930        rerun_wRook = true;3931        while(rerun_wRook){3932          if(d == 'b'){3933            d = 'w';3934          }3935          else if(d == 'w'){3936            d = 'b';3937          }3938          a += 1;3939          c = d + 'a' + a;3940          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3941            f = document.getElementById(c);3942            ret = true;3943            for(xi in wClassList){3944              x = wClassList[xi];3945              y = bClassList[xi];3946              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3947                rerun_wRook = false;3948                ret = false;3949              }3950              else if(y == f.getAttribute('class')){3951                rerun_wRook = false;3952              }3953            }3954            if(ret){3955              $(f).addClass('moveable');3956            }3957          }3958          else {3959            rerun_wRook = false;3960          }3961        }3962        var a = '';3963        d = i[0];3964        a += i[2];3965        a += i[3];3966        a = parseInt(a);3967        rerun_wRook = true;3968        while(rerun_wRook){3969          if(d == 'b'){3970            d = 'w';3971          }3972          else if(d == 'w'){3973            d = 'b';3974          }3975          a -= 10;3976          c = d + 'a' + a;3977          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){3978            f = document.getElementById(c);3979            ret = true;3980            for(xi in wClassList){3981              x = wClassList[xi];3982              y = bClassList[xi];3983              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){3984                rerun_wRook = false;3985                ret = false;3986              }3987              else if(y == f.getAttribute('class')){3988                rerun_wRook = false;3989              }3990            }3991            if(ret){3992              $(f).addClass('moveable');3993            }3994          }3995          else {3996            rerun_wRook = false;3997          }3998        }3999        var a = '';4000        d = i[0];4001        a += i[2];4002        a += i[3];4003        a = parseInt(a);4004        rerun_wRook = true;4005        while(rerun_wRook){4006          if(d == 'b'){4007            d = 'w';4008          }4009          else if(d == 'w'){4010            d = 'b';4011          }4012          a -= 1;4013          c = d + 'a' + a;4014          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4015            f = document.getElementById(c);4016            ret = true;4017            for(xi in wClassList){4018              x = wClassList[xi];4019              y = bClassList[xi];4020              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4021                rerun_wRook = false;4022                ret = false;4023              }4024              else if(y == f.getAttribute('class')){4025                rerun_wRook = false;4026              }4027            }4028            if(ret){4029              $(f).addClass('moveable');4030            }4031          }4032          else {4033            rerun_wRook = false;4034          }4035        }4036        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});4037        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');4038          $(this).off('click');4039          $(b).removeClass('wrook');4040          $('.moveable').off('click');4041          a = '';4042          i = this.id;4043          a += i[2];4044          a += i[3];4045          f = document.getElementsByClassName('wking')[0];4046          if(a == '83' && f.getAttribute('id') == 'ba84'){4047            mking = true;4048          }4049          else {4050            mking = false;4051          }4052          if(mking) {4053            $('#ba82').addClass('wking');4054            $('#ba84').removeClass('wking');4055          }4056          for(xi in wClassList){4057            x = bClassList[xi];4058            $(this).removeClass(x);4059          }4060          if(add){4061            $(this).addClass('wrook');4062          }4063          $(this).addClass('wrook');4064          $('.moveable').removeClass('moveable');4065          others = true;4066          wturn = false;4067          bturn = true;4068          run();4069        });4070      }4071    });4072    $('.wbishop').on('click', function() {4073      if(others && wturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');4074        others = false;4075        $(this).off('click');4076        var i = this.id;4077        var b = this;4078        var a = '';4079        d = i[0];4080        a += i[2];4081        a += i[3];4082        a = parseInt(a);4083        rerun_bRook = true;4084        while(rerun_bRook){4085          a += 9;4086          c = d + 'a' + a;4087          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4088            f = document.getElementById(c);4089            ret = true;4090            for(xi in wClassList){4091              x = wClassList[xi];4092              y = bClassList[xi];4093              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4094                rerun_bRook = false;4095                ret = false;4096              }4097              else if(y == f.getAttribute('class')){4098                rerun_bRook = false;4099              }4100            }4101            if(ret){4102              $(f).addClass('moveable');4103            }4104          }4105          else {4106            rerun_bRook = false;4107          }4108        }4109        var a = '';4110        d = i[0];4111        a += i[2];4112        a += i[3];4113        a = parseInt(a);4114        rerun_bRook = true;4115        while(rerun_bRook){4116          a += 11;4117          c = d + 'a' + a;4118          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4119            f = document.getElementById(c);4120            ret = true;4121            for(xi in wClassList){4122              x = wClassList[xi];4123              y = bClassList[xi];4124              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4125                rerun_bRook = false;4126                ret = false;4127              }4128              else if(y == f.getAttribute('class')){4129                rerun_bRook = false;4130              }4131            }4132            if(ret){4133              $(f).addClass('moveable');4134            }4135          }4136          else {4137            rerun_bRook = false;4138          }4139        }4140        var a = '';4141        d = i[0];4142        a += i[2];4143        a += i[3];4144        a = parseInt(a);4145        rerun_bRook = true;4146        while(rerun_bRook){4147          a -= 9;4148          c = d + 'a' + a;4149          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4150            f = document.getElementById(c);4151            ret = true;4152            for(xi in wClassList){4153              x = wClassList[xi];4154              y = bClassList[xi];4155              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4156                rerun_bRook = false;4157                ret = false;4158              }4159              else if(y == f.getAttribute('class')){4160                rerun_bRook = false;4161              }4162            }4163            if(ret){4164              $(f).addClass('moveable');4165            }4166          }4167          else {4168            rerun_bRook = false;4169          }4170        }4171        var a = '';4172        d = i[0];4173        a += i[2];4174        a += i[3];4175        a = parseInt(a);4176        rerun_bRook = true;4177        while(rerun_bRook){4178          a -= 11;4179          c = d + 'a' + a;4180          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4181            f = document.getElementById(c);4182            ret = true;4183            for(xi in wClassList){4184              x = wClassList[xi];4185              y = bClassList[xi];4186              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4187                rerun_bRook = false;4188                ret = false;4189              }4190              else if(y == f.getAttribute('class')){4191                rerun_bRook = false;4192              }4193            }4194            if(ret){4195              $(f).addClass('moveable');4196            }4197          }4198          else {4199            rerun_bRook = false;4200          }4201        }4202        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});4203        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');4204          $(this).off('click');4205          $(b).removeClass('wbishop');4206          $('.moveable').off('click');4207          a = '';4208          i = this.id;4209          a += i[2];4210          a += i[3];4211          add = true;4212          for(xi in bClassList){4213            x = bClassList[xi];4214            $(this).removeClass(x);4215          }4216          if(add){4217            $(this).addClass('wbishop');4218          }4219          $(this).addClass('wbishop');4220          $('.moveable').removeClass('moveable');4221          others = true;4222          wturn = false;4223          bturn = true;4224          run();4225        });4226      }4227    });4228    $('.wqueen').on('click', function() {4229      if(others && wturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');4230        others = false;4231        $(this).off('click');4232        var i = this.id;4233        var b = this;4234        var a = '';4235        d = i[0];4236        a += i[2];4237        a += i[3];4238        a = parseInt(a);4239        rerun_bRook = true;4240        while(rerun_bRook){4241          if(d == 'b'){4242            d = 'w';4243          }4244          else if(d == 'w'){4245            d = 'b';4246          }4247          a += 10;4248          c = d + 'a' + a;4249          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4250            f = document.getElementById(c);4251            ret = true;4252            for(xi in wClassList){4253              x = wClassList[xi];4254              y = bClassList[xi];4255              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4256                rerun_bRook = false;4257                ret = false;4258              }4259              else if(y == f.getAttribute('class')){4260                rerun_bRook = false;4261              }4262            }4263            if(ret){4264              $(f).addClass('moveable');4265            }4266          }4267          else {4268            rerun_bRook = false;4269          }4270        }4271        var a = '';4272        d = i[0];4273        a += i[2];4274        a += i[3];4275        a = parseInt(a);4276        rerun_bRook = true;4277        while(rerun_bRook){4278          if(d == 'b'){4279            d = 'w';4280          }4281          else if(d == 'w'){4282            d = 'b';4283          }4284          a += 1;4285          c = d + 'a' + a;4286          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4287            f = document.getElementById(c);4288            ret = true;4289            for(xi in wClassList){4290              x = wClassList[xi];4291              y = bClassList[xi];4292              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4293                rerun_bRook = false;4294                ret = false;4295              }4296              else if(y == f.getAttribute('class')){4297                rerun_bRook = false;4298              }4299            }4300            if(ret){4301              $(f).addClass('moveable');4302            }4303          }4304          else {4305            rerun_bRook = false;4306          }4307        }4308        var a = '';4309        d = i[0];4310        a += i[2];4311        a += i[3];4312        a = parseInt(a);4313        rerun_bRook = true;4314        while(rerun_bRook){4315          if(d == 'b'){4316            d = 'w';4317          }4318          else if(d == 'w'){4319            d = 'b';4320          }4321          a -= 10;4322          c = d + 'a' + a;4323          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4324            f = document.getElementById(c);4325            ret = true;4326            for(xi in wClassList){4327              x = wClassList[xi];4328              y = bClassList[xi];4329              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4330                rerun_bRook = false;4331                ret = false;4332              }4333              else if(y == f.getAttribute('class')){4334                rerun_bRook = false;4335              }4336            }4337            if(ret){4338              $(f).addClass('moveable');4339            }4340          }4341          else {4342            rerun_bRook = false;4343          }4344        }4345        var a = '';4346        d = i[0];4347        a += i[2];4348        a += i[3];4349        a = parseInt(a);4350        rerun_bRook = true;4351        while(rerun_bRook){4352          if(d == 'b'){4353            d = 'w';4354          }4355          else if(d == 'w'){4356            d = 'b';4357          }4358          a -= 1;4359          c = d + 'a' + a;4360          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4361            f = document.getElementById(c);4362            ret = true;4363            for(xi in wClassList){4364              x = wClassList[xi];4365              y = bClassList[xi];4366              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4367                rerun_bRook = false;4368                ret = false;4369              }4370              else if(y == f.getAttribute('class')){4371                rerun_bRook = false;4372              }4373            }4374            if(ret){4375              $(f).addClass('moveable');4376            }4377          }4378          else {4379            rerun_bRook = false;4380          }4381        }4382        var i = this.id;4383        var b = this;4384        var a = '';4385        d = i[0];4386        a += i[2];4387        a += i[3];4388        a = parseInt(a);4389        rerun_bRook = true;4390        while(rerun_bRook){4391          a += 9;4392          c = d + 'a' + a;4393          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4394            f = document.getElementById(c);4395            ret = true;4396            for(xi in wClassList){4397              x = wClassList[xi];4398              y = bClassList[xi];4399              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4400                rerun_bRook = false;4401                ret = false;4402              }4403              else if(y == f.getAttribute('class')){4404                rerun_bRook = false;4405              }4406            }4407            if(ret){4408              $(f).addClass('moveable');4409            }4410          }4411          else {4412            rerun_bRook = false;4413          }4414        }4415        var a = '';4416        d = i[0];4417        a += i[2];4418        a += i[3];4419        a = parseInt(a);4420        rerun_bRook = true;4421        while(rerun_bRook){4422          a += 11;4423          c = d + 'a' + a;4424          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4425            f = document.getElementById(c);4426            ret = true;4427            for(xi in wClassList){4428              x = wClassList[xi];4429              y = bClassList[xi];4430              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4431                rerun_bRook = false;4432                ret = false;4433              }4434              else if(y == f.getAttribute('class')){4435                rerun_bRook = false;4436              }4437            }4438            if(ret){4439              $(f).addClass('moveable');4440            }4441          }4442          else {4443            rerun_bRook = false;4444          }4445        }4446        var a = '';4447        d = i[0];4448        a += i[2];4449        a += i[3];4450        a = parseInt(a);4451        rerun_bRook = true;4452        while(rerun_bRook){4453          a -= 9;4454          c = d + 'a' + a;4455          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4456            f = document.getElementById(c);4457            ret = true;4458            for(xi in wClassList){4459              x = wClassList[xi];4460              y = bClassList[xi];4461              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4462                rerun_bRook = false;4463                ret = false;4464              }4465              else if(y == f.getAttribute('class')){4466                rerun_bRook = false;4467              }4468            }4469            if(ret){4470              $(f).addClass('moveable');4471            }4472          }4473          else {4474            rerun_bRook = false;4475          }4476        }4477        var a = '';4478        d = i[0];4479        a += i[2];4480        a += i[3];4481        a = parseInt(a);4482        rerun_bRook = true;4483        while(rerun_bRook){4484          a -= 11;4485          c = d + 'a' + a;4486          if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4487            f = document.getElementById(c);4488            ret = true;4489            for(xi in wClassList){4490              x = wClassList[xi];4491              y = bClassList[xi];4492              if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4493                rerun_bRook = false;4494                ret = false;4495              }4496              else if(y == f.getAttribute('class')){4497                rerun_bRook = false;4498              }4499            }4500            if(ret){4501              $(f).addClass('moveable');4502            }4503          }4504          else {4505            rerun_bRook = false;4506          }4507        }4508        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});4509        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');4510          $(this).off('click');4511          $(b).removeClass('wqueen');4512          $('.moveable').off('click');4513          a = '';4514          i = this.id;4515          a += i[2];4516          a += i[3];4517          add = true;4518          for(xi in bClassList){4519            x = bClassList[xi];4520            if(x == 'bking') {4521              idd = this.id;4522              f = document.getElementById(idd);4523              if(f.getAttribute('class') == 'bking') {4524                add = false;4525              }4526            }4527            $(this).removeClass(x);4528          }4529          if(add){4530            $(this).addClass('wqueen');4531          }4532          $(this).addClass('wqueen');4533          $('.moveable').removeClass('moveable');4534          others = true;4535          wturn = false;4536          bturn = true;4537          run();4538        });4539      }4540    });4541    $('.wking').on('click', function() {4542      if(others && wturn) {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');4543        others = false;4544        $(this).off('click');4545        var i = this.id;4546        var b = this;4547        var a = '';4548        d = i[0];4549        a += i[2];4550        a += i[3];4551        a = parseInt(a);4552        if(d == 'b'){4553          d = 'w';4554        }4555        else if(d == 'w'){4556          d = 'b';4557        }4558        a += 10;4559        c = d + 'a' + a;4560        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4561          f = document.getElementById(c);4562          ret = true;4563          for(xi in wClassList){4564            x = wClassList[xi];4565            y = bClassList[xi];4566            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4567              rerun_bRook = false;4568              ret = false;4569            }4570            else if(y == f.getAttribute('class')){4571              rerun_bRook = false;4572            }4573          }4574          if(ret){4575            $(f).addClass('moveable');4576          }4577        }4578        else {4579          rerun_bRook = false;4580        }4581        var a = '';4582        d = i[0];4583        a += i[2];4584        a += i[3];4585        a = parseInt(a);4586        if(d == 'b'){4587          d = 'w';4588        }4589        else if(d == 'w'){4590          d = 'b';4591        }4592        a += 1;4593        c = d + 'a' + a;4594        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4595          f = document.getElementById(c);4596          ret = true;4597          for(xi in wClassList){4598            x = wClassList[xi];4599            y = bClassList[xi];4600            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4601              rerun_bRook = false;4602              ret = false;4603            }4604            else if(y == f.getAttribute('class')){4605              rerun_bRook = false;4606            }4607          }4608          if(ret){4609            $(f).addClass('moveable');4610          }4611        }4612        else {4613          rerun_bRook = false;4614        }4615        var a = '';4616        d = i[0];4617        a += i[2];4618        a += i[3];4619        a = parseInt(a);4620        if(d == 'b'){4621          d = 'w';4622        }4623        else if(d == 'w'){4624          d = 'b';4625        }4626        a -= 10;4627        c = d + 'a' + a;4628        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4629          f = document.getElementById(c);4630          ret = true;4631          for(xi in wClassList){4632            x = wClassList[xi];4633            y = bClassList[xi];4634            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4635              rerun_bRook = false;4636              ret = false;4637            }4638            else if(y == f.getAttribute('class')){4639              rerun_bRook = false;4640            }4641          }4642          if(ret){4643            $(f).addClass('moveable');4644          }4645        }4646        else {4647          rerun_bRook = false;4648        }4649        var a = '';4650        d = i[0];4651        a += i[2];4652        a += i[3];4653        a = parseInt(a);4654        if(d == 'b'){4655          d = 'w';4656        }4657        else if(d == 'w'){4658          d = 'b';4659        }4660        a -= 1;4661        c = d + 'a' + a;4662        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4663          f = document.getElementById(c);4664          ret = true;4665          for(xi in wClassList){4666            x = wClassList[xi];4667            y = bClassList[xi];4668            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4669              rerun_bRook = false;4670              ret = false;4671            }4672            else if(y == f.getAttribute('class')){4673              rerun_bRook = false;4674            }4675          }4676          if(ret){4677            $(f).addClass('moveable');4678          }4679        }4680        else {4681          rerun_bRook = false;4682        }4683        var i = this.id;4684        var b = this;4685        var a = '';4686        d = i[0];4687        a += i[2];4688        a += i[3];4689        a = parseInt(a);4690        a += 9;4691        c = d + 'a' + a;4692        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4693          f = document.getElementById(c);4694          ret = true;4695          for(xi in wClassList){4696            x = wClassList[xi];4697            y = bClassList[xi];4698            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4699              rerun_bRook = false;4700              ret = false;4701            }4702            else if(y == f.getAttribute('class')){4703              rerun_bRook = false;4704            }4705          }4706          if(ret){4707            $(f).addClass('moveable');4708          }4709        }4710        else {4711          rerun_bRook = false;4712        }4713        var a = '';4714        d = i[0];4715        a += i[2];4716        a += i[3];4717        a = parseInt(a);4718        a += 11;4719        c = d + 'a' + a;4720        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4721          f = document.getElementById(c);4722          ret = true;4723          for(xi in wClassList){4724            x = wClassList[xi];4725            y = bClassList[xi];4726            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4727              rerun_bRook = false;4728              ret = false;4729            }4730            else if(y == f.getAttribute('class')){4731              rerun_bRook = false;4732            }4733          }4734          if(ret){4735            $(f).addClass('moveable');4736          }4737        }4738        else {4739          rerun_bRook = false;4740        }4741        var a = '';4742        d = i[0];4743        a += i[2];4744        a += i[3];4745        a = parseInt(a);4746        a -= 9;4747        c = d + 'a' + a;4748        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4749          f = document.getElementById(c);4750          ret = true;4751          for(xi in wClassList){4752            x = wClassList[xi];4753            y = bClassList[xi];4754            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4755              rerun_bRook = false;4756              ret = false;4757            }4758            else if(y == f.getAttribute('class')){4759              rerun_bRook = false;4760            }4761          }4762          if(ret){4763            $(f).addClass('moveable');4764          }4765        }4766        else {4767          rerun_bRook = false;4768        }4769        var a = '';4770        d = i[0];4771        a += i[2];4772        a += i[3];4773        a = parseInt(a);4774        a -= 11;4775        c = d + 'a' + a;4776        if(a > 10 && a < 89 && a % 10 != 9 && a % 10 != 0){4777          f = document.getElementById(c);4778          ret = true;4779          for(xi in wClassList){4780            x = wClassList[xi];4781            y = bClassList[xi];4782            if(x == f.getAttribute('class') || x + ' moveable2' == f.getAttribute('class')){4783              rerun_bRook = false;4784              ret = false;4785            }4786            else if(y == f.getAttribute('class')){4787              rerun_bRook = false;4788            }4789          }4790          if(ret){4791            $(f).addClass('moveable');4792          }4793        }4794        else {4795          rerun_bRook = false;4796        }4797        $(this).addClass('moveable2');$('.moveable2').on('click', function() {$('.moveable').off('click');$('.moveable').removeClass('moveable');others = true;$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');run();});4798        $('.moveable').on('click', function() {$('.moveable2').off('click');$('.moveable2').removeClass('moveable2');4799          $(this).off('click');4800          $(b).removeClass('wking');4801          $('.moveable').off('click');4802          a = '';4803          i = this.id;4804          a += i[2];4805          a += i[3];4806          add = true;4807          for(xi in bClassList){4808            x = bClassList[xi];4809            $(this).removeClass(x);4810          }4811          $(this).addClass('wking');4812          $('.moveable').removeClass('moveable');4813          others = true;4814          wturn = false;4815          bturn = true;4816          run();4817        });4818      }4819    })4820  }4821  run();...rerun.service.js
Source:rerun.service.js  
1/*2  * AET3  *4  * Copyright (C) 2013 Cognifide Limited5  *6  * Licensed under the Apache License, Version 2.0 (the "License");7  * you may not use this file except in compliance with the License.8  * You may obtain a copy of the License at9  *10  *      http://www.apache.org/licenses/LICENSE-2.011  *12  * Unless required by applicable law or agreed to in writing, software13  * distributed under the License is distributed on an "AS IS" BASIS,14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15  * See the License for the specific language governing permissions and16  * limitations under the License.17  */18 define(['angularAMD', 'endpointConfiguration', 'suiteInfoService' , 'caseFactory'], function (angularAMD) {19  'use strict';20  angularAMD.factory('rerunService', rerunService);21  /**22   * Service responsible for fetching suite's history23   */24  function rerunService($rootScope, $http, endpointConfiguration, suiteInfoService, caseFactory) {25    $rootScope.endpointUrl = endpointConfiguration.getEndpoint().getUrl;26    var service = {27      getRerunStatistics: getRerunStatistics,28      rerunSuite: rerunSuite,29      rerunTest: rerunTest,30      rerunURL: rerunURL,31      checkRerunStatus: checkRerunStatus,32    };33    return service;34    function getRerunStatistics(msg) {35      var statsArray = msg;36      statsArray = statsArray.replace(/:::/, ',');37      statsArray = statsArray.replace(/\d{2}:\d{2}:\d{2}\.\d{3}/g, '');38      statsArray = statsArray.replace(/[a-zA-z]|:/g, '');39      statsArray = statsArray.replace(/\s/g, '');40      statsArray = statsArray.split(',');41      return statsArray;42    }43    function rerunSuite() {44      $rootScope.rerunInProgress = true;45      var suiteInfo = suiteInfoService.getInfo();46      var url = endpointConfiguration.getEndpoint().getUrl + 'suite-rerun';47      $http.post(url, {48        company: suiteInfo.company,49        project: suiteInfo.project,50        suite: suiteInfo.name,51      }).then(function successCallback(response) {52        $rootScope.rerunMsg = 'Suite rerun initialized';53        $rootScope.rerunInProgressSuccessful = true;54        localStorage.setItem('currentRerunEndpointUrl', response.data.statusUrl);55        $rootScope.rerunProgress = 0;56        checkRerunStatus(response.data.statusUrl);57      }, function errorCallback(response) {58        $rootScope.rerunMsg = response.statusText;59      });60    }61    function rerunTest(testName) {62      $rootScope.rerunInProgress = true;63      var suiteInfo = suiteInfoService.getInfo();64      var url = endpointConfiguration.getEndpoint().getUrl + 'suite-rerun';65      $http.post(url, {66        company: suiteInfo.company,67        project: suiteInfo.project,68        suite: suiteInfo.name,69        testName: testName70      }).then(function successCallback(response) {71        $rootScope.rerunMsg = 'Test rerun initialized';72        $rootScope.rerunProgress = 0;73        $rootScope.rerunInProgressSuccessful = true;74        localStorage.setItem('currentRerunEndpointUrl', response.data.statusUrl);75        checkRerunStatus(response.data.statusUrl);76      }, function errorCallback(response) {77        $rootScope.rerunMsg = response.statusText;78      });79    }80    function rerunURL(testName, testUrl) {81      $rootScope.rerunInProgress = true;82      var suiteInfo = suiteInfoService.getInfo();83      var url = endpointConfiguration.getEndpoint().getUrl + 'suite-rerun';84      $http.post(url, {85        company: suiteInfo.company,86        project: suiteInfo.project,87        suite: suiteInfo.name,88        testUrl: testUrl,89        testName: testName90      }).then(function successCallback(response) {91        $rootScope.rerunMsg = 'URL rerun initialized';92        $rootScope.rerunProgress = 0;93        $rootScope.rerunInProgressSuccessful = true;94        localStorage.setItem('currentRerunEndpointUrl', response.data.statusUrl);95        checkRerunStatus(response.data.statusUrl);96      }, function errorCallback(response) {97        $rootScope.rerunMsg = response.statusText;98      });99    }100    function checkRerunStatus(statusUrl) {101      $rootScope.rerunInProgress = true;102      var url = statusUrl;103      setTimeout(function () {104        $http.get(url, {}).then(function successCallback(response) {105          if (response.data.status === 'FINISHED') {106            var suiteInfo = suiteInfoService.getInfo();107            var linkParams = '?' + 'company=' + suiteInfo.company + '&' + 'project=' + suiteInfo.project + '&' +108              'suite=' + suiteInfo.name;109            linkParams = linkParams + '#' + window.location.href.split('#')[1];110            var linkToLatestSuite = location.protocol + '//' + location.host + location.pathname + linkParams;111            $rootScope.rerunMsg = 'Rerun completed. Page will now refresh.';112            $rootScope.rerunProgress = 100;113            localStorage.removeItem('currentRerunEndpointUrl');114            if (window.location.href !== linkToLatestSuite) {115              window.location.assign(linkToLatestSuite);116            } else {117              window.location.reload();118            }119            return;120          } else if (response.data.status === 'PROGRESS') {121            $rootScope.rerunInProgressSuccessful = true;122            var totalTests = response.data.progressLog.collectLog.toReceiveMessages;123            var completedTests = response.data.progressLog.collectLog.receivedMessagesSuccess;124            $rootScope.rerunProgress = ((completedTests / totalTests) * 90);125            $rootScope.rerunMsg = 'Rerun in progress.';126          } else {127            $rootScope.rerunMsg = 'Waiting for results.';128          }129          checkRerunStatus(statusUrl);130        }, function errorCallback(response) {131          $rootScope.rerunMsg = response.data.status;132          return;133        });134      }, 2000);135    }136    137  }...run_rerun_test.js
Source:run_rerun_test.js  
1const assert = require('assert');2const path = require('path');3const expect = require('chai').expect;4const exec = require('child_process').exec;5const runner = path.join(__dirname, '/../../bin/codecept.js');6const codecept_dir = path.join(__dirname, '/../data/sandbox/configs/run-rerun/');7const codecept_run = `${runner} run-rerun`;8const codecept_run_config = (config, grep) => `${codecept_run} --config ${codecept_dir}/${config} --grep "${grep || ''}"`;9describe('run-rerun command', () => {10  before(() => {11    process.chdir(codecept_dir);12  });13  it('should display count of attemps', (done) => {14    exec(`${codecept_run_config('codecept.conf.js')} --debug`, (err, stdout) => {15      stdout.should.include(`16Run Rerun - Command --17  @RunRerun18    I print message "RunRerun"19RunRerun20  â OK`);21      stdout.should.include(`22Run Rerun - Command --23  @RunRerun24    I print message "RunRerun"25    I print message "RunRerun"26RunRerun27  â OK`);28      stdout.should.include(`29Run Rerun - Command --30  @RunRerun31    I print message "RunRerun"32    I print message "RunRerun"33    I print message "RunRerun"34RunRerun35  â OK`);36      stdout.should.include('Process run 1 of max 3, success runs 1/3');37      stdout.should.include('Process run 2 of max 3, success runs 2/3');38      stdout.should.include('Process run 3 of max 3, success runs 3/3');39      stdout.should.include('OK  | 1 passed');40      assert(!err);41      done();42    });43  });44  it('should display 2 success count of attemps', (done) => {45    exec(`${codecept_run_config('codecept.conf.min_less_max.js')} --debug`, (err, stdout) => {46      stdout.should.include(`47Run Rerun - Command --48  @RunRerun49    I print message "RunRerun"50RunRerun51  â OK`);52      stdout.should.include(`53Run Rerun - Command --54  @RunRerun55    I print message "RunRerun"56    I print message "RunRerun"57RunRerun58  â OK`);59      stdout.should.not.include(`60Run Rerun - Command --61  @RunRerun62    I print message "RunRerun"63    I print message "RunRerun"64    I print message "RunRerun"65RunRerun66  â OK`);67      stdout.should.include('Process run 1 of max 3, success runs 1/2');68      stdout.should.include('Process run 2 of max 3, success runs 2/2');69      stdout.should.not.include('Process run 3 of max 3');70      stdout.should.include('OK  | 1 passed');71      assert(!err);72      done();73    });74  });75  it('should display error if minSuccess more than maxReruns', (done) => {76    exec(`${codecept_run_config('codecept.conf.min_more_max.js')} --debug`, (err, stdout) => {77      stdout.should.include('minSuccess must be less than maxReruns');78      assert(err);79      done();80    });81  });82  it('should display errors if test is fail always', (done) => {83    exec(`${codecept_run_config('codecept.conf.fail_test.js', '@RunRerun - Fail all attempt')} --debug`, (err, stdout) => {84      stdout.should.include('Fail run 1 of max 3, success runs 0/2');85      stdout.should.include('Fail run 2 of max 3, success runs 0/2');86      stdout.should.include('Fail run 3 of max 3, success runs 0/2');87      stdout.should.include('Flaky tests detected!');88      assert(err);89      done();90    });91  });92  it('should display success run if test was fail one time of two attepmts and 3 reruns', (done) => {93    exec(`FAIL_ATTEMPT=0  ${codecept_run_config('codecept.conf.fail_test.js', '@RunRerun - fail second test')} --debug`, (err, stdout) => {94      stdout.should.include('Process run 1 of max 3, success runs 1/2');95      stdout.should.include('Fail run 2 of max 3, success runs 1/2');96      stdout.should.include('Process run 3 of max 3, success runs 2/2');97      stdout.should.not.include('Flaky tests detected!');98      assert(!err);99      done();100    });101  });...course_rerun.37283e8ba331.js
Source:course_rerun.37283e8ba331.js  
1define(['domReady', 'jquery', 'underscore', 'js/views/utils/create_course_utils', 'common/js/components/utils/view_utils'],2    function(domReady, $, _, CreateCourseUtilsFactory, ViewUtils) {3        var CreateCourseUtils = new CreateCourseUtilsFactory({4            name: '.rerun-course-name',5            org: '.rerun-course-org',6            number: '.rerun-course-number',7            run: '.rerun-course-run',8            save: '.rerun-course-save',9            errorWrapper: '.wrapper-error',10            errorMessage: '#course_rerun_error',11            tipError: 'span.tip-error',12            error: '.error',13            allowUnicode: '.allow-unicode-course-id'14        }, {15            shown: 'is-shown',16            showing: 'is-showing',17            hiding: 'is-hidden',18            disabled: 'is-disabled',19            error: 'error'20        });21        var saveRerunCourse = function(e) {22            e.preventDefault();23            if (CreateCourseUtils.hasInvalidRequiredFields()) {24                return;25            }26            var $newCourseForm = $(this).closest('#rerun-course-form');27            var display_name = $newCourseForm.find('.rerun-course-name').val();28            var org = $newCourseForm.find('.rerun-course-org').val();29            var number = $newCourseForm.find('.rerun-course-number').val();30            var run = $newCourseForm.find('.rerun-course-run').val();31            course_info = {32                source_course_key: source_course_key,33                org: org,34                number: number,35                display_name: display_name,36                run: run37            };38            analytics.track('Reran a Course', course_info);39            CreateCourseUtils.create(course_info, function(errorMessage) {40                $('.wrapper-error').addClass('is-shown').removeClass('is-hidden');41                $('#course_rerun_error').html('<p>' + errorMessage + '</p>');42                $('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).removeClass('is-processing').html(gettext('Create Re-run'));43                $('.action-cancel').removeClass('is-hidden');44            });45            // Go into creating re-run state46            $('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).addClass('is-processing').html(47               '<span class="icon fa fa-refresh fa-spin" aria-hidden="true"></span>' + gettext('Processing Re-run Request')  // eslint-disable-line max-len48            );49            $('.action-cancel').addClass('is-hidden');50        };51        var cancelRerunCourse = function(e) {52            e.preventDefault();53            // Clear out existing fields and errors54            $('.rerun-course-run').val('');55            $('#course_rerun_error').html('');56            $('wrapper-error').removeClass('is-shown').addClass('is-hidden');57            $('.rerun-course-save').off('click');58            ViewUtils.redirect('/course/');59        };60        var onReady = function() {61            var $cancelButton = $('.rerun-course-cancel');62            var $courseRun = $('.rerun-course-run');63            $courseRun.focus().select();64            $('.rerun-course-save').on('click', saveRerunCourse);65            $cancelButton.bind('click', cancelRerunCourse);66            $('.cancel-button').bind('click', cancelRerunCourse);67            CreateCourseUtils.configureHandlers();68        };69        domReady(onReady);70        // Return these functions so that they can be tested71        return {72            saveRerunCourse: saveRerunCourse,73            cancelRerunCourse: cancelRerunCourse,74            onReady: onReady75        };...course_rerun.fd01705e369f.js
Source:course_rerun.fd01705e369f.js  
1define(["domReady", "jquery", "underscore", "js/views/utils/create_course_utils", "common/js/components/utils/view_utils"],2    function (domReady, $, _, CreateCourseUtilsFactory, ViewUtils) {3        var CreateCourseUtils = new CreateCourseUtilsFactory({4            name: '.rerun-course-name',5            org: '.rerun-course-org',6            number: '.rerun-course-number',7            run: '.rerun-course-run',8            save: '.rerun-course-save',9            errorWrapper: '.wrapper-error',10            errorMessage: '#course_rerun_error',11            tipError: 'span.tip-error',12            error: '.error',13            allowUnicode: '.allow-unicode-course-id'14        }, {15            shown: 'is-shown',16            showing: 'is-showing',17            hiding: 'is-hidden',18            disabled: 'is-disabled',19            error: 'error'20        });21        var saveRerunCourse = function (e) {22            e.preventDefault();23            if (CreateCourseUtils.hasInvalidRequiredFields()) {24                return;25            }26            var $newCourseForm = $(this).closest('#rerun-course-form');27            var display_name = $newCourseForm.find('.rerun-course-name').val();28            var org = $newCourseForm.find('.rerun-course-org').val();29            var number = $newCourseForm.find('.rerun-course-number').val();30            var run = $newCourseForm.find('.rerun-course-run').val();31            course_info = {32                source_course_key: source_course_key,33                org: org,34                number: number,35                display_name: display_name,36                run: run37            };38            analytics.track('Reran a Course', course_info);39            CreateCourseUtils.create(course_info, function (errorMessage) {40                $('.wrapper-error').addClass('is-shown').removeClass('is-hidden');41                $('#course_rerun_error').html('<p>' + errorMessage + '</p>');42                $('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).removeClass('is-processing').html(gettext('Create Re-run'));43                $('.action-cancel').removeClass('is-hidden');44            });45            // Go into creating re-run state46            $('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).addClass('is-processing').html(47               '<i class="icon fa fa-refresh fa-spin"></i>' + gettext('Processing Re-run Request')48            );49            $('.action-cancel').addClass('is-hidden');50        };51        var cancelRerunCourse = function (e) {52            e.preventDefault();53            // Clear out existing fields and errors54            $('.rerun-course-run').val('');55            $('#course_rerun_error').html('');56            $('wrapper-error').removeClass('is-shown').addClass('is-hidden');57            $('.rerun-course-save').off('click');58            ViewUtils.redirect('/course/');59        };60        var onReady = function () {61            var $cancelButton = $('.rerun-course-cancel');62            var $courseRun = $('.rerun-course-run');63            $courseRun.focus().select();64            $('.rerun-course-save').on('click', saveRerunCourse);65            $cancelButton.bind('click', cancelRerunCourse);66            $('.cancel-button').bind('click', cancelRerunCourse);67            CreateCourseUtils.configureHandlers();68        };69        domReady(onReady);70        // Return these functions so that they can be tested71        return {72            saveRerunCourse: saveRerunCourse,73            cancelRerunCourse: cancelRerunCourse,74            onReady: onReady75        };...course_rerun.24c5b8a21ea6.js
Source:course_rerun.24c5b8a21ea6.js  
1define(["domReady", "jquery", "underscore", "js/views/utils/create_course_utils", "js/views/utils/view_utils"],2    function (domReady, $, _, CreateCourseUtilsFactory, ViewUtils) {3        var CreateCourseUtils = new CreateCourseUtilsFactory({4            name: '.rerun-course-name',5            org: '.rerun-course-org',6            number: '.rerun-course-number',7            run: '.rerun-course-run',8            save: '.rerun-course-save',9            errorWrapper: '.wrapper-error',10            errorMessage: '#course_rerun_error',11            tipError: 'span.tip-error',12            error: '.error',13            allowUnicode: '.allow-unicode-course-id'14        }, {15            shown: 'is-shown',16            showing: 'is-showing',17            hiding: 'is-hidden',18            disabled: 'is-disabled',19            error: 'error'20        });21        var saveRerunCourse = function (e) {22            e.preventDefault();23            if (CreateCourseUtils.hasInvalidRequiredFields()) {24                return;25            }26            var $newCourseForm = $(this).closest('#rerun-course-form');27            var display_name = $newCourseForm.find('.rerun-course-name').val();28            var org = $newCourseForm.find('.rerun-course-org').val();29            var number = $newCourseForm.find('.rerun-course-number').val();30            var run = $newCourseForm.find('.rerun-course-run').val();31            course_info = {32                source_course_key: source_course_key,33                org: org,34                number: number,35                display_name: display_name,36                run: run37            };38            analytics.track('Reran a Course', course_info);39            CreateCourseUtils.create(course_info, function (errorMessage) {40                $('.wrapper-error').addClass('is-shown').removeClass('is-hidden');41                $('#course_rerun_error').html('<p>' + errorMessage + '</p>');42                $('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).removeClass('is-processing').html(gettext('Create Re-run'));43                $('.action-cancel').removeClass('is-hidden');44            });45            // Go into creating re-run state46            $('.rerun-course-save').addClass('is-disabled').attr('aria-disabled', true).addClass('is-processing').html(47               '<i class="icon fa fa-refresh fa-spin"></i>' + gettext('Processing Re-run Request')48            );49            $('.action-cancel').addClass('is-hidden');50        };51        var cancelRerunCourse = function (e) {52            e.preventDefault();53            // Clear out existing fields and errors54            $('.rerun-course-run').val('');55            $('#course_rerun_error').html('');56            $('wrapper-error').removeClass('is-shown').addClass('is-hidden');57            $('.rerun-course-save').off('click');58            ViewUtils.redirect('/course/');59        };60        var onReady = function () {61            var $cancelButton = $('.rerun-course-cancel');62            var $courseRun = $('.rerun-course-run');63            $courseRun.focus().select();64            $('.rerun-course-save').on('click', saveRerunCourse);65            $cancelButton.bind('click', cancelRerunCourse);66            $('.cancel-button').bind('click', cancelRerunCourse);67            CreateCourseUtils.configureHandlers();68        };69        domReady(onReady);70        // Return these functions so that they can be tested71        return {72            saveRerunCourse: saveRerunCourse,73            cancelRerunCourse: cancelRerunCourse,74            onReady: onReady75        };...course_rerun.js
Source:course_rerun.js  
1define(["domReady", "jquery", "underscore", "js/views/utils/create_course_utils", "js/views/utils/view_utils"],2    function (domReady, $, _, CreateCourseUtilsFactory, ViewUtils) {3        var CreateCourseUtils = CreateCourseUtilsFactory({4            name: '.rerun-course-name',5            org: '.rerun-course-org',6            number: '.rerun-course-number',7            run: '.rerun-course-run',8            save: '.rerun-course-save',9            errorWrapper: '.wrapper-error',10            errorMessage: '#course_rerun_error',11            tipError: 'span.tip-error',12            error: '.error',13            allowUnicode: '.allow-unicode-course-id'14        }, {15            shown: 'is-shown',16            showing: 'is-showing',17            hiding: 'is-hidden',18            disabled: 'is-disabled',19            error: 'error'20        });21        var saveRerunCourse = function (e) {22            e.preventDefault();23            if (CreateCourseUtils.hasInvalidRequiredFields()) {24                return;25            }26            var $newCourseForm = $(this).closest('#rerun-course-form');27            var display_name = $newCourseForm.find('.rerun-course-name').val();28            var org = $newCourseForm.find('.rerun-course-org').val();29            var number = $newCourseForm.find('.rerun-course-number').val();30            var run = $newCourseForm.find('.rerun-course-run').val();31            course_info = {32                source_course_key: source_course_key,33                org: org,34                number: number,35                display_name: display_name,36                run: run37            };38            analytics.track('Reran a Course', course_info);39            CreateCourseUtils.createCourse(course_info, function (errorMessage) {40                $('.wrapper-error').addClass('is-shown').removeClass('is-hidden');41                $('#course_rerun_error').html('<p>' + errorMessage + '</p>');42                $('.rerun-course-save').addClass('is-disabled').removeClass('is-processing').html(gettext('Create Re-run'));43                $('.action-cancel').removeClass('is-hidden');44            });45            // Go into creating re-run state46            $('.rerun-course-save').addClass('is-disabled').addClass('is-processing').html(47               '<i class="icon icon-refresh icon-spin"></i>' + gettext('Processing Re-run Request')48            );49            $('.action-cancel').addClass('is-hidden');50        };51        var cancelRerunCourse = function (e) {52            e.preventDefault();53            // Clear out existing fields and errors54            $('.rerun-course-run').val('');55            $('#course_rerun_error').html('');56            $('wrapper-error').removeClass('is-shown').addClass('is-hidden');57            $('.rerun-course-save').off('click');58            ViewUtils.redirect('/course/');59        };60        var onReady = function () {61            var $cancelButton = $('.rerun-course-cancel');62            var $courseRun = $('.rerun-course-run');63            $courseRun.focus().select();64            $('.rerun-course-save').on('click', saveRerunCourse);65            $cancelButton.bind('click', cancelRerunCourse);66            $('.cancel-button').bind('click', cancelRerunCourse);67            CreateCourseUtils.configureHandlers();68        };69        domReady(onReady);70        // Return these functions so that they can be tested71        return {72            saveRerunCourse: saveRerunCourse,73            cancelRerunCourse: cancelRerunCourse,74            onReady: onReady75        };...Using AI Code Generation
1const puppeteer = require('puppeteer');2const devices = require('puppeteer/DeviceDescriptors');3const iPhone = devices['iPhone 6'];4(async () => {5  const browser = await puppeteer.launch({6  });7  const page = await browser.newPage();8  await page.emulate(iPhone);9  await page.type('input[name="q"]', 'puppeteer');10  await page.keyboard.press('Enter');11  await page.waitForNavigation();12  await page.screenshot({ path: 'google.png' });13  await browser.close();14})();15const puppeteer = require('puppeteer');16const devices = require('puppeteer/DeviceDescriptors');17const iPhone = devices['iPhone 6'];18(async () => {19  const browser = await puppeteer.launch({20  });21  const page = await browser.newPage();22  await page.emulate(iPhone);23  await page.type('input[name="q"]', 'puppeteer');24  await page.keyboard.press('Enter');25  await page.waitForNavigation();26  await page.screenshot({ path: 'google.png' });27  await browser.close();28})();29const puppeteer = require('puppeteer');30const devices = require('puppeteer/DeviceDescriptors');31const iPhone = devices['iPhone 6'];32(async () => {33  const browser = await puppeteer.launch({34  });35  const page = await browser.newPage();36  await page.emulate(iPhone);37  await page.type('input[name="q"]', 'puppeteer');38  await page.keyboard.press('Enter');39  await page.waitForNavigation();40  await page.screenshot({ path: 'google.png' });41  await browser.close();42})();43const puppeteer = require('puppeteer');Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3  const browser = await puppeteer.launch();4  const page = await browser.newPage();5  await page.screenshot({path: 'screenshot.png'});6  await browser.close();7})();8const puppeteer = require('puppeteer');9(async () => {10  const browser = await puppeteer.launch();11  const page = await browser.newPage();12  await page.screenshot({path: 'screenshot.png'});13  await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17  const browser = await puppeteer.launch();18  const page = await browser.newPage();19  await page.screenshot({path: 'screenshot.png'});20  await page.screenshot({path: 'screenshot2.png'});21  await browser.close();22})();23const puppeteer = require('puppeteer');24(async () => {25  const browser = await puppeteer.launch();26  const page = await browser.newPage();27  for (let i = 0; i < pages.length; i++) {28    await page.goto(pages[i]);29    await page.screenshot({path: `screenshot${i}.png`});30  }31  await browser.close();32})();33const puppeteer = require('puppeteer');34const takeScreenshot = async (page, url, index) => {Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3    const browser = await puppeteer.launch({headless: false});4    const page = await browser.newPage();5    await page.waitForSelector('h1');6    await page.click('h1');7    await page.waitForSelector('h2');8    await page.click('h2');9    await page.waitForSelector('h3');10    await page.click('h3');11    await page.waitForSelector('h4');12    await page.click('h4');13    await page.waitForSelector('h5');14    await page.click('h5');15    await page.waitForSelector('h6');16    await page.click('h6');17    await page.waitForSelector('h7');18    await page.click('h7');19    await page.waitForSelector('h8');20    await page.click('h8');21    await page.waitForSelector('h9');22    await page.click('h9');23    await page.waitForSelector('h10');24    await page.click('h10');25    await page.waitForSelector('h11');26    await page.click('h11');27    await page.waitForSelector('h12');28    await page.click('h12');29    await page.waitForSelector('h13');30    await page.click('h13');31    await page.waitForSelector('h14');32    await page.click('h14');33    await page.waitForSelector('h15');34    await page.click('h15');35    await page.waitForSelector('h16');36    await page.click('h16');37    await page.waitForSelector('h17');38    await page.click('h17');39    await page.waitForSelector('h18');40    await page.click('h18');41    await page.waitForSelector('h19');42    await page.click('h19');43    await page.waitForSelector('h20');44    await page.click('h20');45    await page.waitForSelector('h21');46    await page.click('h21');47    await page.waitForSelector('h22');48    await page.click('h22');49    await page.waitForSelector('h23');50    await page.click('h23');51    await page.waitForSelector('h24');52    await page.click('h24');53    await page.waitForSelector('h25');54    await page.click('h25');55    await page.waitForSelector('h26');56    await page.click('h26');57    await page.waitForSelector('h27');Using AI Code Generation
1const puppeteer = require('puppeteer');2const devices = require('puppeteer/DeviceDescriptors');3const iPhone = devices['iPhone 6'];4(async () => {5    const browser = await puppeteer.launch({headless: false, slowMo: 50});6    const page = await browser.newPage();7    await page.emulate(iPhone);8    await page.screenshot({path: 'google.png'});9    await page.screenshot({path: 'yahoo.png'});10    await page.goBack();11    await page.screenshot({path: 'google2.png'});12    await page.goForward();13    await page.screenshot({path: 'yahoo2.png'});14    await browser.close();15})();16const puppeteer = require('puppeteer');17const devices = require('puppeteer/DeviceDescriptors');18const iPhone = devices['iPhone 6'];19(async () => {20    const browser = await puppeteer.launch({headless: false, slowMo: 50});21    const page = await browser.newPage();22    await page.emulate(iPhone);23    await page.screenshot({path: 'google.png'});24    await page.screenshot({path: 'yahoo.png'});25    await page.reload();26    await page.screenshot({path: 'yahoo2.png'});27    await browser.close();28})();29const puppeteer = require('puppeteer');30(async () => {31    const browser = await puppeteer.launch({headless: false, slowMo: 50});32    const page = await browser.newPage();33    await page.click('input[name="q"]');34    await page.keyboard.type('puppeteer');35    await page.click('input[value="Google Search"]');36    await page.waitForNavigation();37    await page.screenshot({path: 'puppeteer.png'});38    await browser.close();39})();40const puppeteer = require('puppeteer');41(async () => {42    const browser = await puppeteer.launch({headless: false, slowMo: 50});Using AI Code Generation
1const puppeteer = require('puppeteer');2const devices = require('puppeteer/DeviceDescriptors');3const iPhone = devices['iPhone 6'];4(async () => {5    const browser = await puppeteer.launch({6    });7    const page = await browser.newPage();8    await page.emulate(iPhone);9    await page.type('input[name=q]', 'puppeteer');10    await page.click('input[name="btnK"]');11    await page.waitForNavigation();12    await page.screenshot({ path: 'screenshots/google.png', fullPage: true });13    await page.click('input[name="btnK"]');14    await page.waitForNavigation();15    await page.screenshot({ path: 'screenshots/google2.png', fullPage: true });16    await page.goBack();17    await page.screenshot({ path: 'screenshots/google3.png', fullPage: true });18    await page.goForward();19    await page.screenshot({ path: 'screenshots/google4.png', fullPage: true });20    await page.goBack();21    await page.screenshot({ path: 'screenshots/google5.png', fullPage: true });22    await page.reload();23    await page.screenshot({ path: 'screenshots/google6.png', fullPage: true });24    await page.goBack();25    await page.screenshot({ path: 'screenshots/google7.png', fullPage: true });26    await page.reload();27    await page.screenshot({ path: 'screenshots/google8.png', fullPage: true });28    await page.goBack();29    await page.screenshot({ path: 'screenshots/google9.png', fullPage: true });30    await page.reload();31    await page.screenshot({ path: 'screenshots/google10.png', fullPage: true });32    await page.goBack();33    await page.screenshot({ path: 'screenshots/google11.png', fullPage: true });34    await page.reload();35    await page.screenshot({ path: 'screenshots/google12.png', fullPage: true });36    await page.goBack();37    await page.screenshot({ path: 'screenshots/google13.png', fullPage: true });38    await page.reload();39    await page.screenshot({ path: 'screenshots/google14.png', fullPage: true });40    await page.goBack();41    await page.screenshot({ path: 'screenshots/google15.png', fullPage: true });Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4(async () => {5  const browser = await puppeteer.launch();6  const page = await browser.newPage();7  await page.screenshot({path: 'example.png'});8  await browser.close();9})();Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4const devices = require('puppeteer/DeviceDescriptors');5const iPhone = devices['iPhone 6'];6(async () => {7    const browser = await puppeteer.launch({headless: false});8    const page = await browser.newPage();9    await page.emulate(iPhone);10    await page.screenshot({path: 'example.png'});11    await browser.close();12})();13const puppeteer = require('puppeteer');14const fs = require('fs');15const path = require('path');16const devices = require('puppeteer/DeviceDescriptors');17const iPhone = devices['iPhone 6'];18(async () => {19    const browser = await puppeteer.launch({headless: false});20    const page = await browser.newPage();21    await page.emulate(iPhone);22    await page.screenshot({path: 'example.png'});23    await browser.close();24})();25const puppeteer = require('puppeteer');26const fs = require('fs');27const path = require('path');28const devices = require('puppeteer/DeviceDescriptors');29const iPhone = devices['iPhone 6'];30(async () => {31    const browser = await puppeteer.launch({headless: false});32    const page = await browser.newPage();33    await page.emulate(iPhone);34    await page.screenshot({path: 'example.png'});35    await browser.close();36})();37const puppeteer = require('puppeteer');38const fs = require('fs');39const path = require('path');40const devices = require('puppeteer/DeviceDescriptors');41const iPhone = devices['iPhone 6'];42(async () => {43    const browser = await puppeteer.launch({headless: false});44    const page = await browser.newPage();45    await page.emulate(iPhone);Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3  const browser = await puppeteer.launch({4  });5  const page = await browser.newPage();6  await page.screenshot({ path: 'example.png' });7  await browser.close();8})();9const puppeteer = require('puppeteer');10(async () => {11  const browser = await puppeteer.launch({12  });13  const page = await browser.newPage();14  await page.screenshot({ path: 'example.png' });15  await browser.close();16})();17{18  "scripts": {Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
