From 8a0613baae6dbe0f9f3456674d10fa152c53e1bb Mon Sep 17 00:00:00 2001 From: a-Sansara Date: Thu, 17 Dec 2015 00:32:36 +0100 Subject: [PATCH] decouple code between bt and svan with refacto, manage frame context and callback - update version to 0.5 --- README.md | 34 ++++--- demo.html | 31 +++--- src/bt-min.js | 7 +- src/bt.js | 257 ++++++++++++++++++++++++++---------------------- src/svan-min.js | 1 + 5 files changed, 180 insertions(+), 150 deletions(-) create mode 100644 src/svan-min.js diff --git a/README.md b/README.md index 369cf60..0960196 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ # bt -manage communication between browser tabs + + Manage commnunication between browser tabs. + this js lib can perform several actions on browser tabs like : + - append/rewrite/synchro node on all (other) tabs or a specific tab (and possibly on specific frame context) eventually with callback. + - reload all tabs or a specific tab with specified url or tab 's current url + - perform your custom actions on all tabs or specific tab ### require - html5 localStorage + html5 localStorage svan (pluie.org small vanilla jquery-like lib) ### Initialize - $v(document).ready(function() { + $(document).ready(function() { $bt.init(); } @@ -17,21 +22,30 @@ manage communication between browser tabs // 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"); - // rewrite content to specific browser tabs - $bt.html('#test', "it's cool to rewrite", '1449974562012'); + // append content to specific browser tab + $bt.append('#test', "it's cool to rewrite", null, null, '1449974562012'); + + // rewrite content to specified browser tab with callback + $bt.html('#test', "it's cool to rewrite", null, function() { alert('callback'); }, '1449974562012'); + + // append content to specified browser tab on specific frame + $bt.append('#test', "it's cool to rewrite", 'frameName', null, '1449974562012'); // perform a node synchro to other browser tabs $bt.sync('#test'); + // perform a node synchro to specified browser tab on specific frame with callback + $bt.sync('#test', 'frameName', callback, '1449974562012'); + // reload other browser tabs $bt.reload(); - // reload other browser tabs to specific url - $bt.reload(window.location.path+"?reloaded=1"); + // reload specific browser tab to specific url + $bt.reload(window.location.path+"?reloaded=1", '1449974562012'); // get browser tab list $bt.list; @@ -61,11 +75,9 @@ manage communication between browser tabs ### Bonus // alias localStorage : clear|rem|get|set - $l; + $l // alias json : str|obj $j - // minimal vanilla jquery style : ready|on|html|append|attr|val|foreach - $v ### Demo diff --git a/demo.html b/demo.html index 35d95f8..fd3c0cb 100644 --- a/demo.html +++ b/demo.html @@ -19,8 +19,12 @@

pluie.org bt demo :

author : a-sansara - version : 0.4
-

- this js lib can perform several actions on browser tabs. +

Manage commnunication between browser tabs.

+

this js lib can perform several actions on browser tabs like :
+

Static actions

@@ -41,6 +45,7 @@ enter txt or html :

Target output

+