Author: Till Wehowski
Viewers: 11
Last month viewers: 1
Package: µ.Flow
With "webfanIntents" it is possible to delegate an "action" to an arbitrary 3rd party applications implementing the spec while server, client and API does not know of each other.
Read more about the specification...
Quick Usage Example:
First include the library on client and server side:<script type="text/javascript" src="http://api.webfan.de/api-d/4/js-api/library.js"></script>On the client regsiter an intent and start an Activity (by button click):
<intent action="http://webintents.org/pick" type="application/vnd.frdl.webfan.client.sdk+json" title="My SDK Client" disposition="new" icon="favicon.ico" href="?intents=1" /> <button onclick=" window.navigator.startActivity( new Intent( 'http://webintents.org/pick', 'application/vnd.frdl.webfan.client.sdk+json' , { 'API_CLIENT_URL' : frdl.route( 'API_CLIENT_URL' ), 'title' : 'Webfan API SDK Client' } ), function (data) { if( 200 !== parseInt(data.code) ) { alert( 'The service application throws an error: ' + ( data.error || null).toString() ); } else { if(!!data.message)alert(data.message.toString()) } }); " > Test start webfanIntents activity with demo data... </button>On the server side include in your head section:
<script type="text/javascript" src = "http://webfan.de/cdn/frdl/flow/components/webfan/webfat/js/intents.js"></script>Register and run and Service for an Action with a given mime-type:
<div ui-view="mainView"></div> <script> var API_CLIENT_URL; frdl.when( function() { return ('undefined' !== typeof frdl.frdl$intentService ); }, function(){ frdl.frdl$intentService.register( 'application/vnd.frdl.webfan.client.sdk+json', 'http://webintents.org/pick', function(_intent){ API_CLIENT_URL = _intent.data.API_CLIENT_URL; var r = { code : 200, replyTo : _intent._id, message : 'Your Client was picked! ' + "\n" + API_CLIENT_URL + "\n"+' by ' + "\n"+ new frdl.Url().urlMakeNew(), error : null, data : { } }; $('*[ui-view="mainView"]') .html('' + '<section class="console-screen">' +' frdl://webfanIntents/' + 'application/' + 'vnd.frdl.webfan.client.sdk+json' + '/http://webintents.org/pick > '+"\n" +' sendResponse > '+"\n" + JSON.stringify(r)+"\n" +'</section>'); return r; }, { describe: 'config data' }, { describe: 'server data'}) .run() ; }, { describe: 'callback argument' }, function( _intent ){ console.log( 'Failed to register action server' );}, 1); </script>
You need to be a registered user or login to post a comment
25,349 JavaScript developers registered to the JS Classes site.
Be One of Us!
Login Immediately with your account on:
Comments:
No comments were submitted yet.