Choose Language
Hide Translation Bar
Discovery Summit | China 2021
Home
More
Abstracts
Speakers
About the series
China
当经验丰富、才思敏捷、好奇心强的人们齐聚一堂,分享数据分析的经验及洞察,一切美好都将发生。
Online
July 8-10
Discovery Summit China 2021 is over. Please visit the main page to see what events are coming up next.
Discovery Summit
' 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){ } /* 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 = "This post originally written in lilicon-trans-text has been computer translated for you. When you reply, it will also be translated back to lilicon-trans-text.".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 = "This message was translated for your convenience!"; } 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/lingoTrFlag.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-column-alley-left")){ rootElement.querySelector(".lia-quilt-column-alley-left").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); } } } } } } angular.forEach(mszList_l, function (value) { if (document.querySelectorAll('div.lia-js-data-messageUid-' + value).length > 0) { var rootElements = document.querySelectorAll('div.lia-js-data-messageUid-' + value); }else if(document.querySelectorAll('.lia-occasion-message-view .lia-component-occasion-message-view').length >0){ var rootElements = document.querySelectorAll('.lia-occasion-message-view .lia-component-occasion-message-view')[0].querySelectorAll('.lia-occasion-description')[0]; }else { var rootElements = document.querySelectorAll('div.message-uid-' + value); } angular.forEach(rootElements, function (rootElement) { if (value == '755419' && "OccasionPage" == "TkbArticlePage") { rootElement = document.querySelector('.lia-thread-topic'); } /* V1.1 Remove from UI */ if (document.getElementById("tr-msz-" + value)) { document.getElementById("tr-msz-" + value).remove(); } if (document.getElementById("tr-sync-" + value)) { document.getElementById("tr-sync-" + value).remove(); } /* XPath expression for subject and Body */ var lingoRBExp = "//lingo-body[@id = " + "'lingo-body-" + value + "'" + "]"; lingoRSExp = "//lingo-sub[@id = " + "'lingo-sub-" + value + "'" + "]"; /* Get translated subject of the message */ lingoRSXML = doc.evaluate(lingoRSExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < lingoRSXML.snapshotLength; i++) { /* Replace Reply/Comment subject with transalted subject */ var newSub = lingoRSXML.snapshotItem(i); /*** START : extracting subject from source if selected language and source language is same **/ var sub_L = ""; if (newSub.getAttribute("slang").toLowerCase() == code_l.toLowerCase()) { if (value == '755419') { sub_L = decodeURIComponent($scope.sourceContent[value].subject); } else{ sub_L = decodeURIComponent($scope.sourceContent[value].subject); } } else { sub_L = newSub.innerHTML; } /*** End : extracting subject from source if selected language and source language is same **/ /* This code is placed to remove the extra meta tag adding in the UI*/ try{ sub_L = sub_L.replace('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />',''); } catch(e){ } // if($scope.viewTrContentOnly || (newSub.getAttribute("slang").toLowerCase() != code_l.toLowerCase())) { if ($scope.viewTrContentOnly) { if ("OccasionPage" == "IdeaPage") { if (value == '755419') { if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){ document.querySelector('.MessageSubject .lia-message-subject').innerHTML = sub_L; } } } if ("OccasionPage" == "TkbArticlePage") { if (value == '755419') { if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){ var subTkbElement = document.querySelector('.lia-thread-subject'); if(subTkbElement){ document.querySelector('.lia-thread-subject').innerHTML = sub_L; } } } } else if ("OccasionPage" == "BlogArticlePage") { if (value == '755419') { try { if((sub_L != "") && (sub_L!= undefined) && (sub_L != "undefined")){ var subElement = rootElement.querySelector('.lia-blog-article-page-article-subject'); if(subElement) { subElement.innerText = sub_L; } } } catch (e) { } /* var subElement = rootElement.querySelectorAll('.lia-blog-article-page-article-subject'); for (var subI = 0; subI < subElement.length; subI++) { if((sub_L != "") && (sub_L!= undefined) && (sub_L != "undefined")){ subElement[subI].innerHTML = sub_L; } } */ } else { try { // rootElement.querySelectorAll('.lia-blog-article-page-article-subject').innerHTML= sub_L; /** var subElement = rootElement.querySelectorAll('.lia-blog-article-page-article-subject'); for (var j = 0; j < subElement.length; j++) { if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){ subElement[j].innerHTML = sub_L; } } **/ } catch (e) { } } } else { if (value == '755419') { try{ /* Start: This code is written by iTalent as part of iTrack LILICON - 98 */ if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){ if(document.querySelectorAll('.lia-quilt-forum-topic-page').length > 0){ if(rootElement.querySelector('div.lia-message-subject').querySelector('h5')){ rootElement.querySelector('div.lia-message-subject').querySelector('h5').innerText = decodeURIComponent(sub_L); } else { rootElement.querySelector('.MessageSubject .lia-message-subject').innerText = sub_L; } } else { rootElement.querySelector('.MessageSubject .lia-message-subject').innerText = sub_L; } } /* End: This code is written by iTalent as part of iTrack LILICON - 98 */ } catch(e){ console.log("subject not available for second time. error details: " + e); } } else { try { /* Start: This code is written by iTalent as part of LILICON - 98 reported by Ian */ if ("OccasionPage" == "IdeaPage") { if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){ document.querySelector('.lia-js-data-messageUid-'+ value).querySelector('.MessageSubject .lia-message-subject').innerText = sub_L; } } else{ if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){ rootElement.querySelector('.MessageSubject .lia-message-subject').innerText = sub_L; /* End: This code is written as part of LILICON - 98 reported by Ian */ } } } catch (e) { console.log("Reply subject not available. error details: " + e); } } } // Label translation var labelEle = document.querySelector("#labelsForMessage"); if (!labelEle) { labelEle = document.querySelector(".LabelsList"); } if (labelEle) { var listContains = labelEle.querySelector('.label'); if (listContains) { /* Commenting this code as bussiness want to point search with source language label */ // var tagHLink = labelEle.querySelectorAll(".label")[0].querySelector(".label-link").href.split("label-name")[0]; var lingoLabelExp = "//lingo-label/text()"; trLabels = []; trLabelsHtml = ""; /* Get translated labels of the message */ lingoLXML = doc.evaluate(lingoLabelExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); /* try{ for(var j=0;j
,'; } trLabelsHtml = trLabelsHtml+'
'+lTex+'
'; var tagHLink = labelEle.querySelectorAll(".label")[j].querySelector(".label-link").href; trLabelsHtml = trLabelsHtml+'
'+lTex+'
'; } } catch(e){} */ try{ var labelsLength = document.querySelector(".LabelsList").querySelectorAll(".label").length; var labelSnapshotLength = lingoLXML.snapshotLength; if (labelsLength == labelSnapshotLength){ for (var k = 0; k < lingoLXML.snapshotLength; k++) { //trLabels.push(lingoLXML.snapshotItem(i).textContent); if (k != 0) { //trLabelsHtml = trLabelsHtml + '
,
'; //diffVariable = kValue } try{ if(labelEle.querySelectorAll(".label")[k]){ tagHLink = labelEle.querySelectorAll(".label")[k].querySelector(".label-link").href; if ("OccasionPage" == "BlogArticlePage") { trLabelsHtml = trLabelsHtml + '
' + lingoLXML.snapshotItem(k).textContent + '
'; } else { trLabelsHtml = trLabelsHtml + '
' + lingoLXML.snapshotItem(k).textContent + '
'; } } } catch(e){ } } } } catch(e){ } if (newSub.getAttribute("slang").toLowerCase() != code_l.toLowerCase()) { if (trLabelsHtml != "") { labelEle.querySelector("ul").innerHTML = ""; labelEle.querySelector("ul").innerHTML = trLabelsHtml; // trLabels = trLabels.split(","); // trLabels = reverseArr(trLabels); // var tagHLink = labelEle.querySelectorAll(".label")[0].querySelector(".label-link").href.split("label-name")[0]; // cELabels = labelEle.querySelectorAll(".label"); // //cELabels = reverseArr(cELabels); // for(var cE=0; cE < trLabels.length; cE++) { // if(trLabels[cE]){ // cELabels[cE].querySelector(".label-link").text = trLabels[cE]; // } // } } } } } } } /* 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 */ lingoRBXML = doc.evaluate(lingoRBExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); /* Replace Reply/Comment Body with translated Body */ for (var i = 0; i < lingoRBXML.snapshotLength; i++) { var newBody = lingoRBXML.snapshotItem(i); /* try { var cPTags = newBody.getElementsByTagName("p"); var searchText = "
-1) { foundCorrTag = cPTags[i]; if (foundCorrTag.innerHTML.split('src="
')[1]); } } } } catch (e) { } */ /* This code is written as part of video fix by iTalent */ /* try{ var iframeText = newBody.textContent; var searchText = "
-1) { foundiFrame = iframeText; foundiFrame = decodeHTMLEntities(foundiFrame.split('src="')[0] + 'src="' + foundiFrame.split('src="
')[1]); } } catch(e){ } */ /*** START : extracting body from source if selected language and source language is same **/ var body_L = ""; /** Following variable will be used to decide whether we have to show translated content or not **/ showTrContent = true; if (newBody.getAttribute("slang").toLowerCase() == code_l.toLowerCase()) { body_L = decodeURIComponent($scope.sourceContent[value].body); /** We should not replace the source content if user profile language and selected target language matches with source language **/ if(($scope.previousSelCode == "") || ($scope.previousSelCode.toLowerCase() == code_l.toLowerCase())) { showTrContent = false; } } else { // body_L = newBody.innerHTML; } /*** End : extracting body from source if selected language and source language is same **/ // if($scope.viewTrContentOnly || (newBody.getAttribute("slang").toLowerCase() != code_l.toLowerCase())) { if ($scope.viewTrContentOnly) { try { var attachDiv = ""; feedbackDiv = ""; everyoneTagslink = "" if (body_L == "") { /* Attachment Div */ if (rootElement.querySelectorAll('div.lia-quilt-row-main-blog-body').length > 0) { var attachDiv = rootElement.querySelector('div.lia-quilt-row-main-blog-body').querySelector('div.custom-attachments'); if (attachDiv) { attachDiv = attachDiv.outerHTML; } else if(rootElement.querySelector('div.lia-quilt-row-main-blog-body').querySelectorAll('#attachments').length > 0){ if ("OccasionPage" == "BlogArticlePage") { attachDiv = rootElement.querySelector('div.lia-quilt-row-main-blog-body .lia-message-body-content').querySelector('#attachments'); if (attachDiv) { attachDiv = attachDiv.outerHTML; } else{ attachDiv = ""; } }else{ attachDiv = rootElement.querySelector('div.lia-quilt-row-main-blog-body').querySelector('#attachments').outerHTML; } } else { attachDiv = ""; } /* Feedback Div */ var feedbackDiv = ""; var feedbackDivs = rootElement.querySelector('div.lia-quilt-row-main-blog-body').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.lia-component-tags-with-title-link").length > 0){ var everyoneTagslink = document.querySelector('div.lia-quilt-row-main-blog-body').querySelector(".MessageTags.lia-component-tags-with-title-link"); 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; } }); } 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 = iframeHTMLText; foundiFrameTag = decodeHTMLEntities(foundiFrameTag.split('src="')[0] + 'src="' + 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; if ("OccasionPage" == "BlogArticlePage") { if (document.querySelector('div.message-uid-' + value).querySelectorAll('.lia-blog-article-page-article-subject').length > 0) { if (rootElement.querySelectorAll('div.lia-quilt-row-main-blog-body')[0] != undefined) { var subjectInBody = rootElement.querySelector('.lia-quilt-row.lia-quilt-row-main-blog-body .lia-component-article-subject').outerHTML; if (!copyBodySubject) { subjectInBody = ""; } /* rootElement.querySelectorAll('div.lia-quilt-row-main-blog-body')[0].querySelector('.lia-quilt-column-alley-right').innerHTML = subjectInBody + body_L + feedbackDiv + attachDiv + everyoneTagslink; $compile(rootElement.querySelectorAll('div.lia-quilt-row-main-blog-body')[0])($scope); */ subjectInBody = sub_L ; rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = null rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv + everyoneTagslink; $compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope); compiled = true; rootElement.querySelectorAll('div.lia-message-body-content')[0].insertAdjacentHTML('afterend',attachDiv); if(rootElement.querySelectorAll('div.lia-quilt-row-main-blog-body .lia-message-body .lia-attachments-message').length > 1){ rootElement.querySelectorAll('div.lia-quilt-row-main-blog-body .lia-message-body .lia-attachments-message')[1].remove(); } } else { var subjectInBody = rootElement.querySelector('.lia-message-body-content .lia-blog-article-page-article-subject').outerHTML; subjectInBody = ""; rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = subjectInBody + body_L + feedbackDiv + everyoneTagslink; $compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope); compiled = true; rootElement.querySelectorAll('div.lia-message-body-content')[0].insertAdjacentHTML('afterend',attachDiv); } } else { rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = null rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv + attachDiv + everyoneTagslink; } } else { rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = null if("OccasionPage"=="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 { rootElement.querySelectorAll('div.lia-message-body-content')[0].innerHTML = body_L + feedbackDiv + attachDiv; } } /* 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 = "This post originally written in lilicon-trans-text has been computer translated for you. When you reply, it will also be translated back to lilicon-trans-text.".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!"; } 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/lingoTrFlag.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 .lia-quilt-row:nth-child(3)").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) { } } /* $( "div.message-uid-"+value ).find( "div.lia-message-body-content" ).append(body_L); */ } 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 2.0:2 = Reply Sync button for multi source translation */ } catch(e){console.log(e)} }; if ((rContent != undefined) && (rContent != "")) { drawCanvas(decodeURIComponent(rContent)); $window.connectorStatus.prop = "completed"; /** 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) { /* 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 ((trContent.status != "NA") && trContent.status != null) { // $scope.transPercent = String(trContent.status); $scope.actualStatus = String(trContent.status); } else { $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 = "Downloading Translated content. Please refresh after some time."; }); } 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." }); } 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; } }).catch(function (error) { console.error("Manage translation Error:"+error); }); } } /** * @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 { lingoThreadLangSelected(lang, '755419'); } catch (e) { } /* var obj = $filter('filter')($scope.sourceLangList, function (obj) {return obj.code === lang}); if(obj.length > 0) { if((anonymousFlag == undefined) && ("" != obj[0].id)) { $window.location.href = "?profile.language="+obj[0].id; return ""; } } */ /** Display Translated content **/ var getTranslation = lithiumPlugin.getTranslation(lang, "755419"); getTranslation.then(function (trContent) { if (trContent.body != "") { $scope.showPreview(trContent.body, $scope.mszList, lang); } else { $rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes." } }); }; /** * @function openWorkbench * @description Opens the workbench link of the selected code * */ $scope.openWorkbench = function (wbLink) { /* Open workbench link in new tab */ $window.open(decodeURIComponent(wbLink), '_blank'); }; /** * @function detectBrowserLanguage * @description detects the browser language and displays the UI to request translation for browser language * */ $scope.detectBrowserLanguage = function () { /* Get cookie value of the user choice regarding browser language translation */ var brTChoice = cookieService.getBrTChoice() if (brTChoice != undefined && brTChoice == "true") { /* Do nothing if user dont want option for browser language translation */ } else { /* Get user browser language */ var brLangCode = window.navigator.userLanguage || window.navigator.language; brLang = ""; /* Get right language code of the browser language. Get the first value in the matching list */ if (brLangCode.indexOf("-") >= 0) { var obj = $filter('filter')($scope.languages, function (obj) { return obj.code === brLangCode }); if (obj.length > 0) { brLang = obj[0]; } } else { var obj = $filter('filter')($scope.languages, function (obj) { return obj.code.split("-")[0] === brLangCode }); if (obj.length > 0) { brLang = obj[0]; } } /* If browser language is valid one then provide UI to request browser language translation */ if (brLang != "") { var defaultLang = ""; if (('en-US'.indexOf(brLang.code) == -1) && (brLang.code.indexOf('en-US') == -1) && (defaultLang.indexOf(brLang.code) == -1) && (brLang.code.indexOf(defaultLang) == -1)) { $scope.brLang = brLang; $scope.brTransMsg = "brTransMsg.html"; } else { $scope.brTransMsg = ""; } } } } /** * @function neverDisplayBrTransMsg * @description sets cookie if user never want browser language translation choice * */ $scope.neverDisplayBrTransMsg = function () { cookieService.putBrTChoice() $scope.brTransMsg = ""; } /** * @function trnaslateToBrowserLang * @param {isTranslate} isTranslate - true/false * @description Requests for browser translation based on user choice * */ $scope.trnaslateToBrowserLang = function (isTranslate) { if (isTranslate) { /* Point language dropdown to browser language */ $scope.selLang = $scope.brLang.code; /* Initiate preview process for browser language */ $scope.selectThisLang($scope.selLang); /* Remove browser language translation UI */ $scope.brTransMsg = ""; } else { $scope.brTransMsg = ""; } } /* V1.4 */ /** * @function translateThisThread * @description Triggers the translation on button click * @param {mode} manual click or auto - click/null */ $scope.translateThisThread = function (mode) { if (mode != undefined && mode == 'click') { /* Cheking author decision on validation */ if ((document.querySelectorAll(".lingo-TrFlag").length == 0) && ("13402" != "-1")) { if (!confirm("This thread is not selected for translation by the Author. Do you want to translate this thread?")) { return false; } } } $scope.showTransLation = true; /* If language exists in selected languages then initiate or manage translation */ if ("false" == "true") { $scope.selLang = ""; /* 1.4 Update Analytics on language selected */ try { lingoThreadLangSelected('', '755419'); } catch (e) { } if (angular.element(document.querySelector("#trABody"))) { console.log(angular.element(document.querySelector("trABody"))); $scope.showPreview(angular.element(document.querySelector("#trABody")).innerHTML, $scope.mszList, ""); } $scope.manageTranslation("", "755419"); } else { if ("false" == "true") { alert("Requested languages not present in the selected languages list"); } } /* Detecting Browser language */ $scope.detectBrowserLanguage(); } $rootScope.profLang = ""; /* If language exists in selected languages then initiate or manage translation */ /* Get Cookie */ function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } var lang_code = ""; if ("false" == "true") { /* Language from Parameter */ var lang_code = ""; } else if (anonLang = getCookie('lia.anon.profile.language')) { /* Language from cookie */ /* Get code from source list */ var srObj = $filter('filter')($scope.sourceLangList, function (obj) { return obj.id === anonLang }); if (srObj.length > 0) { /* check code in selected languages */ var selObj = $filter('filter')($scope.languages, function (obj) { return obj.code === srObj[0].code }); if (selObj.length > 0) { lang_code = srObj[0].code; } } } else if (brLangCode = window.navigator.userLanguage || window.navigator.language) { /* Browser Language */ /* Get right language code of the browser language. Get the first value in the matching list */ if (brLangCode.indexOf("-") >= 0) { var obj = $filter('filter')($scope.languages, function (obj) { return obj.code === brLangCode }); if (obj.length > 0) { lang_code = obj[0].code; } } else { var obj = $filter('filter')($scope.languages, function (obj) { return obj.code.split("-")[0] === brLangCode }); if (obj.length > 0) { lang_code = obj[0].code; } } } else { } $rootScope.profLang = lang_code; if (lang_code == "") { lang_code = "en-US"; } $scope.selLang = lang_code; if (angular.element(document.querySelector("#trABody"))) { console.log(angular.element(document.querySelector("#trABody")).innerHTML); $scope.showPreview(angular.element(document.querySelector("#trABody")).innerHTML, $scope.mszList, $scope.selLang); } $scope.showTransLation = true; $scope.selectThisLang($scope.selLang, "1"); if ("auto" == "true") { try { lingoThreadLangSelected($scope.selLang, '755419'); } catch (e) { } $scope.manageTranslation($scope.selLang, "755419"); } /* V1.4 Loading dashbaord (converted into script to remove glitch) */ $scope.dashboard = "dashboard.html"; /** * @function triggerRefresh * @description Managess the translation of given language for the thread * @param {string} langCode - Language Code * @param {string} tid - Thread ID */ $scope.triggerRefresh = function (langCode, tid) { if (confirm("Are you sure you want to manually resubmit the translation?")) { $scope.transPercent = ""; var manualTriggerTrans = lithiumPlugin.manualTriggerTrans(langCode, tid); manualTriggerTrans.then(function (status) { if (status == "refresh") { var resetTranslation = lithiumPlugin.resetTranslation(tid); resetTranslation.then(function (error) { if (error) { $rootScope.errorMsg = error.$; } else { var bulkTranslation = lithiumPlugin.bulkTranslation(langCode, tid); bulkTranslation.then(function (data) { $rootScope.errorMsg = "Translation has been refreshed. Please refresh page after some time."; }); } }); } else { $rootScope.errorMsg = status; } }); } } /* V 2.0: 2 = this function called on click reply sync button */ /** * @function manualOOS * @description Sends the Out of sync check request. * */ $scope.manualTriggerOSS = function (replyID) { if ($scope.transPercent != "") { var manualOSS = lithiumPlugin.manualOSS("755419", replyID); manualOSS.then(function (value) { if (!value.includes("false")) { $scope.transPercent = ""; $rootScope.errorMsg = "Downloading Translated content. Please refresh after some time."; } else { $rootScope.errorMsg = "Auto translation of message failed. Please refresh the page and retry."; } }); } else { $rootScope.errorMsg = "Translation is in progress. Please retry in a few minutes."; } } }) .factory('httpInterceptor', ['$q', '$rootScope', function ($q, $rootScope) { /* httpInterceptor intercepts the http calls */ return { request: function (config) { if (config.url.indexOf("lingotek") >= 0) { /* Start Loader */ $rootScope.isLoading = true; $rootScope.errorMsg = ""; } return config || $q.when(config); }, requestError: function (request) { if ((request.config != undefined) && (request.config.url.indexOf("lingotek") >= 0)) { /* Stop Loader */ $rootScope.isLoading = false; /* Display error message */ $rootScope.errorMsg = "Error while processing the request. Please refresh the page and retry."; } return $q.reject(request); }, response: function (response) { if (response.config.url.indexOf("lingotek") >= 0) { /* Stop Loader */ $rootScope.isLoading = false; } return response || $q.when(response); }, responseError: function (response) { if ((response.config != undefined) && (response.config.url.indexOf("lingotek") >= 0)) { /* Display error message */ $rootScope.errorMsg = "Error while processing the request. Please refresh the page and retry."; /* Stop Loader */ $rootScope.isLoading = false; } return $q.reject(response); } }; } ]) .service('lithiumPlugin', function ($http, $rootScope) { /* Service that connects the dashboard with Lithium endpoints */ /* V 2.0:7 = Converting all POST calls GET calls */ /** * @function isOutOfSync * @param {string} sourceID - Thread id * @description Sends the ot of sync check request * */ var isOutOfSync = function (sourceID) { return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=OSS&tid=' + sourceID + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; return apiResponse.result; }, function (result) { // debugger; return {"status": "false"}; }); }; /** * @function getTrContent * @param {string} code - Language code * @param {string} tid - Thread id * @description Get the translated content from Lithium. * */ var getTranslation = function (code, tid) { /* var param = { mode:'trContent', code:code, tid:tid, xslt:'json.xsl' }; */ return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_rest_connector?mode=trContent&code=' + code + '&tid=' + tid + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; return apiResponse.result; }, function (response) { return { "id": "", "body": "", "subject": "", "status": "", "wb": "" }; }); }; /** * @function bulkTransStatus * @param {string} code - Language code * @param {string} tid - Thread id * @description Manages translation of given thread * */ var bulkTranslation = function (code, tid) { /* V1.1: 2*/ /* var param = { mode:'manageTrContent', code:code, tid:tid, xslt:'json.xsl' }; */ return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_rest_connector?mode=manageTrContent&code=' + code + '&tid=' + tid + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; /* V1.4:3 GA code, capturing thread info on post */ if (apiResponse.result.posts != undefined) { var trPosts = JSON.parse(apiResponse.result.posts); angular.forEach(trPosts, function (pObj_l) { try { lingoUpdateSource(pObj_l.source, pObj_l.tid); } catch (error) { console.log(error); } }) } return apiResponse.result; }, function (response) { return { "id": "", "body": "", "status": "", "wb": "" }; }); }; /** * @function setDefaultLang * @param {string} code - Language code * @description Changes the user default language to requested language. * */ var setDefaultLang = function (code) { /* V1.1: 2*/ return $http.get("/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_settings?mode=langSet&xslt=json.xsl&code=" + code).then(function (result) { debugger; return result.data.result.value; }, function (result) { return "Error. Please retry in a few minutes"; }); }; /* V 2.0: 1 */ /** * @function resetTranslation * @param {string} tid - Thread ID * @description Calls the endpoint to reset the translation of given thread. * */ var resetTranslation = function (tid) { return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_support?mode=refresh&tid=' + tid + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; return apiResponse.logs.error; }, function (result) { return ""; }); }; /** * @function manualTriggerTrans * @param {string} code - Language code * @param {string} tid - Thread id * @description Manages translation of given thread * */ var manualTriggerTrans = function (code, tid) { /* V 2.0: 3*/ /* var param = { mode:'mtrigger', code:code, tid:tid, xslt:'json.xsl' }; */ return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=mtrigger&code=' + code + '&tid=' + tid + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; return apiResponse.result.status; }, function (response) { return "Please retry in a few minutes."; }); }; /** @function isOutOfSync * @param {string} sourceID - Thread id * @description Sends the ot of sync check request * */ var manualOSS = function (sourceID, replyID) { return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=manualOSS&tid=' + sourceID + '&reply=' + replyID + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; return apiResponse.result.status; }, function (result) { // debugger; return "false"; }); }; /* V 2.0: 3 */ /** * @function trCompletCallback * @param {string} code - Language code * @param {string} docID - Document id * @description Triggers the translation completed callback from Lithium * */ var trCompletCallback = function (code, docID) { return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=callback&type=target&progress=100&document_id=' + docID + '&locale_code=' + code + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; return apiResponse.result.status; }, function (response) { return "Please retry in a few minutes."; }); }; /* V 2.0: 3 */ /** * @function trCompletUpload * @param {string} code - Language code * @param {string} docID - Document id * @description Triggers the document upload callback from Lithium * */ var trCompletUpload = function (code, docID) { return $http.get('/plugins/custom/sasinstitute/sasinstitute2/lingotek_ep_proj_callback?mode=callback&type=document_uploaded_auto&progress=0&document_id=' + docID + '&xslt=json.xsl').then(function (result) { var apiResponse = result.data; return apiResponse.result.status; }, function (response) { return "Please retry in a few minutes."; }); }; return { isOutOfSync: isOutOfSync, getTranslation: getTranslation, bulkTranslation: bulkTranslation, setDefaultLang: setDefaultLang, resetTranslation: resetTranslation, manualTriggerTrans: manualTriggerTrans, manualOSS: manualOSS, trCompletCallback: trCompletCallback, trCompletUpload: trCompletUpload }; }) .service("cookieService", function () { /* Service for cookie storage */ /** * @function getBrTChoice * @description Returns the cookie set for browser language translation. * */ var getBrTChoice = function () { var cname = "it_lang_notify_hide"; var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length, c.length); } return ""; } /** * @function getBrTChoice * @description Sets the cookie for browser language translation. * */ var putBrTChoice = function () { var cname = "it_lang_notify_hide"; var exdays = 30; var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + "true" + "; " + expires; } return { getBrTChoice: getBrTChoice, putBrTChoice: putBrTChoice } }); })(LITHIUM.angular); // -->