@@ -264,7 +264,7 @@ function sepiaFW_build_embedded_services(){
264264 return serviceResult ;
265265 }
266266
267- //Custom chat with action or card test
267+ //Custom chat with action or card test - Trigger via 'action [test]' or 'card [test]'
268268 Services . customChatWithActionOrCardTest = function ( nluInput , nluResult ) {
269269 //Get dummy answer
270270 var answerText = "Ok" ;
@@ -274,11 +274,15 @@ function sepiaFW_build_embedded_services(){
274274 if ( SepiaFW . offline && nluResult . parameters && nluResult . parameters . data ) {
275275 var cardInfo = "" ;
276276 var actionInfo = "" ;
277- var t = nluResult . parameters . data . test ;
277+ var t = nluResult . parameters . data . test ; //[test] value
278+ //action
278279 if ( nluResult . parameters . data . type == "action" ) {
279- actionInfo = dummyActions [ t ] ;
280+ var fun = dummyActions [ t ] ;
281+ if ( fun ) actionInfo = fun ( ) ;
282+ //card
280283 } else if ( nluResult . parameters . data . type == "card" ) {
281- cardInfo = "" ; //TODO
284+ var fun = dummyCards [ t ] ;
285+ if ( fun ) cardInfo = fun ( ) ;
282286 }
283287 var htmlInfo = "" ;
284288 serviceResult = Services . buildServiceResult (
@@ -325,48 +329,57 @@ function sepiaFW_build_embedded_services(){
325329 return actionInfo ;
326330 }
327331
332+ //NOTE: trigger test via chat "action html_1" etc.
328333 var dummyActions = {
329- "html_1" : Services . buildCustomActionInfo ( "show_html_result" , {
334+ "html_1" : function ( ) { return Services . buildCustomActionInfo ( "show_html_result" , {
330335 data : "<div class='card-box'>"
331336 + "<div style='background:#fff; color:#111; padding:5px;'><span>Hello World</span></div>"
332- + "<script>alert('fail');</script></div>" //<-- script will be filtered out
333- } ) ,
334- "frame_1" : Services . buildCustomActionInfo ( "open_frames_view" , {
335- info : { pageUrl : "templates/frames_template.html" }
336- } ) ,
337- "frame_2" : Services . buildCustomActionInfo ( "open_frames_view" , {
338- info : { pageUrl : ( location . href . replace ( / i n d e x .h t m l $ / , "" ) + "templates/frames_template.html" ) }
339- } ) ,
340- "frame_3" : Services . buildCustomActionInfo ( "open_frames_view" , {
341- info : { pageUrl : "https://b07z.net/downloads/cors/frames_template.html" }
342- } ) ,
343- "frame_4" : Services . buildCustomActionInfo ( "open_frames_view" , {
337+ + "<script>alert('fail');</script></div>" //<-- script will be filtered out (test)
338+ } ) ; } ,
339+ "frame_1" : function ( ) { return Services . buildCustomActionInfo ( "open_frames_view" , { //test relative link and view itself
340+ info : { pageUrl : "xtensions/custom-data/views/demo-view.html" }
341+ } ) ; } ,
342+ "frame_2" : function ( ) { return Services . buildCustomActionInfo ( "open_frames_view" , { //test absolute link
343+ info : { pageUrl : ( location . href . replace ( / i n d e x .h t m l $ / , "" ) + "xtensions/custom-data/views/demo-view.html" ) }
344+ } ) ; } ,
345+ "frame_3" : function ( ) { return Services . buildCustomActionInfo ( "open_frames_view" , { //test remote link
346+ info : { pageUrl : "https://b07z.net/downloads/cors/demo-view.html" }
347+ } ) ; } ,
348+ "frame_4" : function ( ) { return Services . buildCustomActionInfo ( "open_frames_view" , { //test path-replaced link
349+ info : { pageUrl : "<custom_data>/views/clock.html" }
350+ } ) ; } ,
351+ "frame_5" : function ( ) { return Services . buildCustomActionInfo ( "open_frames_view" , { //server-path + old style
344352 info : {
345- pageUrl : "<custom_data>/demo -view.html" , onOpen : "sayHelloOnOpen" ,
353+ pageUrl : "<assist_server>/views/custom -view-demo .html" , onOpen : "sayHelloOnOpen" ,
346354 onSpeechToTextInputHandler : "handleSttData" , onChatOutputHandler : "handleChatOutput"
347355 }
348- } ) ,
349- "frame_5" : Services . buildCustomActionInfo ( "open_frames_view" , {
350- info : {
351- pageUrl : "<assist_server>/views/custom-view-demo.html" , onOpen : "sayHelloOnOpen" ,
352- onSpeechToTextInputHandler : "handleSttData" , onChatOutputHandler : "handleChatOutput"
353- }
354- } ) ,
355- "custom_event_btn_1" : Services . buildCustomActionInfo ( "button_custom_event" , {
356+ } ) ; } ,
357+ "custom_event_btn_1" : function ( ) { return Services . buildCustomActionInfo ( "button_custom_event" , {
356358 title : "Test" , name : "test" , data : { "button" : 1 }
357- } ) ,
358- "custom_event_1" : Services . buildCustomActionInfo ( "trigger_custom_event" , {
359+ } ) ; } ,
360+ "custom_event_1" : function ( ) { return Services . buildCustomActionInfo ( "trigger_custom_event" , {
359361 name : "test" , data : { "direct" : 1 }
360- } ) ,
361- "settings_1" : Services . buildCustomActionInfo ( "open_settings" , {
362+ } ) ; } ,
363+ "settings_1" : function ( ) { return Services . buildCustomActionInfo ( "open_settings" , {
362364 section : "addresses"
363- } )
364-
365- //NOTE: trigger test via chat "action html_1" etc.
365+ } ) ; }
366366 }
367367
368368 //----- Cards dummy data -----
369369
370+ //NOTE: trigger test via chat "card embedded_player" etc.
371+ var dummyCards = {
372+ "embedded_player" : function ( ) {
373+ var url = "" ;
374+ var service = "embedded" ;
375+ var serviceResult = { } ;
376+ return Services . buildEmbeddedPlayerCardInfoDummy ( url , {
377+ artist : "Ed" ,
378+ song : "Twister"
379+ } , service , serviceResult ) ;
380+ }
381+ }
382+
370383 //Build a list with custom or dummy data
371384 Services . buildListCardInfoDummy = function ( id , title , section , indexType , group , listData ) {
372385 if ( ! title ) title = "Demo To-Do List" ;
@@ -543,7 +556,7 @@ function sepiaFW_build_embedded_services(){
543556 }
544557
545558 //Build a radio dummy card
546- Services . buildRadioCardInfoDummy = function ( language ) {
559+ Services . buildRadioCardInfoDummy = function ( language ) {
547560 var cardInfo = [ {
548561 "cardType" : "uni_list" ,
549562 "N" : 2 ,
@@ -562,6 +575,34 @@ function sepiaFW_build_embedded_services(){
562575 return cardInfo ;
563576 }
564577
578+ //Build link dummy card
579+ Services . buildEmbeddedPlayerCardInfoDummy = function ( url , searchObj , service , serviceResult ) {
580+ var image = undefined ;
581+ var imageBackground = undefined ;
582+ var cardInfo = [
583+ SepiaFW . offline . getLinkCard ( url , undefined , undefined , image , imageBackground , { } )
584+ ] ;
585+ if ( ! searchObj ) searchObj = { } ;
586+ cardInfo [ 0 ] . info [ 0 ] . data = {
587+ "title" : "Embedded Player" ,
588+ "desc" : "Test Card" ,
589+ "type" : "musicSearch" , //or "videoSearch"
590+ "autoplay" : true ,
591+ "typeData" : {
592+ "song" : searchObj . song || "" ,
593+ "playlist" : searchObj . playlist || "" ,
594+ "artist" : searchObj . artist || "" ,
595+ "album" : searchObj . album || "" ,
596+ "genre" : searchObj . genre || "" ,
597+ "uri" : url ,
598+ "service" : service || "embedded" ,
599+ "serviceResult" : serviceResult || { } //specific to service
600+ } ,
601+ "brand" : ""
602+ }
603+ return cardInfo ;
604+ }
605+
565606 //Build a weather dummy card
566607 Services . buildWeatherCardInfoDummy = function ( language ) {
567608 var cardInfo = [ {
0 commit comments