Your Custom Widgets offer such a rich collection of features that I decided to write a comprehensive User Guide to help out novice users.
It takes a lot of examples to cover the advanced features of your Enhanced Search Widget which combines Graphical Search and Attribute Search with Spatial Analysis Tools.
It is unwieldy to download and navigate through this large 47MB PDF document.
So I researched and found a nifty program that converts your Word Document into a clean and elegant Web Help system without having to write a single line of code!
It shows where to download the trial version of Dr. Explain, how to create an Online Help system using a sample Word Doc, and whom to contact to purchase an Advanced License that removes the watermarks.
The conversion process is so simple that there is no excuse not to publish an Online Help to go with the Web Apps.
It adds a professional touch and eliminates support calls.
I forget... is there a way to configure eSearch so it will return a number of records that exceeds the "Maximum Number of Records Returned by Server" set in the map service? Or is that accomplished only by increasing that cap in the map service properties?
can you use custom images or any kind of images at all in the specific filters that you want to create based off a layer. Robert Scheitlin, GISP. We are trying to create some custom searches using the enhanced tool just wanted to ask if there was a way to use some custom images. thanks
I didn't completely understand if the e-search widget can do what I want:
I want to select one polygon from a map service and then make a spatial query on a point feature layer to find all the points that intersect the polygon I selected.
I am using your eSearch widget for two apps. One app is running on older version of the widget(2.6) and other is running on current version. The apps lets users search for a parcel by address and suppose they search for an address field that has a value of '555 ne high school rd' as '555 high school', the older version of the widget finds the property but the newer version of the widget cannot find the same property unless they type '555 ne high school'. The older style was very helpful to us because it would find results even when the user did not enter any address direction prefix or suffix to their search. Is there any way that this functionality can be achieved in the newer widget versions?
Yes there is a option in the widgets settings for the old style search. Edit General Settings > "String search that uses contains will search each word in the query separately"
Can you look in the browsers web console after you do the search and compare the SQL (i.e. "SQL Where with layers definition expression: ZONING_TYPE = 'RESIDENTIAL'") that is logged there in both versions?
I see the SQL where definition is different in the two versions.
For the newer version of the widget which did not return results,
It is SQL Where with layers definition expression: Upper(Address) LIKE Upper('%555 high school%')
For the older version of the widget that returned results,
SQL Where with layers definition expression: It is Upper(Address) LIKE Upper('%555%') AND Upper(Address) LIKE Upper('%high%') AND Upper(Address) LIKE Upper('%school%')
OK that is what the Edit General Settings > "String search that uses contains will search each word in the query separately" is suppose to take care of. In the new version after checking that setting and running the search again what is the SQL?
This is what the SQL says in the newer version. I see that it is replacing AND with OR in the query
SQL Where with layers definition expression: Upper(Address) LIKE Upper('%555%') OR Upper(Address) LIKE Upper('%high%') OR Upper(Address) LIKE Upper('%school%')
OK, Now we are getting somewhere. So can you open the eSearch widget config.json in your apps confis/eSearch/*.json file and copy and paste the portion pertaining to this search?
I'm trying to setup a search expression using the IN operator and configure it with a pre-determined list of values, but I can't get it to work. If I enter the values like so: CC,RRC-R10000,RRC-R.5,RRC-R1,RRC-R2,STMU,STR-4 -- then the search expression ends up like this: ZONE IN ('CC,RRC-R10000,RRC-R.5,RRC-R1,RRC-R2,STMU,STR-4'). If I enter the values like so: 'CC','RRC-R10000','RRC-R.5','RRC-R1','RRC-R2','STMU','STR-4' -- then the search expression ends up like this: ZONE IN ('''CC'',''RRC-R10000'',''RRC-R.5'',''RRC-R1'',''RRC-R2'',''STMU'',''STR-4''').
Has anyone tried setting up a search like this an gotten it to work?
Hi all, is it just me or is it if you have multiple instances of the widget, one widget HTML overrides the other one?
I'll give you an example on a test site on WAB 2.12 / eSearch 2.11. https://public.sagis.org/eSearchTest/ First widget on left, the green Parcel Search, is eSearch. The second one, the Blue Cloud aka Site Selection, is a second instance of eSearch. The first one searches only one layer, Parcels. The second, searches several. So the first one doesn't need a 'select layer to search' dropdown. And in fact it seems to hide itself if that is the case. I think maybe I did CSS somewhere to assist with that.
So if you open the Parcel Search then the Blue Cloud, works fine. But... if you do the reverse, and first open the Blue Cloud, THEN the Parcel Search, it gets all messed up. Notice it removes the Layer Selector menu in Blue Cloud.
It gets taller to match the first instance height (I added some extra text on that one as you can see at the bottom) , the Search Layer disappears and other menu shifts to the left.
It also then creates a blank unnecessary Search Layer selection dropdown on the Parcel Search. (You will see it happen)
I tried to no avail to hide it with CSS but to not kill it on the other instance. Including putting it in a DIV and doing #parceleSearch #dijit_form_Select_8_menu visibility: none and #parceleSearch #dijit_form_Select_2_menu (to catch both open orders, but try not to kill the Site Selection instance which does NOT have an ID on the parent DIV containing the dropdown). Any combination of CSS either nukes the layer selector dropdown from both, or doesn't work at all. Curiously most CSS doesn't seem to affect it even with the right specificity and !important etc etc. Really odd I wasn't able to tackle with CSS. Part of this stems from how Dojo assigns arbitrary IDs on the fly which is kind of annoying and breaks the whole concept of HTML at least easily. I don't feel like doing script for simple UI. I guess maybe I'll have to?
I tried starting over, in case some of my custom html in Parcel Search was the issue. By just adding two vanilla eSearch 2.11 instances from scratch, same thing happens. example here: https://public.sagis.org/eSearchTestvanilla/ Thoughts?
Perhaps this goes without saying but could be helpful, but I found that this only starts happening once I add a search Expression so the By Value tab is present. Of course, it's in this Tab that the problem is located in the first place. And it even happens when I create a copy of eSearch in the Stemapp folder, and name it eSearch2 and in manifest add 2 to the name, in case that would have helped. So there is a complete copy of the widget with a new name. Still happens.
Hmm. I have not done much testing with two or more instances. Thanks for pointing this issue out. The fix is a simple code change in the Widget.js _initLayerSelect function.
Lines 4, 11 and 18 now get a specific reference to the current widgets tab dom node.
I added this to both. https://public.sagis.org/esearchtest2/ It shows a 'blank' dropdown on the second one still. It does however fix the removing of the menu in the second instance. So it seems it still needs to add a class to hide the "Search Layer" if there is only layer. (no need to select or show a user a blank menu if there is only one layer to search and it is hard coded as in my Parcel Search instance)
I am also wondering the affect multiple instances would have on the Search URL. That is a dynamite feature. Last, a question... Were you considering ever adding a way to have the Search URL work, if the widget is closed i.e. not open at start up? I know earlier in this thread there was somewhat of a workaround way to get this to work. I eventually settled on just relying on the Share widget.
Mine does not respond that way, i.e. I do not get an empty drop down. Is the last url you posted a vanilla app with none of your css rule changes? The url search feature of the eSearch is definitely designed for one instance of the eSearch. Currently each instance would attempt to search based on the url provided. The current eSearch will attempt to search for the url parameters as soon as it (the widget) is opend.
I didn't have any CSS that I see, none in index or eSearch's css. But it must have been somewhere. Although I initially created a copy of eSearch and gave it a wholly new name, the folder and manifest. (I thought maybe that would help, or at least I wanted to see 'what would happen') So it had two widget folders eSearch and eSearchNEW. The first time in test2. In test3, I did it the 'normal way', where I added the widget, then added it again, all within WAB. So it has one widget folder. And now it works. Perhaps that was why. Anyway no worry, it must just be something I did. Wanted to just check.
As for how loads the Query once opened, that's awesome. However the way widgets 'silently' work, even when closed, like the WAB Share widget, via URL parameter, that allows incoming requests. For example from the Property Card to the map viewer, via PIN (parcel ID) number. Not sure if that would be implementable for eSearch at some point?
Thanks as always Robert. The way eSearch is infinitely customizable is why it lends itself to multiple instances. Looks like it works perfectly now with your new logic.
I am missing something. If you do not have the eSearch widget set to open at start then the widget will never execute any code and thus will not do anything with the URL until the widget is opened. I don't see how the share widget is any different.
However the way widgets 'silently' work, even when closed, like the WAB Share widget, via URL parameter, that allows incoming requests.
The share widget does not do anything with out being opened. The app it self does things based on the url, like setting extent, setting the webmap, scale, etc, etc. All of these things happen because of the MapManager.js and other core code and have nothing to do with the share widget. So no the eSearch can not do anything without being opened so that it's code can do something with the url parameters.
This enables great integration from incoming links from other apps.
Side note: this does however highlight the weakness in the current webmap architecture, where JSON does not stay in sync with services automatically, requiring us to always re-add a service if layers are added, which changes the webmap service id (the 9233 above). I proposed Esri fix this important issue: https://community.esri.com/ideas/16701-keep-webmap-service-item-id-static
Robert, I definitely would have left your eSearch open at startup, if it was up to me. I find your eSearch interface is the most friendly of any option I have seen, to search for a property. And I think it is the best way to present results, better than the popup. But .. it was decided against. So I implemented the Search widget as here.
As I mentioned already that url works because the WAB Core code supports certain URL parameters without the use of any widget. My eSearch widget does not have access to change the Core WAB code base.
Ah ok, they built it in. Maybe the WAB team could in the future make MapManager more exposed or extensible? So as to allow a widget developer to allow parameters without too much extra code? Or maybe that is the point, it is private so as to ensure stability. Just thinking out loud so to speak. Thanks Robert for your thorough explanation.
I've added a secured layer into the config file and created a Group in Portal containing users who can access this layer. For those in the Group, when the eSearch widget is opened, they can see the layer in the search layer pulldown menu. However, for those who do not, a pop-up window appears asking for credentials. Is there a way to suppress this window?
James Ko You could listen for the event, then use a .click() on it, it probably has a unique label or other attribute? Just guessing. Like document.getElementsByClassName('TheButtonClass')[0].click() or document.getElementById("myCheck").click() or even by label (tagname). And use dojo ready() or even a timeout to ensure the DOM is there to click on it. Timeout is not the best way to do things like this so that would be a last ditch effort. Would be best to use published and subscribed events or test for conditions. I really wish Esri gave all their elements DOM id's in WebApp Builder. That would make events much, much easier.
1) How can I make it open in to the Graphical Search tab, after opening?
I set it by default to open in Search by Attribute Value. But when I open it programmatically, I actually want it to open to the Graphical Search tab. So, I tried using document.getElementById("eSearchTab").click(); after appending a DOM id to nearly a few various elements in that tab in widget.html, trying to grab it by the label, which I saw in F12, by tagname.click() even, etc. No luck. I see the logic to push content to shapeTab in eSearch/widget.js and the this.selTab lines, but I am not sure exactly which method to call, to tell your eSearch to activate the Graphic Search tab?
2) Interestingly, it opens fine when I open my first Infographic widget instance. However, if I open another Infographic, it closes it. Then, if I open a third one, it opens again. Apparently if a widget calls to programmatically open it, and it's already open, it closes.
Apparently it is toggling a visibility somehow when it sets that id in WidgetManager? I was thinking there should be a simple 'visible' property for a widget I could test for, with an if statement. I saw a visibility property but that didn't seem to work when tested for. Thoughts?
var widgetCtlr = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0];if(widgetCtlr.getOpenedIds().indexOf(this.appConfig.widgetPool.widgets[7].id)===-1){
widgetCtlr.setOpenedIds([this.appConfig.widgetPool.widgets[7].id]);}setTimeout(lang.hitch(this,function(){var es = WidgetManager.getInstance().getWidgetById(this.appConfig.widgetPool.widgets[7].id);
es.tabContainer.selectTab(es.nls.selectFeatures);}),500);
To make sure that the widget does not toggle first check if it is already part of the OpenedIds (line 2).
I have a question, I am trying to add this widget to my app. I added it to my IIS folder and when I go to add the item into my webmap, I click on custom, click it once to get the check mark but when I click on Ok, nothing happens. The web app has permissions, not sure what Im missing...any ideas?
Are you using Portal or WAB Developer? If Portal what version. The big thing to understand about Portal is that based on your Portal version it is a couple of WAB versions behind so you need to be using the right version of the eSearch. See this link to know what version of WAB your Portal version is using.
';
}
}
}
catch(e){
}
}
}
if (newSub.getAttribute("slang").toLowerCase() != code_l.toLowerCase()) {
if (trLabelsHtml != "") {
var labelSname = "";
if(labelEle[i].querySelector("ul li:nth-child(1)").getAttribute("aria-hidden")){
labelSname = labelEle[i].querySelector("ul li:nth-child(1)").outerHTML;
}
labelEle[i].innerHTML = "";
labelEle[i].innerHTML = labelSname + trLabelsHtml;
}
}
}
}
}
catch(e){
}
}
}
/* V 2.0:3 = Store not translated reply id */
if(lingoRSXML.snapshotLength == 0){
if($scope.falseReplyID == "") {
$scope.falseReplyID = value;
}
}
/* Get translated Body of Replies/Comments */
var lingoRBXML = doc.evaluate(lingoRBExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for(var i=0;i 0) {
var attachDiv = rootElement.querySelector('div.lia-quilt-row-main').querySelector('div.custom-attachments');
if (attachDiv) {
attachDiv = attachDiv.outerHTML;
}
else if(rootElement.querySelector('div.lia-quilt-row-main').querySelectorAll('#attachments').length > 0){
if ("TkbArticlePage" == "BlogArticlePage") {
attachDiv = rootElement.querySelector('div.lia-quilt-row-main .lia-message-body-content').querySelector('#attachments');
if (attachDiv) {
attachDiv = attachDiv.outerHTML;
}
else{
attachDiv = "";
}
}else{
attachDiv = rootElement.querySelector('div.lia-quilt-row-main').querySelector('#attachments').outerHTML;
}
}
else {
attachDiv = "";
}
/* Feedback Div */
var feedbackDiv = "";
var feedbackDivs = rootElement.querySelector('div.lia-quilt-row-main').querySelectorAll('div.lia-panel-feedback-banner-safe');
if (feedbackDivs.length > 0) {
for (var k = 0; k < feedbackDivs.length; k++) {
feedbackDiv = feedbackDiv + feedbackDivs[k].outerHTML;
}
}
}
else {
var attachDiv = rootElement.querySelector('div.lia-message-body-content').querySelector('div.Attachments.preview-attachments');
if (attachDiv) {
attachDiv = attachDiv.outerHTML;
} else {
attachDiv = "";
}
/* Everyone tags links */
if (document.querySelectorAll("div.TagList").length > 0){
var everyoneTagslink = document.querySelector('div.lia-quilt-row-main').querySelector(".MessageTagsTaplet .TagList");
if ((everyoneTagslink != null)||(everyoneTagslink != undefined)){
everyoneTagslink = everyoneTagslink.outerHTML;
}
else{
everyoneTagslink = "";
}
}
/* Feedback Div */
var feedbackDiv = "";
var feedbackDivs = rootElement.querySelector('div.lia-message-body-content').querySelectorAll('div.lia-panel-feedback-banner-safe');
if (feedbackDivs.length > 0) {
for (var m = 0; m < feedbackDivs.length; m++) {
feedbackDiv = feedbackDiv + feedbackDivs[m].outerHTML;
}
}
}
}
} catch (e) {
}
if (body_L == "") {
/* V 2.0:7 Replacing translated video data with source video data */
var newBodyVideoData = newBody.querySelectorAll('div[class*="video-embed"]');
angular.forEach($scope.videoData[value], function (sourceVideoElement, index) {
if (index <= (newBodyVideoData.length - 1)) {
newBodyVideoData[index].outerHTML = sourceVideoElement.outerHTML
}
});
/* V 2.0:7 = Replacing translated image data with source data */
var newBodyImageData = newBody.querySelectorAll('[class*="lia-image"]');
angular.forEach($scope.imageData[value], function (sourceImgElement, index) {
if (index <= (newBodyImageData.length - 1)) {
newBodyImageData[index].outerHTML = sourceImgElement.outerHTML;
}
});
/* V 2.0:7 = Replacing translated pre tag data with source data */
var newBodyPreTagData = newBody.querySelectorAll('pre');
angular.forEach($scope.preTagData[value], function (sourcePreTagElement, index) {
if (index <= (newBodyPreTagData.length - 1)) {
newBodyPreTagData[index].outerHTML = sourcePreTagElement.outerHTML;
}
});
}
var copyBodySubject = false;
if (body_L == "") {
copyBodySubject = true;
body_L = newBody.innerHTML;
}
/* This code is written as part of video fix by iTalent */
/* try{
var iframeHTMLText = body_L;
var searchIframeText = "<IFRAME";
var foundiFrameTag;
if (iframeHTMLText.indexOf(searchIframeText) > -1) {
foundiFrameTag = decodeHTMLEntities(iframeHTMLText);
foundiFrameTag = foundiFrameTag.split('src="')[1];
body_L = foundiFrameTag;
}
}
catch(e){
} */
/* This code is placed to remove the extra meta tag adding in the UI*/
try{
body_L = body_L.replace('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />','');
}
catch(e){
}
/** We should not replace the source content if user profile language and selected target language matches with source language **/
if(showTrContent) {
var compiled = false;
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = null
if("TkbArticlePage"=="IdeaPage"){
// var customAttachDiv = '';
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv ;
$compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope);
compiled = true;
/* Attach atttach div */
// document.querySelector("div.translation-attachments-"+value).innerHTML = attachDiv;
rootElement.querySelectorAll('div.lia-message-body-content')[0].insertAdjacentHTML('afterend',attachDiv);
if(rootElement.querySelectorAll('div.lia-quilt-idea-message .lia-message-body .lia-attachments-message').length > 1){
rootElement.querySelectorAll('div.lia-quilt-idea-message .lia-message-body .lia-attachments-message')[1].remove();
}
} else {
if("TkbArticlePage"=="TkbArticlePage"){
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv ;
}else{
rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv + attachDiv;
compiled = true;
}
}
/* Destroy and recreate OOyala player videos to restore the videos in target languages which is written by iTalent as part of iTrack LILICON-79 */ /* Destroy and recreate OOyala player videos */
try{
// $scope.videoData[value][0].querySelector("div").getAttribute("id");
for(var vidIndex=0; vidIndex<$scope.videoData[value].length; vidIndex++){
if( $scope.videoData[value][vidIndex].querySelector("div") != null){
var containerId = LITHIUM.OOYALA.players[$scope.videoData[value][vidIndex].querySelector("div").getAttribute("id")].containerId;
videoId = LITHIUM.OOYALA.players[$scope.videoData[value][vidIndex].querySelector("div").getAttribute("id")].videoId;
/** Get the Video object */
vid = OO.Player.create(containerId,videoId);
/** Destroy the video **/
vid.destroy();
/** recreate in the same position */
var vid = OO.Player.create(containerId,videoId);
}
}
}
catch(e){
}
try{
for(var vidIndex=0; vidIndex<($scope.videoData[value].length); vidIndex++){
if($scope.videoData[value][vidIndex].querySelector('video-js') != null){
var data_id = $scope.videoData[value][vidIndex].querySelector('video-js').getAttribute('data-video-id');
var data_account = $scope.videoData[value][vidIndex].querySelector('video-js').getAttribute('data-account');
var data_palyer = $scope.videoData[value][vidIndex].querySelector('video-js').getAttribute('data-player');
var div = document.createElement('div');
div.id = "brightcove";
div.class = "brightcove-player";
div.innerHTML =
'(view in my videos)'
var data = div.getElementsByClassName("video-js");
var script = document.createElement('script');
script.src = "https://players.brightcove.net/" + data_account + "/" + data_palyer + "_default/index.min.js";
for(var i=0;i< data.length;i++){
videodata.push(data[i]);
}
}
}
for(var i=0;i< videodata.length;i++){
document.getElementsByClassName('lia-vid-container')[i].innerHTML = videodata[i].outerHTML;
document.body.appendChild(script);
}
}
catch(e){
}
if(!compiled){
/* Re compile html */
$compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope);
}
}
if (code_l.toLowerCase() != newBody.getAttribute("slang").toLowerCase()) {
/* Adding Translation flag */
var tr_obj = $filter('filter')($scope.sourceLangList, function (obj_l) {
return obj_l.code.toLowerCase() === newBody.getAttribute("slang").toLowerCase()
});
if (tr_obj.length > 0) {
tr_text = "Esri may utilize third parties to translate your data and/or imagery to facilitate communication across different languages.".replace(/lilicon-trans-text/g, tr_obj[0].title);
try {
if ($scope.wootMessages[$rootScope.profLang] != undefined) {
tr_text = $scope.wootMessages[$rootScope.profLang].replace(/lilicon-trans-text/g, tr_obj[0].title);
}
} catch (e) {
}
} else {
//tr_text = "This message was translated for your convenience!";
tr_text = "Esri may utilize third parties to translate your data and/or imagery to facilitate communication across different languages.";
}
try {
if (!document.getElementById("tr-msz-" + value)) {
var tr_para = document.createElement("P");
tr_para.setAttribute("id", "tr-msz-" + value);
tr_para.setAttribute("class", "tr-msz");
tr_para.style.textAlign = 'justify';
var tr_fTag = document.createElement("IMG");
tr_fTag.setAttribute("class", "tFlag");
tr_fTag.setAttribute("src", "/html/assets/langTrFlag.PNG");
tr_fTag.style.marginRight = "5px";
tr_fTag.style.height = "14px";
tr_para.appendChild(tr_fTag);
var tr_textNode = document.createTextNode(tr_text);
tr_para.appendChild(tr_textNode);
/* Woot message only for multi source */
if(rootElement.querySelector(".lia-quilt-forum-message")){
rootElement.querySelector(".lia-quilt-forum-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-message-view-blog-topic-message")) {
rootElement.querySelector(".lia-message-view-blog-topic-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-blog-reply-message")){
rootElement.querySelector(".lia-quilt-blog-reply-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-tkb-message")){
rootElement.querySelector(".lia-quilt-tkb-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-tkb-reply-message")){
rootElement.querySelector(".lia-quilt-tkb-reply-message").insertBefore(tr_para,rootElement.querySelector(".lia-quilt-row.lia-quilt-row-footer"));
} else if(rootElement.querySelector(".lia-quilt-idea-message")){
rootElement.querySelector(".lia-quilt-idea-message").appendChild(tr_para);
} else if(rootElement.querySelector('.lia-quilt-occasion-message')){
rootElement.querySelector('.lia-quilt-occasion-message').appendChild(tr_para);
}
else {
if (rootElement.querySelectorAll('div.lia-quilt-row-footer').length > 0) {
rootElement.querySelectorAll('div.lia-quilt-row-footer')[0].appendChild(tr_para);
} else {
rootElement.querySelectorAll('div.lia-quilt-column-message-footer')[0].appendChild(tr_para);
}
}
}
} catch (e) {
}
}
} else {
/* Do not display button for same language */
// syncList.remove(value);
var index = $scope.syncList.indexOf(value);
if (index > -1) {
$scope.syncList.splice(index, 1);
}
}
}
}
});
});
/* V 1.1:2 = Reply Sync button for multi source translation */
} catch(e){
console.log(e);
}
};
if((rContent != undefined) && (rContent != "")) {
drawCanvas(decodeURIComponent(rContent));
/** Update variable with selected language code **/
$scope.previousSelCode = code_l;
}
};
/**
* @function manageTranslation
* @description Managess the translation of given language for the thread
* @param {string} langCode - Language Code
* @param {string} tid - Thread ID
*/
$scope.manageTranslation = function (langCode, tid) {
//debugger;
$scope.showTrText = false;
/* V 2.0:5 = actualStatus variable introduced to indicate detailed connector status on UI. This variable holds the actual translation percentage */
$scope.transPercent = "";
$scope.actualStatus = "";
if (tid != "") {
var bulkTranslation = lithiumPlugin.bulkTranslation(langCode, tid);
bulkTranslation.then(function (trContent) {
if(trContent.body != "") {
$scope.showPreview(trContent.body, $scope.mszList, langCode);
if(langCode != "en-US") {
$scope.showTrText = true;
}
}
if((trContent.status != "NA") && trContent.status != null) {
// $scope.transPercent = String(trContent.status);
$scope.actualStatus = String(trContent.status);
} else {
// $rootScope.errorMsg = "Translation is in progress. Please check again a few minutes."
$rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes."
}
$scope.workbench = trContent.wb;
/* V 2.0:4 = Trigger uncalled or delayed callbacks (documnet uploaded/translation completed from lithium).*/
if(trContent.callback == 'true') {
var trCompletCallback = lithiumPlugin.trCompletCallback(langCode, trContent.docID);
trCompletCallback.then(function (callback){
// $rootScope.errorMsg = "Downloading Translated content in " + langCode + " now. Please check again in a few minutes."
$rootScope.errorMsg = "Uploading content to translate. Please check again in a few minutes."
});
} else if (trContent.callback == 'upload') {
var trCompletUpload = lithiumPlugin.trCompletUpload(langCode, trContent.docID);
trCompletUpload.then(function (callback) {
//$rootScope.errorMsg = "Uploading content to translate. Please check again in a few minutes."
$rootScope.errorMsg = "Uploading content to translate. Please check again in a few minutes."
});
} else if ("many" == "one") {
$scope.updateOOS();
} else if("SmartConx" == "SmartConx"){
if ("many" == "many"){
$scope.updateOOS();
}
}else if ((trContent.status != null) && trContent.status.includes("100")) {
/* If everything fine then only check Out of Sync status */
$scope.updateOOS();
} else {
/* If translation perccent is less than 100 then show the percentage on UI */
$scope.transPercent = $scope.actualStatus;
}
});
}
}
/**
* @function selectThisLang
* @description Called on select dropdown.
* @param {string} lang - Language code
*
*/
$scope.selectThisLang = function (lang, anonymousFlag) {
/* 1.4:3 Update Analytics on language selection */
try {
setTimeout(()=>{
lingoThreadLangSelected(lang, '910880');
console.log("Language",lang);
},5000)
} catch (e) {
console.log(e);
}
/** Display Translated content **/
var getTranslation = lithiumPlugin.getTranslation(lang, "910880");
getTranslation.then(function (trContent) {
if (trContent.body != "") {
$scope.showPreview(trContent.body, $scope.mszList, lang);
} else {
//$rootScope.errorMsg = "Translation is in progress. Please check again in a few minutes."
$rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes."
}
});
};
var decodeEntities = (function() {
// this prevents any overhead from creating the object each time
var element = document.createElement('div');
function decodeHTMLEntities (str) {
if(str && typeof str === 'string') {
// strip script/html tags
str = str.replace(/