{"name":"Youglish Word","key":"youglishword","version":"1.0.1","instructions":"Embed a Youglish player for a specify word or phrase.","showatto":"1","showplayers":"0","requirecss":"","requirejs":"","shim":"","defaults":"term=\"\",language=\"English|Arabic|Chinese|Dutch|French|German|Greek|Hebrew|Italian|Japanese|Korean|Polish|Portuguese|Russian|Spanish|Swedish|Thai|Turkish|Ukrainian|Vietnamese|Sign Languages\"","amd":"1","body":"\n
","bodyend":"","script":"var app = {\n widget: false,\n term: '',\n views: 0,\n curTrack: 0,\n totalTracks: 0,\n YG_ID: @@AUTOID@@ + '_youglish-widget',\n YG_WIDGET: '#' + @@AUTOID@@ + '_youglish-widget',\n YG_PLACEHOLDER: '.youglish-placeholder',\n YGC: {\n searchbox: 1,\n accentpanel: 2,\n title: 4,\n captions:\t8,\n speedcontrols: 16,\n toggleui:\t32,\n controlbuttons: 64,\n dictionary: 128,\n nearbypanel: 256,\n phoneticpanel: 512,\n draggable: 1024,\n minimizable: 2048,\n closable:\t4096,\n allcaptions:\t8192,\n togglelight:\t16384,\n togglethumbnails:\t32768\n },\n\n\n //The API will call this method when the search is done\n onFetchDone: function (event) {\n log.debug('onFetchDone');\n if (event.totalResult === 0) {\n alert(\"No result found\");\n }else{\n app.totalTracks = event.totalResult;\n app.element.find(app.YG_PLACEHOLDER).hide();\n $(app.YG_WIDGET).show();\n }\n },\n\n //The API will call this method when switching to a new video.\n onVideoChange: function (event) {\n app.curTrack = event.trackNumber;\n app.views = 0;\n },\n\n //Player can take API calls now\n onPlayerReady: function (event) {\n log.debug('playerready');\n },\n //Player can take API calls now\n onError: function (event) {\n log.debug('error');\n log.debug('error: ' + event.code);\n },\n\n // The API will call this method when a caption is consumed.\n onCaptionConsumed: function (event) {\n log.debug(app.views,'views');\n if (++app.views < 3) {\n app.widget.replay();\n }else if (app.curTrack < app.totalTracks) {\n //turn autostart on for the next video\n app.widget.autoStart = 1;\n app.widget.next();\n }\n },\n\n\n load: function (lang,term,accent,element) {\n app.term=term;\n app.element=element;\n\n if(!lang||lang==='false'){\n return;\n }\n\n log.debug('loading the term: '+ app.term);\n var thefunc = function () {\n //create the widget\n log.debug('creating the widget');\n app.element.innerHTML = '
';\n app.widget = new YG.Widget(app.YG_ID, {\n width: 480,\n components: app.YGC.captions | app.YGC.dictionary | app.YGC.controlbuttons | app.YGC.toggleui | app.YGC.togglelight | app.YGC.togglethumbnails,\n autoStart: 1,\n events: {\n 'onFetchDone': app.onFetchDone,\n 'onVideoChange': app.onVideoChange,\n 'onCaptionConsumed': app.onCaptionConsumed,\n 'onPlayerReady': app.onPlayerReady,\n 'onError': app.onError\n }\n });\n // process the query\n $('#' + app.YG_ID).hide();\n log.debug('first fetch of the term: '+ app.term);\n if(accent && accent!=='false') {\n app.widget.fetch(app.term, lang, accent);\n }else{\n app.widget.fetch(app.term, lang);\n }\n };\n\n if (typeof YG === 'undefined') {\n $.getScript('https://youglish.com/public/emb/widget.js', thefunc);\n } else if(app.widget===false) {\n thefunc();\n }else{\n log.debug('reusing the widget');\n $(\"#\" + app.YG_ID).detach().appendTo(element);\n $('#' + app.YG_ID).hide();\n log.debug('close the previous widget');\n app.widget.close();\n log.debug('reuse fetch the term: '+ app.term);\n if(accent && accent!=='false') {\n app.widget.fetch(app.term, lang, accent);\n }else{\n app.widget.fetch(app.term, lang);\n }\n }\n },\n clear: function () {\n if(this.widget===false){return;}\n this.widget.close();\n },\n stop: function () {\n if(this.widget===false){return;}\n this.widget.pause();\n }\n }\n app.load(@@language@@,@@term@@,'false',$('#' +@@AUTOID@@)[0]);","style":"","dataset":"","datasetvars":"","alternate":"","alternateend":""}