From a83519cb2cba9688fb5fe83d3f44a6c8f827c68e Mon Sep 17 00:00:00 2001 From: a-Sansara Date: Fri, 11 Dec 2015 13:00:28 +0100 Subject: [PATCH] Create README.md --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4885ad5 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# bt +manage communication between browser tabs + +### require + + jquery html5 localStorage + + +### Initialize + + $(document).ready(function() { + $bt.init(); + } + +### Internal Commands + + // append data on node to other browser tabs + $bt.append('#test', 'it's cool to append'); + // rewrite content on node to other browser tabs + $bt.html('#test', 'it's cool to rewrite'); + +### Custom Commands + + // define a new custom cmd + $bt.CMD_CUSTOM = "customCmd"; + // treat custom command to other browser tabs + $bt.on = function(cmd) { + switch (cmd.name) { + case $bt.CMD_CUSTOM : + // do stuff + $bt.log("custom command `'+cmd.name+'` with `'+cmd.customKey+'`'); + break; + } + } + + // send a custom command to other browser tabs + $bt.send({ name : $bt.CMD_CUSTOM, customKey : 'customValue' }); + + +### Demo + +on chromium/chrome browser make sure to test on a web server (not directly file) + + +enjoy !