From dfc6a082004505dbd37c527c554f4acdeac1a42e Mon Sep 17 00:00:00 2001 From: a-Sansara Date: Fri, 25 Dec 2015 00:34:11 +0100 Subject: [PATCH] replace fn by callback + add before and after --- README.md | 14 ++++++-- demo.html | 26 +++++++++++--- src/bt-min.js | 2 +- src/bt.js | 96 ++++++++++++++++++++++++++++++++++----------------- 4 files changed, 100 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 065fbaf..1cf4f3a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ $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'); + // callback must be define before command with method $bt.setCallback('callbackname', callback); + $bt.html('#test', "it's cool to rewrite", null, 'callbackname', '1449974562012'); // append content to specified browser tab on specific frame $bt.append('#test', "it's cool to rewrite", 'frameName', null, '1449974562012'); @@ -41,7 +42,7 @@ $bt.sync('#test'); // perform a node synchro to specified browser tab on specific frame with callback - $bt.sync('#test', 'frameName', callback, '1449974562012'); + $bt.sync('#test', 'frameName', 'callbackname', '1449974562012'); // reload other browser tabs $bt.reload(); @@ -73,6 +74,15 @@ } } + // it's also possible to define a before and after function : + $bt.before = function(cmd) { + $bt.log("i'm fired before every command"); + } + + $bt.after = function(cmd) { + $bt.log("i'm fired after every command"); + } + // send a custom command to other browser tabs $bt.send({ name : $bt.CMD_CUSTOM, customKey : 'customValue' }); diff --git a/demo.html b/demo.html index ead1909..587fc6e 100644 --- a/demo.html +++ b/demo.html @@ -1,7 +1,7 @@ - pluie.org bt demo - v0.6 + pluie.org bt demo - v0.7