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');
82 ConfigurationAPI._activeGroups = {};
85 ConfigurationAPI._DEFAULT_COMMENT =
"No comment.";
86 ConfigurationAPI._POP_UP_DIALOG_ID =
"ConfigurationAPI-popUpDialog";
116 ConfigurationAPI._VERSION_ALIAS_PREPEND =
"ALIAS:";
117 ConfigurationAPI._SCRATCH_VERSION = 2147483647;
118 ConfigurationAPI._SCRATCH_ALIAS =
"Scratch";
120 ConfigurationAPI._OK_CANCEL_DIALOG_STR =
"";
121 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"<div title='' style='padding:5px;background-color:#eeeeee;border:1px solid #555555;position:relative;z-index:2000;" +
122 "width:95px;height:20px;margin:0 -122px -64px 10px; font-size: 16px; white-space:nowrap; text-align:center;'>";
123 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"<a class='popUpOkCancel' onclick='javascript:ConfigurationAPI.handleEditableFieldEditOK(); event.stopPropagation();' onmouseup='event.stopPropagation();' title='Accept Changes' style='color:green'>" +
124 "<b style='color:green;font-size: 16px;'>OK</b></a> | " +
125 "<a class='popUpOkCancel' onclick='javascript:ConfigurationAPI.handleEditableFieldEditCancel(); event.stopPropagation();' onmouseup='event.stopPropagation();' title='Discard Changes' style='color:red'>" +
126 "<b style='color:red;font-size: 16px;'>Cancel</b></a>";
127 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"</div>";
143 ConfigurationAPI.getActiveGroups =
function(responseHandler)
146 DesktopContent.XMLHttpRequest(
"Request?RequestType=getActiveTableGroups",
149 responseHandler(ConfigurationAPI.extractActiveGroups(req));
154 ConfigurationAPI.extractActiveGroups =
function(req)
159 var activeConfigGroups = [
160 DesktopContent.getXMLValue(req,
"Context-ActiveGroupName"),
161 DesktopContent.getXMLValue(req,
"Context-ActiveGroupKey"),
162 DesktopContent.getXMLValue(req,
"Backbone-ActiveGroupName"),
163 DesktopContent.getXMLValue(req,
"Backbone-ActiveGroupKey"),
164 DesktopContent.getXMLValue(req,
"Iterate-ActiveGroupName"),
165 DesktopContent.getXMLValue(req,
"Iterate-ActiveGroupKey"),
166 DesktopContent.getXMLValue(req,
"Configuration-ActiveGroupName"),
167 DesktopContent.getXMLValue(req,
"Configuration-ActiveGroupKey")];
171 retObj.Context.groupName = activeConfigGroups[i++];
172 retObj.Context.groupKey = activeConfigGroups[i++];
173 retObj.Backbone = {};
174 retObj.Backbone.groupName = activeConfigGroups[i++];
175 retObj.Backbone.groupKey = activeConfigGroups[i++];
177 retObj.Iterate.groupName = activeConfigGroups[i++];
178 retObj.Iterate.groupKey = activeConfigGroups[i++];
179 retObj.Configuration = {};
180 retObj.Configuration.groupName = activeConfigGroups[i++];
181 retObj.Configuration.groupKey = activeConfigGroups[i++];
185 Debug.log(
"Error extracting active groups: " + e);
189 ConfigurationAPI._activeGroups = {};
190 ConfigurationAPI._activeGroups = retObj;
225 ConfigurationAPI.getAliasesAndGroups =
function(responseHandler,optionForNoAliases,
232 if(!optionForNoAliases)
233 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
239 Debug.log(
"getGroupAliases handler");
241 var groupAliases = req.responseXML.getElementsByTagName(
"GroupAlias");
242 var groupNames = req.responseXML.getElementsByTagName(
"GroupName");
243 var groupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
244 var groupComments = req.responseXML.getElementsByTagName(
"GroupComment");
245 var groupTypes = req.responseXML.getElementsByTagName(
"GroupType");
246 var aliasComments = req.responseXML.getElementsByTagName(
"AliasComment");
251 for(var i=0;i<groupAliases.length;++i)
253 type = groupTypes[i].getAttribute(
'value');
255 if(type ==
"")
continue;
257 if(!retObj.aliases[type])
258 retObj.aliases[type] = [];
260 retObj.aliases[type].push({
261 "alias" : groupAliases[i].getAttribute(
'value'),
262 "name" : groupNames[i].getAttribute(
'value'),
263 "key" : groupKeys[i].getAttribute(
'value'),
264 "groupComment" : groupComments[i].getAttribute(
'value'),
265 "groupComment" : groupTypes[i].getAttribute(
'value'),
266 "aliasComment" : aliasComments[i].getAttribute(
'value')
273 (reqCount == 1 && optionForNoGroups))
276 console.log(
"getAliasesAndGroups retObj ",retObj);
277 responseHandler(retObj);
287 if(!optionForNoGroups)
288 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTableGroups"
289 +
"&doNotReturnMembers=1",
293 Debug.log(
"getTableGroups handler");
295 retObj.activeGroups = {};
296 retObj.activeGroups = ConfigurationAPI.extractActiveGroups(req);
298 var groupNames = req.responseXML.getElementsByTagName(
"TableGroupName");
299 var groupKeys = req.responseXML.getElementsByTagName(
"TableGroupKey");
300 var groupTypes = req.responseXML.getElementsByTagName(
"TableGroupType");
301 var groupComments = req.responseXML.getElementsByTagName(
"TableGroupComment");
306 for(var i=0;i<groupNames.length;++i)
308 type = groupTypes[i].getAttribute(
'value');
310 if(type ==
"")
continue;
318 if(!retObj.groups[type])
319 retObj.groups[type] = {};
321 name = groupNames[i].getAttribute(
'value');
322 if(!retObj.groups[type][name])
324 retObj.groups[type][name] = {};
326 retObj.groups[type][name].groupComment = groupComments[i].getAttribute(
'value');
327 retObj.groups[type][name].keys = [];
330 retObj.groups[type][name].keys.push(groupKeys[i].getAttribute(
'value'));
336 (reqCount == 1 && optionForNoAliases))
339 console.log(
"getAliasesAndGroups retObj ",retObj);
340 responseHandler(retObj);
370 ConfigurationAPI.getSubsetRecords =
function(subsetBasePath,
371 filterList,responseHandler,modifiedTables)
373 var modifiedTablesListStr =
"";
374 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
376 if(i) modifiedTablesListStr +=
",";
377 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
378 modifiedTables[i].tableVersion;
380 if(filterList === undefined) filterList =
"";
382 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
384 "&tableGroupKey=-1" +
385 "&hideStatusFalse=0" +
387 "startPath=/" + subsetBasePath +
388 "&filterList=" + filterList +
389 "&modifiedTables=" + modifiedTablesListStr,
392 ConfigurationAPI.extractActiveGroups(req);
395 var err = DesktopContent.getXMLValue(req,
"Error");
398 Debug.log(err,Debug.HIGH_PRIORITY);
399 if(responseHandler) responseHandler(records);
405 var tree = DesktopContent.getXMLNode(req,
"tree");
406 var nodes = tree.children;
407 for(var i=0;i<nodes.length;++i)
408 records.push(nodes[i].getAttribute(
"value"));
409 Debug.log(
"Records: " + records);
410 if(responseHandler) responseHandler(records);
425 ConfigurationAPI.getTree =
function(treeBasePath,depth,modifiedTables,
426 responseHandler,responseHandlerParam)
428 var modifiedTablesListStr =
"";
429 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
431 if(i) modifiedTablesListStr +=
",";
432 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
433 modifiedTables[i].tableVersion;
436 treeBasePath = treeBasePath.trim();
437 if(treeBasePath ==
"/") treeBasePath =
"";
439 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
441 "&tableGroupKey=-1" +
442 "&hideStatusFalse=0" +
444 "startPath=/" + treeBasePath +
445 "&filterList=" +
"" +
446 "&modifiedTables=" + modifiedTablesListStr,
449 var err = DesktopContent.getXMLValue(req,
"Error");
452 Debug.log(err,Debug.HIGH_PRIORITY);
453 if(responseHandler) responseHandler(undefined,responseHandlerParam);
467 if(responseHandler) responseHandler(
468 DesktopContent.getXMLNode(req,
"tree"),
469 responseHandlerParam);
481 ConfigurationAPI.getTreeChildren =
function(tree,pathToChildren)
483 var pathArr = pathToChildren?pathToChildren.split(
'/'):
"";
487 children = tree.children;
490 for(var i=0;i<pathArr.length;++i)
492 if(pathArr[i].trim().length == 0)
continue;
494 Debug.log(i +
": " + pathArr[i]);
497 for(var j=0;j<children.length;++j)
498 if(children[j].getAttribute(
"value") == pathArr[i])
502 children = children[j].children;
503 Debug.log(
"found " + pathArr[i]);
509 Debug.log(
"Invalid path '" + pathToChildren +
"' through tree! How did you get here? Notify admins.", Debug.HIGH_PRIORITY);
517 for(var i=0;i<children.length;++i)
518 if(children[i].nodeName ==
"node")
519 retArr.push(children[i]);
529 ConfigurationAPI.getTreeRecordLinks =
function(node)
531 var children = node.children;
536 for(var i=0;i<children.length;++i)
538 if(children[i].nodeName !=
"node")
continue;
540 subchildren = children[i].children;
542 for(var j=0;j<subchildren.length;++j)
544 if(subchildren[j].nodeName ==
"LinkTableName")
546 retArr.push(children[i]);
560 ConfigurationAPI.getTreeRecordName =
function(node)
564 var children = node.children;
565 if(children.length > 2)
567 if(children[0].nodeName ==
"valueType" &&
568 children[0].getAttribute(
"value") ==
"Disconnected")
569 throw(
"Disconnected link!");
571 if(children[0].nodeName ==
"UID")
572 return children[0].getAttribute(
"value");
574 if(children[1].nodeName ==
"UID")
575 return children[0].getAttribute(
"value");
578 return node.getAttribute(
"value");
585 ConfigurationAPI.getTreeLinkChildren =
function(link)
587 var children = link.children;
590 for(var i=0;i<children.length;++i)
592 if(children[i].nodeName ==
"UID")
597 else if(children[i].nodeName ==
"node")
598 retArr.push(children[i]);
608 ConfigurationAPI.getTreeLinkTable =
function(link)
610 var children = link.children;
611 for(var i=0;i<children.length;++i)
612 if(children[i].nodeName ==
"LinkTableName")
613 return children[i].getAttribute(
"value");
614 throw(
"Table name not found!");
649 ConfigurationAPI.getFieldsOfRecords =
function(subsetBasePath,recordArr,fieldList,
650 maxDepth,responseHandler,modifiedTables)
652 var modifiedTablesListStr =
"";
653 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
655 if(i) modifiedTablesListStr +=
",";
656 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
657 modifiedTables[i].tableVersion;
660 var recordListStr =
"";
661 if(Array.isArray(recordArr))
662 for(var i=0;i<recordArr.length;++i)
664 if(i) recordListStr +=
",";
665 recordListStr += encodeURIComponent(recordArr[i]);
668 recordListStr = encodeURIComponent(recordArr);
670 subsetBasePath = subsetBasePath.trim();
671 if(subsetBasePath ==
"/") subsetBasePath =
"";
673 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeNodeCommonFields" +
675 "&tableGroupKey=-1" +
676 "&depth=" + (maxDepth|0),
677 "startPath=/" + subsetBasePath +
678 "&recordList=" + recordListStr +
679 "&fieldList=" + fieldList +
680 "&modifiedTables=" + modifiedTablesListStr,
684 var err = DesktopContent.getXMLValue(req,
"Error");
687 Debug.log(err,Debug.HIGH_PRIORITY);
688 if(responseHandler) responseHandler(recFields);
692 var fields = DesktopContent.getXMLNode(req,
"fields");
694 var FieldTableNames = fields.getElementsByTagName(
"FieldTableName");
695 var FieldColumnNames = fields.getElementsByTagName(
"FieldColumnName");
696 var FieldRelativePaths = fields.getElementsByTagName(
"FieldRelativePath");
697 var FieldColumnTypes = fields.getElementsByTagName(
"FieldColumnType");
698 var FieldColumnDataTypes = fields.getElementsByTagName(
"FieldColumnDataType");
699 var FieldColumnDataChoices = fields.getElementsByTagName(
"FieldColumnDataChoices");
700 var FieldColumnDefaultValues = fields.getElementsByTagName(
"FieldColumnDefaultValue");
703 for(var i=0;i<FieldTableNames.length;++i)
706 obj.fieldTableName = DesktopContent.getXMLValue(FieldTableNames[i]);
707 obj.fieldColumnName = DesktopContent.getXMLValue(FieldColumnNames[i]);
708 obj.fieldRelativePath = DesktopContent.getXMLValue(FieldRelativePaths[i]);
709 obj.fieldColumnType = DesktopContent.getXMLValue(FieldColumnTypes[i]);
710 obj.fieldColumnDataType = DesktopContent.getXMLValue(FieldColumnDataTypes[i]);
711 obj.fieldColumnDefaultValue = DesktopContent.getXMLValue(FieldColumnDefaultValues[i]);
713 var FieldColumnDataChoicesArr = FieldColumnDataChoices[i].getElementsByTagName(
"FieldColumnDataChoice");
714 obj.fieldColumnDataChoicesArr = [];
715 for(var j=0; j<FieldColumnDataChoicesArr.length;++j)
716 obj.fieldColumnDataChoicesArr.push(DesktopContent.getXMLValue(FieldColumnDataChoicesArr[j]));
720 Debug.log(
"Records length: " + recFields.length);
721 if(responseHandler) responseHandler(recFields);
750 ConfigurationAPI.getFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldObjArr,
751 responseHandler,modifiedTables)
753 var modifiedTablesListStr =
"";
754 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
756 if(i) modifiedTablesListStr +=
",";
757 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
758 modifiedTables[i].tableVersion;
761 var recordListStr =
"";
762 if(Array.isArray(recordArr))
763 for(var i=0;i<recordArr.length;++i)
765 if(i) recordListStr +=
",";
766 recordListStr += encodeURIComponent(recordArr[i]);
769 recordListStr = encodeURIComponent(recordArr);
772 var fieldListStr =
"";
773 if(fieldObjArr.length && (typeof fieldObjArr[0] ===
"string"))
777 if(Array.isArray(fieldObjArr))
778 for(var i=0;i<fieldObjArr.length;++i)
780 if(i) fieldListStr +=
",";
781 fieldListStr += encodeURIComponent(fieldObjArr[i]);
784 fieldListStr = encodeURIComponent(fieldObjArr);
790 for(var i=0;i<fieldObjArr.length;++i)
792 if(i) fieldListStr +=
",";
793 fieldListStr += fieldObjArr[i].fieldRelativePath +
794 fieldObjArr[i].fieldColumnName;
798 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeNodeFieldValues" +
801 "startPath=/" + subsetBasePath +
802 "&recordList=" + recordListStr +
803 "&fieldList=" + fieldListStr +
804 "&modifiedTables=" + modifiedTablesListStr,
807 var recFieldValues = [];
808 var err = DesktopContent.getXMLValue(req,
"Error");
811 Debug.log(err,Debug.HIGH_PRIORITY);
812 if(responseHandler) responseHandler(recFieldValues);
816 var fieldValues = req.responseXML.getElementsByTagName(
"fieldValues");
818 for(var f=0;f<fieldValues.length;++f)
820 var FieldPaths = fieldValues[f].getElementsByTagName(
"FieldPath");
821 var FieldValues = fieldValues[f].getElementsByTagName(
"FieldValue");
822 for(var i=0;i<FieldPaths.length;++i)
825 obj.fieldUID = DesktopContent.getXMLValue(fieldValues[f]);
826 obj.fieldPath = DesktopContent.getXMLValue(FieldPaths[i]);
827 obj.fieldValue = DesktopContent.getXMLValue(FieldValues[i]);
828 recFieldValues.push(obj);
831 fieldObjArr[i].fieldColumnValue = obj.fieldValue;
835 if(responseHandler) responseHandler(recFieldValues);
865 ConfigurationAPI.getUniqueFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldList,
866 responseHandler,modifiedTables)
868 var modifiedTablesListStr =
"";
869 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
871 if(i) modifiedTablesListStr +=
",";
872 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
873 modifiedTables[i].tableVersion;
876 var recordListStr =
"";
877 if(Array.isArray(recordArr))
878 for(var i=0;i<recordArr.length;++i)
880 if(i) recordListStr +=
",";
881 recordListStr += encodeURIComponent(recordArr[i]);
884 recordListStr = encodeURIComponent(recordArr);
886 DesktopContent.XMLHttpRequest(
"Request?RequestType=getUniqueFieldValuesForRecords" +
889 "startPath=/" + subsetBasePath +
890 "&recordList=" + recordListStr +
891 "&fieldList=" + fieldList +
892 "&modifiedTables=" + modifiedTablesListStr,
895 var fieldUniqueValues = [];
896 var err = DesktopContent.getXMLValue(req,
"Error");
899 Debug.log(err,Debug.HIGH_PRIORITY);
900 if(responseHandler) responseHandler(fieldUniqueValues);
904 var fields = req.responseXML.getElementsByTagName(
"field");
906 for(var i=0;i<fields.length;++i)
909 var uniqueValues = fields[i].getElementsByTagName(
"uniqueValue");
910 var groupIdChildLinkIndex = DesktopContent.getXMLNode(
911 fields[i],
"childLinkIndex");
914 obj.fieldName = DesktopContent.getXMLValue(fields[i]);
916 if(groupIdChildLinkIndex)
917 obj.childLinkIndex = DesktopContent.getXMLValue(groupIdChildLinkIndex);
919 obj.fieldUniqueValueArray = [];
920 for(var j=0;j<uniqueValues.length;++j)
921 obj.fieldUniqueValueArray.push(DesktopContent.getXMLValue(uniqueValues[j]));
922 fieldUniqueValues.push(obj);
924 Debug.log(
"fieldUniqueValues length: " + fieldUniqueValues.length);
925 if(responseHandler) responseHandler(fieldUniqueValues);
958 ConfigurationAPI.setFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldObjArr,
959 valueArr,responseHandler,modifiedTablesIn,silenceErrors)
961 var modifiedTablesListStr =
"";
962 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
964 if(i) modifiedTablesListStr +=
",";
965 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
966 modifiedTablesIn[i].tableVersion;
969 var fieldListStr =
"";
970 if(fieldObjArr.length && (typeof fieldObjArr[0] ===
"string"))
974 if(Array.isArray(fieldObjArr))
975 for(var i=0;i<fieldObjArr.length;++i)
977 if(i) fieldListStr +=
",";
978 fieldListStr += encodeURIComponent(fieldObjArr[i]);
981 fieldListStr = encodeURIComponent(fieldObjArr);
987 for(var i=0;i<fieldObjArr.length;++i)
989 if(i) fieldListStr +=
",";
990 fieldListStr += fieldObjArr[i].fieldRelativePath +
991 fieldObjArr[i].fieldColumnName;
996 var valueListStr =
"";
997 if(Array.isArray(valueArr))
998 for(var i=0;i<valueArr.length;++i)
1000 if(i) valueListStr +=
",";
1001 valueListStr += encodeURIComponent(valueArr[i]);
1004 valueListStr = encodeURIComponent(valueArr);
1007 var recordListStr =
"";
1008 if(Array.isArray(recordArr))
1009 for(var i=0;i<recordArr.length;++i)
1011 if(i) recordListStr +=
",";
1012 recordListStr += encodeURIComponent(recordArr[i]);
1015 recordListStr = encodeURIComponent(recordArr);
1017 DesktopContent.XMLHttpRequest(
"Request?RequestType=setTreeNodeFieldValues" +
1019 "&tableGroupKey=-1",
1020 "startPath=/" + subsetBasePath +
1021 "&recordList=" + recordListStr +
1022 "&valueList=" + valueListStr +
1023 "&fieldList=" + fieldListStr +
1024 "&modifiedTables=" + modifiedTablesListStr,
1027 var modifiedTables = [];
1029 var err = DesktopContent.getXMLValue(req,
"Error");
1033 Debug.log(err,Debug.HIGH_PRIORITY);
1034 if(responseHandler) responseHandler(modifiedTables,err);
1038 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
1039 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
1040 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
1044 for(var i=0;i<tableNames.length;++i)
1046 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
1047 if(tableVersion >= -1)
continue;
1049 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
1050 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
1051 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
1052 modifiedTables.push(obj);
1055 if(responseHandler) responseHandler(modifiedTables);
1092 ConfigurationAPI.popUpSaveModifiedTablesForm =
function(modifiedTables,responseHandler)
1096 Debug.log(
"ConfigurationAPI popUpSaveModifiedTablesForm");
1100 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
1103 el = document.createElement(
"div");
1104 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
1106 el.style.display =
"none";
1111 ConfigurationAPI.setPopUpPosition(el,w ,h-gh*2 );
1133 var modTblCount = 0;
1135 var modifiedTablesListStr =
"";
1137 for(var j=0;j<modifiedTables.length;++j)
1138 if((modifiedTables[j].tableVersion|0) < -1)
1142 modTblStr += modifiedTables[j].tableName;
1144 if(modifiedTablesListStr.length)
1145 modifiedTablesListStr +=
",";
1146 modifiedTablesListStr += modifiedTables[j].tableName;
1147 modifiedTablesListStr +=
",";
1148 modifiedTablesListStr += modifiedTables[j].tableVersion;
1151 var str =
"<a id='" +
1152 ConfigurationAPI._POP_UP_DIALOG_ID +
1153 "-cancel' href='#'>Cancel</a><br><br>";
1155 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-div'>";
1156 str +=
"Saving will create new persistent versions of each modified table." +
1158 "Here is the list of modified tables (count=" + modTblCount +
1164 str +=
"<div style='white-space:nowrap; width:" + w +
"px; height:40px; " +
1165 "overflow:auto; font-weight: bold;'>";
1172 DesktopContent.XMLHttpRequest(
"Request?RequestType=getAffectedActiveGroups" +
1175 "&modifiedTables=" + modifiedTablesListStr,
1178 var err = DesktopContent.getXMLValue(req,
"Error");
1181 Debug.log(err,Debug.HIGH_PRIORITY);
1188 var groups = req.responseXML.getElementsByTagName(
"AffectedActiveGroup");
1189 var memberNames, memberVersions;
1192 for(var i=0;i<groups.length;++i)
1194 xmlGroupName = DesktopContent.getXMLValue(groups[i],
"GroupName");
1195 str +=
"<div style='display:none' class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1196 "-affectedGroups' >";
1197 str += xmlGroupName;
1198 str +=
"," + DesktopContent.getXMLValue(groups[i],
"GroupKey");
1200 memberNames = groups[i].getElementsByTagName(
"MemberName");
1201 memberVersions = groups[i].getElementsByTagName(
"MemberVersion");
1202 Debug.log(
"memberNames.length " + memberNames.length);
1203 for(var j=0;j<memberNames.length;++j)
1204 str +=
"," + DesktopContent.getXMLValue(memberNames[j]) +
1205 "," + DesktopContent.getXMLValue(memberVersions[j]);
1209 if(modTblStr.length)
1213 modTblStr +=
"<a style='color:black' href='#' onclick='javascript:" +
1214 "var forFirefox = ConfigurationAPI.handleGroupCommentToggle(\"" +
1215 xmlGroupName +
"\");" +
1216 " ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
");'>";
1217 modTblStr += xmlGroupName;
1218 modTblStr +=
"</a>";
1221 modTblStr +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1222 xmlGroupName +
"' " +
1223 "class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-cache' " +
1224 "style='display:none'>" +
1225 decodeURIComponent(DesktopContent.getXMLValue(groups[i],
"GroupComment")) +
1229 str +=
"Please choose the options you want and click 'Save':" +
1233 str +=
"<input type='checkbox' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1234 "-bumpGroupVersions' checked " +
1235 "onclick='ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
");'>";
1237 str +=
"<a href='#' onclick='javascript:" +
1238 "var el = document.getElementById(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1239 "-bumpGroupVersions\");" +
1240 "var forFirefox = (el.checked = !el.checked);" +
1241 " ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
"); return false;'>";
1242 str +=
"Save Affected Groups as New Keys";
1244 str +=
"</input><br>";
1247 str +=
"<input type='checkbox' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1248 "-activateBumpedGroupVersions' checked " +
1251 str +=
"<a href='#' onclick='javascript:" +
1252 "var el = document.getElementById(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1253 "-activateBumpedGroupVersions\");" +
1254 "if(el.disabled) return false; " +
1255 "var forFirefox = (el.checked = !el.checked);" +
1257 str +=
"Also Activate New Groups";
1259 str +=
"</input><br>";
1261 str +=
"Here is the list of affected groups (count=" + groups.length +
1266 str +=
"<div style='white-space:nowrap; width:" + w +
"px; margin-bottom:20px; " +
1267 "overflow:auto; font-weight: bold;'>";
1269 str +=
"<div id='clearDiv'></div>";
1272 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-header'></div>";
1274 str +=
"<div id='clearDiv'></div>";
1276 str +=
"<textarea id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1277 "-groupComment' rows='4' cols='50' " +
1278 "style='width:417px;height:68px;display:none;margin:0;'>";
1279 str += ConfigurationAPI._DEFAULT_COMMENT;
1280 str +=
"</textarea>";
1285 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1286 "-groupAliasArea' ><center>";
1290 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
1295 var err = DesktopContent.getXMLValue(req,
"Error");
1298 Debug.log(err,Debug.HIGH_PRIORITY);
1303 var aliases = req.responseXML.getElementsByTagName(
"GroupAlias");
1304 var aliasGroupNames = req.responseXML.getElementsByTagName(
"GroupName");
1305 var aliasGroupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
1312 var alias, aliasGroupName, aliasGroupKey;
1313 var groupName, groupKey;
1314 var groupOptionIndex = [];
1315 for(var i=0;i<groups.length;++i)
1317 groupOptionIndex.push([-1,0]);
1319 groupName = DesktopContent.getXMLValue(groups[i],
"GroupName");
1320 groupKey = DesktopContent.getXMLValue(groups[i],
"GroupKey");
1324 for(var j=0;j<aliasGroupNames.length;++j)
1326 alias = DesktopContent.getXMLValue(aliases[j]);
1327 aliasGroupName = DesktopContent.getXMLValue(aliasGroupNames[j]);
1328 aliasGroupKey = DesktopContent.getXMLValue(aliasGroupKeys[j]);
1334 modTblStr +=
"<option value='" + alias +
"' ";
1337 if(aliasGroupName == groupName)
1339 if(groupOptionIndex[i][0] == -1 ||
1340 Math.abs(groupKey - aliasGroupKey) < groupOptionIndex[i][1])
1342 Debug.log(
"found alias");
1343 groupOptionIndex[i][0] = j;
1344 groupOptionIndex[i][1] = Math.abs(groupKey - aliasGroupKey);
1349 modTblStr +=
"</option>";
1352 str +=
"<input type='checkbox' class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias' " +
1353 (groupOptionIndex[i][0] >= 0?
"checked":
"") +
1356 str +=
"<a href='#' onclick='javascript:" +
1357 "var el = document.getElementsByClassName(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias\");" +
1358 "var forFirefox = (el[" + i +
"].checked = !el[" + i +
"].checked);" +
1360 str +=
"Set '<b style='font-size:16px'>" + groupName +
"</b>' to System Alias:";
1363 str +=
"<table cellpadding='0' cellspacing='0' border='0'><tr><td>";
1365 "id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" + (i) +
"' " +
1366 "style='margin:2px; height:" + (25) +
"px'>";
1370 str +=
"<input type='text' " +
1371 "id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-" + (i) +
"' " +
1372 "style='display:none; margin:2px; width:150px; height:" +
1378 str +=
"<div style='display:block' " +
1379 "class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editIcon' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1382 "onclick='ConfigurationAPI.handlePopUpAliasEditToggle(" +
1385 "title='Toggle free-form system alias editing' " +
1388 str +=
"<div class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1389 "-preloadImage' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1390 "-preloadImage-editIconHover'></div>";
1392 str +=
"</td></tr></table>";
1398 el.style.height = h +
"px";
1401 str +=
"</center></div>";
1407 str +=
"</div><br>";
1415 str +=
"<input id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1416 "-submitButton' type='button' " +
1418 "value='Save' title='" +
1419 "Save new versions of every modified table\n" +
1420 "(Optionally, save new active groups and assign system aliases)" +
1425 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
1426 "-submitButton").onmouseup =
function() {
1427 Debug.log(
"Submit mouseup");
1428 this.disabled =
true;
1429 ConfigurationAPI.handleGroupCommentToggle(0,1);
1430 ConfigurationAPI.handlePopUpHeightToggle(h,gh);
1433 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1434 "-bumpGroupVersions").checked;
1435 var activatingSavedGroups =
1436 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1437 "-activateBumpedGroupVersions").checked;
1439 ConfigurationAPI.saveModifiedTables(modifiedTables,responseHandler,
1445 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
1446 "-cancel").onclick =
function(event) {
1447 Debug.log(
"Cancel click");
1448 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
1449 if(el) el.parentNode.removeChild(el);
1450 if(responseHandler) responseHandler([],[],[]);
1456 for(var i=0;i<groups.length;++i)
1457 if(groupOptionIndex[i][0] != -1)
1458 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" +
1459 i).selectedIndex = groupOptionIndex[i][0];
1468 document.body.appendChild(el);
1469 el.style.display =
"block";
1477 ConfigurationAPI.handleGroupCommentToggle =
function(groupName,setHideVal)
1479 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment");
1480 var hel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-header");
1483 var doHide = el.style.display !=
"none";
1484 if(setHideVal !== undefined)
1485 doHide = setHideVal;
1489 if(hel.textContent ==
"")
return;
1492 var gn = hel.textContent.split(
"'")[1];
1493 Debug.log(
"gn " + gn);
1494 cel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1497 cel.appendChild(document.createTextNode(el.value));
1501 el.style.display =
"none";
1504 if(gn == groupName || setHideVal !== undefined)
1511 cel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1513 el.value = cel.textContent;
1514 el.style.display =
"block";
1515 ConfigurationAPI.setCaretPosition(el,0,cel.textContent.length);
1517 hel.innerHTML = (
"'" + groupName +
"' group comment:");
1527 ConfigurationAPI.handlePopUpHeightToggle =
function(h,gh)
1529 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-bumpGroupVersions");
1530 Debug.log(
"ConfigurationAPI.handlePopUpHeightToggle " + el.checked);
1532 var ael = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-activateBumpedGroupVersions");
1534 var groupCommentEl = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment");
1535 var groupCommentHeight = 0;
1537 if(groupCommentEl && groupCommentEl.style.display !=
"none")
1538 groupCommentHeight += 100;
1540 var popEl = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1545 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupAliasArea").style.display =
"none";
1546 popEl.style.height = (h + groupCommentHeight) +
"px";
1547 ael.disabled =
true;
1554 var grps = document.getElementsByClassName(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-affectedGroups");
1555 popEl.style.height = (h + grps.length*gh + groupCommentHeight) +
"px";
1556 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupAliasArea").style.display =
"block";
1557 ael.disabled =
false;
1563 ConfigurationAPI.handlePopUpAliasEditToggle =
function(i)
1565 Debug.log(
"handlePopUpAliasEditToggle " + i);
1567 var sel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-"+i);
1568 var tel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-"+i);
1569 Debug.log(
"sel.style.display " + sel.style.display);
1570 if(sel.style.display ==
"none")
1572 sel.style.display =
"block";
1573 tel.style.display =
"none";
1577 tel.style.width = (sel.offsetWidth-2) +
"px";
1578 sel.style.display =
"none";
1579 tel.style.display =
"block";
1580 ConfigurationAPI.setCaretPosition(tel,0,tel.value.length);
1621 ConfigurationAPI.saveModifiedTables =
function(modifiedTables,responseHandler,
1622 doNotIgnoreWarnings,doNotSaveAffectedGroups,
1623 doNotActivateAffectedGroups,doNotSaveAliases,
1624 doNotIgnoreGroupActivationWarnings,
1629 var savedTables = [];
1630 var savedGroups = [];
1631 var savedAliases = [];
1633 if(!modifiedTables.length)
1635 Debug.log(
"No tables were modified. Nothing to do.", Debug.WARN_PRIORITY);
1636 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1652 var numberOfRequests = 0;
1653 var numberOfReturns = 0;
1654 var allRequestsSent =
false;
1658 function localHandleAffectedGroups()
1660 Debug.log(
"Done with table saving.");
1664 var activatingSavedGroups;
1665 var doRequestAffectedGroups =
false;
1669 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-bumpGroupVersions").checked;
1671 activatingSavedGroups =
1672 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-activateBumpedGroupVersions").checked;
1676 savingGroups = !doNotSaveAffectedGroups;
1677 activatingSavedGroups = !doNotActivateAffectedGroups;
1678 doRequestAffectedGroups =
true;
1684 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1685 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
1686 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1696 Debug.log(
"On to saving groups");
1698 numberOfRequests = 0;
1699 numberOfReturns = 0;
1700 allRequestsSent =
false;
1702 var affectedGroupNames = [];
1703 var affectedGroupComments = [];
1704 var affectedGroupTableMap = [];
1706 var affectedGroupKeys = [];
1708 if(doRequestAffectedGroups)
1711 var modifiedTablesListStr =
"";
1712 var modTblCount = 0;
1714 for(var j=0;j<modifiedTables.length;++j)
1715 if((modifiedTables[j].tableVersion|0) < -1)
1719 modTblStr += modifiedTables[j].tableName;
1721 if(modifiedTablesListStr.length)
1722 modifiedTablesListStr +=
",";
1723 modifiedTablesListStr += modifiedTables[j].tableName;
1724 modifiedTablesListStr +=
",";
1725 modifiedTablesListStr += modifiedTables[j].tableVersion;
1731 DesktopContent.XMLHttpRequest(
"Request?RequestType=getAffectedActiveGroups" +
1734 "&modifiedTables=" + modifiedTablesListStr,
1737 var err = DesktopContent.getXMLValue(req,
"Error");
1740 Debug.log(err,Debug.HIGH_PRIORITY);
1742 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1747 var groups = req.responseXML.getElementsByTagName(
"AffectedActiveGroup");
1748 var memberNames, memberVersions;
1751 for(var i=0;i<groups.length;++i)
1753 affectedGroupNames.push( DesktopContent.getXMLValue(groups[i],
"GroupName"));
1754 affectedGroupComments.push(decodeURIComponent(DesktopContent.getXMLValue(groups[i],
"GroupComment")));
1756 memberNames = groups[i].getElementsByTagName(
"MemberName");
1757 memberVersions = groups[i].getElementsByTagName(
"MemberVersion");
1759 Debug.log(
"memberNames.length " + memberNames.length);
1762 affectedGroupTableMap[i] =
"tableList=";
1763 var memberVersion, memberName;
1764 for(var j=0;j<memberNames.length;++j)
1766 memberVersion = DesktopContent.getXMLValue(memberVersions[j])|0;
1767 memberName = DesktopContent.getXMLValue(memberNames[j]);
1768 if(memberVersion < -1)
1770 Debug.log(
"affectedArr " + memberName +
"-v" + memberVersion);
1772 for(var k=0;k<savedTables.length;++k)
1773 if(memberName == savedTables[k].tableName)
1775 Debug.log(
"found " + savedTables[k].tableName +
"-v" +
1776 savedTables[k].tableVersion);
1777 affectedGroupTableMap[i] += memberName +
"," +
1778 savedTables[k].tableVersion +
",";
1783 affectedGroupTableMap[i] += memberName +
1784 "," + memberVersion +
",";
1788 localHandleSavingAffectedGroups();
1794 var affectedGroupEls =
1795 document.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
1797 var affectedGroupCommentEls =
1798 document.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
1799 "-groupComment-cache");
1802 for(var i=0;i<affectedGroupEls.length;++i)
1804 Debug.log(affectedGroupEls[i].textContent);
1805 Debug.log(
"group comment: " + affectedGroupCommentEls[i].textContent);
1807 var affectedArr = affectedGroupEls[i].textContent.split(
',');
1809 affectedGroupComments.push(affectedGroupCommentEls[i].textContent);
1810 affectedGroupNames.push(affectedArr[0]);
1813 affectedGroupTableMap[i] =
"tableList=";
1815 for(var a=2;a<affectedArr.length;a+=2)
1816 if((affectedArr[a+1]|0) < -1)
1818 Debug.log(
"affectedArr " + affectedArr[a] +
"-v" + affectedArr[a+1]);
1820 for(var k=0;k<savedTables.length;++k)
1821 if(affectedArr[a] == savedTables[k].tableName)
1823 Debug.log(
"found " + savedTables[k].tableName +
"-v" +
1824 savedTables[k].tableVersion);
1825 affectedGroupTableMap[i] += affectedArr[a] +
"," +
1826 savedTables[k].tableVersion +
",";
1831 affectedGroupTableMap[i] += affectedArr[a] +
"," + affectedArr[a+1] +
",";
1834 localHandleSavingAffectedGroups();
1839 function localHandleSavingAffectedGroups()
1842 for(var i=0;i<affectedGroupNames.length;++i)
1845 reqStr =
"Request?RequestType=saveNewTableGroup" +
1846 "&groupName=" + affectedGroupNames[i] +
1847 "&allowDuplicates=0" +
1848 "&lookForEquivalent=1" +
1849 "&ignoreWarnings=" + (doNotIgnoreWarnings?0:1) +
1850 "&groupComment=" + encodeURIComponent(affectedGroupComments[i]);
1852 Debug.log(affectedGroupTableMap[i]);
1856 DesktopContent.XMLHttpRequest(reqStr, affectedGroupTableMap[i],
1857 function(req,affectedGroupIndex)
1860 var attemptedNewGroupName = DesktopContent.getXMLValue(req,
"AttemptedNewGroupName");
1861 var treeErr = DesktopContent.getXMLValue(req,
"TreeErrors");
1864 Debug.log(treeErr,Debug.HIGH_PRIORITY);
1865 Debug.log(
"There were problems identified in the tree view of the " +
1866 "attempted new group '" +
1867 attemptedNewGroupName +
1868 "'.\nThe new group was not created.\n" +
1869 "(Note: Other tables and groups may have been successfully created, " +
1870 "and would have success indications below this error info)\n\n" +
1871 "You can save the group anyway (if you think it is a good idea) by clicking " +
1872 "the button in the pop-up dialog " +
1873 "'<u>Save Groups with Warnings Ignored</u>.' " +
1874 "\n\nOtherwise, you can hit '<u>Cancel</u>.' and fix the tree. " +
1875 "Below you will find the description of the problem:",
1876 Debug.HIGH_PRIORITY);
1879 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-submitButton");
1882 el.onmouseup =
function() {
1883 Debug.log(
"Submit mouseup");
1884 this.disabled =
true;
1885 ConfigurationAPI.handleGroupCommentToggle(0,1);
1886 ConfigurationAPI.handlePopUpHeightToggle(h,gh);
1889 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1890 "-bumpGroupVersions").checked;
1891 var activatingSavedGroups =
1892 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1893 "-activateBumpedGroupVersions").checked;
1895 ConfigurationAPI.saveModifiedTables(modifiedTables,responseHandler,
1897 doNotSaveAffectedGroups,
1898 doNotActivateAffectedGroups,doNotSaveAliases
1901 el.value =
"Save Groups with Warnings Ignored";
1902 el.disabled =
false;
1907 var err = DesktopContent.getXMLValue(req,
"Error");
1910 Debug.log(err,Debug.HIGH_PRIORITY);
1913 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1914 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
1915 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1921 var newGroupKey = DesktopContent.getXMLValue(req,
"TableGroupKey");
1922 affectedGroupKeys.push(newGroupKey);
1926 obj.groupName = attemptedNewGroupName;
1927 obj.groupKey = newGroupKey;
1928 obj.groupComment = affectedGroupComments[affectedGroupIndex];
1929 savedGroups.push(obj);
1933 var foundEquivalentKey = DesktopContent.getXMLValue(req,
"foundEquivalentKey");
1934 if(foundEquivalentKey)
1935 Debug.log(
"Using existing group '" + attemptedNewGroupName +
1936 " (" + newGroupKey +
")'", Debug.INFO_PRIORITY);
1938 Debug.log(
"Successfully created new group '" + attemptedNewGroupName +
1939 " (" + newGroupKey +
")'", Debug.INFO_PRIORITY);
1944 if(activatingSavedGroups)
1945 ConfigurationAPI.activateGroup(attemptedNewGroupName,newGroupKey,
1946 doNotIgnoreGroupActivationWarnings?
false:
true );
1949 if(allRequestsSent &&
1950 numberOfReturns == numberOfRequests)
1952 Debug.log(
"Done with group saving.");
1954 Debug.log(
"Moving on to Alias creation...");
1962 var setAliasCheckboxes;
1964 var groupAlias, groupName, groupKey;
1965 var setAliasCheckboxIndex = -1;
1966 var groupAliasName, groupAliasVersion;
1968 var affectedGroupAliases = [];
1981 setAliasCheckboxes =
1982 document.getElementsByClassName(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias");
1985 if(setAliasCheckboxes.length != affectedGroupNames.length)
1989 localNextAliasHandler();
1990 Debug.log(
"Aliases set in motion");
1995 setAliasCheckboxes = [];
1996 for(var i in affectedGroupNames)
1997 setAliasCheckboxes.push({
"checked" : ((!doNotSaveAliases)?1:0) });
2007 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
2012 var err = DesktopContent.getXMLValue(req,
"Error");
2015 Debug.log(err,Debug.HIGH_PRIORITY);
2016 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2020 var aliases = req.responseXML.getElementsByTagName(
"GroupAlias");
2021 var aliasGroupNames = req.responseXML.getElementsByTagName(
"GroupName");
2022 var aliasGroupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
2027 var alias, aliasGroupName, aliasGroupKey;
2028 var groupName, groupKey;
2029 var groupOptionIndex = [];
2030 for(var i=0;i<affectedGroupNames.length;++i)
2032 groupOptionIndex.push([-1,0]);
2034 groupName = affectedGroupNames[i];
2035 groupKey = affectedGroupKeys[i];
2038 for(var j=0;j<aliasGroupNames.length;++j)
2040 alias = DesktopContent.getXMLValue(aliases[j]);
2041 aliasGroupName = DesktopContent.getXMLValue(aliasGroupNames[j]);
2042 aliasGroupKey = DesktopContent.getXMLValue(aliasGroupKeys[j]);
2048 if(aliasGroupName == groupName)
2050 if(groupOptionIndex[i][0] == -1 ||
2051 Math.abs(groupKey - aliasGroupKey) < groupOptionIndex[i][1])
2053 Debug.log(
"found alias");
2054 groupOptionIndex[i][0] = j;
2055 groupOptionIndex[i][1] = Math.abs(groupKey - aliasGroupKey);
2061 setAliasCheckboxes[i].checked = (groupOptionIndex[i][0] >= 0?1:0);
2063 affectedGroupAliases.push(groupOptionIndex[i][0] >= 0?
2064 DesktopContent.getXMLValue(aliases[groupOptionIndex[i][0]]):
"");
2068 localNextAliasHandler();
2069 Debug.log(
"Aliases set in motion");
2082 function localNextAliasHandler(retParams)
2085 if(setAliasCheckboxIndex >= 0)
2089 if(retParams.newGroupCreated)
2091 Debug.log(
"Successfully modified the active Backbone group " +
2092 " to set the System Alias '" + groupAlias +
"' to " +
2093 " refer to the current group '" + groupName +
2094 " (" + groupKey +
").'" +
2096 "Backbone group '" + retParams.groupName +
" (" +
2097 retParams.groupKey +
")' was created and activated.",
2098 Debug.INFO_PRIORITY);
2102 obj.groupName = groupName;
2103 obj.groupKey = groupKey;
2104 obj.groupAlias = groupAlias;
2105 savedAliases.push(obj);
2109 Debug.log(
"Success, but no need to create a new Backbone group. " +
2110 "An existing Backbone group " +
2111 " already has the System Alias '" + groupAlias +
"' " +
2112 " referring to the current group '" + groupName +
2113 " (" + groupKey +
").'" +
2115 "Backbone group '" + retParams.groupName +
" (" +
2116 retParams.groupKey +
")' was activated.",
2117 Debug.INFO_PRIORITY);
2121 Debug.log(
"Process interrupted. Failed to modify the currently active Backbone!",Debug.HIGH_PRIORITY);
2124 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2125 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2126 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2130 ++setAliasCheckboxIndex;
2133 setAliasCheckboxIndex = 0;
2136 while(setAliasCheckboxIndex < setAliasCheckboxes.length &&
2137 !setAliasCheckboxes[setAliasCheckboxIndex].checked)
2138 Debug.log(
"Skipping checkbox " + (++setAliasCheckboxIndex));
2140 if(setAliasCheckboxIndex >= setAliasCheckboxes.length)
2142 Debug.log(
"Done with alias checkboxes ");
2146 Debug.log(
"No System Aliases were changed, so Backbone was not modified. Done.");
2149 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2150 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2151 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2155 Debug.log(
"Saving and activating Backbone done.");
2158 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2159 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2160 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2167 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" +
2168 setAliasCheckboxIndex);
2169 if(el.style.display ==
"none")
2172 el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-" +
2173 setAliasCheckboxIndex);
2175 groupAlias = el.value;
2181 groupAlias = affectedGroupAliases[setAliasCheckboxIndex];
2184 groupName = affectedGroupNames[setAliasCheckboxIndex];
2185 groupKey = affectedGroupKeys[setAliasCheckboxIndex];
2187 Debug.log(
"groupAlias = " + groupAlias);
2188 Debug.log(
"groupName = " + groupName);
2189 Debug.log(
"groupKey = " + groupKey);
2191 ConfigurationAPI.setGroupAliasInActiveBackbone(groupAlias,groupName,groupKey,
2193 localNextAliasHandler,
2203 allRequestsSent =
true;
2204 if(numberOfRequests == 0)
2207 Debug.log(
"There were no groups to save!", Debug.INFO_PRIORITY);
2210 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2211 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2221 for(var j=0;j<modifiedTables.length;++j)
2222 if((modifiedTables[j].tableVersion|0) < -1)
2224 var reqStr =
"Request?RequestType=saveSpecificTable" +
2225 "&dataOffset=0&chunkSize=0" +
2226 "&tableName=" + modifiedTables[j].tableName +
2227 "&version="+modifiedTables[j].tableVersion +
2230 encodeURIComponent(modifiedTables[j].tableComment?modifiedTables[j].tableComment:
"") +
2231 "&sourceTableAsIs=1" +
2232 "&lookForEquivalent=1";
2239 DesktopContent.XMLHttpRequest(reqStr,
"",
2240 function(req,modifiedTableIndex)
2242 var err = DesktopContent.getXMLValue(req,
"Error");
2245 Debug.log(err,Debug.HIGH_PRIORITY);
2248 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2250 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2254 var tableName = DesktopContent.getXMLValue(req,
"savedName");
2255 var version = DesktopContent.getXMLValue(req,
"savedVersion");
2256 var foundEquivalentVersion = DesktopContent.getXMLValue(req,
"foundEquivalentVersion") | 0;
2258 if(foundEquivalentVersion)
2259 Debug.log(
"Using existing table '" + tableName +
"-v" +
2260 version +
"'",Debug.INFO_PRIORITY);
2262 Debug.log(
"Successfully created new table '" + tableName +
"-v" +
2263 version +
"'",Debug.INFO_PRIORITY);
2268 obj.tableName = tableName;
2269 obj.tableVersion = version;
2270 obj.tableComment = modifiedTables[modifiedTableIndex].tableComment;
2271 savedTables.push(obj);
2276 if(allRequestsSent &&
2277 numberOfReturns == numberOfRequests)
2279 if(!doNotSaveAffectedGroups)
2280 localHandleAffectedGroups();
2286 allRequestsSent =
true;
2287 if(numberOfRequests == 0)
2290 Debug.log(
"No tables were modified. Should be impossible to get here.", Debug.HIGH_PRIORITY);
2297 ConfigurationAPI.activateGroup =
function(groupName, groupKey,
2298 ignoreWarnings, doneHandler)
2300 DesktopContent.XMLHttpRequest(
"Request?RequestType=activateTableGroup" +
2301 "&groupName=" + groupName +
2302 "&groupKey=" + groupKey +
2303 "&ignoreWarnings=" + (ignoreWarnings?
"1":
"0") +
2309 var err = DesktopContent.getXMLValue(req,
"Error");
2312 Debug.log(err,Debug.HIGH_PRIORITY);
2320 str +=
" <a href='#' onclick='javascript:ConfigurationAPI.activateGroup(\"" +
2322 "\",\"" + groupKey +
"\",true); return false;'>";
2323 str +=
"Activate " +
2324 groupName +
"(" + groupKey +
") w/warnings ignored</a>";
2326 Debug.log(
"If you are are sure it is a good idea you can try to " +
2327 "activate the group with warnings ignored: " +
2328 str,Debug.HIGH_PRIORITY);
2332 if(doneHandler) doneHandler();
2350 ConfigurationAPI.setGroupAliasInActiveBackbone =
function(groupAlias,groupName,groupKey,
2351 newBackboneNameAdd,doneHandler,doReturnParams)
2353 Debug.log(
"setGroupAliasInActiveBackbone groupAlias=" + groupAlias);
2354 Debug.log(
"setGroupAliasInActiveBackbone groupName=" + groupName);
2355 Debug.log(
"setGroupAliasInActiveBackbone groupKey=" + groupKey);
2357 if(!groupAlias || groupAlias.trim() ==
"")
2359 Debug.log(
"Process interrupted. Invalid empty alias given!",Debug.HIGH_PRIORITY);
2360 if(doneHandler) doneHandler();
2364 if(!groupName || groupName.trim() ==
"" || !groupKey || groupKey.trim() ==
"")
2366 Debug.log(
"Process interrupted. Invalid group name and key given!",Debug.HIGH_PRIORITY);
2367 if(doneHandler) doneHandler();
2371 if(!newBackboneNameAdd || newBackboneNameAdd ==
"")
2372 newBackboneNameAdd =
"Wiz";
2373 newBackboneNameAdd +=
"Backbone";
2374 Debug.log(
"setGroupAliasInActiveBackbone newBackboneNameAdd=" + newBackboneNameAdd);
2376 DesktopContent.XMLHttpRequest(
"Request?RequestType=setGroupAliasInActiveBackbone" +
2377 "&groupAlias=" + groupAlias +
2378 "&groupName=" + groupName +
2379 "&groupKey=" + groupKey,
"",
2380 ConfigurationAPI.newWizBackboneMemberHandler,
2381 [(
"GroupAlias" + newBackboneNameAdd),doneHandler,doReturnParams],
2393 ConfigurationAPI.newWizBackboneMemberHandler =
function(req,params)
2395 var err = DesktopContent.getXMLValue(req,
"Error");
2398 Debug.log(err,Debug.HIGH_PRIORITY);
2399 Debug.log(
"Process interrupted. Failed to modify the currently active Backbone!",Debug.HIGH_PRIORITY);
2406 var groupAliasName = DesktopContent.getXMLValue(req,
"savedName");
2407 var groupAliasVersion = DesktopContent.getXMLValue(req,
"savedVersion");
2409 Debug.log(
"groupAliasName=" + groupAliasName);
2410 Debug.log(
"groupAliasVersion=" + groupAliasVersion);
2412 var configNames = req.responseXML.getElementsByTagName(
"oldBackboneName");
2413 var tableVersions = req.responseXML.getElementsByTagName(
"oldBackboneVersion");
2416 var tableMap =
"tableList=";
2418 for(var i=0;i<configNames.length;++i)
2420 name = configNames[i].getAttribute(
"value");
2422 if(name == groupAliasName)
2424 tableMap += name +
"," +
2425 groupAliasVersion +
",";
2429 tableMap += name +
"," +
2430 tableVersions[i].getAttribute(
"value") +
",";
2433 console.log(
"backbone tableMap",tableMap);
2435 ConfigurationAPI.saveGroupAndActivate(params[0],tableMap,params[1],params[2],
2441 ConfigurationAPI.saveGroupAndActivate =
function(groupName,tableMap,doneHandler,doReturnParams,
2444 DesktopContent.XMLHttpRequest(
"Request?RequestType=saveNewTableGroup&groupName=" +
2446 "&allowDuplicates=" + (lookForEquivalent?
"0":
"1") +
2447 "&lookForEquivalent=" + (lookForEquivalent?
"1":
"0") +
2452 var err = DesktopContent.getXMLValue(req,
"Error");
2453 var name = DesktopContent.getXMLValue(req,
"TableGroupName");
2454 var key = DesktopContent.getXMLValue(req,
"TableGroupKey");
2455 var newGroupCreated =
true;
2460 Debug.log(err,Debug.HIGH_PRIORITY);
2461 Debug.log(
"Process interrupted. Failed to create a new group!" +
2462 " Please see details below.",
2463 Debug.HIGH_PRIORITY);
2465 if(doneHandler) doneHandler();
2470 Debug.log(err,Debug.WARN_PRIORITY);
2471 Debug.log(
"Process interrupted. Failed to create a new group!" +
2472 " (Likely the currently active group already represents what is being requested)\n\n" +
2473 "Going on with existing backbone group, name=" + name +
" & key=" + key,
2474 Debug.WARN_PRIORITY);
2475 newGroupCreated =
false;
2481 DesktopContent.XMLHttpRequest(
"Request?RequestType=activateTableGroup" +
2482 "&groupName=" + name +
2483 "&groupKey=" + key,
"",
2488 activateSystemConfigHandler(req);
2502 "newGroupCreated" : newGroupCreated
2504 doneHandler(retParams);
2522 ConfigurationAPI.getGroupTypeMemberNames =
function(groupType,responseHandler)
2524 DesktopContent.XMLHttpRequest(
"Request?RequestType=get" + groupType +
"MemberNames",
"",
2529 var err = DesktopContent.getXMLValue(req,
"Error");
2532 Debug.log(err,Debug.HIGH_PRIORITY);
2533 if(responseHandler) responseHandler(retArr);
2536 var memberNames = req.responseXML.getElementsByTagName(groupType +
"Member");
2538 for(var i=0;i<memberNames.length;++i)
2539 retArr[i] = memberNames[i].getAttribute(
"value");
2541 Debug.log(
"Members found for group type " + groupType +
" = " + retArr.length);
2542 if(responseHandler) responseHandler(retArr);
2558 ConfigurationAPI.bitMapDialog =
function(fieldName,bitMapParams,initBitMapValue,okHandler,cancelHandler)
2560 Debug.log(
"ConfigurationAPI bitMapDialog");
2564 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2567 el = document.createElement(
"div");
2568 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
2570 el.style.display =
"none";
2571 el.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmapDialog");
2637 var minValue, maxValue;
2641 var forcedAspectH, forcedAspectW;
2643 var minValueColor, midValueColor, maxValueColor;
2644 var ceilValueColor, floorValueColor;
2646 var doDisplayRowsAscending, doDisplayColsAscending;
2647 var doSnakeColumns, doSnakeRows;
2650 if(!localValidateInputs())
2652 Debug.log(
"Input parameters array to the Bitmap Dialog was as follows:\n " +
2653 bitMapParams, Debug.HIGH_PRIORITY);
2654 Debug.log(
"Input parameters to the Bitmap Dialog are invalid. Aborting.", Debug.HIGH_PRIORITY);
2655 return cancelHandler();
2659 var numberDigitW = 8, numberDigitH = 12;
2660 var axisPaddingExtra = numberDigitW;
2661 function localCalcExtraAxisPadding() {
2663 while((lrows /= 10) > 1) axisPaddingExtra += numberDigitW;
2664 } localCalcExtraAxisPadding();
2666 var axisPaddingMargin = 5;
2667 var axisPadding = axisPaddingMargin + axisPaddingExtra + axisPaddingMargin + butttonSz + axisPaddingMargin;
2668 var bmpGridThickness = 1;
2669 var bmpBorderSize = 1;
2680 var allRowBtns, allColBtns, allBtn;
2681 var rowLeftNums, rowRightNums, colTopNums, colBottomNums;
2682 var bmpCanvas, bmpContext;
2690 var cursorInfo, hdrCursorInfo;
2695 var clickColors = [];
2696 var clickValues = [];
2699 localCreateHeader();
2700 localCreateBitmap();
2701 localCreateGridButtons();
2703 localInitBitmapData();
2706 window.addEventListener(
"resize",localPaint);
2708 document.body.appendChild(el);
2709 el.style.display =
"block";
2715 function localCreateCancelClickHandler()
2717 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2718 "-cancel").onclick =
function(event) {
2719 Debug.log(
"Cancel click");
2720 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2721 if(el) el.parentNode.removeChild(el);
2722 window.removeEventListener(
"resize",localPaint);
2726 } localCreateCancelClickHandler();
2731 function localCreateOkClickHandler()
2733 var convertFunc = localConvertFullGridToRowCol;
2734 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2735 "-ok").onclick =
function(event) {
2736 Debug.log(
"OK click");
2737 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2738 if(el) el.parentNode.removeChild(el);
2739 window.removeEventListener(
"resize",localPaint);
2741 var transGrid = convertFunc();
2742 var dataJsonStr =
"[\n";
2743 for(var r=0;r<transGrid.length;++r)
2745 if(r) dataJsonStr +=
",\n";
2746 dataJsonStr +=
"\t[";
2747 for(var c=0;c<transGrid[0].length;++c)
2749 if(c) dataJsonStr +=
",";
2750 dataJsonStr += transGrid[r][c];
2754 dataJsonStr +=
"\n]";
2755 okHandler(dataJsonStr);
2758 } localCreateOkClickHandler();
2763 function localCreateMouseHandler()
2765 var stopProp =
false;
2766 var rLast = -1, cLast = -1;
2768 var buttonDown = -1;
2775 function localGetRowCol(x,y) {
2776 x -= popSz.x + bmpX + 1;
2777 y -= popSz.y + bmpY + 1;
2778 var r = (y/cellH)|0;
2780 var c = (x/cellW)|0;
2782 var inRowBtnsX = (x >= - axisPaddingMargin - bmpBorderSize - butttonSz) &&
2783 (x <= - axisPaddingMargin - bmpBorderSize);
2784 var inColBtnsY = (y >= bmpH + axisPaddingMargin) &&
2785 (y <= bmpH + axisPaddingMargin + butttonSz + bmpBorderSize*2);
2793 if(inRowBtnsX && r >= 0 && r < rows)
2794 return {
"r":r,
"c":-2};
2795 else if(inColBtnsY && c >= 0 && c < cols)
2796 return {
"r":-2,
"c":c};
2797 else if(inRowBtnsX && inColBtnsY)
2798 return {
"r":-2,
"c":-2};
2799 else if(r < 0 || c < 0 || r >= rows || c >= cols)
2800 return {
"r":-1,
"c":-1};
2801 return {
"r":r,
"c":c};
2806 el.onmousemove =
function(event) {
2807 var cell = localGetRowCol(event.pageX,event.pageY);
2808 var r = cell.r, c = cell.c;
2810 var cursorT = (
event.pageX - popSz.x - bmpX);
2811 if(cursorT < 0) cursorT = 0;
2812 if(cursorT > bmpW) cursorT = bmpW;
2814 cursorInfo.style.left = (
event.pageX - popSz.x +
2817 (cursorT)/bmpW*(-cursorInfo.innerHTML.length*8-20) + (bmpW-cursorT)/bmpW*(2))+
2819 cursorInfo.style.top = (
event.pageY - popSz.y - 35) +
"px";
2822 hdrCursorInfo.style.left = (bmpX + bmpW/2 +
2824 hdrCursorInfo.style.top = (bmpY - 45) +
"px";
2827 if(rLast == r && cLast == c)
2829 rLast = r; cLast = c;
2831 if(r == -1 || c == -1)
2834 rLast = -1; cLast = -1;
2835 bmpOverlay.style.display =
"none";
2836 cursorInfo.style.display =
"none";
2837 hdrCursorInfo.style.display =
"none";
2841 cursorInfo.style.display =
"block";
2848 if(r != -2 && c == -2)
2851 transRC = localConvertGridToRowCol(r,
2852 doDisplayColsAscending?0:cols-1);
2854 transRC = localConvertGridToRowCol(r,0);
2858 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2860 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2861 bmpOverlay.style.top = (bmpY + r*cellH - 1 + (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2862 bmpOverlay.style.width = (butttonSz) +
"px";
2863 bmpOverlay.style.height = (cellH - (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2864 bmpOverlay.style.display =
"block";
2867 infoStr =
"Set all pixels in row " + transRC[0] +
".";
2869 else if(r == -2 && c != -2)
2872 transRC = localConvertGridToRowCol(
2873 doDisplayRowsAscending?0:rows-1,c);
2875 transRC = localConvertGridToRowCol(0,c);
2880 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2882 bmpOverlay.style.left = (bmpX + c*cellW - 1 + (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2883 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2884 bmpOverlay.style.width = (cellW + 1 - (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2885 bmpOverlay.style.height = (butttonSz) +
"px";
2886 bmpOverlay.style.display =
"block";
2889 infoStr =
"Set all pixels in column " + transRC[1] +
".";
2891 else if(r == -2 && c == -2)
2895 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2897 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2898 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2899 bmpOverlay.style.width = (butttonSz) +
"px";
2900 bmpOverlay.style.height = (butttonSz) +
"px";
2901 bmpOverlay.style.display =
"block";
2904 infoStr =
"Set all pixels.";
2908 transRC = localConvertGridToRowCol(r,c);
2914 var overClr = (bmpDataImage.data[(r*cols+c)*4+0] +
2915 bmpDataImage.data[(r*cols+c)*4+1] +
2916 bmpDataImage.data[(r*cols+c)*4+2]) < (256+128)?255:0;
2918 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData(
2919 [overClr,overClr,overClr,100]);
2921 bmpOverlay.style.left = (bmpX + c*cellW) +
"px";
2922 bmpOverlay.style.top = (bmpY + r*cellH) +
"px";
2923 bmpOverlay.style.width = (cellW) +
"px";
2924 bmpOverlay.style.height = (cellH) +
"px";
2925 bmpOverlay.style.display =
"block";
2929 infoStr =
"Value = " + bmpData[r][c] +
" @ (Row,Col) = (" +
2930 transRC[0] +
"," + transRC[1] +
")";
2932 cursorInfo.innerHTML = infoStr;
2933 hdrCursorInfo.innerHTML = infoStr;
2936 if(r == -2 && c == -2)
2942 localSetBitMap(r,c);
2949 el.onmousedown =
function(event) {
2951 var cell = localGetRowCol(event.pageX,event.pageY);
2952 var r = cell.r, c = cell.c;
2956 buttonDown =
event.button;
2958 if(r == -1 || c == -1)
2960 rLast = -1; cLast = -1;
2965 rLast = r; cLast = c;
2966 localSetBitMap(r,c);
2969 event.stopPropagation();
2975 el.onmouseup =
function(event) {
2982 el.oncontextmenu =
function(event) {
2988 event.stopPropagation();
2995 function localSetBitMap(r,c) {
2997 Debug.log(
"set r,c " + buttonDown +
" @ " + r +
"," + c );
2998 buttonDown = buttonDown?1:0;
3000 var maxr = r==-2?rows-1:r;
3001 var minr = r==-2?0:r;
3002 var maxc = c==-2?cols-1:c;
3003 var minc = c==-2?0:c;
3005 for(r=minr;r<=maxr;++r)
3006 for(c=minc;c<=maxc;++c)
3008 bmpData[r][c] = clickValues[buttonDown];
3009 bmpDataImage.data[(r*cols + c)*4 + 0] =
3010 clickColors[buttonDown][0];
3011 bmpDataImage.data[(r*cols + c)*4 + 1] =
3012 clickColors[buttonDown][1];
3013 bmpDataImage.data[(r*cols + c)*4 + 2] =
3014 clickColors[buttonDown][2];
3015 bmpDataImage.data[(r*cols + c)*4 + 3] =
3016 clickColors[buttonDown][3];
3019 bmpContext.putImageData(bmpDataImage,0,0);
3020 bmp.src = bmpCanvas.toDataURL();
3023 } localCreateMouseHandler();
3029 function localValidateInputs() {
3032 if(bitMapParams.length != 16)
3034 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)." +
3035 "\nHere is a printout of the input parameters: " + bitMapParams,Debug.HIGH_PRIORITY);
3038 var DEFAULT =
"DEFAULT";
3040 rows = bitMapParams[0]|0;
3041 cols = bitMapParams[1]|0;
3042 bitFieldSize = bitMapParams[2]|0;
3046 if(rows < 1 || rows >= 1<<30)
3048 Debug.log(
"Illegal input parameters, rows of " + rows +
" is illegal. " +
3049 "(rows possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3052 if(cols < 1 || cols >= 1<<30)
3054 Debug.log(
"Illegal input parameters, cols of " + cols +
" is illegal. " +
3055 "(cols possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3058 if(bitFieldSize < 1 || bitFieldSize > 31)
3060 Debug.log(
"Illegal input parameters, bitFieldSize of " + bitFieldSize +
" is illegal. " +
3061 "(bitFieldSize possible values are from 1 to " + (31) +
".)",Debug.HIGH_PRIORITY);
3066 if(bitFieldSize > 30)
3069 for(var i=0;i<bitFieldSize;++i)
3073 bitMask = (1<<bitFieldSize) - 1;
3075 minValue = bitMapParams[3] ==
"DEFAULT" || bitMapParams[3] ==
""?0:(bitMapParams[3]|0);
3076 maxValue = bitMapParams[4] ==
"DEFAULT" || bitMapParams[4] ==
""?bitMask:(bitMapParams[4]|0);
3077 if(maxValue < minValue)
3079 midValue = (maxValue + minValue)/2;
3080 stepValue = bitMapParams[5] ==
"DEFAULT" || bitMapParams[5] ==
""?1:(bitMapParams[5]|0);
3082 if(minValue < 0 || minValue > bitMask)
3084 Debug.log(
"Illegal input parameters, minValue of " + minValue +
" is illegal. " +
3085 "(minValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3088 if(maxValue < 0 || maxValue > bitMask)
3090 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
" is illegal. " +
3091 "(maxValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3094 if(minValue > maxValue)
3096 Debug.log(
"Illegal input parameters, minValue > maxValue is illegal.",Debug.HIGH_PRIORITY);
3099 if(stepValue < 1 || stepValue > maxValue - minValue)
3101 Debug.log(
"Illegal input parameters, stepValue of " + stepValue +
" is illegal. " +
3102 "(stepValue possible values are from 1 to " + (maxValue - minValue) +
".)",Debug.HIGH_PRIORITY);
3105 if((((maxValue-minValue)/stepValue)|0) != (maxValue-minValue)/stepValue)
3107 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
3108 " must be an integer number of stepValue (stepValue=" + stepValue +
3109 ") steps away from minValue (minValue=" + minValue +
").",Debug.HIGH_PRIORITY);
3113 if(bitMapParams[6] !=
"" &&
3114 bitMapParams[6] != DEFAULT)
3116 forcedAspectH = bitMapParams[6].split(
':');
3117 if(forcedAspectH.length != 2)
3119 Debug.log(
"Illegal input parameter, expecting ':' in string defining cell display aspect ratio " +
3120 "Height:Width (e.g. 100:150)." +
3121 "\nInput aspect ratio string '" + bitMapParams[6] +
"' is invalid.",Debug.HIGH_PRIORITY);
3124 forcedAspectW = forcedAspectH[1].trim()|0;
3125 forcedAspectH = forcedAspectH[0].trim()|0;
3128 forcedAspectW = forcedAspectH = 1;
3132 minValueColor = bitMapParams[7] == DEFAULT || bitMapParams[7] ==
""?
"red":bitMapParams[7];
3133 midValueColor = bitMapParams[8] == DEFAULT || bitMapParams[8] ==
""?
"yellow":bitMapParams[8];
3134 maxValueColor = bitMapParams[9] == DEFAULT || bitMapParams[9] ==
""?
"green":bitMapParams[9];
3135 floorValueColor = bitMapParams[10] == DEFAULT || bitMapParams[10] ==
""?minValueColor:bitMapParams[10];
3136 ceilValueColor = bitMapParams[11] == DEFAULT || bitMapParams[11] ==
""?maxValueColor:bitMapParams[11];
3139 minValueColor = DesktopContent.getColorAsRGBA(minValueColor).split(
"(")[1].split(
")")[0].split(
",");
3140 midValueColor = DesktopContent.getColorAsRGBA(midValueColor).split(
"(")[1].split(
")")[0].split(
",");
3141 maxValueColor = DesktopContent.getColorAsRGBA(maxValueColor).split(
"(")[1].split(
")")[0].split(
",");
3142 ceilValueColor = DesktopContent.getColorAsRGBA(ceilValueColor).split(
"(")[1].split(
")")[0].split(
",");
3143 floorValueColor = DesktopContent.getColorAsRGBA(floorValueColor).split(
"(")[1].split(
")")[0].split(
",");
3146 doDisplayRowsAscending = bitMapParams[12] ==
"Yes"?1:0;
3147 doDisplayColsAscending = bitMapParams[13] ==
"Yes"?1:0;
3148 doSnakeColumns = bitMapParams[14] ==
"Yes"?1:0;
3149 doSnakeRows = bitMapParams[15] ==
"Yes"?1:0;
3151 if(doSnakeColumns && doSnakeRows)
3153 Debug.log(
"Can not have a bitmap that snakes both rows and columns, please choose one or the other (or neither).",Debug.HIGH_PRIORITY);
3166 function localInitBitmapData()
3173 var jsonMatrix = JSON.parse(initBitMapValue);
3176 for(var r=0;r<rows;++r)
3180 for(var c=0;c<cols;++c)
3183 localConvertFullRowColToGrid(jsonMatrix);
3187 Debug.log(
"The input initial value of the bitmap is illegal JSON format. " +
3188 "See error below: \n\n" + err,Debug.HIGH_PRIORITY);
3189 Debug.log(
"Defaulting to initial bitmap with min-value fill.",Debug.HIGH_PRIORITY);
3193 for(var r=0;r<rows;++r)
3197 for(var c=0;c<cols;++c)
3199 bmpData[r][c] = minValue;
3201 color = localConvertValueToRGBA(bmpData[r][c]);
3202 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3203 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3204 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3205 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3209 bmpContext.putImageData(bmpDataImage,0,0);
3210 bmp.src = bmpCanvas.toDataURL();
3221 function localConvertGridToRowCol(r,c)
3224 if(!doDisplayRowsAscending)
3225 retVal[0] = rows - 1 - retVal[0];
3226 if(!doDisplayColsAscending)
3227 retVal[1] = cols - 1 - retVal[1];
3228 if(doSnakeRows && retVal[0]%2 == 1)
3229 retVal[1] = cols + (cols - 1 - retVal[1]);
3230 if(doSnakeColumns && retVal[1]%2 == 1)
3231 retVal[0] = rows + (rows - 1 - retVal[0]);
3239 function localConvertValueToRGBA(val)
3242 return [ceilValueColor[0],
3248 return [floorValueColor[0],
3254 return [midValueColor[0],
3263 t = (val - minValue)/(midValue - minValue);
3264 return [minValueColor[0]*(1-t) + t*midValueColor[0],
3265 minValueColor[1]*(1-t) + t*midValueColor[1],
3266 minValueColor[2]*(1-t) + t*midValueColor[2],
3272 t = (val - midValue)/(maxValue - midValue);
3273 return [midValueColor[0]*(1-t) + t*maxValueColor[0],
3274 midValueColor[1]*(1-t) + t*maxValueColor[1],
3275 midValueColor[2]*(1-t) + t*maxValueColor[2],
3284 function localConvertFullGridToRowCol()
3288 for(var r=0;r<rows;++r)
3289 for(var c=0;c<cols;++c)
3291 convertedRC = localConvertGridToRowCol(r,c);
3294 convertedRC[1] = (convertedRC[1]/2)|0;
3297 convertedRC[0] = (convertedRC[0]/2)|0;
3299 if(retArr[convertedRC[0]] === undefined)
3300 retArr[convertedRC[0]] = [];
3301 retArr[convertedRC[0]][convertedRC[1]] = bmpData[r][c];
3310 function localConvertFullRowColToGrid(srcMatrix)
3314 var noErrors =
true;
3315 for(var r=0;r<rows;++r)
3316 for(var c=0;c<cols;++c)
3318 convertedRC = localConvertGridToRowCol(r,c);
3322 convertedRC[1] = (convertedRC[1]/2)|0;
3325 convertedRC[0] = (convertedRC[0]/2)|0;
3328 bmpData[r][c] = srcMatrix[convertedRC[0]][convertedRC[1]]|0;
3329 if(bmpData[r][c] < minValue)
3330 throw(
"There was an illegal value less than minValue: " +
3331 bmpData[r][c] +
" < " + minValue +
" @ (row,col) = (" +
3332 convertedRC[0] +
"," + convertedRC[0] +
")");
3333 if(bmpData[r][c] > maxValue)
3334 throw(
"There was an illegal value greater than maxValue: " +
3335 bmpData[r][c] +
" > " + maxValue +
" @ (row,col) = (" +
3336 convertedRC[0] +
"," + convertedRC[0] +
")");
3337 if((((bmpData[r][c]-minValue)/stepValue)|0) != (bmpData[r][c]-minValue)/stepValue)
3338 throw(
"There was an illegal value not following stepValue from minValue: " +
3339 bmpData[r][c] +
" != " +
3340 (stepValue*(((bmpData[r][c]-minValue)/stepValue)|0)) +
3341 " @ (row,col) = (" +
3342 convertedRC[0] +
"," + convertedRC[0] +
")");
3343 color = localConvertValueToRGBA(bmpData[r][c]);
3344 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3345 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3346 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3347 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3352 bmpContext.putImageData(bmpDataImage,0,0);
3353 bmp.src = bmpCanvas.toDataURL();
3356 throw(
"There was a mismatch in row/col dimensions. Input matrix was " +
3357 "dimension [row,col] = [" + srcMatrix.length +
"," +
3358 (srcMatrix.length?srcMatrix[0].length:0) +
"]");
3364 function localCreateBitmap()
3366 bmp = document.createElement(
"img");
3367 bmp.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap");
3369 bmpGrid = document.createElement(
"div");
3370 bmpGrid.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid");
3372 bmpOverlay = document.createElement(
"img");
3373 bmpOverlay.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-overlay");
3375 cursorInfo = document.createElement(
"div");
3376 cursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-info");
3377 hdrCursorInfo = document.createElement(
"div");
3378 hdrCursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-hdrInfo");
3381 rowLeftNums = document.createElement(
"div");
3382 rowRightNums = document.createElement(
"div");
3383 colTopNums = document.createElement(
"div");
3384 colBottomNums = document.createElement(
"div");
3385 rowLeftNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowLeft");
3386 rowRightNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowRight");
3387 colTopNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colTop");
3388 colBottomNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colBottom");
3394 bmpCanvas=document.createElement(
"canvas");
3395 bmpCanvas.width = cols;
3396 bmpCanvas.height = rows;
3397 bmpContext = bmpCanvas.getContext(
"2d");
3399 if(bmpDataImage)
delete bmpDataImage;
3400 bmpDataImage = bmpContext.createImageData(cols,rows);
3403 tmpEl = document.createElement(
"div");
3404 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-box");
3405 bmpGrid.appendChild(tmpEl);
3407 for(var i=0;i<rows;++i)
3411 tmpEl = document.createElement(
"div");
3412 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row-dark");
3413 bmpGrid.appendChild(tmpEl);
3414 tmpEl = document.createElement(
"div");
3415 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row");
3416 bmpGrid.appendChild(tmpEl);
3419 for(var j=0;j<cols;++j)
3421 if(i == rows-1 & j < cols-1)
3423 tmpEl = document.createElement(
"div");
3424 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col-dark");
3425 bmpGrid.appendChild(tmpEl);
3426 tmpEl = document.createElement(
"div");
3427 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col");
3428 bmpGrid.appendChild(tmpEl);
3433 bmpContext.putImageData(bmpDataImage,0,0);
3434 bmp.src = bmpCanvas.toDataURL();
3437 bmp.style.position =
"absolute";
3438 bmp.draggable =
false;
3440 bmpGrid.style.position =
"absolute";
3442 bmpOverlay.style.display =
"none";
3443 bmpOverlay.style.position =
"absolute";
3444 bmpOverlay.draggable =
false;
3446 cursorInfo.style.position =
"absolute";
3447 cursorInfo.style.display =
"none";
3448 hdrCursorInfo.style.position =
"absolute";
3449 hdrCursorInfo.style.display =
"none";
3450 hdrCursorInfo.style.width =
"320px";
3452 rowLeftNums.style.position =
"absolute";
3453 rowRightNums.style.position =
"absolute";
3454 colTopNums.style.position =
"absolute";
3455 colBottomNums.style.position =
"absolute";
3457 el.appendChild(bmp);
3458 el.appendChild(bmpGrid);
3459 el.appendChild(bmpOverlay);
3461 el.appendChild(hdrCursorInfo);
3462 el.appendChild(cursorInfo);
3464 el.appendChild(rowLeftNums);
3465 el.appendChild(rowRightNums);
3466 el.appendChild(colTopNums);
3467 el.appendChild(colBottomNums);
3473 function localCreateGridButtons()
3475 allRowBtns = document.createElement(
"div");
3477 allColBtns = document.createElement(
"div");
3479 allBtn = document.createElement(
"div");
3480 allBtn.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3483 for(var i=0;i<rows;++i)
3485 tmpEl = document.createElement(
"div");
3486 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3487 tmpEl.style.position =
"absolute";
3488 allRowBtns.appendChild(tmpEl);
3490 for(var i=0;i<cols;++i)
3492 tmpEl = document.createElement(
"div");
3493 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3494 tmpEl.style.position =
"absolute";
3495 allColBtns.appendChild(tmpEl);
3498 allRowBtns.style.position =
"absolute";
3499 el.appendChild(allRowBtns);
3500 allColBtns.style.position =
"absolute";
3501 el.appendChild(allColBtns);
3502 allBtn.style.position =
"absolute";
3503 el.appendChild(allBtn);
3509 function localCreateHeader()
3511 hdr = document.createElement(
"div");
3512 hdr.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-header");
3516 str +=
"<div style='float:left; margin: 0 0 20px 0;'>";
3517 str +=
"<div style='float:left; '>";
3525 str +=
"<div style='float:left; margin-left: 50px;'>";
3526 str +=
"Number of [Rows,Cols]: " +
"[" + rows +
"," + cols +
"]";
3530 str +=
"<div style='float:right; '>";
3532 ConfigurationAPI._POP_UP_DIALOG_ID +
3533 "-cancel' href='#'>Cancel</a>";
3536 str +=
"<div id='clearDiv'></div>";
3538 str +=
"<div style='float:right; margin: 40px 20px -50px 0;'>";
3540 ConfigurationAPI._POP_UP_DIALOG_ID +
3541 "-ok' href='#'>OK</a>";
3544 str +=
"<div style='float:left; margin: 0 0 0 0;'>";
3545 for(var clickIndex=0;clickIndex<2;++clickIndex)
3547 str +=
"<div style='float:left; margin: 5px 0 0 0;'>";
3548 str +=
"<div style='float:left; width:180px; text-align:right; margin-top: 3px;'>";
3549 str += (clickIndex?
"Right":
"Left") +
"-Click Value:";
3551 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3552 "-bitmap-scrollbar' style='float:left;' " +
3553 "type='range' min='" + minValue +
3554 "' max='" + maxValue +
"' value='" + (clickIndex?maxValue:minValue) +
3555 "' step='" + stepValue +
3556 "' oninput='ConfigurationAPI.bitMapDialog.localUpdateScroll(" + clickIndex +
")' />";
3557 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3558 "-bitmap-btnInput' style='float:left; margin: 0 1px 0 5px;' " +
3559 "type='button' value='<' " +
3560 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,0)' " +
3561 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,1)' " +
3563 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3564 "-bitmap-btnInput' style='float:left;' " +
3565 "type='button' value='>' " +
3566 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,0)' " +
3567 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,1)' " +
3569 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3570 "-bitmap-textInput' style='float:left; margin: 0 5px 0 5px; width: 50px;' " +
3572 "onchange='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",1)' " +
3573 "onkeydown='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3574 "onkeyup='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3576 str +=
"<img class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3577 "-bitmap-colorSample' style='float:left;width:25px; height:25px; margin: -2px 0 2px 0;' " +
3578 "ondragstart='return false;' " +
3579 "draggable='false'" +
3585 str +=
"<div id='clearDiv'></div>";
3590 str +=
"<div style='float:left; margin: 5px 0 0 40px;'>";
3591 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3592 "-bitmap-btnCsv' style='float:left;' " +
3593 "type='button' value='Download as CSV' " +
3594 "onclick='ConfigurationAPI.bitMapDialog.localDownloadCSV()' " +
3596 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3597 "-bitmap-btnCsv' style='float:left; margin: 0 0 0 10px;' " +
3598 "type='button' value='Upload CSV' " +
3599 "onclick='ConfigurationAPI.bitMapDialog.locaPopupUploadCSV()' " +
3603 hdr.innerHTML = str;
3604 hdr.style.overflowY =
"auto";
3605 hdr.style.position =
"absolute";
3607 var scrollEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-scrollbar");
3608 var textInputEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-textInput");
3609 var colorSampleEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-colorSample");
3614 ConfigurationAPI.bitMapDialog.localUpdateScroll =
function(i)
3616 Debug.log(
"localUpdateScroll " + i);
3618 clickValues[i] = scrollEls[i].value|0;
3619 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3621 textInputEls[i].value = clickValues[i];
3622 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3627 ConfigurationAPI.bitMapDialog.localUpdateTextInput =
function(i,finalChange)
3629 Debug.log(
"localUpdateTextInput " + textInputEls[i].value +
" " + finalChange);
3631 clickValues[i] = textInputEls[i].value|0;
3635 if(clickValues[i] < minValue) clickValues[i] = minValue;
3636 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3637 clickValues[i] = (((clickValues[i]-minValue)/stepValue)|0)*stepValue + minValue;
3638 textInputEls[i].value = clickValues[i];
3642 if(clickValues[i] < minValue)
return;
3643 if(clickValues[i] > maxValue)
return;
3644 if((((clickValues[i]-minValue)/stepValue)|0) != (clickValues[i]-minValue)/stepValue)
3646 Debug.log(
"displaying change");
3648 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3650 scrollEls[i].value = clickValues[i];
3651 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3656 var mouseDownTimer = 0;
3657 ConfigurationAPI.bitMapDialog.localUpdateButtonInput =
function(i,dir,mouseUp,delay)
3659 window.clearInterval(mouseDownTimer);
3662 Debug.log(
"cancel mouse down");
3666 mouseDownTimer = window.setInterval(
function()
3669 if(delay > 50) delay -= 50;
3670 ConfigurationAPI.bitMapDialog.localUpdateButtonInput(i,dir,0,50);
3671 },delay!==undefined?delay:300);
3673 Debug.log(
"localUpdateButtonInput " + textInputEls[i].value +
" " + dir);
3675 clickValues[i] = clickValues[i] + (dir?stepValue:-stepValue);
3676 if(clickValues[i] < minValue) clickValues[i] = minValue;
3677 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3679 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3681 textInputEls[i].value = clickValues[i];
3682 scrollEls[i].value = clickValues[i];
3683 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3693 ConfigurationAPI.bitMapDialog.localDownloadCSV =
function()
3695 var transGrid = localConvertFullGridToRowCol();
3696 console.log(transGrid);
3698 var dataStr =
"data:text/csv;charset=utf-8,";
3700 for(var r=0;r<transGrid.length;++r)
3702 if(r) dataStr += encodeURI(
"\n");
3703 for(var c=0;c<transGrid[0].length;++c)
3705 if(c) dataStr +=
",";
3706 dataStr += transGrid[r][c];
3710 Debug.log(
"ConfigurationAPI.bitMapDialog.localDownloadCSV dataStr=" + dataStr);
3712 var link = document.createElement(
"a");
3713 link.setAttribute(
"href", dataStr);
3714 link.setAttribute(
"style",
"display:none");
3715 link.setAttribute(
"download", _currentConfigName +
"_" +
3716 fieldName +
"_download.csv");
3717 document.body.appendChild(link);
3721 link.parentNode.removeChild(link);
3728 ConfigurationAPI.bitMapDialog._csvUploadDataStr;
3729 ConfigurationAPI.bitMapDialog.locaUploadCSV =
function()
3731 Debug.log(
"locaUploadCSV ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3732 var srcDataStr = ConfigurationAPI.bitMapDialog._csvUploadDataStr.split(
'\n');
3734 for(var i=0;i<srcDataStr.length;++i)
3735 src.push(srcDataStr[i].split(
','));
3740 localConvertFullRowColToGrid(src);
3742 Debug.log(
"Successfully uploaded CSV file to bitmap!", Debug.INFO_PRIORITY);
3745 el = document.getElementById(
"popUpDialog");
3746 if(el) el.parentNode.removeChild(el);
3750 Debug.log(
"Errors occured during upload. Bitmap may not reflect contents of CSV file." +
3751 "\nHere is the error description: \n" + err, Debug.HIGH_PRIORITY);
3754 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3760 ConfigurationAPI.bitMapDialog.locaPopupUploadCSV =
function()
3762 Debug.log(
"ConfigurationAPI.bitMapDialog.locaPopupUploadCSV");
3763 ConfigurationAPI.bitMapDialog._csvUploadDataStr =
"";
3767 var pel = document.getElementById(
"popUpDialog");
3770 pel = document.createElement(
"div");
3771 pel.setAttribute(
"id",
"popUpDialog");
3773 pel.style.display =
"none";
3778 ConfigurationAPI.setPopUpPosition(pel,w ,h );
3780 var str =
"<a id='" +
3782 "-header' href='#' onclick='javascript:ConfigurationAPI.bitMapDialog._csvUploadDataStr = \"\"; var pel = document.getElementById(" +
3783 "\"popUpDialog\"); if(pel) pel.parentNode.removeChild(pel); return false;'>Cancel</a><br><br>";
3785 str +=
"<div id='popUpDialog-div'>";
3787 str +=
"Please choose a CSV formatted data file (i.e. commas for columns, and new lines for rows) " +
3788 "to upload:<br><br>";
3792 str +=
"<input type='file' id='popUpDialog-fileUpload' " +
3793 "accept='.csv' enctype='multipart/form-data' />";
3797 str +=
"</center></div><br><br>";
3799 var onmouseupJS =
"";
3800 onmouseupJS +=
"document.getElementById(\"popUpDialog-submitButton\").disabled = true;";
3801 onmouseupJS +=
"ConfigurationAPI.bitMapDialog.locaUploadCSV();";
3803 str +=
"<input id='popUpDialog-submitButton' disabled type='button' onmouseup='" +
3804 onmouseupJS +
"' " +
3805 "value='Upload File' title='" +
3806 "Upload the chosen file to replace the row,col data in the current bitmap." +
3809 pel.innerHTML = str;
3810 el.appendChild(pel);
3811 pel.style.display =
"block";
3813 document.getElementById(
'popUpDialog-fileUpload').addEventListener(
3814 'change',
function(evt) {
3815 var files = evt.target.files;
3816 var file = files[0];
3817 var reader =
new FileReader();
3818 reader.onload =
function() {
3820 ConfigurationAPI.bitMapDialog._csvUploadDataStr = this.result;
3821 Debug.log(
"ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3822 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3824 reader.readAsText(file);
3830 el.appendChild(hdr);
3832 ConfigurationAPI.bitMapDialog.localUpdateScroll(0);
3833 ConfigurationAPI.bitMapDialog.localUpdateScroll(1);
3840 function localPaint()
3842 Debug.log(
"localPaint");
3844 popSz = ConfigurationAPI.setPopUpPosition(el,undefined,undefined,padding,undefined,
3854 bmpY = hdrY+hdrH+padding;
3855 bmpW = popSz.w - 2*axisPadding;
3856 bmpH = popSz.h - hdrH - padding - 2*axisPadding;
3861 localOptimizeAspectRatio();
3864 hdr.style.left = hdrX +
"px";
3865 hdr.style.top = hdrY +
"px";
3866 hdr.style.width = hdrW +
"px";
3867 hdr.style.height = hdrH +
"px";
3870 bmp.style.left = bmpX +
"px";
3871 bmp.style.top = bmpY +
"px";
3872 bmp.style.width = bmpW +
"px";
3873 bmp.style.height = bmpH +
"px";
3879 bmpGrid.style.left = (bmpX-bmpBorderSize) +
"px";
3880 bmpGrid.style.top = (bmpY-bmpBorderSize) +
"px";
3881 bmpGrid.style.width = (bmpW) +
"px";
3882 bmpGrid.style.height = (bmpH) +
"px";
3884 var bmpGridChildren = bmpGrid.childNodes;
3887 allRowBtns.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3888 allRowBtns.style.top = (bmpY - bmpBorderSize) +
"px";
3890 allColBtns.style.left = (bmpX - bmpBorderSize) +
"px";
3891 allColBtns.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3893 allBtn.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3894 allBtn.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3895 allBtn.style.width = butttonSz +
"px";
3896 allBtn.style.height = butttonSz +
"px";
3898 var allRowsChildren = allRowBtns.childNodes;
3899 var allColsChildren = allColBtns.childNodes;
3903 rowLeftNums.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz + (- bmpBorderSize - axisPaddingMargin - axisPaddingExtra)) +
"px";
3904 rowLeftNums.style.top = (bmpY - bmpBorderSize) +
"px";
3905 rowRightNums.style.left = (bmpX + bmpW + axisPaddingMargin + bmpBorderSize) +
"px";
3906 rowRightNums.style.top = (bmpY - bmpBorderSize) +
"px";
3907 colTopNums.style.left = (bmpX - bmpBorderSize) +
"px";
3908 colTopNums.style.top = (bmpY - bmpBorderSize*2 - numberDigitH) +
"px";
3909 colBottomNums.style.left = (bmpX - bmpBorderSize) +
"px";
3910 colBottomNums.style.top = (bmpY + bmpH + bmpBorderSize + axisPaddingMargin + bmpBorderSize + butttonSz + bmpBorderSize) +
"px";
3911 rowLeftNums.innerHTML =
"";
3912 rowRightNums.innerHTML =
"";
3913 colTopNums.innerHTML =
"";
3914 colBottomNums.innerHTML =
"";
3916 var thresholdNumberSpacing = 100;
3918 var oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
3923 bmpGridChildren[0].style.left = 0 +
"px";
3924 bmpGridChildren[0].style.top = 0 +
"px";
3925 bmpGridChildren[0].style.width = (bmpW) +
"px";
3926 bmpGridChildren[0].style.height = (bmpH) +
"px";
3929 for(var i=0;i<rows;++i)
3934 bmpGridChildren[1+i*2].style.left = bmpBorderSize +
"px";
3935 bmpGridChildren[1+i*2].style.top = ((i+1)*cellH) +
"px";
3936 bmpGridChildren[1+i*2].style.width = (bmpW) +
"px";
3937 bmpGridChildren[1+i*2].style.height = (bmpGridThickness+bmpBorderSize*2) +
"px";
3940 bmpGridChildren[1+i*2+1].style.left = 0 +
"px";
3941 bmpGridChildren[1+i*2+1].style.top = ((i+1)*cellH + bmpBorderSize) +
"px";
3942 bmpGridChildren[1+i*2+1].style.width = (bmpW + bmpBorderSize*2) +
"px";
3943 bmpGridChildren[1+i*2+1].style.height = bmpGridThickness +
"px";
3945 bmpGridChildren[1+i*2+1].style.backgroundColor =
3946 (doSnakeRows && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
3950 allRowsChildren[i].style.left = 0 +
"px";
3951 allRowsChildren[i].style.top = (i*cellH + (i?bmpGridThickness+bmpBorderSize*2-1:0)) +
"px";
3952 allRowsChildren[i].style.width = (butttonSz) +
"px";
3953 allRowsChildren[i].style.height = (cellH - 1 + (i?-bmpBorderSize*2:0)) +
"px";
3957 numberLoc[0] = (i*cellH - 1 + cellH/2 - numberDigitH/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
3960 translatedRC = localConvertGridToRowCol(i,0);
3961 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
3962 translatedRC[0]%5 == 0)
3965 numberEl = document.createElement(
"div");
3966 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
3967 numberEl.innerHTML = translatedRC[0];
3968 numberEl.style.top = numberLoc[0] +
"px";
3969 numberEl.style.width = axisPaddingExtra +
"px";
3970 rowLeftNums.appendChild(numberEl);
3971 oldNumberLoc[0] = numberLoc[0];
3975 translatedRC = localConvertGridToRowCol(i,cols>1?1:0);
3976 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
3977 translatedRC[0]%5 == 0)
3980 numberEl = document.createElement(
"div");
3981 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
3982 numberEl.innerHTML = translatedRC[0];
3983 numberEl.style.top = numberLoc[0] +
"px";
3984 numberEl.style.width = axisPaddingExtra +
"px";
3985 rowRightNums.appendChild(numberEl);
3986 oldNumberLoc[1] = numberLoc[0];
3991 oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
3993 for(var i=0;i<cols;++i)
4001 bmpGridChildren[1+(rows-1)*2+i*2].style.top = bmpBorderSize +
"px";
4002 bmpGridChildren[1+(rows-1)*2+i*2].style.left = ((i+1)*cellW + bmpBorderSize) +
"px";
4003 bmpGridChildren[1+(rows-1)*2+i*2].style.height = (bmpH) +
"px";
4004 bmpGridChildren[1+(rows-1)*2+i*2].style.width = (bmpGridThickness+bmpBorderSize*2) +
"px";
4007 bmpGridChildren[1+(rows-1)*2+i*2+1].style.top = 0 +
"px";
4008 bmpGridChildren[1+(rows-1)*2+i*2+1].style.left = ((i+1)*cellW + bmpBorderSize*2) +
"px";
4009 bmpGridChildren[1+(rows-1)*2+i*2+1].style.height = (bmpH + bmpBorderSize*2) +
"px";
4010 bmpGridChildren[1+(rows-1)*2+i*2+1].style.width = bmpGridThickness +
"px";
4012 bmpGridChildren[1+(rows-1)*2+i*2+1].style.backgroundColor =
4013 (doSnakeColumns && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
4017 allColsChildren[i].style.left = (i*cellW - 1 + (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4018 allColsChildren[i].style.top = 0 +
"px";
4019 allColsChildren[i].style.width = (cellW + 1 - (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4020 allColsChildren[i].style.height = (butttonSz) +
"px";
4024 numberLoc[0] = (i*cellW + cellW/2 - axisPaddingExtra/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
4027 translatedRC = localConvertGridToRowCol(0,i);
4028 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
4029 translatedRC[1]%5 == 0)
4032 numberEl = document.createElement(
"div");
4033 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4034 numberEl.innerHTML = translatedRC[1];
4035 numberEl.style.left = numberLoc[0] +
"px";
4036 numberEl.style.width = axisPaddingExtra +
"px";
4037 colTopNums.appendChild(numberEl);
4038 oldNumberLoc[0] = numberLoc[0];
4042 translatedRC = localConvertGridToRowCol(rows>1?1:0,i);
4043 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
4044 translatedRC[1]%5 == 0)
4047 numberEl = document.createElement(
"div");
4048 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4049 numberEl.innerHTML = translatedRC[1];
4050 numberEl.style.left = numberLoc[0] +
"px";
4051 numberEl.style.width = axisPaddingExtra +
"px";
4052 colBottomNums.appendChild(numberEl);
4053 oldNumberLoc[1] = numberLoc[0];
4072 function localOptimizeAspectRatio()
4074 var cellSkew = (cellW>cellH)?cellW/cellH:cellH/cellW;
4078 if(forcedAspectH !== undefined)
4080 var offAspectH = forcedAspectH/cellH;
4081 var offAspectW = forcedAspectW/cellW;
4083 Debug.log(
"Adjusting skew factor = " + forcedAspectH +
"-" + forcedAspectW);
4085 if(offAspectH < offAspectW)
4086 bmpH = bmpW/cols*forcedAspectH/forcedAspectW*rows;
4088 bmpW = bmpH/rows*forcedAspectW/forcedAspectH*cols;
4090 else if(cellSkew > MAX_SKEW)
4092 var adj = cellSkew/MAX_SKEW;
4094 Debug.log(
"Adjusting skew factor = " + adj);
4107 bmpX = padding + (popSz.w-bmpW)/2;
4108 bmpY = bmpY + (popSz.h-bmpY-bmpH)/2;
4109 hdrY = bmpY - padding - hdrH;
4118 ConfigurationAPI.getDateString;
4120 ConfigurationAPI.getDateStringDayArr_ = [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"];
4121 ConfigurationAPI.getDateStringMonthArr_ = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"];
4122 ConfigurationAPI.getDateString =
function(date)
4126 dateStr += ConfigurationAPI.getDateStringDayArr_[date.getDay()];
4128 dateStr += ConfigurationAPI.getDateStringMonthArr_[date.getMonth()];
4130 dateStr += date.getDate();
4132 dateStr += date.getHours();
4134 dateStr += ((date.getMinutes()<10)?
"0":
"") + date.getMinutes();
4136 dateStr += ((date.getSeconds()<10)?
"0":
"") + date.getSeconds();
4138 dateStr += date.getFullYear();
4140 dateStr += date.toLocaleTimeString([],{timeZoneName:
"short"}).split(
" ")[2];
4147 ConfigurationAPI.setCaretPosition =
function(elem, caretPos, endPos)
4150 elem.setSelectionRange(caretPos, endPos);
4155 ConfigurationAPI.removeAllPopUps =
function()
4158 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
4161 el.parentNode.removeChild(el);
4162 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
4173 ConfigurationAPI.setPopUpPosition =
function(el,w,h,padding,border,margin,doNotResize,offsetUp)
4175 Debug.log(
"ConfigurationAPI.setPopUpPosition");
4177 if(padding === undefined) padding = 10;
4178 if(border === undefined) border = 1;
4179 if(margin === undefined) margin = 0;
4186 ConfigurationAPI.setPopUpPosition.stopPropagation =
function(event) {
4188 event.stopPropagation();
4194 ConfigurationAPI.setPopUpPosition.popupResize =
function() {
4200 window.removeEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4201 window.removeEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4205 catch(err) {
return;}
4211 var ww = DesktopContent.getWindowWidth()-(padding+border)*2;
4212 var wh = DesktopContent.getWindowHeight()-(padding+border)*2;
4216 var ah = el.offsetHeight;
4218 if(w === undefined || h === undefined)
4225 x = (DesktopContent.getWindowScrollLeft() + ((ww-w)/2));
4226 y = (DesktopContent.getWindowScrollTop() + ((wh-h)/2)) - (offsetUp|0);
4227 if(y > 110) y -= 100;
4229 if(y<DesktopContent.getWindowScrollTop()+margin)
4230 y = DesktopContent.getWindowScrollTop()+margin;
4233 if(w > ww-margin-padding)
4234 x = -DesktopContent.getWindowScrollLeft();
4235 if(ah > wh-margin-padding)
4236 y = -DesktopContent.getWindowScrollTop();
4238 el.style.left = (x|0) +
"px";
4239 el.style.top = (y|0) +
"px";
4241 ConfigurationAPI.setPopUpPosition.popupResize();
4244 el.style.width = (w|0) +
"px";
4245 el.style.height = (h|0) +
"px";
4249 window.addEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4250 window.addEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4252 el.addEventListener(
"keydown",ConfigurationAPI.setPopUpPosition.stopPropagation);
4253 el.addEventListener(
"mousemove",ConfigurationAPI.setPopUpPosition.stopPropagation);
4254 el.addEventListener(
"mousemove",DesktopContent.mouseMove);
4256 el.style.overflow =
"auto";
4258 return {
"w" : w,
"h" : h,
"x" : x,
"y" : y};
4265 ConfigurationAPI.getOnePixelPngData =
function(rgba)
4267 if(ConfigurationAPI.getOnePixelPngData.canvas === undefined)
4270 ConfigurationAPI.getOnePixelPngData.canvas = document.createElement(
"canvas");
4271 ConfigurationAPI.getOnePixelPngData.canvas.width = 1;
4272 ConfigurationAPI.getOnePixelPngData.canvas.height = 1;
4273 ConfigurationAPI.getOnePixelPngData.ctx = ConfigurationAPI.getOnePixelPngData.canvas.getContext(
"2d");
4274 ConfigurationAPI.getOnePixelPngData.bmpOverlayData = ConfigurationAPI.getOnePixelPngData.ctx.createImageData(1,1);
4277 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[0]=rgba[0];
4278 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[1]=rgba[1];
4279 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[2]=rgba[2];
4280 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[3]=rgba[3]!==undefined?rgba[3]:255;
4282 ConfigurationAPI.getOnePixelPngData.ctx.putImageData(
4283 ConfigurationAPI.getOnePixelPngData.bmpOverlayData,0,0);
4284 return ConfigurationAPI.getOnePixelPngData.canvas.toDataURL();
4310 ConfigurationAPI.editableFieldEditingCell_ = 0;
4311 ConfigurationAPI.editableFieldEditingIdString_;
4312 ConfigurationAPI.editableFieldEditingNodeType_;
4313 ConfigurationAPI.editableFieldEditingOldValue_;
4314 ConfigurationAPI.editableFieldEditingInitValue_;
4315 ConfigurationAPI.editableFieldHoveringCell_ = 0;
4316 ConfigurationAPI.editableFieldHoveringIdString_;
4317 ConfigurationAPI.editableFieldSelectedIdString_ = 0;
4318 ConfigurationAPI.editableFieldHandlersSubscribed_ =
false;
4319 ConfigurationAPI.editableFieldMouseIsSelecting_ =
false;
4320 ConfigurationAPI.editableField_SELECTED_COLOR_ =
"rgb(251, 245, 53)";
4321 ConfigurationAPI.createEditableFieldElement =
function(fieldObj,fieldIndex,
4325 var depth = depthIndex|0;
4326 var uid = fieldIndex|0;
4328 if(!ConfigurationAPI.editableFieldHandlersSubscribed_)
4330 ConfigurationAPI.editableFieldHandlersSubscribed_ =
true;
4333 DesktopContent.mouseMoveSubscriber(ConfigurationAPI.handleEditableFieldBodyMouseMove);
4336 var fieldEl = document.createElement(
"div");
4337 fieldEl.setAttribute(
"class",
"ConfigurationAPI-EditableField");
4338 fieldEl.setAttribute(
"id",
"ConfigurationAPI-EditableField-" +
4339 ( depth +
"-" + uid ));
4341 Debug.log(
"Field type " + fieldObj.fieldColumnType);
4344 var valueType = fieldObj.fieldColumnType;
4345 var choices = fieldObj.fieldColumnDataChoicesArr;
4346 var value = fieldObj.fieldColumnDefaultValue;
4347 var path = fieldObj.fieldRelativePath;
4348 var nodeName = fieldObj.fieldColumnName;
4349 fieldObj.depthIndex = depth;
4350 fieldObj.fieldIndex = uid;
4351 fieldObj.fieldColumnValue = value;
4355 var isGroupLink,childLinkIndex,linkId;
4356 if(valueType.indexOf(
"ChildLink") == 0)
4358 Debug.log(
"Looking up matching link pair for " + nodeName);
4360 childLinkIndex = valueType.split(
'-')[1];
4361 console.log(
"childLinkIndex",childLinkIndex);
4364 for(var i=0;i<_fields.length;++i)
4365 if(_fields[i].fieldColumnType.indexOf(
"ChildLink") == 0 &&
4366 (_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U' ||
4367 _fields[i].fieldColumnType[(
"ChildLink").length] ==
'G') &&
4368 childLinkIndex == _fields[i].fieldColumnType.split(
'-')[1])
4370 Debug.log(
"Found matching pair field " +
4371 _fields[i].fieldColumnName);
4372 if(_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U')
4373 isGroupLink =
false;
4376 linkId = _fields[i].fieldColumnDefaultValue;
4380 if(isGroupLink === undefined)
4382 Debug.log(
"Invalid table! Could not find matching child link columns for " +
4383 nodeName, Debug.HIGH_PRIORITY);
4388 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4389 depth,nodeName,value,valueType,choices,path,
4390 isGroupLink,childLinkIndex,linkId);
4397 ConfigurationAPI.getEditableFieldValue =
function(fieldObj,fieldIndex,depthIndex )
4402 ConfigurationAPI.handleEditableFieldEditOK();
4405 var depth = fieldObj.depthIndex === undefined?
4406 (depthIndex|0):fieldObj.depthIndex;
4407 var uid = fieldObj.fieldIndex === undefined?
4408 (fieldIndex|0):fieldObj.fieldIndex;
4410 var fieldEl = document.getElementById(
"editableFieldNode-Value-leafNode-" +
4411 ( depth +
"-" + uid ));
4414 Debug.log(
"getEditableFieldValue Error! Invalid target field element '" +
4415 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4419 var valueType = fieldObj.fieldColumnType;
4420 var value = fieldEl.textContent;
4434 ConfigurationAPI.setEditableFieldValue =
function(fieldObj,value,fieldIndex,depthIndex )
4439 var depth = fieldObj.depthIndex === undefined?
4440 (depthIndex|0):fieldObj.depthIndex;
4441 var uid = fieldObj.fieldIndex === undefined?
4442 (fieldIndex|0):fieldObj.fieldIndex;
4444 var fieldEl = document.getElementById(
"ConfigurationAPI-EditableField-" +
4445 ( depth +
"-" + uid ));
4448 Debug.log(
"setEditableFieldValue Error! Invalid target field element '" +
4449 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4452 var valueType = fieldObj.fieldColumnType;
4453 var choices = fieldObj.fieldColumnDataChoicesArr;
4454 var path = fieldObj.fieldRelativePath;
4455 var nodeName = fieldObj.fieldColumnName;
4456 fieldObj.fieldColumnValue = value;
4460 var isGroupLink,childLinkIndex,linkId;
4461 if(valueType.indexOf(
"ChildLink") == 0)
4463 Debug.log(
"Looking up matching link pair for " + nodeName);
4465 childLinkIndex = valueType.split(
'-')[1];
4466 console.log(
"childLinkIndex",childLinkIndex);
4469 for(var i=0;i<_fields.length;++i)
4470 if(_fields[i].fieldColumnType.indexOf(
"ChildLink") == 0 &&
4471 (_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U' ||
4472 _fields[i].fieldColumnType[(
"ChildLink").length] ==
'G') &&
4473 childLinkIndex == _fields[i].fieldColumnType.split(
'-')[1])
4475 Debug.log(
"Found matching pair field " +
4476 _fields[i].fieldColumnName);
4477 if(_fields[i].fieldColumnType[(
"ChildLink").length] ==
'U')
4478 isGroupLink =
false;
4481 linkId = _fields[i].fieldColumnValue;
4485 if(isGroupLink === undefined)
4487 Debug.log(
"Invalid table! Could not find matching child link columns for " +
4488 nodeName, Debug.HIGH_PRIORITY);
4493 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4494 depth,nodeName,value,valueType,choices,path,
4495 isGroupLink,childLinkIndex,linkId);
4504 ConfigurationAPI.fillEditableFieldElement =
function(fieldEl,uid,
4505 depth,nodeName,value,valueType,choices,path,
4506 isGroupLink,childLinkIndex,linkId)
4510 var pathHTML = path;
4512 pathHTML = pathHTML.replace(/</g,
"<");
4513 pathHTML = pathHTML.replace(/>/g,
">");
4515 str +=
"<div class='editableFieldNode-Path' style='display:none' id='editableFieldNode-path-" +
4516 ( depth +
"-" + uid ) +
"'>" +
4521 var childLinkFixedChoice =
false;
4522 var isChildLink = valueType.indexOf(
"ChildLink") == 0;
4524 if(valueType ==
"FixedChoiceData" ||
4525 (isChildLink && choices.length > 1))
4528 childLinkFixedChoice = valueType.indexOf(
"ChildLink") == 0;
4532 "<div class='editableFieldNode-FixedChoice-CSV' style='display:none' " +
4533 "id='editableFieldNode-FixedChoice-CSV-" +
4534 ( depth +
"-" + uid ) +
"'>";
4536 for(var j=0;j<choices.length;++j)
4545 else if(valueType ==
"BitMap")
4549 "<div class='editableFieldNode-BitMap-Params' style='display:none' " +
4550 "id='editableFieldNode-BitMap-Params-" +
4551 ( depth +
"-" + uid ) +
"'>";
4553 for(var j=1;j<choices.length;++j)
4556 str += choices[j].replace(/;/g,
",");
4565 "<div class='editableFieldNode-Value editableFieldNode-ValueType-" +
4567 (childLinkFixedChoice?
"ChildLinkFixedChoice":valueType) +
4569 "id='editableFieldNode-Value-" +
4570 (depth +
"-" + uid) +
"' " +
4572 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4573 depth +
"," + uid +
"," +
4576 "onmousemove='ConfigurationAPI.handleEditableFieldHover(" +
4577 depth +
"," + uid +
"," +
4582 titleStr =
"~ Leaf Value Node ~\n";
4583 titleStr +=
"Path: \t" + path + nodeName +
"\n";
4587 "<div style='float:left' title='" + titleStr +
"'>" +
4588 "<b class='editableFieldNode-Value-leafNode-fieldName bold-header'>" +
4590 "</div><div style='float:left'> :</div>";
4594 "<div class='editableFieldNode-Value-editIcon' id='editableFieldNode-Value-editIcon-" +
4595 (depth +
"-" + uid) +
"' " +
4596 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4597 depth +
"," + uid +
"," +
4598 "1,\"value\"); event.stopPropagation();' " +
4599 "title='Edit the value of this node.' " +
4603 str +=
"<div style='float:left; margin-left:9px;' id='editableFieldNode-Value-leafNode-" +
4604 (depth +
"-" + uid) +
4606 "editableFieldNode-Value-leafNode-ColumnName-" + nodeName +
4611 if(valueType ==
"OnOff" ||
4612 valueType ==
"YesNo" ||
4613 valueType ==
"TrueFalse")
4616 str +=
"<div style='float:left'>";
4620 var color = (value ==
"On" || value ==
"Yes" || value ==
"True")?
4621 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
4622 str +=
"<div style='width:10px;height:10px;" +
4623 "background-color:" + color +
";" +
4625 "border-radius: 7px;" +
4626 "border: 2px solid white;" +
4627 "margin: 2px 0 0 6px;" +
4630 else if(valueType ==
"Timestamp")
4631 str += ConfigurationAPI.getDateString(
new Date((value|0)*1000));
4639 value.indexOf(
"Table") == value.length - (
"Table").length)
4643 var recordAlias =
"";
4644 for(var c=0;c<value.length - (
"Table").length;++c)
4646 if(c && c+1 < value.length &&
4649 (value[c+1] >=
'a' &&
4652 recordAlias += value[c];
4654 if(recordAlias.length && recordAlias[recordAlias.length-1] !=
's')
4657 var newWindowStr =
"/WebPath/html/ConfigurationGUI_subset.html?urn=" +
4658 DesktopContent._localUrnLid +
4659 "&subsetBasePath=" + value +
4660 "&groupingFieldList=AUTO" +
4661 "&recordAlias=" + recordAlias +
4662 "&editableFieldList=" +
"!*CommentDescription";
4668 newWindowStr +=
"&selectedGroupIDs=" +
4670 childLinkIndex +
"=" +
4676 newWindowStr +=
"&selectedRecords=" + linkId;
4679 str +=
"<div style='float:left; margin-left:9px;' " +
4680 " id='editableFieldNode-ChildLink-SubConfigLinkWindow-" +
4681 (depth +
"-" + uid) +
"' " +
4683 "editableFieldNode-ChildLink-SubConfigLink" +
4686 "event.stopPropagation(); " +
4687 "DesktopContent.openNewWindow(" +
4689 " Subset-Configuration\",\"\",\"" +
4692 "\",false /*unique*/);" +
4694 " title='Open " + value +
" subset configuration in a new desktop window.' " +
4695 ">Open Window</div>";
4697 str +=
"<div style='float:left; margin-left:9px;' " +
4698 " id='editableFieldNode-ChildLink-SubConfigLinkTab-" +
4699 (depth +
"-" + uid) +
"' " +
4701 "editableFieldNode-ChildLink-SubConfigLink" +
4704 "event.stopPropagation(); " +
4705 "DesktopContent.openNewBrowserTab(" +
4707 " Subset-Configuration\",\"\",\"" +
4710 "\",false /*unique*/);" +
4712 " title='Open " + value +
" subset configuration in a new browser tab.' " +
4718 fieldEl.innerHTML = str;
4722 if(ConfigurationAPI.editableFieldSelectedIdString_ == (depth +
"-" + uid))
4723 fieldEl.getElementsByClassName(
"editableFieldNode-Value")[0].style.backgroundColor =
4724 ConfigurationAPI.editableField_SELECTED_COLOR_;
4735 ConfigurationAPI.handleEditableFieldClick =
function(depth,uid,editClick,type)
4737 var idString = depth +
"-" + uid;
4738 ConfigurationAPI.editableFieldEditingIdString_ = idString;
4740 Debug.log(
"handleEditableFieldClick editClick " + editClick);
4741 Debug.log(
"handleEditableFieldClick idString " + idString);
4743 var el = document.getElementById(
"editableFieldNode-Value-" + idString);
4747 Debug.log(
"Invalid element pointed to by idString. Ignoring and exiting.");
4751 if(ConfigurationAPI.editableFieldHoveringCell_)
4754 ConfigurationAPI.handleEditableFieldBodyMouseMove();
4757 if(ConfigurationAPI.editableFieldEditingCell_)
4759 if(ConfigurationAPI.editableFieldEditingCell_ == el)
4761 ConfigurationAPI.handleEditableFieldEditOK();
4764 var path = document.getElementById(
"editableFieldNode-path-" + idString).textContent;
4770 Debug.log(
"handleEditableFieldClick path " + path);
4772 Debug.log(
"handleEditableFieldClick type " + type);
4803 Debug.log(
"edit value mode");
4805 selectThisTreeNode(idString,type);
4807 function selectThisTreeNode(idString,type)
4811 var el = document.getElementById(
"editableFieldNode-Value-leafNode-" + idString);
4812 var vel = document.getElementById(
"editableFieldNode-Value-" + idString);
4815 var colType = vel.className.split(
' ')[1].split(
'-');
4816 if(colType[1] ==
"ValueType")
4817 colType = colType[2];
4819 var fieldName = el.className.substr((
"editableFieldNode-Value-leafNode-ColumnName-").length);
4821 Debug.log(
"fieldName=" + fieldName);
4822 Debug.log(
"colType=" + colType);
4824 if(colType ==
"Author" ||
4825 colType ==
"Timestamp")
4827 Debug.log(
"Can not edit Author or Timestamp fields.",
4828 Debug.WARN_PRIORITY);
4834 var optionIndex = -1;
4837 if(colType ==
"YesNo" ||
4838 colType ==
"TrueFalse" ||
4842 ConfigurationAPI.editableFieldEditingOldValue_ = el.innerHTML;
4844 var initVal = el.childNodes[0].textContent;
4845 ConfigurationAPI.editableFieldEditingInitValue_ = initVal;
4848 if(colType ==
"YesNo")
4849 boolVals = [
"No",
"Yes"];
4850 else if(colType ==
"TrueFalse")
4851 boolVals = [
"False",
"True"];
4852 else if(colType ==
"OnOff")
4853 boolVals = [
"Off",
"On"];
4856 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4857 "onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4858 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_); event.stopPropagation();' " +
4859 "onclick='event.stopPropagation();'" +
4860 "style='margin:-8px -2px -2px -1px; height:" + (el.offsetHeight+6) +
"px'>";
4861 for(var i=0;i<boolVals.length;++i)
4863 str +=
"<option value='" + boolVals[i] +
"'>";
4866 if(boolVals[i] == initVal)
4870 if(optionIndex == -1) optionIndex = 0;
4872 else if(colType ==
"FixedChoiceData" ||
4873 colType ==
"ChildLinkFixedChoice")
4875 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4876 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4878 var allowFixedChoiceArbitraryEdit =
false;
4879 var optionCount = -1;
4882 str +=
"<div onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4883 "onmouseup='event.stopPropagation();' " +
4884 "onclick='event.stopPropagation();' " +
4886 "white-space:nowrap;" +
4887 "margin:-3px -2px -2px -1px;" +
4888 "height:" + (el.offsetHeight+6) +
"px'>";
4890 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4891 "id='fixedChoice-editSelectBox' " +
4892 "onmouseup='event.stopPropagation();' " +
4893 "onclick='event.stopPropagation();' " +
4896 "margin:-2px -2px -2px -1px; height:" +
4897 (el.offsetHeight+6) +
"px'>";
4901 var vel = document.getElementById(
"editableFieldNode-FixedChoice-CSV-" +
4903 var choices = vel.textContent.split(
',');
4905 var isChildLinkFixedChoice = colType ==
"ChildLinkFixedChoice";
4907 if(isChildLinkFixedChoice)
4911 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
4912 (depth +
"-" + uid) ).style.display =
"none";
4913 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
4914 (depth +
"-" + uid) ).style.display =
"none";
4919 if(choices.length > 1 &&
4920 choices[1].indexOf(
"arbitraryBool=") == 0)
4923 allowFixedChoiceArbitraryEdit =
4924 choices[1][(
"arbitraryBool=").length] ==
"1"?
4926 Debug.log(
"allowFixedChoiceArbitraryEdit " + allowFixedChoiceArbitraryEdit);
4929 for(var i=0;i<choices.length;++i)
4931 if(i == 0 && isChildLinkFixedChoice && !allowFixedChoiceArbitraryEdit)
4938 if(choices[i].indexOf(
"arbitraryBool=") == 0)
4954 str += decodeURIComponent(choices[i]);
4956 if(decodeURIComponent(choices[i])
4957 == ConfigurationAPI.editableFieldEditingOldValue_)
4958 optionIndex = optionCount;
4962 if(allowFixedChoiceArbitraryEdit)
4964 var ww = (el.offsetWidth-6);
4965 if(ww < 150) ww = 150;
4966 str +=
"<input type='text' " +
4967 "id='fixedChoice-editTextBox' " +
4968 "style='display:none;" +
4970 "margin:-2px 0 -" + (el.offsetHeight+6) +
"px 0;" +
4972 ww +
"px; height:" + (el.offsetHeight+6) +
"px" +
4976 str +=
"<div style='display:block;" +
4977 "margin: -2px 0 -7px 14px;" +
4979 "class='editableFieldNode-Value-editIcon' id='fixedChoice-editIcon" +
4981 "onclick='ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle();' " +
4982 "title='Toggle free-form editing' " +
4987 else if(colType ==
"BitMap")
4989 Debug.log(
"Handling bitmap select");
4991 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4994 ConfigurationAPI.bitMapDialog(
4996 "Target Field: "" +
4997 fieldName_ +
""",
4998 document.getElementById(
"editableFieldNode-BitMap-Params-" +
4999 idString).textContent.split(
';'),
5000 ConfigurationAPI.editableFieldEditingOldValue_,
5003 Debug.log(
"yes " + val);
5005 el.appendChild(document.createTextNode(val));
5006 ConfigurationAPI.editableFieldEditingCell_ = el;
5015 Debug.log(
"cancel bitmap");
5016 ConfigurationAPI.editableFieldEditingCell_ = 0;
5020 else if(colType ==
"MultilineData")
5022 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
5023 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
5025 str +=
"<textarea rows='4' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' cols='50' style='font-size: 14px; " +
5026 "margin:-8px -2px -2px -1px;width:" +
5027 (el.offsetWidth-6) +
"px; height:" + (el.offsetHeight-8) +
"px' ";
5028 str +=
" onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
5029 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
5030 "onclick='event.stopPropagation();'" +
5032 str += ConfigurationAPI.editableFieldEditingOldValue_;
5033 str +=
"</textarea>";
5037 if(colType ==
"GroupID")
5040 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
5041 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
5043 var ow = el.offsetWidth+6;
5046 str +=
"<input type='text' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' style='margin:-8px -2px -2px -1px;width:" +
5047 (ow) +
"px; height:" + (el.offsetHeight>20?el.offsetHeight:20) +
"px' value='";
5048 str += ConfigurationAPI.editableFieldEditingOldValue_;
5049 str +=
"' onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
5050 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
5051 "onclick='event.stopPropagation();'" +
5056 str += ConfigurationAPI._OK_CANCEL_DIALOG_STR;
5061 if(colType ==
"YesNo" ||
5062 colType ==
"TrueFalse" ||
5065 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
5066 el.getElementsByTagName(
"select")[0].focus();
5068 else if(colType ==
"FixedChoiceData" ||
5069 colType ==
"ChildLinkFixedChoice")
5071 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
5072 el.getElementsByTagName(
"select")[0].focus();
5075 else if(colType ==
"MultilineData")
5076 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"textarea")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
5078 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"input")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
5082 ConfigurationAPI.editableFieldEditingCell_ = el;
5083 ConfigurationAPI.editableFieldEditingNodeType_ = type;
5088 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
5097 Debug.log(
"Toggling selection of target field " + idString);
5101 if(ConfigurationAPI.editableFieldSelectedIdString_ &&
5102 (vel = document.getElementById(
"editableFieldNode-Value-" +
5103 ConfigurationAPI.editableFieldSelectedIdString_)))
5104 vel.style.backgroundColor =
"transparent";
5107 vel = document.getElementById(
"editableFieldNode-Value-" +
5109 if(ConfigurationAPI.editableFieldSelectedIdString_ == idString)
5113 ConfigurationAPI.editableFieldSelectedIdString_ = undefined;
5116 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
5117 ConfigurationAPI.editableFieldSelectedIdString_ = idString;
5121 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
5132 ConfigurationAPI.getSelectedEditableFieldIndex =
function()
5134 if(!ConfigurationAPI.editableFieldSelectedIdString_)
5137 var idStr = ConfigurationAPI.editableFieldSelectedIdString_;
5138 return idStr.split(
'-')[1];
5144 ConfigurationAPI.handleEditableFieldHover =
function(depth,uid,event)
5146 var idString = depth +
"-" + uid;
5150 event.stopPropagation();
5151 DesktopContent.mouseMove(event);
5154 if(ConfigurationAPI.editableFieldEditingCell_)
return;
5156 var el = document.getElementById(
"editableFieldNode-Value-editIcon-" + idString);
5157 if(ConfigurationAPI.editableFieldHoveringCell_ == el)
return;
5159 if(ConfigurationAPI.editableFieldHoveringCell_)
5162 bodyMouseMoveHandler();
5166 ConfigurationAPI.editableFieldHoveringIdString_ = idString;
5167 ConfigurationAPI.editableFieldHoveringCell_ = el;
5168 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"block";
5169 var vel = document.getElementById(
"editableFieldNode-Value-" +
5170 ConfigurationAPI.editableFieldHoveringIdString_);
5171 vel.style.backgroundColor =
"rgb(218, 194, 194)";
5176 ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle =
function()
5178 Debug.log(
"handleEditableFieldFixedChoiceEditToggle");
5180 var sel = document.getElementById(
"fixedChoice-editSelectBox");
5181 var tel = document.getElementById(
"fixedChoice-editTextBox");
5183 Debug.log(
"sel.style.display " + sel.style.display);
5184 if(sel.style.display ==
"none")
5186 sel.style.display =
"block";
5187 tel.style.display =
"none";
5191 tel.style.width = ((sel.offsetWidth>150?sel.offsetWidth:150)-2) +
"px";
5192 tel.parentNode.style.width = ((sel.offsetWidth>150?sel.offsetWidth:150)+50) +
"px";
5193 sel.style.display =
"none";
5196 tel.value = ConfigurationAPI.editableFieldEditingOldValue_;
5198 tel.style.display =
"block";
5199 ConfigurationAPI.setCaretPosition(tel,0,tel.value.length);
5205 ConfigurationAPI.handleEditableFieldBodyMouseMove =
function(e)
5207 if(ConfigurationAPI.editableFieldHoveringCell_)
5210 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"none";
5211 ConfigurationAPI.editableFieldHoveringCell_ = 0;
5213 var vel = document.getElementById(
"editableFieldNode-Value-" +
5214 ConfigurationAPI.editableFieldHoveringIdString_);
5217 if(ConfigurationAPI.editableFieldHoveringIdString_ ==
5218 ConfigurationAPI.editableFieldSelectedIdString_)
5219 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
5221 vel.style.backgroundColor =
"transparent";
5229 ConfigurationAPI.handleEditableFieldKeyDown =
function(e,keyEl)
5241 key = window.event.keyCode;
5242 shiftIsDown = !!window.event.shiftKey;
5247 shiftIsDown = !!e.shiftKey;
5256 if(ConfigurationAPI.editableFieldEditingCell_ &&
5257 (tel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"textarea")).length)
5261 if(e.keyCode == TABKEY)
5264 if(e.preventDefault)
5267 var i = tel.selectionStart;
5268 var j = tel.selectionEnd;
5269 tel.value = tel.value.substr(0,i) +
5270 '\t' + tel.value.substr(j);
5271 tel.selectionStart = tel.selectionEnd = j+1;
5280 if(e.keyCode == TABKEY || e.keyCode == ENTERKEY ||
5281 e.keyCode == UPKEY || e.keyCode == DNKEY)
5284 if(e.preventDefault)
5288 var idString = ConfigurationAPI.editableFieldEditingIdString_;
5290 ConfigurationAPI.handleEditableFieldEditOK();
5298 if(e.keyCode == ENTERKEY)
5301 var depth = idString.split(
'-')[0];
5302 var uid = idString.split(
'-')[1];
5304 if((!shiftIsDown && e.keyCode == TABKEY) || e.keyCode == DNKEY)
5306 else if((shiftIsDown && e.keyCode == TABKEY) || e.keyCode == UPKEY)
5308 if(uid < 0)
return false;
5311 ConfigurationAPI.handleEditableFieldClick(depth,uid,1,
"value");
5312 Debug.log(
"new uid=" + uid);
5316 else if(e.keyCode == ESCKEY)
5318 if(e.preventDefault)
5320 ConfigurationAPI.handleEditableFieldEditCancel();
5323 else if((e.keyCode >= 48 && e.keyCode <= 57) ||
5324 (e.keyCode >= 96 && e.keyCode <= 105))
5328 if((sel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"select")).length)
5333 sel = sel[sel.length-1];
5338 selNum = e.keyCode - 96;
5340 selNum = e.keyCode - 48;
5342 sel.selectedIndex = selNum % (sel.options.length);
5345 Debug.log(
"number select =" + sel.selectedIndex);
5355 ConfigurationAPI.handleEditableFieldEditCancel =
function()
5357 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5358 Debug.log(
"handleEditableFieldEditCancel type " + ConfigurationAPI.editableFieldEditingNodeType_);
5362 var idSplit = ConfigurationAPI.editableFieldEditingCell_.id.split(
'-');
5363 var depth = idSplit[idSplit.length-2];
5364 var uid = idSplit[idSplit.length-1];
5365 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
5366 (depth +
"-" + uid) ).style.display =
"block";
5367 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
5368 (depth +
"-" + uid) ).style.display =
"block";
5373 if(ConfigurationAPI.editableFieldEditingNodeType_ ==
"value-bool")
5376 ConfigurationAPI.editableFieldEditingCell_.innerHTML = ConfigurationAPI.editableFieldEditingOldValue_;
5380 ConfigurationAPI.editableFieldEditingCell_.innerHTML =
"";
5381 ConfigurationAPI.editableFieldEditingCell_.appendChild(
5382 document.createTextNode(ConfigurationAPI.editableFieldEditingOldValue_));
5385 ConfigurationAPI.editableFieldEditingCell_ = 0;
5391 ConfigurationAPI.handleEditableFieldEditOK =
function()
5393 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5394 Debug.log(
"handleEditableFieldEditOK type " + ConfigurationAPI.editableFieldEditingNodeType_);
5398 var idSplit = ConfigurationAPI.editableFieldEditingCell_.id.split(
'-');
5399 var depth = idSplit[idSplit.length-2];
5400 var uid = idSplit[idSplit.length-1];
5401 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
5402 (depth +
"-" + uid) ).style.display =
"block";
5403 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
5404 (depth +
"-" + uid) ).style.display =
"block";
5408 var el = ConfigurationAPI.editableFieldEditingCell_;
5409 var type = ConfigurationAPI.editableFieldEditingNodeType_;
5413 function localEditTreeNodeOKRequestsComplete(newValue)
5419 if(type ==
"value" ||
5420 type ==
"value-bitmap")
5426 el.appendChild(document.createTextNode(decodeURIComponent(newValue)));
5429 else if(type ==
"value-bool")
5434 str +=
"<div style='float:left'>";
5438 var color = (newValue ==
"On" || newValue ==
"Yes" || newValue ==
"True")?
5439 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
5440 str +=
"<div style='width:10px;height:10px;" +
5441 "background-color:" + color +
";" +
5443 "border-radius: 7px;" +
5444 "border: 2px solid white;" +
5445 "margin: 2px 0 0 6px;" +
5449 else if(type ==
"value-groupid")
5451 el.appendChild(document.createTextNode(newValue));
5455 Debug.log(
"Unrecognizd tree edit type! Should be impossible!",Debug.HIGH_PRIORITY);
5456 ConfigurationAPI.handleEditableFieldEditCancel();
return;
5460 ConfigurationAPI.editableFieldEditingCell_ = 0;
5467 type ==
"value-bool" ||
5468 type ==
"value-bitmap" ||
5469 type ==
"value-groupid")
5474 if(type ==
"value-bool")
5476 var sel = el.getElementsByTagName(
"select")[0];
5477 newValue = sel.options[sel.selectedIndex].value;
5479 else if(type ==
"value-bitmap")
5481 newValue = encodeURIComponent(el.textContent);
5486 if((sel = el.getElementsByTagName(
"textarea")).length)
5487 newValue = sel[0].value;
5488 else if((sel = el.getElementsByTagName(
"select")).length)
5491 if(sel[0].style.display ==
"none")
5495 newValue = el.getElementsByTagName(
"input")[0].value;
5498 newValue = sel[0].options[sel[0].selectedIndex].value;
5501 newValue = el.getElementsByTagName(
"input")[0].value;
5503 newValue = encodeURIComponent(newValue.trim());
5506 Debug.log(
"CfgGUI editTreeNodeOK editing " + type +
" node = " +
5509 if(ConfigurationAPI.editableFieldEditingInitValue_ == newValue)
5511 Debug.log(
"No change. Do nothing.");
5512 ConfigurationAPI.handleEditableFieldEditCancel();
5520 localEditTreeNodeOKRequestsComplete(newValue);
5525 Debug.log(
"Unrecognizd tree edit type! Should be impossible!",Debug.HIGH_PRIORITY);
5526 editCellCancel();
return;
5533 ConfigurationAPI.hasClass =
function(ele,cls)
5535 return !!ele.className.match(
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)'));
5540 ConfigurationAPI.addClass =
function(ele,cls)
5542 if (!ConfigurationAPI.hasClass(ele,cls)) ele.className +=
" "+cls;
5547 ConfigurationAPI.removeClass =
function(ele,cls)
5549 if (ConfigurationAPI.hasClass(ele,cls))
5551 var reg =
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)');
5552 ele.className=ele.className.replace(reg,
'');
5572 ConfigurationAPI.addSubsetRecords =
function(subsetBasePath,
5573 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
5575 var modifiedTablesListStr =
"";
5576 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
5578 if(i) modifiedTablesListStr +=
",";
5579 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
5580 modifiedTablesIn[i].tableVersion;
5583 var recordListStr =
"";
5584 if(Array.isArray(recordArr))
5585 for(var i=0;i<recordArr.length;++i)
5587 if(i) recordListStr +=
",";
5588 recordListStr += encodeURIComponent(recordArr[i]);
5591 recordListStr = encodeURIComponent(recordArr);
5593 DesktopContent.XMLHttpRequest(
"Request?RequestType=addTreeNodeRecords" +
5595 "&tableGroupKey=-1",
5596 "startPath=/" + subsetBasePath +
5597 "&recordList=" + recordListStr +
5598 "&modifiedTables=" + modifiedTablesListStr,
5601 var modifiedTables = [];
5603 var err = DesktopContent.getXMLValue(req,
"Error");
5607 Debug.log(err,Debug.HIGH_PRIORITY);
5608 responseHandler(modifiedTables,err);
5615 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
5616 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
5617 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
5621 for(var i=0;i<tableNames.length;++i)
5623 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
5624 if(tableVersion >= -1)
continue;
5626 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
5627 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
5628 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
5629 modifiedTables.push(obj);
5631 responseHandler(modifiedTables);
5655 ConfigurationAPI.deleteSubsetRecords =
function(subsetBasePath,
5656 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
5658 var modifiedTablesListStr =
"";
5659 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
5661 if(i) modifiedTablesListStr +=
",";
5662 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
5663 modifiedTablesIn[i].tableVersion;
5666 var recordListStr =
"";
5667 var recordCount = 1;
5668 if(Array.isArray(recordArr))
5670 for(var i=0;i<recordArr.length;++i)
5672 if(i) recordListStr +=
",";
5673 recordListStr += encodeURIComponent(recordArr[i]);
5675 recordCount = recordArr.length;
5678 recordListStr = encodeURIComponent(recordArr);
5680 DesktopContent.XMLHttpRequest(
"Request?RequestType=deleteTreeNodeRecords" +
5682 "&tableGroupKey=-1",
5683 "startPath=/" + subsetBasePath +
5684 "&recordList=" + recordListStr +
5685 "&modifiedTables=" + modifiedTablesListStr,
5689 var err = DesktopContent.getXMLValue(req,
"Error");
5690 var modifiedTables = [];
5694 Debug.log(err,Debug.HIGH_PRIORITY);
5695 responseHandler(modifiedTables,err);
5702 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
5703 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
5704 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
5708 for(var i=0;i<tableNames.length;++i)
5710 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
5711 if(tableVersion >= -1)
continue;
5713 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
5714 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
5715 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
5716 modifiedTables.push(obj);
5718 responseHandler(modifiedTables,undefined,subsetBasePath,recordCount);
5728 ConfigurationAPI.incrementName =
function(name)
5731 for(var i=name.length-1;i>=0;--i)
5732 if(!(name[i] >=
'0' && name[i] <=
'9'))
5735 var num = (name.substr(i+1)|0) + 1;
5736 name = name.substr(0,i+1);
5742 ConfigurationAPI.createNewRecordName =
function(startingName,existingArr)
5744 var retVal = startingName;
5748 var apps = existingArr;
5751 retVal = ConfigurationAPI.incrementName(retVal);
5753 for(i=0;i<apps.length;++i)
5754 if(apps[i] == retVal)
5755 {found =
true;
break;}
5757 Debug.log(
"createNewRecordName " + retVal);
5762 return ConfigurationAPI.incrementName(retVal);