diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a289ba2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +# Getting Started +Run a webserver locally: `cd public && python -m SimpleHTTPServer 8080` + +# Running high scores server +Get JSON-RPC: `pip install json-rpc` +Run high scores server: `cd server && python server.py` \ No newline at end of file diff --git a/public/client.js b/public/client.js new file mode 100644 index 0000000..0d01958 --- /dev/null +++ b/public/client.js @@ -0,0 +1,32 @@ +function RPC(method, params, callback) { + var url = '/server' + var data = JSON.stringify({ + 'method': method, + 'params': params, + 'id': 0, + 'jsonrpc': '2.0' + }); + + var cbk = function(x) { + console.log(x); + if (callback) { + callback(x); + } + } + + $.ajax({ + url:url, + type:"POST", + data:data, + contentType:"application/json; charset=utf-8", + dataType:"json", + success: cbk + }); +} + +/* +usage: +RPC('reportScore', [10, 'powerset', 'steven1']); +RPC('reportScore', [5, 'powerset', 'steven2']); +RPC('getScores', ['powerset']); + */ \ No newline at end of file diff --git a/public/index.html b/public/index.html index a4b8dbc..3dfd7f4 100644 --- a/public/index.html +++ b/public/index.html @@ -58,6 +58,7 @@ +