38 var ConfigurationAPI = ConfigurationAPI || {};
40 if (typeof Debug ==
'undefined')
41 alert(
'ERROR: Debug is undefined! Must include Debug.js before ConfigurationAPI.js');
42 if (typeof Globals ==
'undefined')
43 alert(
'ERROR: Globals is undefined! Must include Globals.js before ConfigurationAPI.js');
44 if (typeof DesktopContent ==
'undefined' &&
45 typeof Desktop ==
'undefined')
46 alert(
'ERROR: DesktopContent is undefined! Must include DesktopContent.js before ConfigurationAPI.js');
84 ConfigurationAPI._activeGroups = {};
85 ConfigurationAPI._activeTables = {};
88 ConfigurationAPI._DEFAULT_COMMENT =
"No comment.";
89 ConfigurationAPI._POP_UP_DIALOG_ID =
"ConfigurationAPI-popUpDialog";
119 ConfigurationAPI._VERSION_ALIAS_PREPEND =
"ALIAS:";
120 ConfigurationAPI._SCRATCH_VERSION = 2147483647;
121 ConfigurationAPI._SCRATCH_ALIAS =
"Scratch";
123 ConfigurationAPI._OK_CANCEL_DIALOG_STR =
"";
124 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"<div title='' style='padding:5px;background-color:#eeeeee;border:1px solid #555555;position:relative;z-index:2000;" +
125 "width:95px;height:20px;margin:0 -122px -64px 10px; font-size: 16px; white-space:nowrap; text-align:center;'>";
126 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"<a class='popUpOkCancel' onclick='javascript:ConfigurationAPI.handleEditableFieldEditOK(); event.stopPropagation();' onmouseup='event.stopPropagation();' title='Accept Changes' style='color:green'>" +
127 "<b style='color:green;font-size: 16px;'>OK</b></a> | " +
128 "<a class='popUpOkCancel' onclick='javascript:ConfigurationAPI.handleEditableFieldEditCancel(); event.stopPropagation();' onmouseup='event.stopPropagation();' title='Discard Changes' style='color:red'>" +
129 "<b style='color:red;font-size: 16px;'>Cancel</b></a>";
130 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"</div>";
146 ConfigurationAPI.getActiveGroups =
function(responseHandler)
149 DesktopContent.XMLHttpRequest(
"Request?RequestType=getActiveTableGroups",
152 responseHandler(ConfigurationAPI.extractActiveGroups(req));
157 ConfigurationAPI.extractActiveGroups =
function(req)
162 var activeConfigGroups = [
163 DesktopContent.getXMLValue(req,
"Context-ActiveGroupName"),
164 DesktopContent.getXMLValue(req,
"Context-ActiveGroupKey"),
165 DesktopContent.getXMLValue(req,
"Backbone-ActiveGroupName"),
166 DesktopContent.getXMLValue(req,
"Backbone-ActiveGroupKey"),
167 DesktopContent.getXMLValue(req,
"Iterate-ActiveGroupName"),
168 DesktopContent.getXMLValue(req,
"Iterate-ActiveGroupKey"),
169 DesktopContent.getXMLValue(req,
"Configuration-ActiveGroupName"),
170 DesktopContent.getXMLValue(req,
"Configuration-ActiveGroupKey")];
174 retObj.Context.groupName = activeConfigGroups[i++];
175 retObj.Context.groupKey = activeConfigGroups[i++];
176 retObj.Backbone = {};
177 retObj.Backbone.groupName = activeConfigGroups[i++];
178 retObj.Backbone.groupKey = activeConfigGroups[i++];
180 retObj.Iterate.groupName = activeConfigGroups[i++];
181 retObj.Iterate.groupKey = activeConfigGroups[i++];
182 retObj.Configuration = {};
183 retObj.Configuration.groupName = activeConfigGroups[i++];
184 retObj.Configuration.groupKey = activeConfigGroups[i++];
188 Debug.log(
"Error extracting active groups: " + e);
192 ConfigurationAPI._activeGroups = {};
193 ConfigurationAPI._activeGroups = retObj;
228 ConfigurationAPI.getAliasesAndGroups =
function(responseHandler,optionForNoAliases,
235 if(!optionForNoAliases)
236 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
242 Debug.log(
"getGroupAliases handler");
244 var groupAliases = req.responseXML.getElementsByTagName(
"GroupAlias");
245 var groupNames = req.responseXML.getElementsByTagName(
"GroupName");
246 var groupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
247 var groupComments = req.responseXML.getElementsByTagName(
"GroupComment");
248 var groupTypes = req.responseXML.getElementsByTagName(
"GroupType");
249 var aliasComments = req.responseXML.getElementsByTagName(
"AliasComment");
254 for(var i=0;i<groupAliases.length;++i)
256 type = groupTypes[i].getAttribute(
'value');
258 if(type ==
"")
continue;
260 if(!retObj.aliases[type])
261 retObj.aliases[type] = [];
263 retObj.aliases[type].push({
264 "alias" : groupAliases[i].getAttribute(
'value'),
265 "name" : groupNames[i].getAttribute(
'value'),
266 "key" : groupKeys[i].getAttribute(
'value'),
267 "groupComment" : groupComments[i].getAttribute(
'value'),
268 "groupComment" : groupTypes[i].getAttribute(
'value'),
269 "aliasComment" : aliasComments[i].getAttribute(
'value')
276 (reqCount == 1 && optionForNoGroups))
279 console.log(
"getAliasesAndGroups retObj ",retObj);
280 responseHandler(retObj);
290 if(!optionForNoGroups)
291 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTableGroups"
292 +
"&doNotReturnMembers=1",
296 Debug.log(
"getTableGroups handler");
298 retObj.activeGroups = {};
299 retObj.activeGroups = ConfigurationAPI.extractActiveGroups(req);
301 var groupNames = req.responseXML.getElementsByTagName(
"TableGroupName");
302 var groupKeys = req.responseXML.getElementsByTagName(
"TableGroupKey");
303 var groupTypes = req.responseXML.getElementsByTagName(
"TableGroupType");
304 var groupComments = req.responseXML.getElementsByTagName(
"TableGroupComment");
309 for(var i=0;i<groupNames.length;++i)
311 type = groupTypes[i].getAttribute(
'value');
313 if(type ==
"")
continue;
321 if(!retObj.groups[type])
322 retObj.groups[type] = {};
324 name = groupNames[i].getAttribute(
'value');
325 if(!retObj.groups[type][name])
327 retObj.groups[type][name] = {};
329 retObj.groups[type][name].groupComment = groupComments[i].getAttribute(
'value');
330 retObj.groups[type][name].keys = [];
333 retObj.groups[type][name].keys.push(groupKeys[i].getAttribute(
'value'));
339 (reqCount == 1 && optionForNoAliases))
342 console.log(
"getAliasesAndGroups retObj ",retObj);
343 responseHandler(retObj);
373 ConfigurationAPI.getSubsetRecords =
function(subsetBasePath,
374 filterList,responseHandler,modifiedTables)
376 var modifiedTablesListStr =
"";
377 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
379 if(i) modifiedTablesListStr +=
",";
380 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
381 modifiedTables[i].tableVersion;
383 if(filterList === undefined) filterList =
"";
385 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
387 "&tableGroupKey=-1" +
388 "&hideStatusFalse=0" +
390 "startPath=/" + subsetBasePath +
391 "&filterList=" + filterList +
392 "&modifiedTables=" + modifiedTablesListStr,
395 ConfigurationAPI.extractActiveGroups(req);
398 var err = DesktopContent.getXMLValue(req,
"Error");
401 Debug.log(err,Debug.HIGH_PRIORITY);
402 if(responseHandler) responseHandler(records);
408 var tree = DesktopContent.getXMLNode(req,
"tree");
409 var nodes = tree.children;
410 for(var i=0;i<nodes.length;++i)
411 records.push(nodes[i].getAttribute(
"value"));
412 Debug.log(
"Records: " + records);
413 if(responseHandler) responseHandler(records);
428 ConfigurationAPI.getTree =
function(treeBasePath,depth,modifiedTables,
429 responseHandler,responseHandlerParam)
431 var modifiedTablesListStr =
"";
432 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
434 if(i) modifiedTablesListStr +=
",";
435 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
436 modifiedTables[i].tableVersion;
439 treeBasePath = treeBasePath.trim();
440 if(treeBasePath ==
"/") treeBasePath =
"";
442 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
444 "&tableGroupKey=-1" +
445 "&hideStatusFalse=0" +
447 "startPath=/" + treeBasePath +
448 "&filterList=" +
"" +
449 "&modifiedTables=" + modifiedTablesListStr,
452 var err = DesktopContent.getXMLValue(req,
"Error");
455 Debug.log(err,Debug.HIGH_PRIORITY);
456 if(responseHandler) responseHandler(undefined,responseHandlerParam);
470 if(responseHandler) responseHandler(
471 DesktopContent.getXMLNode(req,
"tree"),
472 responseHandlerParam);
484 ConfigurationAPI.getTreeChildren =
function(tree,pathToChildren)
486 var pathArr = pathToChildren?pathToChildren.split(
'/'):
"";
490 children = tree.children;
493 for(var i=0;i<pathArr.length;++i)
495 if(pathArr[i].trim().length == 0)
continue;
497 Debug.log(i +
": " + pathArr[i]);
500 for(var j=0;j<children.length;++j)
501 if(children[j].getAttribute(
"value") == pathArr[i])
505 children = children[j].children;
506 Debug.log(
"found " + pathArr[i]);
512 Debug.log(
"Invalid path '" + pathToChildren +
"' through tree! How did you get here? Notify admins.", Debug.HIGH_PRIORITY);
520 for(var i=0;i<children.length;++i)
521 if(children[i].nodeName ==
"node")
522 retArr.push(children[i]);
532 ConfigurationAPI.getTreeRecordLinks =
function(node)
534 var children = node.children;
539 for(var i=0;i<children.length;++i)
541 if(children[i].nodeName !=
"node")
continue;
543 subchildren = children[i].children;
545 for(var j=0;j<subchildren.length;++j)
547 if(subchildren[j].nodeName ==
"LinkTableName")
549 retArr.push(children[i]);
563 ConfigurationAPI.getTreeRecordName =
function(node)
567 var children = node.children;
568 if(children.length > 2)
570 if(children[0].nodeName ==
"valueType" &&
571 children[0].getAttribute(
"value") ==
"Disconnected")
572 throw(
"Disconnected link!");
574 if(children[0].nodeName ==
"UID")
575 return children[0].getAttribute(
"value");
577 if(children[1].nodeName ==
"UID")
578 return children[0].getAttribute(
"value");
581 return node.getAttribute(
"value");
588 ConfigurationAPI.getTreeLinkChildren =
function(link)
590 var children = link.children;
593 for(var i=0;i<children.length;++i)
595 if(children[i].nodeName ==
"UID")
600 else if(children[i].nodeName ==
"node")
601 retArr.push(children[i]);
611 ConfigurationAPI.getTreeLinkTable =
function(link)
613 var children = link.children;
614 for(var i=0;i<children.length;++i)
615 if(children[i].nodeName ==
"LinkTableName")
616 return children[i].getAttribute(
"value");
617 throw(
"Table name not found!");
652 ConfigurationAPI.getFieldsOfRecords =
function(subsetBasePath,recordArr,fieldList,
653 maxDepth,responseHandler,modifiedTables)
655 var modifiedTablesListStr =
"";
656 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
658 if(i) modifiedTablesListStr +=
",";
659 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
660 modifiedTables[i].tableVersion;
663 var recordListStr =
"";
664 if(Array.isArray(recordArr))
665 for(var i=0;i<recordArr.length;++i)
667 if(i) recordListStr +=
",";
668 recordListStr += encodeURIComponent(recordArr[i]);
671 recordListStr = encodeURIComponent(recordArr);
673 subsetBasePath = subsetBasePath.trim();
674 if(subsetBasePath ==
"/") subsetBasePath =
"";
676 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeNodeCommonFields" +
678 "&tableGroupKey=-1" +
679 "&depth=" + (maxDepth|0),
680 "startPath=/" + subsetBasePath +
681 "&recordList=" + recordListStr +
682 "&fieldList=" + fieldList +
683 "&modifiedTables=" + modifiedTablesListStr,
687 var err = DesktopContent.getXMLValue(req,
"Error");
690 Debug.log(err,Debug.HIGH_PRIORITY);
691 if(responseHandler) responseHandler(recFields);
697 var tableNames = req.responseXML.getElementsByTagName(
"ActiveTableName");
698 var tableVersions = req.responseXML.getElementsByTagName(
"ActiveTableVersion");
699 ConfigurationAPI._activeTables = {};
700 for(var i=0;i<tableNames.length;++i)
702 ConfigurationAPI._activeTables[DesktopContent.getXMLValue(tableNames[i])] =
703 DesktopContent.getXMLValue(tableVersions[i]);
705 Debug.logv(
"ConfigurationAPI._activeTables =",ConfigurationAPI._activeTables);
709 var fields = DesktopContent.getXMLNode(req,
"fields");
711 var FieldTableNames = fields.getElementsByTagName(
"FieldTableName");
712 var FieldColumnNames = fields.getElementsByTagName(
"FieldColumnName");
713 var FieldRelativePaths = fields.getElementsByTagName(
"FieldRelativePath");
714 var FieldColumnTypes = fields.getElementsByTagName(
"FieldColumnType");
715 var FieldColumnDataTypes = fields.getElementsByTagName(
"FieldColumnDataType");
716 var FieldColumnDataChoices = fields.getElementsByTagName(
"FieldColumnDataChoices");
717 var FieldColumnDefaultValues = fields.getElementsByTagName(
"FieldColumnDefaultValue");
720 for(var i=0;i<FieldTableNames.length;++i)
723 obj.fieldTableName = DesktopContent.getXMLValue(FieldTableNames[i]);
724 obj.fieldColumnName = DesktopContent.getXMLValue(FieldColumnNames[i]);
725 obj.fieldRelativePath = DesktopContent.getXMLValue(FieldRelativePaths[i]);
726 obj.fieldColumnType = DesktopContent.getXMLValue(FieldColumnTypes[i]);
727 obj.fieldColumnDataType = DesktopContent.getXMLValue(FieldColumnDataTypes[i]);
728 obj.fieldColumnDefaultValue = DesktopContent.getXMLValue(FieldColumnDefaultValues[i]);
730 var FieldColumnDataChoicesArr = FieldColumnDataChoices[i].getElementsByTagName(
"FieldColumnDataChoice");
731 obj.fieldColumnDataChoicesArr = [];
732 for(var j=0; j<FieldColumnDataChoicesArr.length;++j)
733 obj.fieldColumnDataChoicesArr.push(DesktopContent.getXMLValue(FieldColumnDataChoicesArr[j]));
737 Debug.log(
"Records length: " + recFields.length);
738 if(responseHandler) responseHandler(recFields);
767 ConfigurationAPI.getFieldValuesForRecords =
function(subsetBasePath,
768 recordArr,fieldObjArr,
769 responseHandler,modifiedTables,silenceErrors)
771 var modifiedTablesListStr =
"";
772 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
774 if(i) modifiedTablesListStr +=
",";
775 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
776 modifiedTables[i].tableVersion;
779 var recordListStr =
"";
780 if(Array.isArray(recordArr))
781 for(var i=0;i<recordArr.length;++i)
783 if(i) recordListStr +=
",";
784 recordListStr += encodeURIComponent(recordArr[i]);
787 recordListStr = encodeURIComponent(recordArr);
790 var fieldListStr =
"";
791 if(fieldObjArr.length && (typeof fieldObjArr[0] ===
"string"))
795 if(Array.isArray(fieldObjArr))
796 for(var i=0;i<fieldObjArr.length;++i)
798 if(i) fieldListStr +=
",";
799 fieldListStr += encodeURIComponent(fieldObjArr[i]);
802 fieldListStr = encodeURIComponent(fieldObjArr);
808 for(var i=0;i<fieldObjArr.length;++i)
810 if(i) fieldListStr +=
",";
811 fieldListStr += fieldObjArr[i].fieldRelativePath +
812 fieldObjArr[i].fieldColumnName;
816 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeNodeFieldValues" +
819 "startPath=/" + subsetBasePath +
820 "&recordList=" + recordListStr +
821 "&fieldList=" + fieldListStr +
822 "&modifiedTables=" + modifiedTablesListStr,
825 var recFieldValues = [];
826 var err = DesktopContent.getXMLValue(req,
"Error");
829 if(!silenceErrors) Debug.log(err,Debug.HIGH_PRIORITY);
830 if(responseHandler) responseHandler(recFieldValues,err);
834 var fieldValues = req.responseXML.getElementsByTagName(
"fieldValues");
836 for(var f=0;f<fieldValues.length;++f)
838 var FieldPaths = fieldValues[f].getElementsByTagName(
"FieldPath");
839 var FieldValues = fieldValues[f].getElementsByTagName(
"FieldValue");
840 for(var i=0;i<FieldPaths.length;++i)
843 obj.fieldUID = DesktopContent.getXMLValue(fieldValues[f]);
844 obj.fieldPath = DesktopContent.getXMLValue(FieldPaths[i]);
845 obj.fieldValue = DesktopContent.getXMLValue(FieldValues[i]);
846 recFieldValues.push(obj);
849 fieldObjArr[i].fieldColumnValue = obj.fieldValue;
853 if(responseHandler) responseHandler(recFieldValues);
883 ConfigurationAPI.getUniqueFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldList,
884 responseHandler,modifiedTables)
886 var modifiedTablesListStr =
"";
887 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
889 if(i) modifiedTablesListStr +=
",";
890 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
891 modifiedTables[i].tableVersion;
894 var recordListStr =
"";
895 if(Array.isArray(recordArr))
896 for(var i=0;i<recordArr.length;++i)
898 if(i) recordListStr +=
",";
899 recordListStr += encodeURIComponent(recordArr[i]);
902 recordListStr = encodeURIComponent(recordArr);
904 DesktopContent.XMLHttpRequest(
"Request?RequestType=getUniqueFieldValuesForRecords" +
907 "startPath=/" + subsetBasePath +
908 "&recordList=" + recordListStr +
909 "&fieldList=" + fieldList +
910 "&modifiedTables=" + modifiedTablesListStr,
913 var fieldUniqueValues = [];
914 var err = DesktopContent.getXMLValue(req,
"Error");
917 Debug.log(err,Debug.HIGH_PRIORITY);
918 if(responseHandler) responseHandler(fieldUniqueValues);
922 var fields = req.responseXML.getElementsByTagName(
"field");
924 for(var i=0;i<fields.length;++i)
927 var uniqueValues = fields[i].getElementsByTagName(
"uniqueValue");
928 var groupIdChildLinkIndex = DesktopContent.getXMLNode(
929 fields[i],
"childLinkIndex");
932 obj.fieldName = DesktopContent.getXMLValue(fields[i]);
934 if(groupIdChildLinkIndex)
935 obj.childLinkIndex = DesktopContent.getXMLValue(groupIdChildLinkIndex);
937 obj.fieldUniqueValueArray = [];
938 for(var j=0;j<uniqueValues.length;++j)
939 obj.fieldUniqueValueArray.push(DesktopContent.getXMLValue(uniqueValues[j]));
940 fieldUniqueValues.push(obj);
942 Debug.log(
"fieldUniqueValues length: " + fieldUniqueValues.length);
943 if(responseHandler) responseHandler(fieldUniqueValues);
976 ConfigurationAPI.setFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldObjArr,
977 valueArr,responseHandler,modifiedTablesIn,silenceErrors)
979 var modifiedTablesListStr =
"";
980 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
982 if(i) modifiedTablesListStr +=
",";
983 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
984 modifiedTablesIn[i].tableVersion;
987 var fieldListStr =
"";
988 if(fieldObjArr.length && (typeof fieldObjArr[0] ===
"string"))
992 if(Array.isArray(fieldObjArr))
993 for(var i=0;i<fieldObjArr.length;++i)
995 if(i) fieldListStr +=
",";
996 fieldListStr += encodeURIComponent(fieldObjArr[i]);
999 fieldListStr = encodeURIComponent(fieldObjArr);
1005 for(var i=0;i<fieldObjArr.length;++i)
1007 if(i) fieldListStr +=
",";
1008 fieldListStr += fieldObjArr[i].fieldRelativePath +
1009 fieldObjArr[i].fieldColumnName;
1014 var valueListStr =
"";
1015 if(Array.isArray(valueArr))
1016 for(var i=0;i<valueArr.length;++i)
1018 if(i) valueListStr +=
",";
1019 valueListStr += encodeURIComponent(valueArr[i]);
1022 valueListStr = encodeURIComponent(valueArr);
1025 var recordListStr =
"";
1026 if(Array.isArray(recordArr))
1027 for(var i=0;i<recordArr.length;++i)
1029 if(i) recordListStr +=
",";
1030 recordListStr += encodeURIComponent(recordArr[i]);
1033 recordListStr = encodeURIComponent(recordArr);
1035 DesktopContent.XMLHttpRequest(
"Request?RequestType=setTreeNodeFieldValues" +
1037 "&tableGroupKey=-1",
1038 "startPath=/" + subsetBasePath +
1039 "&recordList=" + recordListStr +
1040 "&valueList=" + valueListStr +
1041 "&fieldList=" + fieldListStr +
1042 "&modifiedTables=" + modifiedTablesListStr,
1045 var modifiedTables = [];
1047 var err = DesktopContent.getXMLValue(req,
"Error");
1051 Debug.log(err,Debug.HIGH_PRIORITY);
1052 if(responseHandler) responseHandler(modifiedTables,err);
1056 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
1057 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
1058 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
1062 for(var i=0;i<tableNames.length;++i)
1064 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
1065 if(tableVersion >= -1)
continue;
1067 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
1068 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
1069 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
1070 modifiedTables.push(obj);
1073 if(responseHandler) responseHandler(modifiedTables);
1110 ConfigurationAPI.popUpSaveModifiedTablesForm =
function(modifiedTables,responseHandler)
1114 Debug.log(
"ConfigurationAPI popUpSaveModifiedTablesForm");
1118 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
1121 el = document.createElement(
"div");
1122 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
1124 el.style.display =
"none";
1129 ConfigurationAPI.setPopUpPosition(el,w ,h-gh*2 );
1151 var modTblCount = 0;
1153 var modifiedTablesListStr =
"";
1155 for(var j=0;j<modifiedTables.length;++j)
1156 if((modifiedTables[j].tableVersion|0) < -1)
1160 modTblStr += modifiedTables[j].tableName;
1162 if(modifiedTablesListStr.length)
1163 modifiedTablesListStr +=
",";
1164 modifiedTablesListStr += modifiedTables[j].tableName;
1165 modifiedTablesListStr +=
",";
1166 modifiedTablesListStr += modifiedTables[j].tableVersion;
1169 var str =
"<a id='" +
1170 ConfigurationAPI._POP_UP_DIALOG_ID +
1171 "-cancel' href='#'>Cancel</a><br><br>";
1173 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-div'>";
1174 str +=
"Saving will create new persistent versions of each modified table." +
1176 "Here is the list of modified tables (count=" + modTblCount +
1182 str +=
"<div style='white-space:nowrap; width:" + w +
"px; height:40px; " +
1183 "overflow:auto; font-weight: bold;'>";
1190 DesktopContent.XMLHttpRequest(
"Request?RequestType=getAffectedActiveGroups" +
1193 "&modifiedTables=" + modifiedTablesListStr,
1196 var err = DesktopContent.getXMLValue(req,
"Error");
1199 Debug.log(err,Debug.HIGH_PRIORITY);
1206 var groups = req.responseXML.getElementsByTagName(
"AffectedActiveGroup");
1207 var memberNames, memberVersions;
1210 for(var i=0;i<groups.length;++i)
1212 xmlGroupName = DesktopContent.getXMLValue(groups[i],
"GroupName");
1213 str +=
"<div style='display:none' class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1214 "-affectedGroups' >";
1215 str += xmlGroupName;
1216 str +=
"," + DesktopContent.getXMLValue(groups[i],
"GroupKey");
1218 memberNames = groups[i].getElementsByTagName(
"MemberName");
1219 memberVersions = groups[i].getElementsByTagName(
"MemberVersion");
1220 Debug.log(
"memberNames.length " + memberNames.length);
1221 for(var j=0;j<memberNames.length;++j)
1222 str +=
"," + DesktopContent.getXMLValue(memberNames[j]) +
1223 "," + DesktopContent.getXMLValue(memberVersions[j]);
1227 if(modTblStr.length)
1231 modTblStr +=
"<a style='color:black' href='#' onclick='javascript:" +
1232 "var forFirefox = ConfigurationAPI.handleGroupCommentToggle(\"" +
1233 xmlGroupName +
"\");" +
1234 " ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
");'>";
1235 modTblStr += xmlGroupName;
1236 modTblStr +=
"</a>";
1239 modTblStr +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1240 xmlGroupName +
"' " +
1241 "class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-cache' " +
1242 "style='display:none'>" +
1243 decodeURIComponent(DesktopContent.getXMLValue(groups[i],
"GroupComment")) +
1247 str +=
"Please choose the options you want and click 'Save':" +
1251 str +=
"<input type='checkbox' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1252 "-bumpGroupVersions' checked " +
1253 "onclick='ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
");'>";
1255 str +=
"<a href='#' onclick='javascript:" +
1256 "var el = document.getElementById(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1257 "-bumpGroupVersions\");" +
1258 "var forFirefox = (el.checked = !el.checked);" +
1259 " ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
"); return false;'>";
1260 str +=
"Save Affected Groups as New Keys";
1262 str +=
"</input><br>";
1265 str +=
"<input type='checkbox' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1266 "-activateBumpedGroupVersions' checked " +
1269 str +=
"<a href='#' onclick='javascript:" +
1270 "var el = document.getElementById(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1271 "-activateBumpedGroupVersions\");" +
1272 "if(el.disabled) return false; " +
1273 "var forFirefox = (el.checked = !el.checked);" +
1275 str +=
"Also Activate New Groups";
1277 str +=
"</input><br>";
1279 str +=
"Here is the list of affected groups (count=" + groups.length +
1284 str +=
"<div style='white-space:nowrap; width:" + w +
"px; margin-bottom:20px; " +
1285 "overflow:auto; font-weight: bold;'>";
1287 str +=
"<div id='clearDiv'></div>";
1290 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-header'></div>";
1292 str +=
"<div id='clearDiv'></div>";
1294 str +=
"<textarea id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1295 "-groupComment' rows='4' cols='50' " +
1296 "style='width:417px;height:68px;display:none;margin:0;'>";
1297 str += ConfigurationAPI._DEFAULT_COMMENT;
1298 str +=
"</textarea>";
1303 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1304 "-groupAliasArea' ><center>";
1308 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
1313 var err = DesktopContent.getXMLValue(req,
"Error");
1316 Debug.log(err,Debug.HIGH_PRIORITY);
1321 var aliases = req.responseXML.getElementsByTagName(
"GroupAlias");
1322 var aliasGroupNames = req.responseXML.getElementsByTagName(
"GroupName");
1323 var aliasGroupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
1330 var alias, aliasGroupName, aliasGroupKey;
1331 var groupName, groupKey;
1332 var groupOptionIndex = [];
1333 for(var i=0;i<groups.length;++i)
1335 groupOptionIndex.push([-1,0]);
1337 groupName = DesktopContent.getXMLValue(groups[i],
"GroupName");
1338 groupKey = DesktopContent.getXMLValue(groups[i],
"GroupKey");
1342 for(var j=0;j<aliasGroupNames.length;++j)
1344 alias = DesktopContent.getXMLValue(aliases[j]);
1345 aliasGroupName = DesktopContent.getXMLValue(aliasGroupNames[j]);
1346 aliasGroupKey = DesktopContent.getXMLValue(aliasGroupKeys[j]);
1352 modTblStr +=
"<option value='" + alias +
"' ";
1355 if(aliasGroupName == groupName)
1357 if(groupOptionIndex[i][0] == -1 ||
1358 Math.abs(groupKey - aliasGroupKey) < groupOptionIndex[i][1])
1360 Debug.log(
"found alias");
1361 groupOptionIndex[i][0] = j;
1362 groupOptionIndex[i][1] = Math.abs(groupKey - aliasGroupKey);
1367 modTblStr +=
"</option>";
1370 str +=
"<input type='checkbox' class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias' " +
1371 (groupOptionIndex[i][0] >= 0?
"checked":
"") +
1374 str +=
"<a href='#' onclick='javascript:" +
1375 "var el = document.getElementsByClassName(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias\");" +
1376 "var forFirefox = (el[" + i +
"].checked = !el[" + i +
"].checked);" +
1378 str +=
"Set '<b style='font-size:16px'>" + groupName +
"</b>' to System Alias:";
1381 str +=
"<table cellpadding='0' cellspacing='0' border='0'><tr><td>";
1383 "id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" + (i) +
"' " +
1384 "style='margin:2px; height:" + (25) +
"px'>";
1388 str +=
"<input type='text' " +
1389 "id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-" + (i) +
"' " +
1390 "style='display:none; margin:2px; width:150px; height:" +
1396 str +=
"<div style='display:block' " +
1397 "class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editIcon' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1400 "onclick='ConfigurationAPI.handlePopUpAliasEditToggle(" +
1403 "title='Toggle free-form system alias editing' " +
1406 str +=
"<div class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1407 "-preloadImage' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1408 "-preloadImage-editIconHover'></div>";
1410 str +=
"</td></tr></table>";
1416 el.style.height = h +
"px";
1419 str +=
"</center></div>";
1425 str +=
"</div><br>";
1433 str +=
"<input id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1434 "-submitButton' type='button' " +
1436 "value='Save' title='" +
1437 "Save new versions of every modified table\n" +
1438 "(Optionally, save new active groups and assign system aliases)" +
1443 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
1444 "-submitButton").onmouseup =
function() {
1445 Debug.log(
"Submit mouseup");
1446 this.disabled =
true;
1447 ConfigurationAPI.handleGroupCommentToggle(0,1);
1448 ConfigurationAPI.handlePopUpHeightToggle(h,gh);
1451 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1452 "-bumpGroupVersions").checked;
1453 var activatingSavedGroups =
1454 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1455 "-activateBumpedGroupVersions").checked;
1457 ConfigurationAPI.saveModifiedTables(modifiedTables,responseHandler,
1463 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
1464 "-cancel").onclick =
function(event) {
1465 Debug.log(
"Cancel click");
1466 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
1467 if(el) el.parentNode.removeChild(el);
1468 if(responseHandler) responseHandler([],[],[]);
1474 for(var i=0;i<groups.length;++i)
1475 if(groupOptionIndex[i][0] != -1)
1476 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" +
1477 i).selectedIndex = groupOptionIndex[i][0];
1486 document.body.appendChild(el);
1487 el.style.display =
"block";
1495 ConfigurationAPI.handleGroupCommentToggle =
function(groupName,setHideVal)
1497 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment");
1498 var hel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-header");
1501 var doHide = el.style.display !=
"none";
1502 if(setHideVal !== undefined)
1503 doHide = setHideVal;
1507 if(hel.textContent ==
"")
return;
1510 var gn = hel.textContent.split(
"'")[1];
1511 Debug.log(
"gn " + gn);
1512 cel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1515 cel.appendChild(document.createTextNode(el.value));
1519 el.style.display =
"none";
1522 if(gn == groupName || setHideVal !== undefined)
1529 cel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1531 el.value = cel.textContent;
1532 el.style.display =
"block";
1533 ConfigurationAPI.setCaretPosition(el,0,cel.textContent.length);
1535 hel.innerHTML = (
"'" + groupName +
"' group comment:");
1545 ConfigurationAPI.handlePopUpHeightToggle =
function(h,gh)
1547 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-bumpGroupVersions");
1548 Debug.log(
"ConfigurationAPI.handlePopUpHeightToggle " + el.checked);
1550 var ael = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-activateBumpedGroupVersions");
1552 var groupCommentEl = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment");
1553 var groupCommentHeight = 0;
1555 if(groupCommentEl && groupCommentEl.style.display !=
"none")
1556 groupCommentHeight += 100;
1558 var popEl = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1563 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupAliasArea").style.display =
"none";
1564 popEl.style.height = (h + groupCommentHeight) +
"px";
1565 ael.disabled =
true;
1572 var grps = document.getElementsByClassName(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-affectedGroups");
1573 popEl.style.height = (h + grps.length*gh + groupCommentHeight) +
"px";
1574 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupAliasArea").style.display =
"block";
1575 ael.disabled =
false;
1581 ConfigurationAPI.handlePopUpAliasEditToggle =
function(i)
1583 Debug.log(
"handlePopUpAliasEditToggle " + i);
1585 var sel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-"+i);
1586 var tel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-"+i);
1587 Debug.log(
"sel.style.display " + sel.style.display);
1588 if(sel.style.display ==
"none")
1590 sel.style.display =
"block";
1591 tel.style.display =
"none";
1595 tel.style.width = (sel.offsetWidth-2) +
"px";
1596 sel.style.display =
"none";
1597 tel.style.display =
"block";
1598 ConfigurationAPI.setCaretPosition(tel,0,tel.value.length);
1604 ConfigurationAPI.addTableToConfigurationGroup =
function(tableName)
1606 Debug.log(
"addTableToConfigurationGroup",tableName);
1608 ConfigurationAPI.saveModifiedTables([{
"tableName":tableName,
"tableVersion":-1}]);
1650 ConfigurationAPI.saveModifiedTables =
function(modifiedTables,responseHandler,
1651 doNotIgnoreWarnings,doNotSaveAffectedGroups,
1652 doNotActivateAffectedGroups,doNotSaveAliases,
1653 doNotIgnoreGroupActivationWarnings,
1654 doNotKillPopUpEl, tablesToAdd)
1658 var savedTables = [];
1659 var savedGroups = [];
1660 var savedAliases = [];
1662 if(!modifiedTables.length)
1664 Debug.log(
"No tables were modified. Nothing to do.", Debug.WARN_PRIORITY);
1665 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1681 var numberOfRequests = 0;
1682 var numberOfReturns = 0;
1683 var allRequestsSent =
false;
1687 function localHandleAffectedGroups()
1689 Debug.log(
"Done with table saving.");
1693 var activatingSavedGroups;
1694 var doRequestAffectedGroups =
false;
1698 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-bumpGroupVersions").checked;
1700 activatingSavedGroups =
1701 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-activateBumpedGroupVersions").checked;
1705 savingGroups = !doNotSaveAffectedGroups;
1706 activatingSavedGroups = !doNotActivateAffectedGroups;
1707 doRequestAffectedGroups =
true;
1713 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1714 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
1715 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1725 Debug.log(
"On to saving groups");
1727 numberOfRequests = 0;
1728 numberOfReturns = 0;
1729 allRequestsSent =
false;
1731 var affectedGroupNames = [];
1732 var affectedGroupComments = [];
1733 var affectedGroupTableMap = [];
1735 var affectedGroupKeys = [];
1737 if(doRequestAffectedGroups)
1740 var modifiedTablesListStr =
"";
1741 var modTblCount = 0;
1743 for(var j=0;j<modifiedTables.length;++j)
1744 if((modifiedTables[j].tableVersion|0) < 0)
1748 modTblStr += modifiedTables[j].tableName;
1750 if(modifiedTablesListStr.length)
1751 modifiedTablesListStr +=
",";
1752 modifiedTablesListStr += modifiedTables[j].tableName;
1753 modifiedTablesListStr +=
",";
1754 modifiedTablesListStr += modifiedTables[j].tableVersion;
1760 DesktopContent.XMLHttpRequest(
"Request?RequestType=getAffectedActiveGroups" +
1763 "&modifiedTables=" + modifiedTablesListStr,
1766 var err = DesktopContent.getXMLValue(req,
"Error");
1769 Debug.log(err,Debug.HIGH_PRIORITY);
1771 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1776 var groups = req.responseXML.getElementsByTagName(
"AffectedActiveGroup");
1777 var memberNames, memberVersions;
1780 for(var i=0;i<groups.length;++i)
1782 affectedGroupNames.push( DesktopContent.getXMLValue(groups[i],
"GroupName"));
1783 affectedGroupComments.push(decodeURIComponent(DesktopContent.getXMLValue(groups[i],
"GroupComment")));
1785 memberNames = groups[i].getElementsByTagName(
"MemberName");
1786 memberVersions = groups[i].getElementsByTagName(
"MemberVersion");
1788 Debug.log(
"memberNames.length " + memberNames.length);
1791 affectedGroupTableMap[i] =
"tableList=";
1792 var memberVersion, memberName;
1793 for(var j=0;j<memberNames.length;++j)
1795 memberVersion = DesktopContent.getXMLValue(memberVersions[j])|0;
1796 memberName = DesktopContent.getXMLValue(memberNames[j]);
1797 if(memberVersion < -1)
1799 Debug.log(
"affectedArr " + memberName +
"-v" + memberVersion);
1801 for(var k=0;k<savedTables.length;++k)
1802 if(memberName == savedTables[k].tableName)
1804 Debug.log(
"found " + savedTables[k].tableName +
"-v" +
1805 savedTables[k].tableVersion);
1806 affectedGroupTableMap[i] += memberName +
"," +
1807 savedTables[k].tableVersion +
",";
1812 affectedGroupTableMap[i] += memberName +
1813 "," + memberVersion +
",";
1816 for(var t=0;tablesToAdd && t<tablesToAdd.length;++t)
1817 if(memberName == tablesToAdd[t].tableName)
1819 Debug.log(
"Removing table to add '" +
1820 memberName +
"', already in group.");
1821 tablesToAdd.splice(t,1);
1822 console.log(
"Now tablesToAdd",tablesToAdd);
1828 if(i==groups.length-1 && tablesToAdd)
1830 for(var j=0;j<tablesToAdd.length;++j)
1831 affectedGroupTableMap[i] += tablesToAdd[j].tableName +
1832 "," + tablesToAdd[j].tableVersion +
",";
1836 localHandleSavingAffectedGroups();
1842 var affectedGroupEls =
1843 document.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
1845 var affectedGroupCommentEls =
1846 document.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
1847 "-groupComment-cache");
1850 for(var i=0;i<affectedGroupEls.length;++i)
1852 Debug.log(affectedGroupEls[i].textContent);
1853 Debug.log(
"group comment: " + affectedGroupCommentEls[i].textContent);
1855 var affectedArr = affectedGroupEls[i].textContent.split(
',');
1857 affectedGroupComments.push(affectedGroupCommentEls[i].textContent);
1858 affectedGroupNames.push(affectedArr[0]);
1861 affectedGroupTableMap[i] =
"tableList=";
1863 for(var a=2;a<affectedArr.length;a+=2)
1864 if((affectedArr[a+1]|0) < -1)
1866 Debug.log(
"affectedArr " + affectedArr[a] +
"-v" + affectedArr[a+1]);
1868 for(var k=0;k<savedTables.length;++k)
1869 if(affectedArr[a] == savedTables[k].tableName)
1871 Debug.log(
"found " + savedTables[k].tableName +
"-v" +
1872 savedTables[k].tableVersion);
1873 affectedGroupTableMap[i] += affectedArr[a] +
"," +
1874 savedTables[k].tableVersion +
",";
1879 affectedGroupTableMap[i] += affectedArr[a] +
"," + affectedArr[a+1] +
",";
1882 localHandleSavingAffectedGroups();
1887 function localHandleSavingAffectedGroups()
1890 for(var i=0;i<affectedGroupNames.length;++i)
1893 reqStr =
"Request?RequestType=saveNewTableGroup" +
1894 "&groupName=" + affectedGroupNames[i] +
1895 "&allowDuplicates=0" +
1896 "&lookForEquivalent=1" +
1897 "&ignoreWarnings=" + (doNotIgnoreWarnings?0:1) +
1898 "&groupComment=" + encodeURIComponent(affectedGroupComments[i]);
1900 Debug.log(affectedGroupTableMap[i]);
1904 DesktopContent.XMLHttpRequest(reqStr, affectedGroupTableMap[i],
1905 function(req,affectedGroupIndex)
1908 var attemptedNewGroupName = DesktopContent.getXMLValue(req,
"AttemptedNewGroupName");
1909 var treeErr = DesktopContent.getXMLValue(req,
"TreeErrors");
1912 Debug.log(treeErr,Debug.HIGH_PRIORITY);
1913 Debug.log(
"There were problems identified in the tree view of the " +
1914 "attempted new group '" +
1915 attemptedNewGroupName +
1916 "'.\nThe new group was not created.\n" +
1917 "(Note: Other tables and groups may have been successfully created, " +
1918 "and would have success indications below this error info)\n\n" +
1919 "You can save the group anyway (if you think it is a good idea) by clicking " +
1920 "the button in the pop-up dialog " +
1921 "'<u>Save Groups with Warnings Ignored</u>.' " +
1922 "\n\nOtherwise, you can hit '<u>Cancel</u>.' and fix the tree. " +
1923 "Below you will find the description of the problem:",
1924 Debug.HIGH_PRIORITY);
1927 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-submitButton");
1930 el.onmouseup =
function() {
1931 Debug.log(
"Submit mouseup");
1932 this.disabled =
true;
1933 ConfigurationAPI.handleGroupCommentToggle(0,1);
1934 ConfigurationAPI.handlePopUpHeightToggle(h,gh);
1937 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1938 "-bumpGroupVersions").checked;
1939 var activatingSavedGroups =
1940 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1941 "-activateBumpedGroupVersions").checked;
1943 ConfigurationAPI.saveModifiedTables(modifiedTables,responseHandler,
1945 doNotSaveAffectedGroups,
1946 doNotActivateAffectedGroups,doNotSaveAliases
1949 el.value =
"Save Groups with Warnings Ignored";
1950 el.disabled =
false;
1955 var err = DesktopContent.getXMLValue(req,
"Error");
1958 Debug.log(err,Debug.HIGH_PRIORITY);
1961 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1962 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
1963 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1969 var newGroupKey = DesktopContent.getXMLValue(req,
"TableGroupKey");
1970 affectedGroupKeys.push(newGroupKey);
1974 obj.groupName = attemptedNewGroupName;
1975 obj.groupKey = newGroupKey;
1976 obj.groupComment = affectedGroupComments[affectedGroupIndex];
1977 savedGroups.push(obj);
1981 var foundEquivalentKey = DesktopContent.getXMLValue(req,
"foundEquivalentKey");
1982 if(foundEquivalentKey)
1983 Debug.log(
"Using existing group '" + attemptedNewGroupName +
1984 " (" + newGroupKey +
")'", Debug.INFO_PRIORITY);
1986 Debug.log(
"Successfully created new group '" + attemptedNewGroupName +
1987 " (" + newGroupKey +
")'", Debug.INFO_PRIORITY);
1992 if(activatingSavedGroups)
1993 ConfigurationAPI.activateGroup(attemptedNewGroupName,newGroupKey,
1994 doNotIgnoreGroupActivationWarnings?
false:
true );
1997 if(allRequestsSent &&
1998 numberOfReturns == numberOfRequests)
2000 Debug.log(
"Done with group saving.");
2002 Debug.log(
"Moving on to Alias creation...");
2010 var setAliasCheckboxes;
2012 var groupAlias, groupName, groupKey;
2013 var setAliasCheckboxIndex = -1;
2014 var groupAliasName, groupAliasVersion;
2016 var affectedGroupAliases = [];
2029 setAliasCheckboxes =
2030 document.getElementsByClassName(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias");
2033 if(setAliasCheckboxes.length != affectedGroupNames.length)
2037 localNextAliasHandler();
2038 Debug.log(
"Aliases set in motion");
2043 setAliasCheckboxes = [];
2044 for(var i in affectedGroupNames)
2045 setAliasCheckboxes.push({
"checked" : ((!doNotSaveAliases)?1:0) });
2055 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
2060 var err = DesktopContent.getXMLValue(req,
"Error");
2063 Debug.log(err,Debug.HIGH_PRIORITY);
2064 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2068 var aliases = req.responseXML.getElementsByTagName(
"GroupAlias");
2069 var aliasGroupNames = req.responseXML.getElementsByTagName(
"GroupName");
2070 var aliasGroupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
2075 var alias, aliasGroupName, aliasGroupKey;
2076 var groupName, groupKey;
2077 var groupOptionIndex = [];
2078 for(var i=0;i<affectedGroupNames.length;++i)
2080 groupOptionIndex.push([-1,0]);
2082 groupName = affectedGroupNames[i];
2083 groupKey = affectedGroupKeys[i];
2086 for(var j=0;j<aliasGroupNames.length;++j)
2088 alias = DesktopContent.getXMLValue(aliases[j]);
2089 aliasGroupName = DesktopContent.getXMLValue(aliasGroupNames[j]);
2090 aliasGroupKey = DesktopContent.getXMLValue(aliasGroupKeys[j]);
2096 if(aliasGroupName == groupName)
2098 if(groupOptionIndex[i][0] == -1 ||
2099 Math.abs(groupKey - aliasGroupKey) < groupOptionIndex[i][1])
2101 Debug.log(
"found alias");
2102 groupOptionIndex[i][0] = j;
2103 groupOptionIndex[i][1] = Math.abs(groupKey - aliasGroupKey);
2109 setAliasCheckboxes[i].checked = (groupOptionIndex[i][0] >= 0?1:0);
2111 affectedGroupAliases.push(groupOptionIndex[i][0] >= 0?
2112 DesktopContent.getXMLValue(aliases[groupOptionIndex[i][0]]):
"");
2116 localNextAliasHandler();
2117 Debug.log(
"Aliases set in motion");
2130 function localNextAliasHandler(retParams)
2133 if(setAliasCheckboxIndex >= 0)
2137 if(retParams.newGroupCreated)
2139 Debug.log(
"Successfully modified the active Backbone group " +
2140 " to set the System Alias '" + groupAlias +
"' to " +
2141 " refer to the current group '" + groupName +
2142 " (" + groupKey +
").'" +
2144 "Backbone group '" + retParams.groupName +
" (" +
2145 retParams.groupKey +
")' was created and activated.",
2146 Debug.INFO_PRIORITY);
2150 obj.groupName = groupName;
2151 obj.groupKey = groupKey;
2152 obj.groupAlias = groupAlias;
2153 savedAliases.push(obj);
2157 Debug.log(
"Success, but no need to create a new Backbone group. " +
2158 "An existing Backbone group " +
2159 " already has the System Alias '" + groupAlias +
"' " +
2160 " referring to the current group '" + groupName +
2161 " (" + groupKey +
").'" +
2163 "Backbone group '" + retParams.groupName +
" (" +
2164 retParams.groupKey +
")' was activated.",
2165 Debug.INFO_PRIORITY);
2169 Debug.log(
"Process interrupted. Failed to modify the currently active Backbone!",Debug.HIGH_PRIORITY);
2172 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2173 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2174 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2178 ++setAliasCheckboxIndex;
2181 setAliasCheckboxIndex = 0;
2184 while(setAliasCheckboxIndex < setAliasCheckboxes.length &&
2185 !setAliasCheckboxes[setAliasCheckboxIndex].checked)
2186 Debug.log(
"Skipping checkbox " + (++setAliasCheckboxIndex));
2188 if(setAliasCheckboxIndex >= setAliasCheckboxes.length)
2190 Debug.log(
"Done with alias checkboxes ");
2194 Debug.log(
"No System Aliases were changed, so Backbone was not modified. Done.");
2197 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2198 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2199 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2203 Debug.log(
"Saving and activating Backbone done.");
2206 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2207 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2208 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2215 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" +
2216 setAliasCheckboxIndex);
2217 if(el.style.display ==
"none")
2220 el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-" +
2221 setAliasCheckboxIndex);
2223 groupAlias = el.value;
2229 groupAlias = affectedGroupAliases[setAliasCheckboxIndex];
2232 groupName = affectedGroupNames[setAliasCheckboxIndex];
2233 groupKey = affectedGroupKeys[setAliasCheckboxIndex];
2235 Debug.log(
"groupAlias = " + groupAlias);
2236 Debug.log(
"groupName = " + groupName);
2237 Debug.log(
"groupKey = " + groupKey);
2239 ConfigurationAPI.setGroupAliasInActiveBackbone(groupAlias,groupName,groupKey,
2241 localNextAliasHandler,
2251 allRequestsSent =
true;
2252 if(numberOfRequests == 0)
2255 Debug.log(
"There were no groups to save!", Debug.INFO_PRIORITY);
2258 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2259 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2269 for(var j=0;j<modifiedTables.length;++j)
2270 if((modifiedTables[j].tableVersion|0) < 0)
2272 var reqStr =
"Request?RequestType=saveSpecificTable" +
2273 "&dataOffset=0&chunkSize=0" +
2274 "&tableName=" + modifiedTables[j].tableName +
2275 "&version="+modifiedTables[j].tableVersion +
2278 encodeURIComponent(modifiedTables[j].tableComment?modifiedTables[j].tableComment:
"") +
2279 "&sourceTableAsIs=1" +
2280 "&lookForEquivalent=1";
2287 DesktopContent.XMLHttpRequest(reqStr,
"",
2288 function(req,modifiedTableIndex)
2290 var err = DesktopContent.getXMLValue(req,
"Error");
2293 Debug.log(err,Debug.HIGH_PRIORITY);
2296 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2298 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2302 var tableName = DesktopContent.getXMLValue(req,
"savedName");
2303 var version = DesktopContent.getXMLValue(req,
"savedVersion");
2304 var foundEquivalentVersion = DesktopContent.getXMLValue(req,
"foundEquivalentVersion") | 0;
2306 if(foundEquivalentVersion)
2307 Debug.log(
"Using existing table '" + tableName +
"-v" +
2308 version +
"'",Debug.INFO_PRIORITY);
2310 Debug.log(
"Successfully created new table '" + tableName +
"-v" +
2311 version +
"'",Debug.INFO_PRIORITY);
2316 obj.tableName = tableName;
2317 obj.tableVersion = version;
2318 obj.tableComment = modifiedTables[modifiedTableIndex].tableComment;
2319 savedTables.push(obj);
2324 if(allRequestsSent &&
2325 numberOfReturns == numberOfRequests)
2327 if(!doNotSaveAffectedGroups)
2328 localHandleAffectedGroups();
2334 allRequestsSent =
true;
2335 if(numberOfRequests == 0)
2338 Debug.log(
"No tables were modified. Should be impossible to get here.", Debug.HIGH_PRIORITY);
2345 ConfigurationAPI.activateGroup =
function(groupName, groupKey,
2346 ignoreWarnings, doneHandler)
2348 DesktopContent.XMLHttpRequest(
"Request?RequestType=activateTableGroup" +
2349 "&groupName=" + groupName +
2350 "&groupKey=" + groupKey +
2351 "&ignoreWarnings=" + (ignoreWarnings?
"1":
"0") +
2357 var err = DesktopContent.getXMLValue(req,
"Error");
2360 Debug.log(err,Debug.HIGH_PRIORITY);
2368 str +=
" <a href='#' onclick='javascript:ConfigurationAPI.activateGroup(\"" +
2370 "\",\"" + groupKey +
"\",true); return false;'>";
2371 str +=
"Activate " +
2372 groupName +
"(" + groupKey +
") w/warnings ignored</a>";
2374 Debug.log(
"If you are are sure it is a good idea you can try to " +
2375 "activate the group with warnings ignored: " +
2376 str,Debug.HIGH_PRIORITY);
2380 if(doneHandler) doneHandler();
2398 ConfigurationAPI.setGroupAliasInActiveBackbone =
function(groupAlias,groupName,groupKey,
2399 newBackboneNameAdd,doneHandler,doReturnParams)
2401 Debug.log(
"setGroupAliasInActiveBackbone groupAlias=" + groupAlias);
2402 Debug.log(
"setGroupAliasInActiveBackbone groupName=" + groupName);
2403 Debug.log(
"setGroupAliasInActiveBackbone groupKey=" + groupKey);
2405 if(!groupAlias || groupAlias.trim() ==
"")
2407 Debug.log(
"Process interrupted. Invalid empty alias given!",Debug.HIGH_PRIORITY);
2408 if(doneHandler) doneHandler();
2412 if(!groupName || groupName.trim() ==
"" || !groupKey || groupKey.trim() ==
"")
2414 Debug.log(
"Process interrupted. Invalid group name and key given!",Debug.HIGH_PRIORITY);
2415 if(doneHandler) doneHandler();
2419 if(!newBackboneNameAdd || newBackboneNameAdd ==
"")
2420 newBackboneNameAdd =
"Wiz";
2421 newBackboneNameAdd +=
"Backbone";
2422 Debug.log(
"setGroupAliasInActiveBackbone newBackboneNameAdd=" + newBackboneNameAdd);
2424 DesktopContent.XMLHttpRequest(
"Request?RequestType=setGroupAliasInActiveBackbone" +
2425 "&groupAlias=" + groupAlias +
2426 "&groupName=" + groupName +
2427 "&groupKey=" + groupKey,
"",
2428 ConfigurationAPI.newWizBackboneMemberHandler,
2429 [(
"GroupAlias" + newBackboneNameAdd),doneHandler,doReturnParams],
2441 ConfigurationAPI.newWizBackboneMemberHandler =
function(req,params)
2443 var err = DesktopContent.getXMLValue(req,
"Error");
2446 Debug.log(err,Debug.HIGH_PRIORITY);
2447 Debug.log(
"Process interrupted. Failed to modify the currently active Backbone!",Debug.HIGH_PRIORITY);
2454 var groupAliasName = DesktopContent.getXMLValue(req,
"savedName");
2455 var groupAliasVersion = DesktopContent.getXMLValue(req,
"savedVersion");
2457 Debug.log(
"groupAliasName=" + groupAliasName);
2458 Debug.log(
"groupAliasVersion=" + groupAliasVersion);
2460 var configNames = req.responseXML.getElementsByTagName(
"oldBackboneName");
2461 var tableVersions = req.responseXML.getElementsByTagName(
"oldBackboneVersion");
2464 var tableMap =
"tableList=";
2466 for(var i=0;i<configNames.length;++i)
2468 name = configNames[i].getAttribute(
"value");
2470 if(name == groupAliasName)
2472 tableMap += name +
"," +
2473 groupAliasVersion +
",";
2477 tableMap += name +
"," +
2478 tableVersions[i].getAttribute(
"value") +
",";
2481 console.log(
"backbone tableMap",tableMap);
2483 ConfigurationAPI.saveGroupAndActivate(params[0],tableMap,params[1],params[2],
2489 ConfigurationAPI.saveGroupAndActivate =
function(groupName,tableMap,
2490 doneHandler,doReturnParams,
2493 DesktopContent.XMLHttpRequest(
"Request?RequestType=saveNewTableGroup&groupName=" +
2495 "&allowDuplicates=" + (lookForEquivalent?
"0":
"1") +
2496 "&lookForEquivalent=" + (lookForEquivalent?
"1":
"0") +
2501 var err = DesktopContent.getXMLValue(req,
"Error");
2502 var name = DesktopContent.getXMLValue(req,
"TableGroupName");
2503 var key = DesktopContent.getXMLValue(req,
"TableGroupKey");
2504 var newGroupCreated =
true;
2509 Debug.log(err,Debug.HIGH_PRIORITY);
2510 Debug.log(
"Process interrupted. Failed to create a new group!" +
2511 " Please see details below.",
2512 Debug.HIGH_PRIORITY);
2514 if(doneHandler) doneHandler();
2519 Debug.log(err,Debug.WARN_PRIORITY);
2520 Debug.log(
"Process interrupted. Failed to create a new group!" +
2521 " (Likely the currently active group already represents what is being requested)\n\n" +
2522 "Going on with existing backbone group, name=" + name +
" & key=" + key,
2523 Debug.WARN_PRIORITY);
2524 newGroupCreated =
false;
2530 DesktopContent.XMLHttpRequest(
"Request?RequestType=activateTableGroup" +
2531 "&groupName=" + name +
2532 "&groupKey=" + key,
"",
2537 activateSystemConfigHandler(req);
2551 "newGroupCreated" : newGroupCreated
2553 doneHandler(retParams);
2571 ConfigurationAPI.getGroupTypeMemberNames =
function(groupType,responseHandler)
2573 DesktopContent.XMLHttpRequest(
"Request?RequestType=get" + groupType +
"MemberNames",
"",
2578 var err = DesktopContent.getXMLValue(req,
"Error");
2581 Debug.log(err,Debug.HIGH_PRIORITY);
2582 if(responseHandler) responseHandler(retArr);
2585 var memberNames = req.responseXML.getElementsByTagName(groupType +
"Member");
2587 for(var i=0;i<memberNames.length;++i)
2588 retArr[i] = memberNames[i].getAttribute(
"value");
2590 Debug.log(
"Members found for group type " + groupType +
" = " + retArr.length);
2591 if(responseHandler) responseHandler(retArr);
2607 ConfigurationAPI.bitMapDialog =
function(fieldName,bitMapParams,initBitMapValue,okHandler,cancelHandler)
2609 Debug.log(
"ConfigurationAPI bitMapDialog");
2613 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2616 el = document.createElement(
"div");
2617 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
2619 el.style.display =
"none";
2620 el.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmapDialog");
2686 var minValue, maxValue;
2690 var forcedAspectH, forcedAspectW;
2692 var minValueColor, midValueColor, maxValueColor;
2693 var ceilValueColor, floorValueColor;
2695 var doDisplayRowsAscending, doDisplayColsAscending;
2696 var doSnakeColumns, doSnakeRows;
2699 if(!localValidateInputs())
2701 Debug.log(
"Input parameters array to the Bitmap Dialog was as follows:\n " +
2702 bitMapParams, Debug.HIGH_PRIORITY);
2703 Debug.log(
"Input parameters to the Bitmap Dialog are invalid. Aborting.", Debug.HIGH_PRIORITY);
2704 return cancelHandler();
2708 var numberDigitW = 8, numberDigitH = 12;
2709 var axisPaddingExtra = numberDigitW;
2710 function localCalcExtraAxisPadding() {
2712 while((lrows /= 10) > 1) axisPaddingExtra += numberDigitW;
2713 } localCalcExtraAxisPadding();
2715 var axisPaddingMargin = 5;
2716 var axisPadding = axisPaddingMargin + axisPaddingExtra + axisPaddingMargin + butttonSz + axisPaddingMargin;
2717 var bmpGridThickness = 1;
2718 var bmpBorderSize = 1;
2729 var allRowBtns, allColBtns, allBtn;
2730 var rowLeftNums, rowRightNums, colTopNums, colBottomNums;
2731 var bmpCanvas, bmpContext;
2739 var cursorInfo, hdrCursorInfo;
2744 var clickColors = [];
2745 var clickValues = [];
2748 localCreateHeader();
2749 localCreateBitmap();
2750 localCreateGridButtons();
2752 localInitBitmapData();
2755 window.addEventListener(
"resize",localPaint);
2757 document.body.appendChild(el);
2758 el.style.display =
"block";
2764 function localCreateCancelClickHandler()
2766 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2767 "-cancel").onclick =
function(event) {
2768 Debug.log(
"Cancel click");
2769 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2770 if(el) el.parentNode.removeChild(el);
2771 window.removeEventListener(
"resize",localPaint);
2775 } localCreateCancelClickHandler();
2780 function localCreateOkClickHandler()
2782 var convertFunc = localConvertFullGridToRowCol;
2783 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2784 "-ok").onclick =
function(event) {
2785 Debug.log(
"OK click");
2786 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2787 if(el) el.parentNode.removeChild(el);
2788 window.removeEventListener(
"resize",localPaint);
2790 var transGrid = convertFunc();
2791 var dataJsonStr =
"[\n";
2792 for(var r=0;r<transGrid.length;++r)
2794 if(r) dataJsonStr +=
",\n";
2795 dataJsonStr +=
"\t[";
2796 for(var c=0;c<transGrid[0].length;++c)
2798 if(c) dataJsonStr +=
",";
2799 dataJsonStr += transGrid[r][c];
2803 dataJsonStr +=
"\n]";
2804 okHandler(dataJsonStr);
2807 } localCreateOkClickHandler();
2812 function localCreateMouseHandler()
2814 var stopProp =
false;
2815 var rLast = -1, cLast = -1;
2817 var buttonDown = -1;
2824 function localGetRowCol(x,y) {
2825 x -= popSz.x + bmpX + 1;
2826 y -= popSz.y + bmpY + 1;
2827 var r = (y/cellH)|0;
2829 var c = (x/cellW)|0;
2831 var inRowBtnsX = (x >= - axisPaddingMargin - bmpBorderSize - butttonSz) &&
2832 (x <= - axisPaddingMargin - bmpBorderSize);
2833 var inColBtnsY = (y >= bmpH + axisPaddingMargin) &&
2834 (y <= bmpH + axisPaddingMargin + butttonSz + bmpBorderSize*2);
2842 if(inRowBtnsX && r >= 0 && r < rows)
2843 return {
"r":r,
"c":-2};
2844 else if(inColBtnsY && c >= 0 && c < cols)
2845 return {
"r":-2,
"c":c};
2846 else if(inRowBtnsX && inColBtnsY)
2847 return {
"r":-2,
"c":-2};
2848 else if(r < 0 || c < 0 || r >= rows || c >= cols)
2849 return {
"r":-1,
"c":-1};
2850 return {
"r":r,
"c":c};
2855 el.onmousemove =
function(event) {
2856 var cell = localGetRowCol(event.pageX,event.pageY);
2857 var r = cell.r, c = cell.c;
2859 var cursorT = (
event.pageX - popSz.x - bmpX);
2860 if(cursorT < 0) cursorT = 0;
2861 if(cursorT > bmpW) cursorT = bmpW;
2863 cursorInfo.style.left = (
event.pageX - popSz.x +
2866 (cursorT)/bmpW*(-cursorInfo.innerHTML.length*8-20) + (bmpW-cursorT)/bmpW*(2))+
2868 cursorInfo.style.top = (
event.pageY - popSz.y - 35) +
"px";
2871 hdrCursorInfo.style.left = (bmpX + bmpW/2 +
2873 hdrCursorInfo.style.top = (bmpY - 45) +
"px";
2876 if(rLast == r && cLast == c)
2878 rLast = r; cLast = c;
2880 if(r == -1 || c == -1)
2883 rLast = -1; cLast = -1;
2884 bmpOverlay.style.display =
"none";
2885 cursorInfo.style.display =
"none";
2886 hdrCursorInfo.style.display =
"none";
2890 cursorInfo.style.display =
"block";
2897 if(r != -2 && c == -2)
2900 transRC = localConvertGridToRowCol(r,
2901 doDisplayColsAscending?0:cols-1);
2903 transRC = localConvertGridToRowCol(r,0);
2907 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2909 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2910 bmpOverlay.style.top = (bmpY + r*cellH - 1 + (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2911 bmpOverlay.style.width = (butttonSz) +
"px";
2912 bmpOverlay.style.height = (cellH - (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2913 bmpOverlay.style.display =
"block";
2916 infoStr =
"Set all pixels in row " + transRC[0] +
".";
2918 else if(r == -2 && c != -2)
2921 transRC = localConvertGridToRowCol(
2922 doDisplayRowsAscending?0:rows-1,c);
2924 transRC = localConvertGridToRowCol(0,c);
2929 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2931 bmpOverlay.style.left = (bmpX + c*cellW - 1 + (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2932 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2933 bmpOverlay.style.width = (cellW + 1 - (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2934 bmpOverlay.style.height = (butttonSz) +
"px";
2935 bmpOverlay.style.display =
"block";
2938 infoStr =
"Set all pixels in column " + transRC[1] +
".";
2940 else if(r == -2 && c == -2)
2944 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2946 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2947 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2948 bmpOverlay.style.width = (butttonSz) +
"px";
2949 bmpOverlay.style.height = (butttonSz) +
"px";
2950 bmpOverlay.style.display =
"block";
2953 infoStr =
"Set all pixels.";
2957 transRC = localConvertGridToRowCol(r,c);
2963 var overClr = (bmpDataImage.data[(r*cols+c)*4+0] +
2964 bmpDataImage.data[(r*cols+c)*4+1] +
2965 bmpDataImage.data[(r*cols+c)*4+2]) < (256+128)?255:0;
2967 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData(
2968 [overClr,overClr,overClr,100]);
2970 bmpOverlay.style.left = (bmpX + c*cellW) +
"px";
2971 bmpOverlay.style.top = (bmpY + r*cellH) +
"px";
2972 bmpOverlay.style.width = (cellW) +
"px";
2973 bmpOverlay.style.height = (cellH) +
"px";
2974 bmpOverlay.style.display =
"block";
2978 infoStr =
"Value = " + bmpData[r][c] +
" @ (Row,Col) = (" +
2979 transRC[0] +
"," + transRC[1] +
")";
2981 cursorInfo.innerHTML = infoStr;
2982 hdrCursorInfo.innerHTML = infoStr;
2985 if(r == -2 && c == -2)
2991 localSetBitMap(r,c);
2998 el.onmousedown =
function(event) {
3000 var cell = localGetRowCol(event.pageX,event.pageY);
3001 var r = cell.r, c = cell.c;
3005 buttonDown =
event.button;
3007 if(r == -1 || c == -1)
3009 rLast = -1; cLast = -1;
3014 rLast = r; cLast = c;
3015 localSetBitMap(r,c);
3018 event.stopPropagation();
3024 el.onmouseup =
function(event) {
3031 el.oncontextmenu =
function(event) {
3037 event.stopPropagation();
3044 function localSetBitMap(r,c) {
3046 Debug.log(
"set r,c " + buttonDown +
" @ " + r +
"," + c );
3047 buttonDown = buttonDown?1:0;
3049 var maxr = r==-2?rows-1:r;
3050 var minr = r==-2?0:r;
3051 var maxc = c==-2?cols-1:c;
3052 var minc = c==-2?0:c;
3054 for(r=minr;r<=maxr;++r)
3055 for(c=minc;c<=maxc;++c)
3057 bmpData[r][c] = clickValues[buttonDown];
3058 bmpDataImage.data[(r*cols + c)*4 + 0] =
3059 clickColors[buttonDown][0];
3060 bmpDataImage.data[(r*cols + c)*4 + 1] =
3061 clickColors[buttonDown][1];
3062 bmpDataImage.data[(r*cols + c)*4 + 2] =
3063 clickColors[buttonDown][2];
3064 bmpDataImage.data[(r*cols + c)*4 + 3] =
3065 clickColors[buttonDown][3];
3068 bmpContext.putImageData(bmpDataImage,0,0);
3069 bmp.src = bmpCanvas.toDataURL();
3072 } localCreateMouseHandler();
3078 function localValidateInputs() {
3081 if(bitMapParams.length != 16)
3083 Debug.log(
"Illegal input parameters, expecting 16 parameters and count is " + bitMapParams.length +
". There is a mismatch in Table Editor handling of BitMap fields (contact an admin to fix)." +
3084 "\nHere is a printout of the input parameters: " + bitMapParams,Debug.HIGH_PRIORITY);
3087 var DEFAULT =
"DEFAULT";
3089 rows = bitMapParams[0]|0;
3090 cols = bitMapParams[1]|0;
3091 bitFieldSize = bitMapParams[2]|0;
3095 if(rows < 1 || rows >= 1<<30)
3097 Debug.log(
"Illegal input parameters, rows of " + rows +
" is illegal. " +
3098 "(rows possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3101 if(cols < 1 || cols >= 1<<30)
3103 Debug.log(
"Illegal input parameters, cols of " + cols +
" is illegal. " +
3104 "(cols possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3107 if(bitFieldSize < 1 || bitFieldSize > 31)
3109 Debug.log(
"Illegal input parameters, bitFieldSize of " + bitFieldSize +
" is illegal. " +
3110 "(bitFieldSize possible values are from 1 to " + (31) +
".)",Debug.HIGH_PRIORITY);
3115 if(bitFieldSize > 30)
3118 for(var i=0;i<bitFieldSize;++i)
3122 bitMask = (1<<bitFieldSize) - 1;
3124 minValue = bitMapParams[3] ==
"DEFAULT" || bitMapParams[3] ==
""?0:(bitMapParams[3]|0);
3125 maxValue = bitMapParams[4] ==
"DEFAULT" || bitMapParams[4] ==
""?bitMask:(bitMapParams[4]|0);
3126 if(maxValue < minValue)
3128 midValue = (maxValue + minValue)/2;
3129 stepValue = bitMapParams[5] ==
"DEFAULT" || bitMapParams[5] ==
""?1:(bitMapParams[5]|0);
3131 if(minValue < 0 || minValue > bitMask)
3133 Debug.log(
"Illegal input parameters, minValue of " + minValue +
" is illegal. " +
3134 "(minValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3137 if(maxValue < 0 || maxValue > bitMask)
3139 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
" is illegal. " +
3140 "(maxValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3143 if(minValue > maxValue)
3145 Debug.log(
"Illegal input parameters, minValue > maxValue is illegal.",Debug.HIGH_PRIORITY);
3148 if(stepValue < 1 || stepValue > maxValue - minValue)
3150 Debug.log(
"Illegal input parameters, stepValue of " + stepValue +
" is illegal. " +
3151 "(stepValue possible values are from 1 to " + (maxValue - minValue) +
".)",Debug.HIGH_PRIORITY);
3154 if((((maxValue-minValue)/stepValue)|0) != (maxValue-minValue)/stepValue)
3156 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
3157 " must be an integer number of stepValue (stepValue=" + stepValue +
3158 ") steps away from minValue (minValue=" + minValue +
").",Debug.HIGH_PRIORITY);
3162 if(bitMapParams[6] !=
"" &&
3163 bitMapParams[6] != DEFAULT)
3165 forcedAspectH = bitMapParams[6].split(
':');
3166 if(forcedAspectH.length != 2)
3168 Debug.log(
"Illegal input parameter, expecting ':' in string defining cell display aspect ratio " +
3169 "Height:Width (e.g. 100:150)." +
3170 "\nInput aspect ratio string '" + bitMapParams[6] +
"' is invalid.",Debug.HIGH_PRIORITY);
3173 forcedAspectW = forcedAspectH[1].trim()|0;
3174 forcedAspectH = forcedAspectH[0].trim()|0;
3177 forcedAspectW = forcedAspectH = 1;
3181 minValueColor = bitMapParams[7] == DEFAULT || bitMapParams[7] ==
""?
"red":bitMapParams[7];
3182 midValueColor = bitMapParams[8] == DEFAULT || bitMapParams[8] ==
""?
"yellow":bitMapParams[8];
3183 maxValueColor = bitMapParams[9] == DEFAULT || bitMapParams[9] ==
""?
"green":bitMapParams[9];
3184 floorValueColor = bitMapParams[10] == DEFAULT || bitMapParams[10] ==
""?minValueColor:bitMapParams[10];
3185 ceilValueColor = bitMapParams[11] == DEFAULT || bitMapParams[11] ==
""?maxValueColor:bitMapParams[11];
3188 minValueColor = DesktopContent.getColorAsRGBA(minValueColor).split(
"(")[1].split(
")")[0].split(
",");
3189 midValueColor = DesktopContent.getColorAsRGBA(midValueColor).split(
"(")[1].split(
")")[0].split(
",");
3190 maxValueColor = DesktopContent.getColorAsRGBA(maxValueColor).split(
"(")[1].split(
")")[0].split(
",");
3191 ceilValueColor = DesktopContent.getColorAsRGBA(ceilValueColor).split(
"(")[1].split(
")")[0].split(
",");
3192 floorValueColor = DesktopContent.getColorAsRGBA(floorValueColor).split(
"(")[1].split(
")")[0].split(
",");
3195 doDisplayRowsAscending = bitMapParams[12] ==
"Yes"?1:0;
3196 doDisplayColsAscending = bitMapParams[13] ==
"Yes"?1:0;
3197 doSnakeColumns = bitMapParams[14] ==
"Yes"?1:0;
3198 doSnakeRows = bitMapParams[15] ==
"Yes"?1:0;
3200 if(doSnakeColumns && doSnakeRows)
3202 Debug.log(
"Can not have a bitmap that snakes both rows and columns, please choose one or the other (or neither).",Debug.HIGH_PRIORITY);
3215 function localInitBitmapData()
3222 var jsonMatrix = JSON.parse(initBitMapValue);
3225 for(var r=0;r<rows;++r)
3229 for(var c=0;c<cols;++c)
3232 localConvertFullRowColToGrid(jsonMatrix);
3236 Debug.log(
"The input initial value of the bitmap is illegal JSON format. " +
3237 "See error below: \n\n" + err,Debug.HIGH_PRIORITY);
3238 Debug.log(
"Defaulting to initial bitmap with min-value fill.",Debug.HIGH_PRIORITY);
3242 for(var r=0;r<rows;++r)
3246 for(var c=0;c<cols;++c)
3248 bmpData[r][c] = minValue;
3250 color = localConvertValueToRGBA(bmpData[r][c]);
3251 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3252 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3253 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3254 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3258 bmpContext.putImageData(bmpDataImage,0,0);
3259 bmp.src = bmpCanvas.toDataURL();
3270 function localConvertGridToRowCol(r,c)
3273 if(!doDisplayRowsAscending)
3274 retVal[0] = rows - 1 - retVal[0];
3275 if(!doDisplayColsAscending)
3276 retVal[1] = cols - 1 - retVal[1];
3277 if(doSnakeRows && retVal[0]%2 == 1)
3278 retVal[1] = cols + (cols - 1 - retVal[1]);
3279 if(doSnakeColumns && retVal[1]%2 == 1)
3280 retVal[0] = rows + (rows - 1 - retVal[0]);
3288 function localConvertValueToRGBA(val)
3291 return [ceilValueColor[0],
3297 return [floorValueColor[0],
3303 return [midValueColor[0],
3312 t = (val - minValue)/(midValue - minValue);
3313 return [minValueColor[0]*(1-t) + t*midValueColor[0],
3314 minValueColor[1]*(1-t) + t*midValueColor[1],
3315 minValueColor[2]*(1-t) + t*midValueColor[2],
3321 t = (val - midValue)/(maxValue - midValue);
3322 return [midValueColor[0]*(1-t) + t*maxValueColor[0],
3323 midValueColor[1]*(1-t) + t*maxValueColor[1],
3324 midValueColor[2]*(1-t) + t*maxValueColor[2],
3333 function localConvertFullGridToRowCol()
3337 for(var r=0;r<rows;++r)
3338 for(var c=0;c<cols;++c)
3340 convertedRC = localConvertGridToRowCol(r,c);
3343 convertedRC[1] = (convertedRC[1]/2)|0;
3346 convertedRC[0] = (convertedRC[0]/2)|0;
3348 if(retArr[convertedRC[0]] === undefined)
3349 retArr[convertedRC[0]] = [];
3350 retArr[convertedRC[0]][convertedRC[1]] = bmpData[r][c];
3359 function localConvertFullRowColToGrid(srcMatrix)
3363 var noErrors =
true;
3364 for(var r=0;r<rows;++r)
3365 for(var c=0;c<cols;++c)
3367 convertedRC = localConvertGridToRowCol(r,c);
3371 convertedRC[1] = (convertedRC[1]/2)|0;
3374 convertedRC[0] = (convertedRC[0]/2)|0;
3377 bmpData[r][c] = srcMatrix[convertedRC[0]][convertedRC[1]]|0;
3378 if(bmpData[r][c] < minValue)
3379 throw(
"There was an illegal value less than minValue: " +
3380 bmpData[r][c] +
" < " + minValue +
" @ (row,col) = (" +
3381 convertedRC[0] +
"," + convertedRC[0] +
")");
3382 if(bmpData[r][c] > maxValue)
3383 throw(
"There was an illegal value greater than maxValue: " +
3384 bmpData[r][c] +
" > " + maxValue +
" @ (row,col) = (" +
3385 convertedRC[0] +
"," + convertedRC[0] +
")");
3386 if((((bmpData[r][c]-minValue)/stepValue)|0) != (bmpData[r][c]-minValue)/stepValue)
3387 throw(
"There was an illegal value not following stepValue from minValue: " +
3388 bmpData[r][c] +
" != " +
3389 (stepValue*(((bmpData[r][c]-minValue)/stepValue)|0)) +
3390 " @ (row,col) = (" +
3391 convertedRC[0] +
"," + convertedRC[0] +
")");
3392 color = localConvertValueToRGBA(bmpData[r][c]);
3393 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3394 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3395 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3396 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3401 bmpContext.putImageData(bmpDataImage,0,0);
3402 bmp.src = bmpCanvas.toDataURL();
3405 throw(
"There was a mismatch in row/col dimensions. Input matrix was " +
3406 "dimension [row,col] = [" + srcMatrix.length +
"," +
3407 (srcMatrix.length?srcMatrix[0].length:0) +
"]");
3413 function localCreateBitmap()
3415 bmp = document.createElement(
"img");
3416 bmp.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap");
3418 bmpGrid = document.createElement(
"div");
3419 bmpGrid.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid");
3421 bmpOverlay = document.createElement(
"img");
3422 bmpOverlay.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-overlay");
3424 cursorInfo = document.createElement(
"div");
3425 cursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-info");
3426 hdrCursorInfo = document.createElement(
"div");
3427 hdrCursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-hdrInfo");
3430 rowLeftNums = document.createElement(
"div");
3431 rowRightNums = document.createElement(
"div");
3432 colTopNums = document.createElement(
"div");
3433 colBottomNums = document.createElement(
"div");
3434 rowLeftNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowLeft");
3435 rowRightNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowRight");
3436 colTopNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colTop");
3437 colBottomNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colBottom");
3443 bmpCanvas=document.createElement(
"canvas");
3444 bmpCanvas.width = cols;
3445 bmpCanvas.height = rows;
3446 bmpContext = bmpCanvas.getContext(
"2d");
3448 if(bmpDataImage)
delete bmpDataImage;
3449 bmpDataImage = bmpContext.createImageData(cols,rows);
3452 tmpEl = document.createElement(
"div");
3453 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-box");
3454 bmpGrid.appendChild(tmpEl);
3456 for(var i=0;i<rows;++i)
3460 tmpEl = document.createElement(
"div");
3461 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row-dark");
3462 bmpGrid.appendChild(tmpEl);
3463 tmpEl = document.createElement(
"div");
3464 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row");
3465 bmpGrid.appendChild(tmpEl);
3468 for(var j=0;j<cols;++j)
3470 if(i == rows-1 & j < cols-1)
3472 tmpEl = document.createElement(
"div");
3473 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col-dark");
3474 bmpGrid.appendChild(tmpEl);
3475 tmpEl = document.createElement(
"div");
3476 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col");
3477 bmpGrid.appendChild(tmpEl);
3482 bmpContext.putImageData(bmpDataImage,0,0);
3483 bmp.src = bmpCanvas.toDataURL();
3486 bmp.style.position =
"absolute";
3487 bmp.draggable =
false;
3489 bmpGrid.style.position =
"absolute";
3491 bmpOverlay.style.display =
"none";
3492 bmpOverlay.style.position =
"absolute";
3493 bmpOverlay.draggable =
false;
3495 cursorInfo.style.position =
"absolute";
3496 cursorInfo.style.display =
"none";
3497 hdrCursorInfo.style.position =
"absolute";
3498 hdrCursorInfo.style.display =
"none";
3499 hdrCursorInfo.style.width =
"320px";
3501 rowLeftNums.style.position =
"absolute";
3502 rowRightNums.style.position =
"absolute";
3503 colTopNums.style.position =
"absolute";
3504 colBottomNums.style.position =
"absolute";
3506 el.appendChild(bmp);
3507 el.appendChild(bmpGrid);
3508 el.appendChild(bmpOverlay);
3510 el.appendChild(hdrCursorInfo);
3511 el.appendChild(cursorInfo);
3513 el.appendChild(rowLeftNums);
3514 el.appendChild(rowRightNums);
3515 el.appendChild(colTopNums);
3516 el.appendChild(colBottomNums);
3522 function localCreateGridButtons()
3524 allRowBtns = document.createElement(
"div");
3526 allColBtns = document.createElement(
"div");
3528 allBtn = document.createElement(
"div");
3529 allBtn.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3532 for(var i=0;i<rows;++i)
3534 tmpEl = document.createElement(
"div");
3535 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3536 tmpEl.style.position =
"absolute";
3537 allRowBtns.appendChild(tmpEl);
3539 for(var i=0;i<cols;++i)
3541 tmpEl = document.createElement(
"div");
3542 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3543 tmpEl.style.position =
"absolute";
3544 allColBtns.appendChild(tmpEl);
3547 allRowBtns.style.position =
"absolute";
3548 el.appendChild(allRowBtns);
3549 allColBtns.style.position =
"absolute";
3550 el.appendChild(allColBtns);
3551 allBtn.style.position =
"absolute";
3552 el.appendChild(allBtn);
3558 function localCreateHeader()
3560 hdr = document.createElement(
"div");
3561 hdr.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-header");
3565 str +=
"<div style='float:left; margin: 0 0 20px 0;'>";
3566 str +=
"<div style='float:left; '>";
3574 str +=
"<div style='float:left; margin-left: 50px;'>";
3575 str +=
"Number of [Rows,Cols]: " +
"[" + rows +
"," + cols +
"]";
3579 str +=
"<div style='float:right; '>";
3581 ConfigurationAPI._POP_UP_DIALOG_ID +
3582 "-cancel' href='#'>Cancel</a>";
3585 str +=
"<div id='clearDiv'></div>";
3587 str +=
"<div style='float:right; margin: 40px 20px -50px 0;'>";
3589 ConfigurationAPI._POP_UP_DIALOG_ID +
3590 "-ok' href='#'>OK</a>";
3593 str +=
"<div style='float:left; margin: 0 0 0 0;'>";
3594 for(var clickIndex=0;clickIndex<2;++clickIndex)
3596 str +=
"<div style='float:left; margin: 5px 0 0 0;'>";
3597 str +=
"<div style='float:left; width:180px; text-align:right; margin-top: 3px;'>";
3598 str += (clickIndex?
"Right":
"Left") +
"-Click Value:";
3600 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3601 "-bitmap-scrollbar' style='float:left;' " +
3602 "type='range' min='" + minValue +
3603 "' max='" + maxValue +
"' value='" + (clickIndex?maxValue:minValue) +
3604 "' step='" + stepValue +
3605 "' oninput='ConfigurationAPI.bitMapDialog.localUpdateScroll(" + clickIndex +
")' />";
3606 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3607 "-bitmap-btnInput' style='float:left; margin: 0 1px 0 5px;' " +
3608 "type='button' value='<' " +
3609 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,0)' " +
3610 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,1)' " +
3612 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3613 "-bitmap-btnInput' style='float:left;' " +
3614 "type='button' value='>' " +
3615 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,0)' " +
3616 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,1)' " +
3618 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3619 "-bitmap-textInput' style='float:left; margin: 0 5px 0 5px; width: 50px;' " +
3621 "onchange='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",1)' " +
3622 "onkeydown='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3623 "onkeyup='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3625 str +=
"<img class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3626 "-bitmap-colorSample' style='float:left;width:25px; height:25px; margin: -2px 0 2px 0;' " +
3627 "ondragstart='return false;' " +
3628 "draggable='false'" +
3634 str +=
"<div id='clearDiv'></div>";
3639 str +=
"<div style='float:left; margin: 5px 0 0 40px;'>";
3640 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3641 "-bitmap-btnCsv' style='float:left;' " +
3642 "type='button' value='Download as CSV' " +
3643 "onclick='ConfigurationAPI.bitMapDialog.localDownloadCSV()' " +
3645 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3646 "-bitmap-btnCsv' style='float:left; margin: 0 0 0 10px;' " +
3647 "type='button' value='Upload CSV' " +
3648 "onclick='ConfigurationAPI.bitMapDialog.locaPopupUploadCSV()' " +
3652 hdr.innerHTML = str;
3653 hdr.style.overflowY =
"auto";
3654 hdr.style.position =
"absolute";
3656 var scrollEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-scrollbar");
3657 var textInputEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-textInput");
3658 var colorSampleEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-colorSample");
3663 ConfigurationAPI.bitMapDialog.localUpdateScroll =
function(i)
3665 Debug.log(
"localUpdateScroll " + i);
3667 clickValues[i] = scrollEls[i].value|0;
3668 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3670 textInputEls[i].value = clickValues[i];
3671 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3676 ConfigurationAPI.bitMapDialog.localUpdateTextInput =
function(i,finalChange)
3678 Debug.log(
"localUpdateTextInput " + textInputEls[i].value +
" " + finalChange);
3680 clickValues[i] = textInputEls[i].value|0;
3684 if(clickValues[i] < minValue) clickValues[i] = minValue;
3685 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3686 clickValues[i] = (((clickValues[i]-minValue)/stepValue)|0)*stepValue + minValue;
3687 textInputEls[i].value = clickValues[i];
3691 if(clickValues[i] < minValue)
return;
3692 if(clickValues[i] > maxValue)
return;
3693 if((((clickValues[i]-minValue)/stepValue)|0) != (clickValues[i]-minValue)/stepValue)
3695 Debug.log(
"displaying change");
3697 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3699 scrollEls[i].value = clickValues[i];
3700 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3705 var mouseDownTimer = 0;
3706 ConfigurationAPI.bitMapDialog.localUpdateButtonInput =
function(i,dir,mouseUp,delay)
3708 window.clearInterval(mouseDownTimer);
3711 Debug.log(
"cancel mouse down");
3715 mouseDownTimer = window.setInterval(
function()
3718 if(delay > 50) delay -= 50;
3719 ConfigurationAPI.bitMapDialog.localUpdateButtonInput(i,dir,0,50);
3720 },delay!==undefined?delay:300);
3722 Debug.log(
"localUpdateButtonInput " + textInputEls[i].value +
" " + dir);
3724 clickValues[i] = clickValues[i] + (dir?stepValue:-stepValue);
3725 if(clickValues[i] < minValue) clickValues[i] = minValue;
3726 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3728 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3730 textInputEls[i].value = clickValues[i];
3731 scrollEls[i].value = clickValues[i];
3732 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3742 ConfigurationAPI.bitMapDialog.localDownloadCSV =
function()
3744 var transGrid = localConvertFullGridToRowCol();
3745 console.log(transGrid);
3747 var dataStr =
"data:text/csv;charset=utf-8,";
3749 for(var r=0;r<transGrid.length;++r)
3751 if(r) dataStr += encodeURI(
"\n");
3752 for(var c=0;c<transGrid[0].length;++c)
3754 if(c) dataStr +=
",";
3755 dataStr += transGrid[r][c];
3759 Debug.log(
"ConfigurationAPI.bitMapDialog.localDownloadCSV dataStr=" + dataStr);
3761 var link = document.createElement(
"a");
3762 link.setAttribute(
"href", dataStr);
3763 link.setAttribute(
"style",
"display:none");
3764 link.setAttribute(
"download", _currentConfigName +
"_" +
3765 fieldName +
"_download.csv");
3766 document.body.appendChild(link);
3770 link.parentNode.removeChild(link);
3777 ConfigurationAPI.bitMapDialog._csvUploadDataStr;
3778 ConfigurationAPI.bitMapDialog.locaUploadCSV =
function()
3780 Debug.log(
"locaUploadCSV ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3781 var srcDataStr = ConfigurationAPI.bitMapDialog._csvUploadDataStr.split(
'\n');
3783 for(var i=0;i<srcDataStr.length;++i)
3784 src.push(srcDataStr[i].split(
','));
3789 localConvertFullRowColToGrid(src);
3791 Debug.log(
"Successfully uploaded CSV file to bitmap!", Debug.INFO_PRIORITY);
3794 el = document.getElementById(
"popUpDialog");
3795 if(el) el.parentNode.removeChild(el);
3799 Debug.log(
"Errors occured during upload. Bitmap may not reflect contents of CSV file." +
3800 "\nHere is the error description: \n" + err, Debug.HIGH_PRIORITY);
3803 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3809 ConfigurationAPI.bitMapDialog.locaPopupUploadCSV =
function()
3811 Debug.log(
"ConfigurationAPI.bitMapDialog.locaPopupUploadCSV");
3812 ConfigurationAPI.bitMapDialog._csvUploadDataStr =
"";
3816 var pel = document.getElementById(
"popUpDialog");
3819 pel = document.createElement(
"div");
3820 pel.setAttribute(
"id",
"popUpDialog");
3822 pel.style.display =
"none";
3827 ConfigurationAPI.setPopUpPosition(pel,w ,h );
3829 var str =
"<a id='" +
3831 "-header' href='#' onclick='javascript:ConfigurationAPI.bitMapDialog._csvUploadDataStr = \"\"; var pel = document.getElementById(" +
3832 "\"popUpDialog\"); if(pel) pel.parentNode.removeChild(pel); return false;'>Cancel</a><br><br>";
3834 str +=
"<div id='popUpDialog-div'>";
3836 str +=
"Please choose a CSV formatted data file (i.e. commas for columns, and new lines for rows) " +
3837 "to upload:<br><br>";
3841 str +=
"<input type='file' id='popUpDialog-fileUpload' " +
3842 "accept='.csv' enctype='multipart/form-data' />";
3846 str +=
"</center></div><br><br>";
3848 var onmouseupJS =
"";
3849 onmouseupJS +=
"document.getElementById(\"popUpDialog-submitButton\").disabled = true;";
3850 onmouseupJS +=
"ConfigurationAPI.bitMapDialog.locaUploadCSV();";
3852 str +=
"<input id='popUpDialog-submitButton' disabled type='button' onmouseup='" +
3853 onmouseupJS +
"' " +
3854 "value='Upload File' title='" +
3855 "Upload the chosen file to replace the row,col data in the current bitmap." +
3858 pel.innerHTML = str;
3859 el.appendChild(pel);
3860 pel.style.display =
"block";
3862 document.getElementById(
'popUpDialog-fileUpload').addEventListener(
3863 'change',
function(evt) {
3864 var files = evt.target.files;
3865 var file = files[0];
3866 var reader =
new FileReader();
3867 reader.onload =
function() {
3869 ConfigurationAPI.bitMapDialog._csvUploadDataStr = this.result;
3870 Debug.log(
"ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3871 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3873 reader.readAsText(file);
3879 el.appendChild(hdr);
3881 ConfigurationAPI.bitMapDialog.localUpdateScroll(0);
3882 ConfigurationAPI.bitMapDialog.localUpdateScroll(1);
3889 function localPaint()
3891 Debug.log(
"localPaint");
3893 popSz = ConfigurationAPI.setPopUpPosition(el,undefined,undefined,padding,undefined,
3903 bmpY = hdrY+hdrH+padding;
3904 bmpW = popSz.w - 2*axisPadding;
3905 bmpH = popSz.h - hdrH - padding - 2*axisPadding;
3910 localOptimizeAspectRatio();
3913 hdr.style.left = hdrX +
"px";
3914 hdr.style.top = hdrY +
"px";
3915 hdr.style.width = hdrW +
"px";
3916 hdr.style.height = hdrH +
"px";
3919 bmp.style.left = bmpX +
"px";
3920 bmp.style.top = bmpY +
"px";
3921 bmp.style.width = bmpW +
"px";
3922 bmp.style.height = bmpH +
"px";
3928 bmpGrid.style.left = (bmpX-bmpBorderSize) +
"px";
3929 bmpGrid.style.top = (bmpY-bmpBorderSize) +
"px";
3930 bmpGrid.style.width = (bmpW) +
"px";
3931 bmpGrid.style.height = (bmpH) +
"px";
3933 var bmpGridChildren = bmpGrid.childNodes;
3936 allRowBtns.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3937 allRowBtns.style.top = (bmpY - bmpBorderSize) +
"px";
3939 allColBtns.style.left = (bmpX - bmpBorderSize) +
"px";
3940 allColBtns.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3942 allBtn.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3943 allBtn.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3944 allBtn.style.width = butttonSz +
"px";
3945 allBtn.style.height = butttonSz +
"px";
3947 var allRowsChildren = allRowBtns.childNodes;
3948 var allColsChildren = allColBtns.childNodes;
3952 rowLeftNums.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz + (- bmpBorderSize - axisPaddingMargin - axisPaddingExtra)) +
"px";
3953 rowLeftNums.style.top = (bmpY - bmpBorderSize) +
"px";
3954 rowRightNums.style.left = (bmpX + bmpW + axisPaddingMargin + bmpBorderSize) +
"px";
3955 rowRightNums.style.top = (bmpY - bmpBorderSize) +
"px";
3956 colTopNums.style.left = (bmpX - bmpBorderSize) +
"px";
3957 colTopNums.style.top = (bmpY - bmpBorderSize*2 - numberDigitH) +
"px";
3958 colBottomNums.style.left = (bmpX - bmpBorderSize) +
"px";
3959 colBottomNums.style.top = (bmpY + bmpH + bmpBorderSize + axisPaddingMargin + bmpBorderSize + butttonSz + bmpBorderSize) +
"px";
3960 rowLeftNums.innerHTML =
"";
3961 rowRightNums.innerHTML =
"";
3962 colTopNums.innerHTML =
"";
3963 colBottomNums.innerHTML =
"";
3965 var thresholdNumberSpacing = 100;
3967 var oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
3972 bmpGridChildren[0].style.left = 0 +
"px";
3973 bmpGridChildren[0].style.top = 0 +
"px";
3974 bmpGridChildren[0].style.width = (bmpW) +
"px";
3975 bmpGridChildren[0].style.height = (bmpH) +
"px";
3978 for(var i=0;i<rows;++i)
3983 bmpGridChildren[1+i*2].style.left = bmpBorderSize +
"px";
3984 bmpGridChildren[1+i*2].style.top = ((i+1)*cellH) +
"px";
3985 bmpGridChildren[1+i*2].style.width = (bmpW) +
"px";
3986 bmpGridChildren[1+i*2].style.height = (bmpGridThickness+bmpBorderSize*2) +
"px";
3989 bmpGridChildren[1+i*2+1].style.left = 0 +
"px";
3990 bmpGridChildren[1+i*2+1].style.top = ((i+1)*cellH + bmpBorderSize) +
"px";
3991 bmpGridChildren[1+i*2+1].style.width = (bmpW + bmpBorderSize*2) +
"px";
3992 bmpGridChildren[1+i*2+1].style.height = bmpGridThickness +
"px";
3994 bmpGridChildren[1+i*2+1].style.backgroundColor =
3995 (doSnakeRows && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
3999 allRowsChildren[i].style.left = 0 +
"px";
4000 allRowsChildren[i].style.top = (i*cellH + (i?bmpGridThickness+bmpBorderSize*2-1:0)) +
"px";
4001 allRowsChildren[i].style.width = (butttonSz) +
"px";
4002 allRowsChildren[i].style.height = (cellH - 1 + (i?-bmpBorderSize*2:0)) +
"px";
4006 numberLoc[0] = (i*cellH - 1 + cellH/2 - numberDigitH/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
4009 translatedRC = localConvertGridToRowCol(i,0);
4010 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
4011 translatedRC[0]%5 == 0)
4014 numberEl = document.createElement(
"div");
4015 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4016 numberEl.innerHTML = translatedRC[0];
4017 numberEl.style.top = numberLoc[0] +
"px";
4018 numberEl.style.width = axisPaddingExtra +
"px";
4019 rowLeftNums.appendChild(numberEl);
4020 oldNumberLoc[0] = numberLoc[0];
4024 translatedRC = localConvertGridToRowCol(i,cols>1?1:0);
4025 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
4026 translatedRC[0]%5 == 0)
4029 numberEl = document.createElement(
"div");
4030 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4031 numberEl.innerHTML = translatedRC[0];
4032 numberEl.style.top = numberLoc[0] +
"px";
4033 numberEl.style.width = axisPaddingExtra +
"px";
4034 rowRightNums.appendChild(numberEl);
4035 oldNumberLoc[1] = numberLoc[0];
4040 oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
4042 for(var i=0;i<cols;++i)
4050 bmpGridChildren[1+(rows-1)*2+i*2].style.top = bmpBorderSize +
"px";
4051 bmpGridChildren[1+(rows-1)*2+i*2].style.left = ((i+1)*cellW + bmpBorderSize) +
"px";
4052 bmpGridChildren[1+(rows-1)*2+i*2].style.height = (bmpH) +
"px";
4053 bmpGridChildren[1+(rows-1)*2+i*2].style.width = (bmpGridThickness+bmpBorderSize*2) +
"px";
4056 bmpGridChildren[1+(rows-1)*2+i*2+1].style.top = 0 +
"px";
4057 bmpGridChildren[1+(rows-1)*2+i*2+1].style.left = ((i+1)*cellW + bmpBorderSize*2) +
"px";
4058 bmpGridChildren[1+(rows-1)*2+i*2+1].style.height = (bmpH + bmpBorderSize*2) +
"px";
4059 bmpGridChildren[1+(rows-1)*2+i*2+1].style.width = bmpGridThickness +
"px";
4061 bmpGridChildren[1+(rows-1)*2+i*2+1].style.backgroundColor =
4062 (doSnakeColumns && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
4066 allColsChildren[i].style.left = (i*cellW - 1 + (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4067 allColsChildren[i].style.top = 0 +
"px";
4068 allColsChildren[i].style.width = (cellW + 1 - (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4069 allColsChildren[i].style.height = (butttonSz) +
"px";
4073 numberLoc[0] = (i*cellW + cellW/2 - axisPaddingExtra/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
4076 translatedRC = localConvertGridToRowCol(0,i);
4077 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
4078 translatedRC[1]%5 == 0)
4081 numberEl = document.createElement(
"div");
4082 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4083 numberEl.innerHTML = translatedRC[1];
4084 numberEl.style.left = numberLoc[0] +
"px";
4085 numberEl.style.width = axisPaddingExtra +
"px";
4086 colTopNums.appendChild(numberEl);
4087 oldNumberLoc[0] = numberLoc[0];
4091 translatedRC = localConvertGridToRowCol(rows>1?1:0,i);
4092 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
4093 translatedRC[1]%5 == 0)
4096 numberEl = document.createElement(
"div");
4097 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4098 numberEl.innerHTML = translatedRC[1];
4099 numberEl.style.left = numberLoc[0] +
"px";
4100 numberEl.style.width = axisPaddingExtra +
"px";
4101 colBottomNums.appendChild(numberEl);
4102 oldNumberLoc[1] = numberLoc[0];
4121 function localOptimizeAspectRatio()
4123 var cellSkew = (cellW>cellH)?cellW/cellH:cellH/cellW;
4127 if(forcedAspectH !== undefined)
4129 var offAspectH = forcedAspectH/cellH;
4130 var offAspectW = forcedAspectW/cellW;
4132 Debug.log(
"Adjusting skew factor = " + forcedAspectH +
"-" + forcedAspectW);
4134 if(offAspectH < offAspectW)
4135 bmpH = bmpW/cols*forcedAspectH/forcedAspectW*rows;
4137 bmpW = bmpH/rows*forcedAspectW/forcedAspectH*cols;
4139 else if(cellSkew > MAX_SKEW)
4141 var adj = cellSkew/MAX_SKEW;
4143 Debug.log(
"Adjusting skew factor = " + adj);
4156 bmpX = padding + (popSz.w-bmpW)/2;
4157 bmpY = bmpY + (popSz.h-bmpY-bmpH)/2;
4158 hdrY = bmpY - padding - hdrH;
4167 ConfigurationAPI.getDateString;
4169 ConfigurationAPI.getDateStringDayArr_ = [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"];
4170 ConfigurationAPI.getDateStringMonthArr_ = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"];
4171 ConfigurationAPI.getDateString =
function(date)
4175 dateStr += ConfigurationAPI.getDateStringDayArr_[date.getDay()];
4177 dateStr += ConfigurationAPI.getDateStringMonthArr_[date.getMonth()];
4179 dateStr += date.getDate();
4181 dateStr += date.getHours();
4183 dateStr += ((date.getMinutes()<10)?
"0":
"") + date.getMinutes();
4185 dateStr += ((date.getSeconds()<10)?
"0":
"") + date.getSeconds();
4187 dateStr += date.getFullYear();
4189 dateStr += date.toLocaleTimeString([],{timeZoneName:
"short"}).split(
" ")[2];
4196 ConfigurationAPI.setCaretPosition =
function(elem, caretPos, endPos)
4199 elem.setSelectionRange(caretPos, endPos);
4204 ConfigurationAPI.removeAllPopUps =
function()
4207 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
4210 el.parentNode.removeChild(el);
4211 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
4222 ConfigurationAPI.setPopUpPosition =
function(el,w,h,padding,border,margin,doNotResize,offsetUp)
4224 Debug.log(
"ConfigurationAPI.setPopUpPosition");
4226 if(padding === undefined) padding = 10;
4227 if(border === undefined) border = 1;
4228 if(margin === undefined) margin = 0;
4235 ConfigurationAPI.setPopUpPosition.stopPropagation =
function(event) {
4237 event.stopPropagation();
4243 ConfigurationAPI.setPopUpPosition.popupResize =
function() {
4249 window.removeEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4250 window.removeEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4254 catch(err) {
return;}
4260 var ww = DesktopContent.getWindowWidth()-(padding+border)*2;
4261 var wh = DesktopContent.getWindowHeight()-(padding+border)*2;
4265 var ah = el.offsetHeight;
4267 if(w === undefined || h === undefined)
4274 x = (DesktopContent.getWindowScrollLeft() + ((ww-w)/2));
4275 y = (DesktopContent.getWindowScrollTop() + ((wh-h)/2)) - (offsetUp|0);
4276 if(y > 110) y -= 100;
4278 if(y<DesktopContent.getWindowScrollTop()+margin)
4279 y = DesktopContent.getWindowScrollTop()+margin;
4282 if(w > ww-margin-padding)
4283 x = -DesktopContent.getWindowScrollLeft();
4284 if(ah > wh-margin-padding)
4285 y = -DesktopContent.getWindowScrollTop();
4287 el.style.left = (x|0) +
"px";
4288 el.style.top = (y|0) +
"px";
4290 ConfigurationAPI.setPopUpPosition.popupResize();
4293 el.style.width = (w|0) +
"px";
4294 el.style.height = (h|0) +
"px";
4298 window.addEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4299 window.addEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4301 el.addEventListener(
"keydown",ConfigurationAPI.setPopUpPosition.stopPropagation);
4302 el.addEventListener(
"mousemove",ConfigurationAPI.setPopUpPosition.stopPropagation);
4303 el.addEventListener(
"mousemove",DesktopContent.mouseMove);
4305 el.style.overflow =
"auto";
4307 return {
"w" : w,
"h" : h,
"x" : x,
"y" : y};
4314 ConfigurationAPI.getOnePixelPngData =
function(rgba)
4316 if(ConfigurationAPI.getOnePixelPngData.canvas === undefined)
4319 ConfigurationAPI.getOnePixelPngData.canvas = document.createElement(
"canvas");
4320 ConfigurationAPI.getOnePixelPngData.canvas.width = 1;
4321 ConfigurationAPI.getOnePixelPngData.canvas.height = 1;
4322 ConfigurationAPI.getOnePixelPngData.ctx = ConfigurationAPI.getOnePixelPngData.canvas.getContext(
"2d");
4323 ConfigurationAPI.getOnePixelPngData.bmpOverlayData = ConfigurationAPI.getOnePixelPngData.ctx.createImageData(1,1);
4326 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[0]=rgba[0];
4327 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[1]=rgba[1];
4328 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[2]=rgba[2];
4329 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[3]=rgba[3]!==undefined?rgba[3]:255;
4331 ConfigurationAPI.getOnePixelPngData.ctx.putImageData(
4332 ConfigurationAPI.getOnePixelPngData.bmpOverlayData,0,0);
4333 return ConfigurationAPI.getOnePixelPngData.canvas.toDataURL();
4359 ConfigurationAPI.editableFieldEditingCell_ = 0;
4360 ConfigurationAPI.editableFieldEditingIdString_;
4361 ConfigurationAPI.editableFieldEditingNodeType_;
4362 ConfigurationAPI.editableFieldEditingOldValue_;
4363 ConfigurationAPI.editableFieldEditingInitValue_;
4364 ConfigurationAPI.editableFieldHoveringCell_ = 0;
4365 ConfigurationAPI.editableFieldHoveringIdString_;
4366 ConfigurationAPI.editableFieldSelectedIdString_ = 0;
4367 ConfigurationAPI.editableFieldHandlersSubscribed_ =
false;
4368 ConfigurationAPI.editableFieldMouseIsSelecting_ =
false;
4369 ConfigurationAPI.editableField_SELECTED_COLOR_ =
"rgb(251, 245, 53)";
4370 ConfigurationAPI.createEditableFieldElement =
function(fieldObj,fieldIndex,
4374 var depth = depthIndex|0;
4375 var uid = fieldIndex|0;
4377 if(!ConfigurationAPI.editableFieldHandlersSubscribed_)
4379 ConfigurationAPI.editableFieldHandlersSubscribed_ =
true;
4382 DesktopContent.mouseMoveSubscriber(ConfigurationAPI.handleEditableFieldBodyMouseMove);
4385 var fieldEl = document.createElement(
"div");
4386 fieldEl.setAttribute(
"class",
"ConfigurationAPI-EditableField");
4387 fieldEl.setAttribute(
"id",
"ConfigurationAPI-EditableField-" +
4388 ( depth +
"-" + uid ));
4390 Debug.log(
"Field type " + fieldObj.fieldColumnType);
4393 var valueType = fieldObj.fieldColumnType;
4394 var choices = fieldObj.fieldColumnDataChoicesArr;
4395 var value = fieldObj.fieldColumnDefaultValue;
4396 var path = fieldObj.fieldRelativePath;
4397 var nodeName = fieldObj.fieldColumnName;
4398 fieldObj.depthIndex = depth;
4399 fieldObj.fieldIndex = uid;
4400 fieldObj.fieldColumnValue = value;
4404 var isGroupLink,childLinkIndex,linkId;
4405 if(valueType.indexOf(
"ChildLink") == 0)
4407 Debug.log(
"Looking up matching link pair for " + nodeName);
4409 childLinkIndex = valueType.split(
'-')[1];
4410 console.log(
"childLinkIndex",childLinkIndex);
4413 for(var i=0;i<_fields.length;++i)
4414 if(_fields[i].fieldColumnType.indexOf(
"ChildLink") == 0 &&
4415 (_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U' ||
4416 _fields[i].fieldColumnType[(
"ChildLink").length] ==
'G') &&
4417 childLinkIndex == _fields[i].fieldColumnType.split(
'-')[1])
4419 Debug.log(
"Found matching pair field " +
4420 _fields[i].fieldColumnName);
4421 if(_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U')
4422 isGroupLink =
false;
4425 linkId = _fields[i].fieldColumnDefaultValue;
4429 if(isGroupLink === undefined)
4431 Debug.log(
"Invalid table! Could not find matching child link columns for " +
4432 nodeName, Debug.HIGH_PRIORITY);
4437 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4438 depth,nodeName,value,valueType,choices,path,
4439 isGroupLink,childLinkIndex,linkId);
4446 ConfigurationAPI.getEditableFieldValue =
function(fieldObj,fieldIndex,depthIndex )
4451 ConfigurationAPI.handleEditableFieldEditOK();
4454 var depth = fieldObj.depthIndex === undefined?
4455 (depthIndex|0):fieldObj.depthIndex;
4456 var uid = fieldObj.fieldIndex === undefined?
4457 (fieldIndex|0):fieldObj.fieldIndex;
4459 var fieldEl = document.getElementById(
"editableFieldNode-Value-leafNode-" +
4460 ( depth +
"-" + uid ));
4463 Debug.log(
"getEditableFieldValue Error! Invalid target field element '" +
4464 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4468 var valueType = fieldObj.fieldColumnType;
4469 var value = fieldEl.textContent;
4483 ConfigurationAPI.setEditableFieldValue =
function(fieldObj,value,fieldIndex,depthIndex )
4488 var depth = fieldObj.depthIndex === undefined?
4489 (depthIndex|0):fieldObj.depthIndex;
4490 var uid = fieldObj.fieldIndex === undefined?
4491 (fieldIndex|0):fieldObj.fieldIndex;
4493 var fieldEl = document.getElementById(
"ConfigurationAPI-EditableField-" +
4494 ( depth +
"-" + uid ));
4497 Debug.log(
"setEditableFieldValue Error! Invalid target field element '" +
4498 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4501 var valueType = fieldObj.fieldColumnType;
4502 var choices = fieldObj.fieldColumnDataChoicesArr;
4503 var path = fieldObj.fieldRelativePath;
4504 var nodeName = fieldObj.fieldColumnName;
4505 fieldObj.fieldColumnValue = value;
4509 var isGroupLink,childLinkIndex,linkId;
4510 if(valueType.indexOf(
"ChildLink") == 0)
4512 Debug.log(
"Looking up matching link pair for " + nodeName);
4514 childLinkIndex = valueType.split(
'-')[1];
4515 console.log(
"childLinkIndex",childLinkIndex);
4518 for(var i=0;i<_fields.length;++i)
4519 if(_fields[i].fieldColumnType.indexOf(
"ChildLink") == 0 &&
4520 (_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U' ||
4521 _fields[i].fieldColumnType[(
"ChildLink").length] ==
'G') &&
4522 childLinkIndex == _fields[i].fieldColumnType.split(
'-')[1])
4524 Debug.log(
"Found matching pair field " +
4525 _fields[i].fieldColumnName);
4526 if(_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U')
4527 isGroupLink =
false;
4530 linkId = _fields[i].fieldColumnValue;
4534 if(isGroupLink === undefined)
4536 Debug.log(
"Invalid table! Could not find matching child link columns for " +
4537 nodeName, Debug.HIGH_PRIORITY);
4542 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4543 depth,nodeName,value,valueType,choices,path,
4544 isGroupLink,childLinkIndex,linkId);
4553 ConfigurationAPI.fillEditableFieldElement =
function(fieldEl,uid,
4554 depth,nodeName,value,valueType,choices,path,
4555 isGroupLink,childLinkIndex,linkId)
4559 var pathHTML = path;
4561 pathHTML = pathHTML.replace(/</g,
"<");
4562 pathHTML = pathHTML.replace(/>/g,
">");
4564 str +=
"<div class='editableFieldNode-Path' style='display:none' id='editableFieldNode-path-" +
4565 ( depth +
"-" + uid ) +
"'>" +
4570 var childLinkFixedChoice =
false;
4571 var isChildLink = valueType.indexOf(
"ChildLink") == 0;
4573 if(valueType ==
"FixedChoiceData" ||
4574 (isChildLink && choices.length > 1))
4577 childLinkFixedChoice = valueType.indexOf(
"ChildLink") == 0;
4581 "<div class='editableFieldNode-FixedChoice-CSV' style='display:none' " +
4582 "id='editableFieldNode-FixedChoice-CSV-" +
4583 ( depth +
"-" + uid ) +
"'>";
4585 for(var j=0;j<choices.length;++j)
4594 else if(valueType ==
"BitMap")
4598 "<div class='editableFieldNode-BitMap-Params' style='display:none' " +
4599 "id='editableFieldNode-BitMap-Params-" +
4600 ( depth +
"-" + uid ) +
"'>";
4602 for(var j=1;j<choices.length;++j)
4605 str += choices[j].replace(/;/g,
",");
4614 "<div class='editableFieldNode-Value editableFieldNode-ValueType-" +
4616 (childLinkFixedChoice?
"ChildLinkFixedChoice":valueType) +
4618 "id='editableFieldNode-Value-" +
4619 (depth +
"-" + uid) +
"' " +
4621 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4622 depth +
"," + uid +
"," +
4625 "onmousemove='ConfigurationAPI.handleEditableFieldHover(" +
4626 depth +
"," + uid +
"," +
4631 titleStr =
"~ Leaf Value Node ~\n";
4632 titleStr +=
"Path: \t" + path + nodeName +
"\n";
4636 "<div style='float:left' title='" + titleStr +
"'>" +
4637 "<b class='editableFieldNode-Value-leafNode-fieldName bold-header'>" +
4639 "</div><div style='float:left'> :</div>";
4643 "<div class='editableFieldNode-Value-editIcon' id='editableFieldNode-Value-editIcon-" +
4644 (depth +
"-" + uid) +
"' " +
4645 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4646 depth +
"," + uid +
"," +
4647 "1,\"value\"); event.stopPropagation();' " +
4648 "title='Edit the value of this node.' " +
4652 str +=
"<div style='float:left; margin-left:9px;' id='editableFieldNode-Value-leafNode-" +
4653 (depth +
"-" + uid) +
4655 "editableFieldNode-Value-leafNode-ColumnName-" + nodeName +
4660 if(valueType ==
"OnOff" ||
4661 valueType ==
"YesNo" ||
4662 valueType ==
"TrueFalse")
4665 str +=
"<div style='float:left'>";
4669 var color = (value ==
"On" || value ==
"Yes" || value ==
"True")?
4670 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
4671 str +=
"<div style='width:10px;height:10px;" +
4672 "background-color:" + color +
";" +
4674 "border-radius: 7px;" +
4675 "border: 2px solid white;" +
4676 "margin: 2px 0 0 6px;" +
4679 else if(valueType ==
"Timestamp")
4680 str += ConfigurationAPI.getDateString(
new Date((value|0)*1000));
4688 value.indexOf(
"Table") == value.length - (
"Table").length)
4692 var recordAlias =
"";
4693 for(var c=0;c<value.length - (
"Table").length;++c)
4695 if(c && c+1 < value.length &&
4698 (value[c+1] >=
'a' &&
4701 recordAlias += value[c];
4703 if(recordAlias.length && recordAlias[recordAlias.length-1] !=
's')
4706 var newWindowStr =
"/WebPath/html/ConfigurationGUI_subset.html?urn=" +
4707 DesktopContent._localUrnLid +
4708 "&subsetBasePath=" + value +
4709 "&groupingFieldList=AUTO" +
4710 "&recordAlias=" + recordAlias +
4711 "&editableFieldList=" +
"!*CommentDescription";
4717 newWindowStr +=
"&selectedGroupIDs=" +
4719 childLinkIndex +
"=" +
4722 if(childLinkIndex.split(
' ').length >= 2)
4723 childLinkIndex = childLinkIndex.split(
' ')[1];
4725 str +=
"<div id='editableFieldNode-ChildLink-groupIndex-" +
4726 (depth +
"-" + uid) +
"' " +
4727 " style='display:none;' >" +
4728 childLinkIndex +
"</div>";
4733 newWindowStr +=
"&selectedRecords=" + linkId;
4737 str +=
"<div style='float:left; margin-left:9px;' " +
4738 " id='editableFieldNode-ChildLink-SubConfigLinkWindow-" +
4739 (depth +
"-" + uid) +
"' " +
4741 "editableFieldNode-ChildLink-SubConfigLink" +
4744 "event.stopPropagation(); " +
4745 "DesktopContent.openNewWindow(" +
4747 " Subset-Configuration\",\"\",\"" +
4750 "\",false /*unique*/);" +
4752 " title='Open " + value +
" subset configuration in a new desktop window.' " +
4753 ">Open Window</div>";
4755 str +=
"<div style='float:left; margin-left:9px;' " +
4756 " id='editableFieldNode-ChildLink-SubConfigLinkTab-" +
4757 (depth +
"-" + uid) +
"' " +
4759 "editableFieldNode-ChildLink-SubConfigLink" +
4762 "event.stopPropagation(); " +
4763 "DesktopContent.openNewBrowserTab(" +
4765 " Subset-Configuration\",\"\",\"" +
4768 "\",false /*unique*/);" +
4770 " title='Open " + value +
" subset configuration in a new browser tab.' " +
4776 fieldEl.innerHTML = str;
4780 if(ConfigurationAPI.editableFieldSelectedIdString_ == (depth +
"-" + uid))
4781 fieldEl.getElementsByClassName(
"editableFieldNode-Value")[0].style.backgroundColor =
4782 ConfigurationAPI.editableField_SELECTED_COLOR_;
4793 ConfigurationAPI.handleEditableFieldClick =
function(depth,uid,editClick,type)
4795 var idString = depth +
"-" + uid;
4796 ConfigurationAPI.editableFieldEditingIdString_ = idString;
4798 Debug.log(
"handleEditableFieldClick editClick " + editClick);
4799 Debug.log(
"handleEditableFieldClick idString " + idString);
4801 var el = document.getElementById(
"editableFieldNode-Value-" + idString);
4805 Debug.log(
"Invalid element pointed to by idString. Ignoring and exiting.");
4809 if(ConfigurationAPI.editableFieldHoveringCell_)
4812 ConfigurationAPI.handleEditableFieldBodyMouseMove();
4815 if(ConfigurationAPI.editableFieldEditingCell_)
4817 if(ConfigurationAPI.editableFieldEditingCell_ == el)
4819 ConfigurationAPI.handleEditableFieldEditOK();
4822 var path = document.getElementById(
"editableFieldNode-path-" + idString).textContent;
4828 Debug.log(
"handleEditableFieldClick path " + path);
4830 Debug.log(
"handleEditableFieldClick type " + type);
4861 Debug.log(
"edit value mode");
4863 selectThisTreeNode(idString,type);
4865 function selectThisTreeNode(idString,type)
4869 var el = document.getElementById(
"editableFieldNode-Value-leafNode-" + idString);
4870 var vel = document.getElementById(
"editableFieldNode-Value-" + idString);
4873 var colType = vel.className.split(
' ')[1].split(
'-');
4874 if(colType[1] ==
"ValueType")
4875 colType = colType[2];
4877 var fieldName = el.className.substr((
"editableFieldNode-Value-leafNode-ColumnName-").length);
4879 Debug.log(
"fieldName=" + fieldName);
4880 Debug.log(
"colType=" + colType);
4882 if(colType ==
"Author" ||
4883 colType ==
"Timestamp")
4885 Debug.log(
"Can not edit Author or Timestamp fields.",
4886 Debug.WARN_PRIORITY);
4889 else if(colType ==
"GroupID")
4890 DesktopContent.tooltip(
"GroupID Editing",
4891 "The GroupID field places this record in one or more " +
4892 "parent group link collections. The value must match the parent's value " +
4893 "in the parent's LinkGroupID field. \n\nTo speficify that this record is in " +
4894 "more than one group, use the '|' (vertical bar) character. For example, " +
4895 "'Parent0Group | Parent1Group' would place this record in two groups (the " +
4896 "Parent0Group and Parent1Group).");
4899 var optionIndex = -1;
4902 if(colType ==
"YesNo" ||
4903 colType ==
"TrueFalse" ||
4907 ConfigurationAPI.editableFieldEditingOldValue_ = el.innerHTML;
4909 var initVal = el.childNodes[0].textContent;
4910 ConfigurationAPI.editableFieldEditingInitValue_ = initVal;
4913 if(colType ==
"YesNo")
4914 boolVals = [
"No",
"Yes"];
4915 else if(colType ==
"TrueFalse")
4916 boolVals = [
"False",
"True"];
4917 else if(colType ==
"OnOff")
4918 boolVals = [
"Off",
"On"];
4921 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4922 "onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4923 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_); event.stopPropagation();' " +
4924 "onclick='event.stopPropagation();'" +
4925 "style='margin:-8px -2px -2px -1px; height:" + (el.offsetHeight+6) +
"px'>";
4926 for(var i=0;i<boolVals.length;++i)
4928 str +=
"<option value='" + boolVals[i] +
"'>";
4931 if(boolVals[i] == initVal)
4935 if(optionIndex == -1) optionIndex = 0;
4937 else if(colType ==
"FixedChoiceData" ||
4938 colType ==
"ChildLinkFixedChoice")
4940 if(colType ==
"ChildLinkFixedChoice")
4941 type +=
"-childLink";
4943 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4944 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4946 var allowFixedChoiceArbitraryEdit =
false;
4947 var optionCount = -1;
4950 str +=
"<div onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4951 "onmouseup='event.stopPropagation();' " +
4952 "onclick='event.stopPropagation();' " +
4954 "white-space:nowrap;" +
4955 "margin:-3px -2px -2px -1px;" +
4956 "height:" + (el.offsetHeight+6) +
"px'>";
4958 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4959 "id='fixedChoice-editSelectBox' " +
4960 "onmouseup='event.stopPropagation();' " +
4961 "onclick='event.stopPropagation();' " +
4964 "margin:-2px -2px -2px -1px; height:" +
4965 (el.offsetHeight+6) +
"px'>";
4969 var vel = document.getElementById(
"editableFieldNode-FixedChoice-CSV-" +
4971 var choices = vel.textContent.split(
',');
4973 var isChildLinkFixedChoice = colType ==
"ChildLinkFixedChoice";
4975 if(isChildLinkFixedChoice)
4979 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
4980 (depth +
"-" + uid) ).style.display =
"none";
4981 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
4982 (depth +
"-" + uid) ).style.display =
"none";
4987 if(choices.length > 1 &&
4988 choices[1].indexOf(
"arbitraryBool=") == 0)
4991 allowFixedChoiceArbitraryEdit =
4992 choices[1][(
"arbitraryBool=").length] ==
"1"?
4994 Debug.log(
"allowFixedChoiceArbitraryEdit " + allowFixedChoiceArbitraryEdit);
4997 for(var i=0;i<choices.length;++i)
4999 if(i == 0 && isChildLinkFixedChoice && !allowFixedChoiceArbitraryEdit)
5006 if(choices[i].indexOf(
"arbitraryBool=") == 0)
5022 str += decodeURIComponent(choices[i]);
5024 if(decodeURIComponent(choices[i])
5025 == ConfigurationAPI.editableFieldEditingOldValue_)
5026 optionIndex = optionCount;
5030 if(allowFixedChoiceArbitraryEdit)
5032 var ww = (el.offsetWidth-6);
5033 if(ww < 150) ww = 150;
5034 str +=
"<input type='text' " +
5035 "id='fixedChoice-editTextBox' " +
5036 "style='display:none;" +
5038 "margin:-2px 0 -" + (el.offsetHeight+6) +
"px 0;" +
5040 ww +
"px; height:" + (el.offsetHeight+6) +
"px" +
5044 str +=
"<div style='display:block;" +
5045 "margin: -2px 0 -7px 14px;" +
5047 "class='editableFieldNode-Value-editIcon' id='fixedChoice-editIcon" +
5049 "onclick='ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle();' " +
5050 "title='Toggle free-form editing' " +
5055 else if(colType ==
"BitMap")
5057 Debug.log(
"Handling bitmap select");
5059 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
5062 ConfigurationAPI.bitMapDialog(
5064 "Target Field: "" +
5065 fieldName_ +
""",
5066 document.getElementById(
"editableFieldNode-BitMap-Params-" +
5067 idString).textContent.split(
';'),
5068 ConfigurationAPI.editableFieldEditingOldValue_,
5071 Debug.log(
"yes " + val);
5073 el.appendChild(document.createTextNode(val));
5074 ConfigurationAPI.editableFieldEditingCell_ = el;
5083 Debug.log(
"cancel bitmap");
5084 ConfigurationAPI.editableFieldEditingCell_ = 0;
5088 else if(colType ==
"MultilineData")
5090 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
5091 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
5093 str +=
"<textarea rows='4' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' cols='50' style='font-size: 14px; " +
5094 "margin:-8px -2px -2px -1px;width:" +
5095 (el.offsetWidth-6) +
"px; height:" + (el.offsetHeight-8) +
"px' ";
5096 str +=
" onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
5097 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
5098 "onclick='event.stopPropagation();'" +
5100 str += ConfigurationAPI.editableFieldEditingOldValue_;
5101 str +=
"</textarea>";
5105 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
5106 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
5109 if(colType ==
"GroupID")
5111 else if(colType ==
"ChildLinkGroupID" || colType ==
"ChildLinkUID")
5113 type +=
"-" + colType;
5118 var tableIdString = depth +
"-" + ((uid|0)-1);
5119 var tableEl = document.getElementById(
"editableFieldNode-Value-leafNode-" +
5125 ConfigurationAPI.editableFieldEditingCell_ = el;
5126 ConfigurationAPI.editableFieldEditingNodeType_ = type;
5127 el.innerHTML = str +
5128 localFinishUpTextValueCell();
5129 if(colType ==
"ChildLinkUID")
5131 localHandleDropdownForLinkUID(tableEl);
5138 var indexEl = document.getElementById(
5139 "editableFieldNode-ChildLink-groupIndex-" +
5143 localHandleDropdownForLinkGroupID(
5149 Debug.log(
"Could not find matching group link index at ",tableIdString);
5154 Debug.log(
"Could not find matching table field at ",tableIdString);
5157 str += localFinishUpTextValueCell();
5162 localFinishUpSelectCell();
5167 function localFinishUpTextValueCell()
5169 Debug.log(
"localFinishUpTextValueCell()");
5172 var ow = el.offsetWidth+6;
5176 str +=
"<input type='text' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event);' style='margin:-8px -2px -2px -1px;width:" +
5177 (ow) +
"px; height:" + (el.offsetHeight>20?el.offsetHeight:20) +
"px' value='";
5178 str += ConfigurationAPI.editableFieldEditingOldValue_;
5179 str +=
"' onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
5180 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
5181 "onclick='event.stopPropagation();'" +
5187 function localFinishUpSelectCell()
5189 Debug.log(
"localFinishUpSelectCell()");
5191 str += ConfigurationAPI._OK_CANCEL_DIALOG_STR;
5197 if(colType ==
"YesNo" ||
5198 colType ==
"TrueFalse" ||
5201 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
5202 el.getElementsByTagName(
"select")[0].focus();
5204 else if(colType ==
"FixedChoiceData" ||
5205 colType ==
"ChildLinkFixedChoice" ||
5206 colType ==
"ChildLinkGroupID" ||
5207 colType ==
"ChildLinkUID")
5211 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
5212 el.getElementsByTagName(
"select")[0].focus();
5216 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"input")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
5220 else if(colType ==
"MultilineData")
5221 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"textarea")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
5223 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"input")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
5227 ConfigurationAPI.editableFieldEditingCell_ = el;
5228 ConfigurationAPI.editableFieldEditingNodeType_ = type;
5232 function localHandleDropdownForLinkUID()
5234 Debug.log(
"localHandleDropdownForLinkUID()",tableEl.innerText);
5237 ConfigurationAPI.getSubsetRecords(tableEl.innerText,
5242 Debug.logv({records});
5243 if(!records || !records.length)
5246 Debug.log(
"Aborting link group ID search.");
5247 str += localFinishUpTextValueCell();
5248 localFinishUpSelectCell();
5253 str +=
"<div onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
5254 "onmouseup='event.stopPropagation();' " +
5255 "onclick='event.stopPropagation();' " +
5257 "white-space:nowrap;" +
5258 "margin:-3px -2px -2px -1px;" +
5259 "height:" + (el.offsetHeight+6) +
"px'>";
5261 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
5262 "id='fixedChoice-editSelectBox' " +
5263 "onmouseup='event.stopPropagation();' " +
5264 "onclick='event.stopPropagation();' " +
5267 "margin:-2px -2px -2px -1px; height:" +
5268 (el.offsetHeight+6) +
"px'>";
5270 for (var i = 0; i < records.length; ++i)
5272 str +=
"<option value='" + records[i]
5277 == ConfigurationAPI.editableFieldEditingOldValue_)
5281 if(optionIndex == -1 &&
5282 ConfigurationAPI.editableFieldEditingOldValue_.length)
5284 str +=
"<option value='" + encodeURIComponent(
5285 ConfigurationAPI.editableFieldEditingOldValue_)
5287 str += encodeURIComponent(ConfigurationAPI.editableFieldEditingOldValue_);
5289 optionIndex = records.length;
5296 var ww = (el.offsetWidth-6);
5297 if(ww < 150) ww = 150;
5298 str +=
"<input type='text' " +
5299 "id='fixedChoice-editTextBox' " +
5300 "style='display:none;" +
5302 "margin:-2px 0 -" + (el.offsetHeight+6) +
"px 0;" +
5304 ww +
"px; height:" + (el.offsetHeight+6) +
"px" +
5308 str +=
"<div style='display:block;" +
5309 "margin: -2px 0 -7px 14px;" +
5311 "class='editableFieldNode-Value-editIcon' id='fixedChoice-editIcon" +
5313 "onclick='ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle();' " +
5314 "title='Toggle free-form editing' " +
5321 Debug.log(
"Finishing up select cell handling...");
5322 localFinishUpSelectCell();
5331 function localHandleDropdownForLinkGroupID(targetTable,childLinkIndex)
5333 Debug.log(
"localHandleDropdownForLinkGroupID()",
5338 DesktopContent.XMLHttpRequest(
"Request?RequestType=getSpecificTable" +
5339 "&dataOffset=0&chunkSize=" + 0 +
5340 "&tableName=" + targetTable +
5346 var err = DesktopContent.getXMLValue(req,
"Error");
5349 Debug.log(err, Debug.HIGH_PRIORITY);
5351 Debug.log(
"There were errors loading the mockup version of '" +
5352 targetTable +
"'.\n\n" +
5353 "Please see the detailed Errors below:", Debug.HIGH_PRIORITY);
5358 var warns = DesktopContent.getXMLValue(req,
"TableWarnings");
5360 Debug.log(
"There were warnings found when loading table '" +
5362 "' (you can treat them as informational):\n\n" +
5363 warns, Debug.WARN_PRIORITY);
5365 var colTypeEls = req.responseXML.getElementsByTagName(
"CurrentVersionColumnHeaders")[0].getElementsByTagName(
"ColumnType");
5366 var colHdrs = req.responseXML.getElementsByTagName(
"CurrentVersionColumnHeaders")[0].getElementsByTagName(
"ColumnHeader");
5368 Debug.log(
"Looking for groupID column in linked to table matching " +
5371 var groupIdCol = -1;
5373 for (var i = 0; i < colTypeEls.length; ++i)
5374 if (colTypeEls[i].getAttribute(
"value").split(
'-')[1] == childLinkIndex)
5376 groupIdField = colHdrs[i].getAttribute(
"value");
5377 Debug.log(
"Found link groupid col " + i +
" - " + groupIdField);
5383 if (groupIdCol == -1)
5385 Debug.log(
"No matching GroupID column found at linked to table!", Debug.HIGH_PRIORITY);
5392 ConfigurationAPI.getSubsetRecords(tableEl.innerText,
5397 Debug.logv({records});
5398 if(!records || !records.length)
5401 Debug.log(
"Aborting link group ID search.");
5402 str += localFinishUpTextValueCell();
5403 localFinishUpSelectCell();
5407 ConfigurationAPI.getUniqueFieldValuesForRecords(
5415 if(!obj || !obj.length)
5418 Debug.log(
"Aborting link group ID search.");
5419 str += localFinishUpTextValueCell();
5420 localFinishUpSelectCell();
5426 groupIds = obj[0].fieldUniqueValueArray;
5430 Debug.log(
"Caught error: " + e);
5433 localFinishGroupIdDropdown();
5440 function localFinishGroupIdDropdown()
5443 str +=
"<div onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
5444 "onmouseup='event.stopPropagation();' " +
5445 "onclick='event.stopPropagation();' " +
5447 "white-space:nowrap;" +
5448 "margin:-3px -2px -2px -1px;" +
5449 "height:" + (el.offsetHeight+6) +
"px'>";
5451 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
5452 "id='fixedChoice-editSelectBox' " +
5453 "onmouseup='event.stopPropagation();' " +
5454 "onclick='event.stopPropagation();' " +
5457 "margin:-2px -2px -2px -1px; height:" +
5458 (el.offsetHeight+6) +
"px'>";
5459 for (var i = 0; i < groupIds.length; ++i)
5461 str +=
"<option value='" + groupIds[i]
5466 == ConfigurationAPI.editableFieldEditingOldValue_)
5470 if(optionIndex == -1 &&
5471 ConfigurationAPI.editableFieldEditingOldValue_.length)
5473 str +=
"<option value='" + encodeURIComponent(
5474 ConfigurationAPI.editableFieldEditingOldValue_)
5476 str += encodeURIComponent(ConfigurationAPI.editableFieldEditingOldValue_);
5478 optionIndex = groupIds.length;
5485 var ww = (el.offsetWidth-6);
5486 if(ww < 150) ww = 150;
5487 str +=
"<input type='text' " +
5488 "id='fixedChoice-editTextBox' " +
5489 "style='display:none;" +
5491 "margin:-2px 0 -" + (el.offsetHeight+6) +
"px 0;" +
5493 ww +
"px; height:" + (el.offsetHeight+6) +
"px" +
5497 str +=
"<div style='display:block;" +
5498 "margin: -2px 0 -7px 14px;" +
5500 "class='editableFieldNode-Value-editIcon' id='fixedChoice-editIcon" +
5502 "onclick='ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle();' " +
5503 "title='Toggle free-form editing' " +
5510 Debug.log(
"Finishing up group-id select cell handling...");
5511 localFinishUpSelectCell();
5523 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
5532 Debug.log(
"Toggling selection of target field " + idString);
5536 if(ConfigurationAPI.editableFieldSelectedIdString_ &&
5537 (vel = document.getElementById(
"editableFieldNode-Value-" +
5538 ConfigurationAPI.editableFieldSelectedIdString_)))
5539 vel.style.backgroundColor =
"transparent";
5542 vel = document.getElementById(
"editableFieldNode-Value-" +
5544 if(ConfigurationAPI.editableFieldSelectedIdString_ == idString)
5548 ConfigurationAPI.editableFieldSelectedIdString_ = undefined;
5551 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
5552 ConfigurationAPI.editableFieldSelectedIdString_ = idString;
5556 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
5568 ConfigurationAPI.getSelectedEditableFieldIndex =
function()
5570 if(!ConfigurationAPI.editableFieldSelectedIdString_)
5573 var idStr = ConfigurationAPI.editableFieldSelectedIdString_;
5574 return idStr.split(
'-')[1];
5580 ConfigurationAPI.handleEditableFieldHover =
function(depth,uid,event)
5582 var idString = depth +
"-" + uid;
5586 event.stopPropagation();
5587 DesktopContent.mouseMove(event);
5590 if(ConfigurationAPI.editableFieldEditingCell_)
return;
5592 var el = document.getElementById(
"editableFieldNode-Value-editIcon-" + idString);
5593 if(ConfigurationAPI.editableFieldHoveringCell_ == el)
return;
5595 if(ConfigurationAPI.editableFieldHoveringCell_)
5598 bodyMouseMoveHandler();
5602 ConfigurationAPI.editableFieldHoveringIdString_ = idString;
5603 ConfigurationAPI.editableFieldHoveringCell_ = el;
5604 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"block";
5605 var vel = document.getElementById(
"editableFieldNode-Value-" +
5606 ConfigurationAPI.editableFieldHoveringIdString_);
5607 vel.style.backgroundColor =
"rgb(218, 194, 194)";
5612 ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle =
function()
5614 Debug.log(
"handleEditableFieldFixedChoiceEditToggle");
5616 var sel = document.getElementById(
"fixedChoice-editSelectBox");
5617 var tel = document.getElementById(
"fixedChoice-editTextBox");
5619 Debug.log(
"sel.style.display " + sel.style.display);
5620 if(sel.style.display ==
"none")
5622 sel.style.display =
"block";
5623 tel.style.display =
"none";
5627 tel.style.width = ((sel.offsetWidth>150?sel.offsetWidth:150)-2) +
"px";
5628 tel.parentNode.style.width = ((sel.offsetWidth>150?sel.offsetWidth:150)+50) +
"px";
5629 sel.style.display =
"none";
5632 tel.value = ConfigurationAPI.editableFieldEditingOldValue_;
5634 tel.style.display =
"block";
5635 ConfigurationAPI.setCaretPosition(tel,0,tel.value.length);
5641 ConfigurationAPI.handleEditableFieldBodyMouseMove =
function(e)
5643 if(ConfigurationAPI.editableFieldHoveringCell_)
5646 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"none";
5647 ConfigurationAPI.editableFieldHoveringCell_ = 0;
5649 var vel = document.getElementById(
"editableFieldNode-Value-" +
5650 ConfigurationAPI.editableFieldHoveringIdString_);
5653 if(ConfigurationAPI.editableFieldHoveringIdString_ ==
5654 ConfigurationAPI.editableFieldSelectedIdString_)
5655 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
5657 vel.style.backgroundColor =
"transparent";
5665 ConfigurationAPI.handleEditableFieldKeyDown =
function(e,keyEl)
5677 key = window.event.keyCode;
5678 shiftIsDown = !!window.event.shiftKey;
5683 shiftIsDown = !!e.shiftKey;
5692 if(ConfigurationAPI.editableFieldEditingCell_ &&
5693 (tel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"textarea")).length)
5697 if(e.keyCode == TABKEY)
5700 if(e.preventDefault)
5703 var i = tel.selectionStart;
5704 var j = tel.selectionEnd;
5705 tel.value = tel.value.substr(0,i) +
5706 '\t' + tel.value.substr(j);
5707 tel.selectionStart = tel.selectionEnd = j+1;
5716 if(e.keyCode == TABKEY || e.keyCode == ENTERKEY ||
5717 e.keyCode == UPKEY || e.keyCode == DNKEY)
5720 if(e.preventDefault)
5724 var idString = ConfigurationAPI.editableFieldEditingIdString_;
5726 ConfigurationAPI.handleEditableFieldEditOK();
5734 if(e.keyCode == ENTERKEY)
5737 var depth = idString.split(
'-')[0];
5738 var uid = idString.split(
'-')[1];
5740 if((!shiftIsDown && e.keyCode == TABKEY) || e.keyCode == DNKEY)
5742 else if((shiftIsDown && e.keyCode == TABKEY) || e.keyCode == UPKEY)
5744 if(uid < 0)
return false;
5747 ConfigurationAPI.handleEditableFieldClick(depth,uid,1,
"value");
5748 Debug.log(
"new uid=" + uid);
5752 else if(e.keyCode == ESCKEY)
5754 if(e.preventDefault)
5756 ConfigurationAPI.handleEditableFieldEditCancel();
5759 else if((e.keyCode >= 48 && e.keyCode <= 57) ||
5760 (e.keyCode >= 96 && e.keyCode <= 105))
5764 if((sel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"select")).length)
5769 sel = sel[sel.length-1];
5774 selNum = e.keyCode - 96;
5776 selNum = e.keyCode - 48;
5778 sel.selectedIndex = selNum % (sel.options.length);
5781 Debug.log(
"number select =" + sel.selectedIndex);
5791 ConfigurationAPI.handleEditableFieldEditCancel =
function()
5793 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5794 Debug.log(
"handleEditableFieldEditCancel type " + ConfigurationAPI.editableFieldEditingNodeType_);
5798 var idSplit = ConfigurationAPI.editableFieldEditingCell_.id.split(
'-');
5799 var depth = idSplit[idSplit.length-2];
5800 var uid = idSplit[idSplit.length-1];
5801 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
5802 (depth +
"-" + uid) ).style.display =
"block";
5803 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
5804 (depth +
"-" + uid) ).style.display =
"block";
5809 if(ConfigurationAPI.editableFieldEditingNodeType_ ==
"value-bool")
5812 ConfigurationAPI.editableFieldEditingCell_.innerHTML = ConfigurationAPI.editableFieldEditingOldValue_;
5816 ConfigurationAPI.editableFieldEditingCell_.innerHTML =
"";
5817 ConfigurationAPI.editableFieldEditingCell_.appendChild(
5818 document.createTextNode(ConfigurationAPI.editableFieldEditingOldValue_));
5821 ConfigurationAPI.editableFieldEditingCell_ = 0;
5827 ConfigurationAPI.handleEditableFieldEditOK =
function()
5829 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5830 Debug.log(
"handleEditableFieldEditOK type " + ConfigurationAPI.editableFieldEditingNodeType_);
5834 var idSplit = ConfigurationAPI.editableFieldEditingCell_.id.split(
'-');
5835 var depth = idSplit[idSplit.length-2];
5836 var uid = idSplit[idSplit.length-1];
5837 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
5838 (depth +
"-" + uid) ).style.display =
"block";
5839 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
5840 (depth +
"-" + uid) ).style.display =
"block";
5844 var el = ConfigurationAPI.editableFieldEditingCell_;
5845 var type = ConfigurationAPI.editableFieldEditingNodeType_;
5849 function localEditTreeNodeOKRequestsComplete(newValue)
5855 if(type ==
"value" ||
5856 type ==
"value-bitmap" ||
5857 type ==
"value-groupid" ||
5858 type ==
"value-childLink" ||
5859 type ==
"value-ChildLinkGroupID" ||
5860 type ==
"value-ChildLinkUID")
5864 el.appendChild(document.createTextNode(decodeURIComponent(newValue)));
5866 else if(type ==
"value-bool")
5871 str +=
"<div style='float:left'>";
5875 var color = (newValue ==
"On" || newValue ==
"Yes" || newValue ==
"True")?
5876 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
5877 str +=
"<div style='width:10px;height:10px;" +
5878 "background-color:" + color +
";" +
5880 "border-radius: 7px;" +
5881 "border: 2px solid white;" +
5882 "margin: 2px 0 0 6px;" +
5888 Debug.err(
"Unrecognizd tree edit type '" +
5889 type +
"'! Should be impossible!");
5890 ConfigurationAPI.handleEditableFieldEditCancel();
return;
5894 ConfigurationAPI.editableFieldEditingCell_ = 0;
5901 type ==
"value-bool" ||
5902 type ==
"value-bitmap" ||
5903 type ==
"value-groupid" ||
5904 type ==
"value-childLink" ||
5905 type ==
"value-ChildLinkGroupID" ||
5906 type ==
"value-ChildLinkUID")
5911 if(type ==
"value-bool")
5913 var sel = el.getElementsByTagName(
"select")[0];
5914 newValue = sel.options[sel.selectedIndex].value;
5916 else if(type ==
"value-bitmap")
5918 newValue = encodeURIComponent(el.textContent);
5923 if((sel = el.getElementsByTagName(
"textarea")).length)
5924 newValue = sel[0].value;
5925 else if((sel = el.getElementsByTagName(
"select")).length)
5928 if(sel[0].style.display ==
"none")
5932 newValue = el.getElementsByTagName(
"input")[0].value;
5935 newValue = sel[0].options[sel[0].selectedIndex].value;
5938 newValue = el.getElementsByTagName(
"input")[0].value;
5940 newValue = encodeURIComponent(newValue.trim());
5942 if(type ==
"value-childLink")
5944 Debug.log(
"Checking link value against active tables");
5946 for(var activeTable in ConfigurationAPI._activeTables)
5947 if(newValue == activeTable)
5949 found =
true;
break;
5953 Debug.warn(
"We noticed the child link target table '" +
5954 newValue +
"' was not found in the list of active tables. " +
5955 "You may be able to ignore this issue, or your table group might fail to activate during State Machine transitions. " +
5957 "To add a table to a group, in the Configuration Editor GUI, go to go to the " +
5958 "group view, then click 'Add/Remove/Modify Member Tables.' You " +
5959 "can then add or remove tables and save the new group." +
5961 "OR!!! Click the following button to add the table '" + newValue +
5962 "' to the Configuration Group: " +
5963 "<input type='button' style='color:black !important;' " +
5964 "title='Click to add table to the active Configuration Group' " +
5965 "onclick='ConfigurationAPI.addTableToConfigurationGroup(\"" +
5966 newValue +
"\"); Debug.closeErrorPop();event.stopPropagation(); ' value='Add Table'>" +
5972 Debug.log(
"CfgGUI editTreeNodeOK editing " + type +
" node = " +
5975 if(ConfigurationAPI.editableFieldEditingInitValue_ == newValue)
5977 Debug.log(
"No change. Do nothing.");
5978 ConfigurationAPI.handleEditableFieldEditCancel();
5986 localEditTreeNodeOKRequestsComplete(newValue);
5991 Debug.err(
"Unrecognizd tree edit type '" +
5992 type +
"'! Should be impossible!");
5993 ConfigurationAPI.handleEditableFieldEditCancel();
return;
6000 ConfigurationAPI.hasClass =
function(ele,cls)
6002 return !!ele.className.match(
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)'));
6007 ConfigurationAPI.addClass =
function(ele,cls)
6009 if (!ConfigurationAPI.hasClass(ele,cls)) ele.className +=
" "+cls;
6014 ConfigurationAPI.removeClass =
function(ele,cls)
6016 if (ConfigurationAPI.hasClass(ele,cls))
6018 var reg =
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)');
6019 ele.className=ele.className.replace(reg,
'');
6039 ConfigurationAPI.addSubsetRecords =
function(subsetBasePath,
6040 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
6042 var modifiedTablesListStr =
"";
6043 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
6045 if(i) modifiedTablesListStr +=
",";
6046 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
6047 modifiedTablesIn[i].tableVersion;
6050 var recordListStr =
"";
6051 if(Array.isArray(recordArr))
6052 for(var i=0;i<recordArr.length;++i)
6054 if(i) recordListStr +=
",";
6055 recordListStr += encodeURIComponent(recordArr[i]);
6058 recordListStr = encodeURIComponent(recordArr);
6060 DesktopContent.XMLHttpRequest(
"Request?RequestType=addTreeNodeRecords" +
6062 "&tableGroupKey=-1",
6063 "startPath=/" + subsetBasePath +
6064 "&recordList=" + recordListStr +
6065 "&modifiedTables=" + modifiedTablesListStr,
6068 var modifiedTables = [];
6070 var err = DesktopContent.getXMLValue(req,
"Error");
6074 Debug.log(err,Debug.HIGH_PRIORITY);
6075 responseHandler(modifiedTables,err);
6082 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
6083 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
6084 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
6088 for(var i=0;i<tableNames.length;++i)
6090 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
6091 if(tableVersion >= -1)
continue;
6093 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
6094 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
6095 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
6096 modifiedTables.push(obj);
6098 responseHandler(modifiedTables);
6122 ConfigurationAPI.deleteSubsetRecords =
function(subsetBasePath,
6123 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
6125 var modifiedTablesListStr =
"";
6126 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
6128 if(i) modifiedTablesListStr +=
",";
6129 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
6130 modifiedTablesIn[i].tableVersion;
6133 var recordListStr =
"";
6134 var recordCount = 1;
6135 if(Array.isArray(recordArr))
6137 for(var i=0;i<recordArr.length;++i)
6139 if(i) recordListStr +=
",";
6140 recordListStr += encodeURIComponent(recordArr[i]);
6142 recordCount = recordArr.length;
6145 recordListStr = encodeURIComponent(recordArr);
6147 DesktopContent.XMLHttpRequest(
"Request?RequestType=deleteTreeNodeRecords" +
6149 "&tableGroupKey=-1",
6150 "startPath=/" + subsetBasePath +
6151 "&recordList=" + recordListStr +
6152 "&modifiedTables=" + modifiedTablesListStr,
6156 var err = DesktopContent.getXMLValue(req,
"Error");
6157 var modifiedTables = [];
6161 Debug.log(err,Debug.HIGH_PRIORITY);
6162 responseHandler(modifiedTables,err);
6169 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
6170 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
6171 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
6175 for(var i=0;i<tableNames.length;++i)
6177 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
6178 if(tableVersion >= -1)
continue;
6180 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
6181 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
6182 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
6183 modifiedTables.push(obj);
6185 responseHandler(modifiedTables,undefined,subsetBasePath,recordCount);
6208 ConfigurationAPI.renameSubsetRecords =
function(subsetBasePath,
6209 recordArr,newRecordArr,responseHandler,modifiedTablesIn,silenceErrors)
6211 Debug.log(
"renameSubsetRecords()");
6213 var modifiedTablesListStr =
"";
6214 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
6216 if(i) modifiedTablesListStr +=
",";
6217 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
6218 modifiedTablesIn[i].tableVersion;
6221 var recordListStr =
"";
6222 var recordCount = 1;
6223 if(Array.isArray(recordArr))
6225 for(var i=0;i<recordArr.length;++i)
6227 if(i) recordListStr +=
",";
6228 recordListStr += encodeURIComponent(recordArr[i]);
6230 recordCount = recordArr.length;
6233 recordListStr = encodeURIComponent(recordArr);
6235 var newRecordListStr =
"";
6236 var newRecordCount = 1;
6237 if(Array.isArray(newRecordArr))
6239 for(var i=0;i<newRecordArr.length;++i)
6241 if(i) newRecordListStr +=
",";
6242 newRecordListStr += encodeURIComponent(newRecordArr[i]);
6244 newRecordCount = newRecordArr.length;
6247 newRecordListStr = encodeURIComponent(newRecordArr);
6249 DesktopContent.XMLHttpRequest(
"Request?RequestType=renameTreeNodeRecords" +
6251 "&tableGroupKey=-1",
6252 "startPath=/" + subsetBasePath +
6253 "&recordList=" + recordListStr +
6254 "&newRecordList=" + newRecordListStr +
6255 "&modifiedTables=" + modifiedTablesListStr,
6259 var err = DesktopContent.getXMLValue(req,
"Error");
6260 var modifiedTables = [];
6264 Debug.log(err,Debug.HIGH_PRIORITY);
6265 responseHandler(modifiedTables,err);
6272 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
6273 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
6274 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
6278 for(var i=0;i<tableNames.length;++i)
6280 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
6281 if(tableVersion >= -1)
continue;
6283 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
6284 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
6285 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
6286 modifiedTables.push(obj);
6288 responseHandler(modifiedTables,undefined,subsetBasePath,recordCount);
6312 ConfigurationAPI.copySubsetRecords =
function(subsetBasePath,
6313 recordArr,numberOfCopies,responseHandler,modifiedTablesIn,silenceErrors)
6315 if(!numberOfCopies) numberOfCopies = 1;
6316 Debug.log(
"copySubsetRecords() " + numberOfCopies);
6318 var modifiedTablesListStr =
"";
6319 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
6321 if(i) modifiedTablesListStr +=
",";
6322 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
6323 modifiedTablesIn[i].tableVersion;
6326 var recordListStr =
"";
6327 var recordCount = 1;
6328 if(Array.isArray(recordArr))
6330 for(var i=0;i<recordArr.length;++i)
6332 if(i) recordListStr +=
",";
6333 recordListStr += encodeURIComponent(recordArr[i]);
6335 recordCount = recordArr.length;
6338 recordListStr = encodeURIComponent(recordArr);
6340 DesktopContent.XMLHttpRequest(
"Request?RequestType=copyTreeNodeRecords" +
6342 "&tableGroupKey=-1" +
6343 "&numberOfCopies=" + numberOfCopies,
6344 "startPath=/" + subsetBasePath +
6345 "&recordList=" + recordListStr +
6346 "&modifiedTables=" + modifiedTablesListStr,
6350 var err = DesktopContent.getXMLValue(req,
"Error");
6351 var modifiedTables = [];
6355 Debug.log(err,Debug.HIGH_PRIORITY);
6356 responseHandler(modifiedTables,err);
6363 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
6364 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
6365 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
6369 for(var i=0;i<tableNames.length;++i)
6371 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
6372 if(tableVersion >= -1)
continue;
6374 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
6375 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
6376 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
6377 modifiedTables.push(obj);
6379 responseHandler(modifiedTables,undefined,subsetBasePath,recordCount);
6389 ConfigurationAPI.incrementName =
function(name)
6392 for(var i=name.length-1;i>=0;--i)
6393 if(!(name[i] >=
'0' && name[i] <=
'9'))
6396 var num = (name.substr(i+1)|0) + 1;
6397 name = name.substr(0,i+1);
6403 ConfigurationAPI.createNewRecordName =
function(startingName,existingArr)
6405 var retVal = startingName;
6409 var apps = existingArr;
6412 retVal = ConfigurationAPI.incrementName(retVal);
6414 for(i=0;i<apps.length;++i)
6415 if(apps[i] == retVal)
6416 {found =
true;
break;}
6418 Debug.log(
"createNewRecordName " + retVal);
6423 return ConfigurationAPI.incrementName(retVal);