JS Classes
  All package blogs All package blogs   .Flow .Flow   Blog .Flow package blog   RSS 1.0 feed RSS 2.0 feed   Blog Using the webfanInten...  
  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  
Top featured articles

1. Tutorial of How to View the JavaScript Diff of Two Strings to Patch the Text and a PHP Alternative
2. Front-end interactive treeview
3. Load Page Content Faster by the Right Order
3. Cross-Domain AJAX versus JSONP
3. Protecting Browser Side User Data in JavaScript using Cryptography with secStore.js



Author:

Updated on: 2016-04-09

Posted on:

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.





By Germany

webfan.de

<email contact>

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

Login Immediately with your account on:

FacebookGmail
HotmailStackOverflow
GitHubYahoo


Comments:

No comments were submitted yet.



  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  
  All package blogs All package blogs   .Flow .Flow   Blog .Flow package blog   RSS 1.0 feed RSS 2.0 feed   Blog Using the webfanInten...