One issue that was noted by a user was that after publishing the StagingGDB, they were unable to collect features using Collector for ArcGIS. The issue stems from the fact that the feature classes have z-values and when publishing directly from ArcMap to ArcGIS Online, the feature service sets "'enableZDefaults' : false,". Without the ability to collect z-values or set a default, Collector is not able to add new features. A workaround for this, is to create a Service Definition from ArcMap (Share As, Publish, Save a service definition file) and then uploads this to ArcGIS Online. This will set the "'enableZDefaults': true".
If publishing to ArcGIS Server, users can change the z-defaults parameter during the publishing stage.
Or, you can simply publish from ArcGIS Pro and the value will be set to 'true' as well.
I was able to configure the script with my data, but I am having one problem. The barcode decoder only works if every feature has a barcode value entered. If one feature has a null value the tool will skip all other features that have barcodes and not decode any of them. Is there a way to get around this problem?
Within the python script is a function called: AppendSelectedRecords. this function is where each featureclass of selected features is processed. The first part of this function runs a cursor to test individually each record in the featureclasses selected set. For each row it tests whether the BARCODE value is NULL. If it is NULL is skips the row and moves onto the next row in the selection set. If the BARCODE value is populated, it attempts to decode it.
There is messaging built into the function to indicate for each ROW whether it thinks the BARCODE is NULL or whether it is processing the BARCODE.
If you are not seeing either of these two messages, than the script is not seeing a selection set. When this occurs you should see a message stating: "No Selected Staging Features".
This would happen if you did not run the tool interactively in ArcMap, and draw the polygon which is used to intersect (ie. Select by Location) the staging featureclasses.
Yes, we have successfully prototyped the use of Arcade scripting and the new Attribute Rule capability to automatically decode the ASTM F2897 barcodes. There are a couple of minor issues with the scripts that we have not yet had a chance to address. Specifically;
1) The Error handling of the Manufacture Date is not consistently working correctly in all use cases.
2) For Diameter and Wallthickness the decoding of a 2 diameter fitting (i.e. reducer) is not processing correctly. Single diameter fittings and pipe are working correctly.
These Attribute Rules will work with Collector, ArcGIS Pro, and web maps. They do not work within ArcMap. Additionally they require an Enterprise Geodatabase working with ArcGIS Enterprise 10.6.1 or higher.
Until, there two known issues are resolved, I do not intend to post the arcade scripts. But, if you are interested in using them, please contact me directly and I will provide them to you.
It doesn't appear that the script I am running is testing each row whether the BARCODE value is NULL. If I have any that are null at all it fails. I am using ArcMap 10.6.
My Gas Main Connector layer is the only current layer that has Barcode values populated.
Appending Gas Main Connector Processing Barcode = PE3tlZ96MB830v60 Processing Barcode = None Failed script AppendStagingGDBData...
Traceback (most recent call last): File "R:\Tracking and Traceability\AppendStagingGDBData.py", line 442, in <module> AppendSelectedRecords(Staking_GasMainConnector, Enterprise_GasMainConnector, Feature_Set, "MANUFACTURER","MANUFACTURELOTNO","","","","","","","") File "R:\Tracking and Traceability\AppendStagingGDBData.py", line 180, in AppendSelectedRecords MFGMATERIAL = BARCODE[9] IndexError: string index out of range
Failed to execute (AppendStagingGDBData). Failed at Wed Nov 14 14:41:54 2018 (Elapsed Time: 54.81 seconds)
# --------------------------------------------------------------------------- # AppendStagingGDBData.py # Created on: 2016-09-23 # Updated on: 2017-04-11 Added support for multi-diameter devices # # Usage: AppendStagingGDBData <Feature_Set> # # Description: Purpose is to interactively select the hosted feature layer data # which was collected via digital as-builting and load it into the enterprise GDB. # As part of the append process the BARCODE value is decoded and attirbutes are # auto-populated. # ---------------------------------------------------------------------------
# Import arcpy module import collections import sys, os, arcpy, traceback, datetime from arcpy import env import math
# Script arguments Feature_Set = arcpy.GetParameterAsText(0) if Feature_Set == '#' or not Feature_Set: arcpy.AddMessage("Feature Set is Empty") Feature_Set = "in_memory\\{E4B69402-D56F-43EB-91A6-E84B26D09D9F}" # provide a default value if unspecified
# Staging Geodatabase Layers: Staking_GasServicePoint = "Staking\\Gas Service Point" Staking_GasMainPipe = "Staking\\Staking Gas Main Pipe" Staking_GasDimension = "Staking\\Staking Gas Dimension" Staking_GasAnode = "Staking\\Staking Gas Anode" Staking_GasValve = "Staking\\Staking Gas Valve" Staking_GasCPTestPoint = "Staking\\Staking Gas CP Test Point" Staking_GasFlowControlDevice = "Staking\\Staking Gas Flow Control Device" Staking_GasFitting = "Staking\\Staking Gas Fitting" Staking_GasMonitoringDevice = "Staking\\Staking Gas Monitoring Device" Staking_GasServiceValve = "Staking\\Staking Gas Service Valve" Staking_GasLocatingPoint = "Staking\\Staking Gas Locating Point" Staking_GasMainConnector = "Staking\\Staking Gas Main Connector" Staking_GasServicePipe = "Staking\\Staking Gas Service Pipe" # StagingAnode = "RockGas.DBO.Staking\\Anode" # StagingRectifier = "RockGas.DBO.Staking\\Rectifier" # StagingProjectLocation= "RockGas.DBO.Staking\\Project Location"
############################################################################### # Function Convert Base62 to Base 10 # # ---------------DO NOT MODIFY THIS FUNCTION-------------------- # ############################################################################### BASE2 = "01" BASE10 = "0123456789" BASE16 = "0123456789ABCDEF" BASE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
def baseconvert(number,fromdigits,todigits): """ converts a "number" between two bases of arbitrary digits
The input number is assumed to be a string of digits from the fromdigits string (which is in order of smallest to largest digit). The return value is a string of elements from todigits (ordered in the same way). The input and output bases are determined from the lengths of the digit strings. Negative signs are passed through.
decimal to a base that uses A-Z0-9a-z for its digits >>> baseconvert(257938572394L,BASE10,BASE62) 'E78Lxik'
..convert back >>> baseconvert('E78Lxik',BASE62,BASE10) '257938572394' """
if str(number)[0]=='-': number = str(number)[1:] neg=1 else: neg=0
# make an integer out of the number x=0 for digit in str(number): x = x*len(fromdigits) + fromdigits.index(digit)
# create the result in base 'len(todigits)' if x == 0: res = todigits[0] else: res="" while x>0: digit = x % len(todigits) res = todigits[digit] + res x = int(x / len(todigits)) if neg: res = "-"+res
return res
############################################################################# # Function Append Selected Records # # ---------------DO NOT MODIFY THIS FUNCTION-------------------- # # StagingLayer- Name of TrackingGDB Staging Layer to have its selected features appended # EnterpriseLayer- Name of the EnterpriseGDB Enterprise Layer to receive the selected features of the TrackingGDB Staging Layer # FeatureSet- The User defined polygon which will act as a spatial filter on the TrackingGDB Staging Layer # MANUFACTURER- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer name # MFGLOTNO- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Lot number value # MANUFACTUREDATE- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Date # MANUFACTUREMAT- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Material value # MANUFACTURECOMP- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Model value # MANUFACTUREDIAMETER- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Diameter value # MANUFACTUREWALLTHICK- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Wall thickness value # MANUFACTUREDIAMETER2- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Diameter 2 value # MANUFACTUREWALLTHICK2-Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Wall thickness 2 value # ############################################################################# def AppendSelectedRecords(StagingLayer,EnterpriseLayer,FeatureSet,MANUFACTURER,MFGLOTNO,MANUFACTUREDATE,MANUFACTUREMAT,MANUFACTURECOMP,MANUFACTUREDIAMETER,MANUFACTUREWALLTHICK,MANUFACTUREDIAMETER2,MANUFACTUREWALLTHICK2):
# Process: Export Selected Hosted Feature Service Layer features to in-memory layer arcpy.FeatureClassToFeatureClass_conversion(StagingLayer, "in_memory", "INMEMORY_TEMP", "", "", "") INMEMORY_TEMP = "in_memory\\INMEMORY_TEMP" CountSelected = str(arcpy.GetCount_management(INMEMORY_TEMP))
# Check for existance of BARCODE attribute. If does not exist, skip decoding fields = arcpy.ListFields(StagingLayer, "BARCODE")
# Use Update Cursor to decode BARCODE for newly appended records with a not NULL BARCODE attribute for field in fields: cursor = arcpy.UpdateCursor(INMEMORY_TEMP) row = cursor.next() if row == None: arcpy.AddMessage(" No Selected Staging Features") elif row.isNull("BARCODE"): arcpy.AddMessage(" BARCODE value is NULL") else: while row: BARCODE = str(row.getValue("BARCODE")) arcpy.AddMessage(" Processing Barcode = " + BARCODE) MFG = BARCODE[0:2] LOTNO = BARCODE[2:6] MFGDATE = BARCODE[6:9] MFGMATERIAL = BARCODE[9] MFGCOMPONENT = BARCODE[10:12] MFGSIZE = BARCODE[12:15]
# Query for Pipes or fittings where C1 = C2 SIZECODE = int(baseconvert(MFGSIZE,BASE62,BASE10)) C1FACTOR = (SIZECODE - 1)/379 if ASTMSIZE.has_key(C1FACTOR): C1VALUESET = ASTMSIZE.get(C1FACTOR) MFGDIAMETER = C1VALUESET[0] MFGWALLTHICKNESS = C1VALUESET[3] else: MFGDIAMETER = 0 MFGWALLTHICKNESS = 0 arcpy.AddMessage("Multiple Diameters") ########################################################################## # Need to add in logic to query for fittings with 2 diameters # NOTES: Valid answer is first combination of C1/C2 values meeting the following criteria # NOTES: C1 and C2 valid values are 1 to 378 # NOTES: C2 much be greater then C1 value # NOTES: Equation to solve: SIZECODE = (C1 * 378)+ C2 + 1 ########################################################################## C1Candidate = 0 for C1Candidate in range(1, 378): C2Start = C1Candidate + 1 for C2Candidate in range(C2Start, 378): SIZECODECandidate = (C1Candidate * 378) + C2Candidate + 1 if SIZECODECandidate == SIZECODE: C1VALUESET = ASTMSIZE.get(C1Candidate) C2VALUESET = ASTMSIZE.get(C2Candidate) break # end if # end for C2Candidate # end for C1Candidate MFGDIAMETER = C1VALUESET[0] MFGWALLTHICKNESS = C1VALUESET[3] MFGDIAMETER2 = C2VALUESET[0] MFGWALLTHICKNESS2 = C2VALUESET[3]
# Update columns with BARCODE decoded values if MANUFACTURER != "": row.setValue(MANUFACTURER, MFG) if MFGLOTNO != "": row.setValue(MFGLOTNO, baseconvert(LOTNO,BASE62,BASE10)) if MANUFACTUREDATE != "": row.setValue(MANUFACTUREDATE, str(MFGDATECONVERTED)) if MANUFACTUREMAT != "": row.setValue(MANUFACTUREMAT, MFGMATERIAL) if MANUFACTURECOMP != "": row.setValue(MANUFACTURECOMP, MFGCOMPONENT) if MANUFACTUREDIAMETER != "": row.setValue(MANUFACTUREDIAMETER, MFGDIAMETER) if MANUFACTUREWALLTHICK != "": row.setValue(MANUFACTUREWALLTHICK, MFGWALLTHICKNESS) if MANUFACTUREDIAMETER2 != "": row.setValue(MANUFACTUREDIAMETER2, MFGDIAMETER2) if MANUFACTUREWALLTHICK2 != "": row.setValue(MANUFACTUREWALLTHICK2, MFGWALLTHICKNESS2) cursor.updateRow(row)
################################################################### ## ## Mapping of Enterprise GDB Layer attributes for receiving the appending Tracking features ## ## StagingLayer- Name of TrackingGDB Staging Layer to have its selected features appended ## EnterpriseLayer- Name of the EnterpriseGDB Enterprise Layer to receive the selected features of the TrackingGDB Staging Layer ## FeatureSet- The User defined polygon which will act as a spatial filter on the TrackingGDB Staging Layer ## MANUFACTURER- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer name ## MANUFACTURELOTNO- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Lot number value ## MANUFACTUREDATE- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Date ## MATERIAL- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Material value ## MANUFACTUREMODEL- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacturer Model value ## DIAMETER- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Diameter value ## WALLTHICKNESS- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Wall thickness value ## DIAMETER2- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Diameter 2 value ## WALLTHICKNESS2- Name of the EnterpriseGDB Enterprise layer field to store the ASTM barcode Manufacture Wall thichness 2 value ###################################################################
# ########################### # Gas Service Point # ########################### arcpy.AddMessage("Appending GasServicePoint") AppendSelectedRecords(Staking_GasServicePoint, Enterprise_GasServicePoint, Feature_Set, "", "", "", "","", "","","","") arcpy.AddMessage(" Completed Appending GasServicePoint") arcpy.AddMessage(" ")
# ############################ # # Gas Dimension # ############################ arcpy.AddMessage("Appending Gas Dimension") AppendSelectedRecords(Staking_GasDimension, Enterprise_GasDimension, Feature_Set, "", "", "", "","","","","","") arcpy.AddMessage(" Completed Appending Gas Dimension") arcpy.AddMessage(" ")
# ############################ # # Gas Anode # ############################ arcpy.AddMessage("Appending Gas Anode") AppendSelectedRecords(Staking_GasAnode, Enterprise_GasAnode, Feature_Set,"","","","","","","","","") arcpy.AddMessage(" Completed Gas Anode") arcpy.AddMessage(" ")
# ############################ # # Gas Valve # ############################ arcpy.AddMessage("Appending Gas Valve") AppendSelectedRecords(Staking_GasValve, Enterprise_GasValve, Feature_Set, "MANUFACTURER", "MANUFACTURELOTNO", "MANUFACTUREDATE", "MATERIAL", "MANUFACTUREMODEL","DIAMETER","","","") arcpy.AddMessage(" Completed Appending Gas Valve") arcpy.AddMessage(" ")
# ############################ # # Gas CP Test Point # ############################ arcpy.AddMessage("Appending CP Test Point") AppendSelectedRecords(Staking_GasCPTestPoint, Enterprise_CPTestPoint, Feature_Set,"MANUFACTURER","","","","MANUFACTUREMODEL","","","","") arcpy.AddMessage(" Completed Appending CP Test Point") arcpy.AddMessage(" ")
# ############################ # # Gas Flow Control Device # ############################ arcpy.AddMessage("Appending Gas Flow Control Device") AppendSelectedRecords(Staking_GasFlowControlDevice, Enterprise_GasFlowControlDevice, Feature_Set, "MANUFACTURER", "MANUFACTURELOTNO", "MANUFACTUREDATE", "", "MANUFACTUREMODEL","DIAMETER","","","") arcpy.AddMessage(" Completed Appending Gas Flow Control Device") arcpy.AddMessage(" ")
# ############################ # # Gas Fitting # ############################ arcpy.AddMessage("Appending Gas Fitting") AppendSelectedRecords(Staking_GasFitting, Enterprise_GasFitting, Feature_Set, "MANUFACTURER", "MANUFACTURERLOTNO", "MANUFACTUREDATE", "", "MANUFACTUREMODEL","DIAMETER","","","") arcpy.AddMessage(" Completed Appending Gas Fitting") arcpy.AddMessage(" ")
# ############################ # # Gas Service Valve # ############################ arcpy.AddMessage("Appending Gas Service Valve") AppendSelectedRecords(Staking_GasServiceValve, Enterprise_GasServiceValve, Feature_Set, "MANUFACTURER", "MANUFACTURERLOTNO", "MANUFACTUREDATE", "", "MANUFACTUREMODEL","DIAMETER","","","") arcpy.AddMessage(" Completed Appending Gas Service Valve") arcpy.AddMessage(" ")
# ############################ # # Gas Locating Point # ############################ arcpy.AddMessage("Appending Gas Locating Point") AppendSelectedRecords(Staking_GasLocatingPoint, Enterprise_GasLocatingPoint, Feature_Set, "MANUFACTURER", "MANUFACTURERLOTNO", "MANUFACTUREDATE", "", "MANUFACTUREMODEL","DIAMETER","","","") arcpy.AddMessage(" Completed Appending Gas Locating Point") arcpy.AddMessage(" ")
# ############################ # # Gas Main Connector # ############################ arcpy.AddMessage("Appending Gas Main Connector") AppendSelectedRecords(Staking_GasMainConnector, Enterprise_GasMainConnector, Feature_Set, "MANUFACTURER","MANUFACTURELOTNO","","","","","","","") arcpy.AddMessage(" Completed Appending Gas Main Connector") arcpy.AddMessage(" ")
# ############################ # # Gas Service Pipe # ############################ arcpy.AddMessage("Appending Gas Service Pipe") AppendSelectedRecords(Staking_GasServicePipe, Enterprise_GasServicePipe, Feature_Set,"MANUFACTURER", "MANUFACTURELOTNO", "MANUFACTUREDATE", "PIPEGRADE", "PIPESPECIFICATION", "NOMINALDIAMETER","WALLTHICKNESS","","") arcpy.AddMessage(" Completed Gas Service Pipe") arcpy.AddMessage(" ")
# ############################ # # Test Point # ############################ # arcpy.AddMessage("Appending Test Point") # AppendSelectedRecords(StagingTestPoint, Enterprise_TestPoint, Feature_Set,"","","","","","","","","") # arcpy.AddMessage(" Completed Appending Test Point") # arcpy.AddMessage(" ")
';
}
}
}
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 {
lingoThreadLangSelected(lang, '916669');
} catch (e) {
}
/** Display Translated content **/
var getTranslation = lithiumPlugin.getTranslation(lang, "916669");
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(/