File: test.js

Recommend this page to a friend!
  Classes of Melanie Wehowski   webfan JavaScript Intents Service Server   test.js   Download  
File: test.js
Role: Example script
Content type: text/plain
Description: test.js
Class: webfan JavaScript Intents Service Server
Register and call services to handle Web intents
Author: By
Last change:
Date: 8 years ago
Size: 4,230 bytes
 

Contents

Class file image Download
/* website http://test.freizeittreffen.de/pmx/#/frdl/webfan/console/start/361582188 */ try{ if(''===newValue || newValue===oldValue || '' === new frdl.Url(newValue).getScheme()){ $scope.urls.API_CLIENT_URL=oldValue; return; } var metaApiUrl = document.querySelector('meta[name="flow.component.frdl.webfan.api.url"]'); if(null!==metaApiUrl){ metaApiUrl.setAttribute('content', newValue); } else{ metaApiUrl=frdl.Dom.create('meta'); metaApiUrl.setAttribute('name', 'flow.component.frdl.webfan.api.url'); metaApiUrl.setAttribute('content', newValue); frdl.Dom.add(metaApiUrl, frdl.$q('head', false)); } $('*[data-frdl-component-console-terminal*=""]').data('url2', newValue); $scope.caption = $scope.captionInitial + ' [@'+ newValue+']'; if(false===_fromIntent){ window.navigator.startActivity(new Intent( 'http://webintents.org/pick', 'application/vnd.frdl.webfan.client.sdk+json' , $.extend( { 'API_CLIENT_URL' : newValue, 'title' : $scope.title }, $scope.installData || {} ) ), function (data) { if(200 !== parseInt(data.code)){ frdl.alert.error('The service application throws an error: ' +(data.error || null).toString() ); }else{ if(!!data.message)frdl.alert.log(data.message.toString(), 'success', 0) } }); } _fromIntent=false; }catch(err){ console.warn(err); } /* service */ frdl.when(function(){ if( null === new frdl.Url().getParam('intents') || ''===new frdl.Url().getParam('intents'))return null; return ( 'undefined'!==typeof frdl.frdl$intentService); }, function(){ console.log('Register Intent ...'); frdl.frdl$intentService.register('application/vnd.frdl.webfan.client.sdk+json', 'http://webintents.org/pick', function(_intent){ _fromIntent = true; $scope.urls.API_CLIENT_URL = _intent.data.API_CLIENT_URL; _DB.save('API_CLIENT_URL', $scope.urls.API_CLIENT_URL); clearViews('*[ui-view]', '*[data-webfan-view]'); var r = { code : 200, replyTo : _intent._id, message : 'Your Client was picked! ' + "\n" + $scope.urls.API_CLIENT_URL + "\n"+' by ' + "\n"+ new frdl.Url().getHost(), 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" + frdl.Dom.renderJSON(r)+"\n" +'</section>' +'[ <a href="javascript:;" onclick="window.close();try{window.opener.close();}catch(err){console.warn(err)}" style="color:red;">Close</a> ]' ); return r; }, {}, AppData) .run() ; }, $scope, function(_intent){console.log('Failed to register action server');}, 1);