Icontem

File: test2/test.service.html

Recommend this page to a friend!
  Classes of Till Wehowski  >  webfan JavaScript Intents Service Server  >  test2/test.service.html  >  Download  
File: test2/test.service.html
Role: Example script
Content type: text/plain
Description: Example/test (service)
Class: webfan JavaScript Intents Service Server
Register and call services to handle Web intents
Author: By
Last change:
Date: 1 year ago
Size: 3,083 bytes
 

Contents

Class file image Download
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://api.webfan.de/api-d/4/js-api/library.js"></script>
<script type="text/javascript" src="http://frdl.webfan.de/cdn/frdl/flow/components/frdl/intent/webintents.js"></script>
<script type="text/javascript" src="http://webfan.de/cdn/frdl/flow/components/webfan/webfat/js/intents.js"></script>
</head>
<body>
<b>TestMock service...</b>


 <script type="text/javascript">
 
  /* 
 var attachEventListener = function(obj, type, func, capture) {
  var objs = obj instanceof Array  || obj instanceof NodeList ? obj : [obj];

  for(var i in objs) {
    if(!!objs[i].addEventListener) {
      objs[i].addEventListener(type, func, capture);
    }
    else if(!!objs[i].attachEvent) {
      objs[i].attachEvent("on" + type, func);
    }
  }
};
 

    	

 
    attachEventListener(window, "message", function(ev) {
      if(!intent)return;
 
      intent.postResult("Test result from service");
      window.opener.focus();
      setTimeout(function(){
       	 alert('Resolved testIntent (response was posted back to client): ' + JSON.stringify(intent) + ' EventData: '+ JSON.stringify(ev.data) + ' Event: '+ JSON.stringify(ev));
      	 window.close();
      },1500);
     
    }, false);

     */ 
  setTimeout(function(){     
     frdl.when(function(){
 	  return ( 'undefined'!==typeof frdl.frdl$intentService);
 	},
    function(){        
       frdl.frdl$intentService.register('text/uri-list', 'com.webfan.intents.test', 
               function(_intent,config,appData){
                   
                       
       	           var r = {
			              code : 200,
			              replyTo : _intent._id,
			              message : 'Testantwort',
			              error : null,
			              data : {
			              	message : 'Testantwort'
			              }
			         }; 
       	           

                     return r;   	
                },
                function(){
                  console.log('initFn')	;
                }, 
                {}, {})
         .run()  
          ;
    	},
    		   
    {}, 
     function(_intent){console.log('Failed to register action server');},
   1);
 },10000);         
        
 </script>
 <!-- -->
 
 
    <!--
    
    <intent
    action="http://webintents.org/shorten"
    type="text/uri-list"
    href="http://examples.webintents.org/intents/shorten/shorten_action.html"
    title="Kinlan's Link Shortener" />
    
    
    
    attachEventListener(window, "load", function() {
  var output = document.getElementById("output");
  setText(output, intent.data);
  intent.postResult("http://kin.ly/A");
}, false);

http://examples.webintents.org/intents/shorten/shorten_action.html
    
    
    
    
    
  window.navigator.startActivity(new Intent(
      "http://webintents.org/shorten",
      "text/uri-list",
      'http://example.com'), 
    function (data) {
      alert(data);  
  });



    -->
</body>    	
</html>