From 50bf4cde648d7f0377774560442ccb11fa6aa84b Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Tue, 29 Nov 2016 21:50:29 +0100 Subject: documenting wallet detection --- php/doc/tutorial.texi | 79 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'php') diff --git a/php/doc/tutorial.texi b/php/doc/tutorial.texi index 5ae990b..4a31fc8 100644 --- a/php/doc/tutorial.texi +++ b/php/doc/tutorial.texi @@ -554,8 +554,83 @@ See below both parts: @section Reacting to the presence of a Taler wallet @cindex wallet -FIXME. -@c with and without JavaScript! +Taler offers the way to the frontend developer to detect whether +a user has the wallet installed in their browser, and take actions +accordingly. + +@subsection The no-JavaScript way +The follwing example shows all that is needed to perform the detection +without using JavaScript: + +@smallexample + + + + Tutorial + + + +

+ No wallet found. +

+

+ Wallet found! +

+ + +@end smallexample + +The @code{taler-fallback.css} is part of the Taler's @emph{web-common} repository, +available at @code{https://git.taler.net/web-common.git}. Please adjust the @code{href} +attribute in order to make it work with your Web site. + +The detection works by @code{taler-fallback.css} hiding any tag from the +@code{taler-installed-show} class, in case no wallet is installed. If otherwise +the wallet is installed, the wallet takes action by hiding any tag from +@code{taler-installed-hide} and overriding @code{taler-fallback.css} logic +by showing any tag from the @code{taler-installed-show} class. + +@subsection The JavaScript way + +In this case, the @code{taler-wallet-lib} helps the frontend, by providing +the way to register two callbacks: one to be executed if a wallet is present, +the other if it is not. See the example below: + +@smallexample + + + + + +
+
+ + + +@end smallexample + +@code{taler-wallet-lib.js} exports the @code{taler} object that +exposes the @code{onPresent} and the @code{onAbsent} functions needed +to register the frontend's callbacks. Thus the function @code{walletInstalled} +will be executed whenever a wallet is installed, and @code{walletNotInstalled} +if not. Note that since now we can use JavaScript we can register +callbacks that do more than just showing and hiding elements. @node Taler contracts -- cgit v1.2.3