From 94e2c9a768fa45f99535c5db64e0df542e384878 Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 18 May 2018 00:49:54 +0200 Subject: [PATCH] Init commit --- black.png | Bin 0 -> 2147 bytes func.js | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 34 ++++++++++++++++++++ style.css | 9 ++++++ white.png | Bin 0 -> 2037 bytes 5 files changed, 136 insertions(+) create mode 100644 black.png create mode 100644 func.js create mode 100644 index.html create mode 100644 style.css create mode 100644 white.png diff --git a/black.png b/black.png new file mode 100644 index 0000000000000000000000000000000000000000..9d3c4bacd1099a4d679e4fc5a417cdf8421ab363 GIT binary patch literal 2147 zcmV-p2%PtcP)($S88_BehLB>jjRHnRFeKmwxo{zaoj@vy1cAMU?Z%ZMO~C#S)+TNOh6Gn} zu`vjQRV{e4U==PbSV0WNg)w-VWQ(wnYNcl9Y~kOPMprZU+%t3E@ACm;tU1>j&3*Jc zFZa!P@96{Q+zPO0f6f4>?WKjc-uz&PhV0ak$Xz*!4P z6^6hr@C?}Y-v1ohplv!480Xxg1>`Dl4mb&Tz=gIgN%Fn-f#<+O3(zpMVbirXFcy+k z;47;jBVZ8Pt|rNQ8v@?~TWt+bs{-SkJ7pocX@Ch$eWyPSC?Kiej7zsWPMMh3=$atBxrwe6@K;C2&( z)2P5$*K^M*ioB~hUpJ|%YD9^5&Yg13-2vVLYoYc%vIe|$&fT#Af9-0oFwVJE-~sSn zQv%#TBj7*44e$L{sBxKU3yl57Yyg)+ZRLocfc3hj;x;23V{s267&V5()*ru{B$!0)L>?m=iLG7@S9X0=~s+m+JJI>Zs zUI9y0eb1g4*k}66KI77rzVn=O*MO(i1xYy;fT#9Zm#Wk*$vO8Ua5>aY3iZf)eU#ejdEe0Gx=r?j2#<#r4`)P z*#kbB_1M!)U6LIkeWI|m(gN^g)}!1r1qS%**tN;hKBsLTMvLx}?8KeNp?1;=Yq6(% zMg_*o*e`YhkF?(&@IlP!p0QohhQ=+Oa? z`=PedO1}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)vrk&*oX~k5So&Xt6PDl5!5=iDmrH|wHwx@Q~@ z>;qS3IiF=-wFHL4b80q#OQE)M#81HbEa$Qmp|UP1&3pg5oqW7zmpSMRzUfBx8LfHm zKdmb))EStBmDMHS8~c)ib13;NzOn0uD(`~QYU`3Fv6<98;EPb(p4bGwu5wTtQhS9N z=e-|#@4o~t*g3;}wF6x6-hbJou+X#$lV%HkH?87~nilW^B|qCHaKDNLxLGwiFbV6b zZUNUicz4fzy9s5ki{b0miohgnD!yt}=d7(sv~3+HdC$9cYp|_4XFai66_{~Wbyk6| zfW?M)S;>1F+P(X?+E7gDM}S$I}}tH3$yw(6`t$@kv3hf_TSw%Zz#ah(WEnse?G z3($G%x)wv*6eM|8!!rxW&!G+4rjvo0#AaNJ_UDWpH3#@OuxZ*0`}+;>(n2z9^30}4 Z{|5>pCQKn6o;Lsh002ovPDHLkV1kQ02^|0c literal 0 HcmV?d00001 diff --git a/func.js b/func.js new file mode 100644 index 0000000..a847a36 --- /dev/null +++ b/func.js @@ -0,0 +1,93 @@ + +$(function () { + + var sortables = [] + // Build pins + for (var i = 1; i < 25; i++) { + var div = $("
").addClass("pin").attr('id', 'pin-'+i); + var checkers_div = $("
").addClass("checkers").attr('id', 'checkers-'+i); + var checkers_list = $("
    ").addClass("checkers_list").attr('id', 'checkers_list-'+i); + sortables.push("#checkers_list-"+i); + + checkers_div.append(checkers_list); + div.append(checkers_div); + $( "#pins" ).append(div); + } + + convertBoard(); + convertToBoard(); + + console.log(sortables.join()); + $( sortables.join() ).sortable({ + connectWith: ".checkers_list" + }); + +}); + + +function convertToBoard() { + var board = [0] + + for (var i = 1; i < 25; i++) { + var amount = $( "#checkers_list-"+i ).children('li').length; + board.push(amount); + } + + board.push(0) + console.log(board); +} + +function convertBoard() { + // TODO: Take board as input + var board = [0, 2, 0, 0, 0, 0, -5, 0, -3, 0, 0, 0, 5, -5, 0, 0, 0, 3, 0, 5, 0, 0, 0, 0, -2, 0]; + // We don't want to deal with bars RIGHT now, TODO: Fix this. + for (var i = 1; i < 25; i++) { + for (var amt_at_pin = 0; amt_at_pin < Math.abs(board[i]); amt_at_pin++) { + var sign = Math.sign(board[i]); + if (sign > 0) { + var list_obj = $( "
  • ").addClass(Math.sign(board[i]).toString()); + } else if (sign < 0) { + var list_obj = $( "
  • ").addClass(Math.sign(board[i]).toString()); + } + + $( '#checkers_list-'+i ).append(list_obj); + } + } +}; + + +function onReceived(data) { + var obj = JSON.stringify(data); + alert(obj); +}; + + +function get_request() { + $.ajax({ + url: 'http://127.0.0.1:5000/', + dataType: 'JSONP', + data: { + format: 'json' + }, + type: 'GET', + success: onReceived + }); +}; + + +function onPost(data) { + console.log(data); +}; + + +function post_request() { + var board = [0, 2, 0, 0, 0, 0, -5, 0, -3, 0, 0, 0, 5, -5, 0, 0, 0, 3, 0, 5, 0, 0, 0, 0, -2, 0] + + var data = {'board' : board.toString()} + $.ajax({ + type : "POST", + url : "http://127.0.0.1:5000/post_request", + data: JSON.stringify(data), + success: onPost + }); +}; diff --git a/index.html b/index.html new file mode 100644 index 0000000..7de1783 --- /dev/null +++ b/index.html @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..e7c565c --- /dev/null +++ b/style.css @@ -0,0 +1,9 @@ +body { + text-align: center; + background-color: green; +} + +ul { + padding-top: 5px; + display: inline-block; +} diff --git a/white.png b/white.png new file mode 100644 index 0000000000000000000000000000000000000000..69ebd278a970bc01211d41ed55fff20e17d37e1f GIT binary patch literal 2037 zcmVItf>^{f6A+6aL@;0qiw$T5t2+_|FNJ4gCD;V?KS+W$fk1+l7Eut6 zTouR<$Q2d}Ifx(@BDhUVApxu0HQ7y(?{k@(o1JH#-TA$r7l`KW8E>8W~ zf%A1;ir4jj^b+tAIPGgFdz=RTuzgs$ssl3sz5%`m4zzI4tqFR-o3;2TYtjeq~3QIjM*uF1CS%Fbl>Q!23$_UI|8(5Nhoi8IaMF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