commit 94e2c9a768fa45f99535c5db64e0df542e384878
Author: = <=>
Date: Fri May 18 00:49:54 2018 +0200
Init commit
diff --git a/black.png b/black.png
new file mode 100644
index 0000000..9d3c4ba
Binary files /dev/null and b/black.png differ
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 0000000..69ebd27
Binary files /dev/null and b/white.png differ