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');
81 ConfigurationAPI._activeGroups = {};
84 ConfigurationAPI._DEFAULT_COMMENT =
"No comment.";
85 ConfigurationAPI._POP_UP_DIALOG_ID =
"ConfigurationAPI-popUpDialog";
115 ConfigurationAPI._VERSION_ALIAS_PREPEND =
"ALIAS:";
116 ConfigurationAPI._SCRATCH_VERSION = 2147483647;
117 ConfigurationAPI._SCRATCH_ALIAS =
"Scratch";
119 ConfigurationAPI._OK_CANCEL_DIALOG_STR =
"";
120 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"<div title='' style='padding:5px;background-color:#eeeeee;border:1px solid #555555;position:relative;z-index:2000;" +
121 "width:95px;height:20px;margin:0 -122px -64px 10px; font-size: 16px; white-space:nowrap; text-align:center;'>";
122 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"<a class='popUpOkCancel' onclick='javascript:ConfigurationAPI.handleEditableFieldEditOK(); event.stopPropagation();' onmouseup='event.stopPropagation();' title='Accept Changes' style='color:green'>" +
123 "<b style='color:green;font-size: 16px;'>OK</b></a> | " +
124 "<a class='popUpOkCancel' onclick='javascript:ConfigurationAPI.handleEditableFieldEditCancel(); event.stopPropagation();' onmouseup='event.stopPropagation();' title='Discard Changes' style='color:red'>" +
125 "<b style='color:red;font-size: 16px;'>Cancel</b></a>";
126 ConfigurationAPI._OK_CANCEL_DIALOG_STR +=
"</div>";
142 ConfigurationAPI.getActiveGroups =
function(responseHandler)
145 DesktopContent.XMLHttpRequest(
"Request?RequestType=getActiveConfigGroups",
148 responseHandler(ConfigurationAPI.extractActiveGroups(req));
153 ConfigurationAPI.extractActiveGroups =
function(req)
158 var activeConfigGroups = [
159 DesktopContent.getXMLValue(req,
"Context-ActiveGroupName"),
160 DesktopContent.getXMLValue(req,
"Context-ActiveGroupKey"),
161 DesktopContent.getXMLValue(req,
"Backbone-ActiveGroupName"),
162 DesktopContent.getXMLValue(req,
"Backbone-ActiveGroupKey"),
163 DesktopContent.getXMLValue(req,
"Iterate-ActiveGroupName"),
164 DesktopContent.getXMLValue(req,
"Iterate-ActiveGroupKey"),
165 DesktopContent.getXMLValue(req,
"Configuration-ActiveGroupName"),
166 DesktopContent.getXMLValue(req,
"Configuration-ActiveGroupKey")];
170 retObj.Context.groupName = activeConfigGroups[i++];
171 retObj.Context.groupKey = activeConfigGroups[i++];
172 retObj.Backbone = {};
173 retObj.Backbone.groupName = activeConfigGroups[i++];
174 retObj.Backbone.groupKey = activeConfigGroups[i++];
176 retObj.Iterate.groupName = activeConfigGroups[i++];
177 retObj.Iterate.groupKey = activeConfigGroups[i++];
178 retObj.Configuration = {};
179 retObj.Configuration.groupName = activeConfigGroups[i++];
180 retObj.Configuration.groupKey = activeConfigGroups[i++];
184 Debug.log(
"Error extracting active groups: " + e);
188 ConfigurationAPI._activeGroups = {};
189 ConfigurationAPI._activeGroups = retObj;
224 ConfigurationAPI.getAliasesAndGroups =
function(responseHandler,optionForNoAliases,
231 if(!optionForNoAliases)
232 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
238 Debug.log(
"getGroupAliases handler");
240 var groupAliases = req.responseXML.getElementsByTagName(
"GroupAlias");
241 var groupNames = req.responseXML.getElementsByTagName(
"GroupName");
242 var groupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
243 var groupComments = req.responseXML.getElementsByTagName(
"GroupComment");
244 var groupTypes = req.responseXML.getElementsByTagName(
"GroupType");
245 var aliasComments = req.responseXML.getElementsByTagName(
"AliasComment");
250 for(var i=0;i<groupAliases.length;++i)
252 type = groupTypes[i].getAttribute(
'value');
254 if(type ==
"")
continue;
256 if(!retObj.aliases[type])
257 retObj.aliases[type] = [];
259 retObj.aliases[type].push({
260 "alias" : groupAliases[i].getAttribute(
'value'),
261 "name" : groupNames[i].getAttribute(
'value'),
262 "key" : groupKeys[i].getAttribute(
'value'),
263 "groupComment" : groupComments[i].getAttribute(
'value'),
264 "groupComment" : groupTypes[i].getAttribute(
'value'),
265 "aliasComment" : aliasComments[i].getAttribute(
'value')
272 (reqCount == 1 && optionForNoGroups))
275 console.log(
"getAliasesAndGroups retObj ",retObj);
276 responseHandler(retObj);
286 if(!optionForNoGroups)
287 DesktopContent.XMLHttpRequest(
"Request?RequestType=getConfigurationGroups"
288 +
"&doNotReturnMembers=1",
292 Debug.log(
"getConfigurationGroups handler");
294 retObj.activeGroups = {};
295 retObj.activeGroups = ConfigurationAPI.extractActiveGroups(req);
297 var groupNames = req.responseXML.getElementsByTagName(
"ConfigurationGroupName");
298 var groupKeys = req.responseXML.getElementsByTagName(
"ConfigurationGroupKey");
299 var groupTypes = req.responseXML.getElementsByTagName(
"ConfigurationGroupType");
300 var groupComments = req.responseXML.getElementsByTagName(
"ConfigurationGroupComment");
305 for(var i=0;i<groupNames.length;++i)
307 type = groupTypes[i].getAttribute(
'value');
309 if(type ==
"")
continue;
317 if(!retObj.groups[type])
318 retObj.groups[type] = {};
320 name = groupNames[i].getAttribute(
'value');
321 if(!retObj.groups[type][name])
323 retObj.groups[type][name] = {};
325 retObj.groups[type][name].groupComment = groupComments[i].getAttribute(
'value');
326 retObj.groups[type][name].keys = [];
329 retObj.groups[type][name].keys.push(groupKeys[i].getAttribute(
'value'));
335 (reqCount == 1 && optionForNoAliases))
338 console.log(
"getAliasesAndGroups retObj ",retObj);
339 responseHandler(retObj);
369 ConfigurationAPI.getSubsetRecords =
function(subsetBasePath,
370 filterList,responseHandler,modifiedTables)
372 var modifiedTablesListStr =
"";
373 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
375 if(i) modifiedTablesListStr +=
",";
376 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
377 modifiedTables[i].tableVersion;
379 if(filterList === undefined) filterList =
"";
381 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
383 "&configGroupKey=-1" +
384 "&hideStatusFalse=0" +
386 "startPath=/" + subsetBasePath +
387 "&filterList=" + filterList +
388 "&modifiedTables=" + modifiedTablesListStr,
391 ConfigurationAPI.extractActiveGroups(req);
394 var err = DesktopContent.getXMLValue(req,
"Error");
397 Debug.log(err,Debug.HIGH_PRIORITY);
398 if(responseHandler) responseHandler(records);
404 var tree = DesktopContent.getXMLNode(req,
"tree");
405 var nodes = tree.children;
406 for(var i=0;i<nodes.length;++i)
407 records.push(nodes[i].getAttribute(
"value"));
408 Debug.log(
"Records: " + records);
409 if(responseHandler) responseHandler(records);
424 ConfigurationAPI.getTree =
function(treeBasePath,depth,modifiedTables,
425 responseHandler,responseHandlerParam)
427 var modifiedTablesListStr =
"";
428 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
430 if(i) modifiedTablesListStr +=
",";
431 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
432 modifiedTables[i].tableVersion;
435 treeBasePath = treeBasePath.trim();
436 if(treeBasePath ==
"/") treeBasePath =
"";
438 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
440 "&configGroupKey=-1" +
441 "&hideStatusFalse=0" +
443 "startPath=/" + treeBasePath +
444 "&filterList=" +
"" +
445 "&modifiedTables=" + modifiedTablesListStr,
448 var err = DesktopContent.getXMLValue(req,
"Error");
451 Debug.log(err,Debug.HIGH_PRIORITY);
452 if(responseHandler) responseHandler(undefined,responseHandlerParam);
466 if(responseHandler) responseHandler(
467 DesktopContent.getXMLNode(req,
"tree"),
468 responseHandlerParam);
480 ConfigurationAPI.getTreeChildren =
function(tree,pathToChildren)
482 var pathArr = pathToChildren?pathToChildren.split(
'/'):
"";
486 children = tree.children;
489 for(var i=0;i<pathArr.length;++i)
491 if(pathArr[i].trim().length == 0)
continue;
493 Debug.log(i +
": " + pathArr[i]);
496 for(var j=0;j<children.length;++j)
497 if(children[j].getAttribute(
"value") == pathArr[i])
501 children = children[j].children;
502 Debug.log(
"found " + pathArr[i]);
508 Debug.log(
"Invalid path '" + pathToChildren +
"' through tree! How did you get here? Notify admins.", Debug.HIGH_PRIORITY);
516 for(var i=0;i<children.length;++i)
517 if(children[i].nodeName ==
"node")
518 retArr.push(children[i]);
528 ConfigurationAPI.getTreeRecordLinks =
function(node)
530 var children = node.children;
535 for(var i=0;i<children.length;++i)
537 if(children[i].nodeName !=
"node")
continue;
539 subchildren = children[i].children;
541 for(var j=0;j<subchildren.length;++j)
543 if(subchildren[j].nodeName ==
"LinkConfigurationName")
545 retArr.push(children[i]);
559 ConfigurationAPI.getTreeRecordName =
function(node)
563 var children = node.children;
564 if(children.length > 2)
566 if(children[0].nodeName ==
"valueType" &&
567 children[0].getAttribute(
"value") ==
"Disconnected")
568 throw(
"Disconnected link!");
570 if(children[0].nodeName ==
"UID")
571 return children[0].getAttribute(
"value");
573 if(children[1].nodeName ==
"UID")
574 return children[0].getAttribute(
"value");
577 return node.getAttribute(
"value");
584 ConfigurationAPI.getTreeLinkChildren =
function(link)
586 var children = link.children;
589 for(var i=0;i<children.length;++i)
591 if(children[i].nodeName ==
"UID")
596 else if(children[i].nodeName ==
"node")
597 retArr.push(children[i]);
607 ConfigurationAPI.getTreeLinkTable =
function(link)
609 var children = link.children;
610 for(var i=0;i<children.length;++i)
611 if(children[i].nodeName ==
"LinkConfigurationName")
612 return children[i].getAttribute(
"value");
613 throw(
"Table name not found!");
648 ConfigurationAPI.getFieldsOfRecords =
function(subsetBasePath,recordArr,fieldList,
649 maxDepth,responseHandler,modifiedTables)
651 var modifiedTablesListStr =
"";
652 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
654 if(i) modifiedTablesListStr +=
",";
655 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
656 modifiedTables[i].tableVersion;
659 var recordListStr =
"";
660 if(Array.isArray(recordArr))
661 for(var i=0;i<recordArr.length;++i)
663 if(i) recordListStr +=
",";
664 recordListStr += encodeURIComponent(recordArr[i]);
667 recordListStr = encodeURIComponent(recordArr);
669 subsetBasePath = subsetBasePath.trim();
670 if(subsetBasePath ==
"/") subsetBasePath =
"";
672 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeNodeCommonFields" +
674 "&configGroupKey=-1" +
675 "&depth=" + (maxDepth|0),
676 "startPath=/" + subsetBasePath +
677 "&recordList=" + recordListStr +
678 "&fieldList=" + fieldList +
679 "&modifiedTables=" + modifiedTablesListStr,
683 var err = DesktopContent.getXMLValue(req,
"Error");
686 Debug.log(err,Debug.HIGH_PRIORITY);
687 if(responseHandler) responseHandler(recFields);
691 var fields = DesktopContent.getXMLNode(req,
"fields");
693 var FieldTableNames = fields.getElementsByTagName(
"FieldTableName");
694 var FieldColumnNames = fields.getElementsByTagName(
"FieldColumnName");
695 var FieldRelativePaths = fields.getElementsByTagName(
"FieldRelativePath");
696 var FieldColumnTypes = fields.getElementsByTagName(
"FieldColumnType");
697 var FieldColumnDataTypes = fields.getElementsByTagName(
"FieldColumnDataType");
698 var FieldColumnDataChoices = fields.getElementsByTagName(
"FieldColumnDataChoices");
699 var FieldColumnDefaultValues = fields.getElementsByTagName(
"FieldColumnDefaultValue");
702 for(var i=0;i<FieldTableNames.length;++i)
705 obj.fieldTableName = DesktopContent.getXMLValue(FieldTableNames[i]);
706 obj.fieldColumnName = DesktopContent.getXMLValue(FieldColumnNames[i]);
707 obj.fieldRelativePath = DesktopContent.getXMLValue(FieldRelativePaths[i]);
708 obj.fieldColumnType = DesktopContent.getXMLValue(FieldColumnTypes[i]);
709 obj.fieldColumnDataType = DesktopContent.getXMLValue(FieldColumnDataTypes[i]);
710 obj.fieldColumnDefaultValue = DesktopContent.getXMLValue(FieldColumnDefaultValues[i]);
712 var FieldColumnDataChoicesArr = FieldColumnDataChoices[i].getElementsByTagName(
"FieldColumnDataChoice");
713 obj.fieldColumnDataChoicesArr = [];
714 for(var j=0; j<FieldColumnDataChoicesArr.length;++j)
715 obj.fieldColumnDataChoicesArr.push(DesktopContent.getXMLValue(FieldColumnDataChoicesArr[j]));
719 Debug.log(
"Records length: " + recFields.length);
720 if(responseHandler) responseHandler(recFields);
749 ConfigurationAPI.getFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldObjArr,
750 responseHandler,modifiedTables)
752 var modifiedTablesListStr =
"";
753 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
755 if(i) modifiedTablesListStr +=
",";
756 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
757 modifiedTables[i].tableVersion;
760 var recordListStr =
"";
761 if(Array.isArray(recordArr))
762 for(var i=0;i<recordArr.length;++i)
764 if(i) recordListStr +=
",";
765 recordListStr += encodeURIComponent(recordArr[i]);
768 recordListStr = encodeURIComponent(recordArr);
771 var fieldListStr =
"";
772 if(fieldObjArr.length && (typeof fieldObjArr[0] ===
"string"))
776 if(Array.isArray(fieldObjArr))
777 for(var i=0;i<fieldObjArr.length;++i)
779 if(i) fieldListStr +=
",";
780 fieldListStr += encodeURIComponent(fieldObjArr[i]);
783 fieldListStr = encodeURIComponent(fieldObjArr);
789 for(var i=0;i<fieldObjArr.length;++i)
791 if(i) fieldListStr +=
",";
792 fieldListStr += fieldObjArr[i].fieldRelativePath +
793 fieldObjArr[i].fieldColumnName;
797 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeNodeFieldValues" +
799 "&configGroupKey=-1",
800 "startPath=/" + subsetBasePath +
801 "&recordList=" + recordListStr +
802 "&fieldList=" + fieldListStr +
803 "&modifiedTables=" + modifiedTablesListStr,
806 var recFieldValues = [];
807 var err = DesktopContent.getXMLValue(req,
"Error");
810 Debug.log(err,Debug.HIGH_PRIORITY);
811 if(responseHandler) responseHandler(recFieldValues);
815 var fieldValues = req.responseXML.getElementsByTagName(
"fieldValues");
817 for(var f=0;f<fieldValues.length;++f)
819 var FieldPaths = fieldValues[f].getElementsByTagName(
"FieldPath");
820 var FieldValues = fieldValues[f].getElementsByTagName(
"FieldValue");
821 for(var i=0;i<FieldPaths.length;++i)
824 obj.fieldUID = DesktopContent.getXMLValue(fieldValues[f]);
825 obj.fieldPath = DesktopContent.getXMLValue(FieldPaths[i]);
826 obj.fieldValue = DesktopContent.getXMLValue(FieldValues[i]);
827 recFieldValues.push(obj);
831 if(responseHandler) responseHandler(recFieldValues);
861 ConfigurationAPI.getUniqueFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldList,
862 responseHandler,modifiedTables)
864 var modifiedTablesListStr =
"";
865 for(var i=0;modifiedTables && i<modifiedTables.length;++i)
867 if(i) modifiedTablesListStr +=
",";
868 modifiedTablesListStr += modifiedTables[i].tableName +
"," +
869 modifiedTables[i].tableVersion;
872 var recordListStr =
"";
873 if(Array.isArray(recordArr))
874 for(var i=0;i<recordArr.length;++i)
876 if(i) recordListStr +=
",";
877 recordListStr += encodeURIComponent(recordArr[i]);
880 recordListStr = encodeURIComponent(recordArr);
882 DesktopContent.XMLHttpRequest(
"Request?RequestType=getUniqueFieldValuesForRecords" +
884 "&configGroupKey=-1",
885 "startPath=/" + subsetBasePath +
886 "&recordList=" + recordListStr +
887 "&fieldList=" + fieldList +
888 "&modifiedTables=" + modifiedTablesListStr,
891 var fieldUniqueValues = [];
892 var err = DesktopContent.getXMLValue(req,
"Error");
895 Debug.log(err,Debug.HIGH_PRIORITY);
896 if(responseHandler) responseHandler(fieldUniqueValues);
900 var fields = req.responseXML.getElementsByTagName(
"field");
902 for(var i=0;i<fields.length;++i)
905 var uniqueValues = fields[i].getElementsByTagName(
"uniqueValue");
908 obj.fieldName = DesktopContent.getXMLValue(fields[i]);
909 obj.fieldUniqueValueArray = [];
910 for(var j=0;j<uniqueValues.length;++j)
911 obj.fieldUniqueValueArray.push(DesktopContent.getXMLValue(uniqueValues[j]));
912 fieldUniqueValues.push(obj);
914 Debug.log(
"fieldUniqueValues length: " + fieldUniqueValues.length);
915 if(responseHandler) responseHandler(fieldUniqueValues);
948 ConfigurationAPI.setFieldValuesForRecords =
function(subsetBasePath,recordArr,fieldObjArr,
949 valueArr,responseHandler,modifiedTablesIn,silenceErrors)
951 var modifiedTablesListStr =
"";
952 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
954 if(i) modifiedTablesListStr +=
",";
955 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
956 modifiedTablesIn[i].tableVersion;
959 var fieldListStr =
"";
960 if(fieldObjArr.length && (typeof fieldObjArr[0] ===
"string"))
964 if(Array.isArray(fieldObjArr))
965 for(var i=0;i<fieldObjArr.length;++i)
967 if(i) fieldListStr +=
",";
968 fieldListStr += encodeURIComponent(fieldObjArr[i]);
971 fieldListStr = encodeURIComponent(fieldObjArr);
977 for(var i=0;i<fieldObjArr.length;++i)
979 if(i) fieldListStr +=
",";
980 fieldListStr += fieldObjArr[i].fieldRelativePath +
981 fieldObjArr[i].fieldColumnName;
986 var valueListStr =
"";
987 if(Array.isArray(valueArr))
988 for(var i=0;i<valueArr.length;++i)
990 if(i) valueListStr +=
",";
991 valueListStr += encodeURIComponent(valueArr[i]);
994 valueListStr = encodeURIComponent(valueArr);
997 var recordListStr =
"";
998 if(Array.isArray(recordArr))
999 for(var i=0;i<recordArr.length;++i)
1001 if(i) recordListStr +=
",";
1002 recordListStr += encodeURIComponent(recordArr[i]);
1005 recordListStr = encodeURIComponent(recordArr);
1007 DesktopContent.XMLHttpRequest(
"Request?RequestType=setTreeNodeFieldValues" +
1009 "&configGroupKey=-1",
1010 "startPath=/" + subsetBasePath +
1011 "&recordList=" + recordListStr +
1012 "&valueList=" + valueListStr +
1013 "&fieldList=" + fieldListStr +
1014 "&modifiedTables=" + modifiedTablesListStr,
1017 var modifiedTables = [];
1019 var err = DesktopContent.getXMLValue(req,
"Error");
1023 Debug.log(err,Debug.HIGH_PRIORITY);
1024 if(responseHandler) responseHandler(modifiedTables,err);
1028 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
1029 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
1030 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
1034 for(var i=0;i<tableNames.length;++i)
1036 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
1037 if(tableVersion >= -1)
continue;
1039 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
1040 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
1041 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
1042 modifiedTables.push(obj);
1045 if(responseHandler) responseHandler(modifiedTables);
1082 ConfigurationAPI.popUpSaveModifiedTablesForm =
function(modifiedTables,responseHandler)
1086 Debug.log(
"ConfigurationAPI popUpSaveModifiedTablesForm");
1090 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
1093 el = document.createElement(
"div");
1094 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
1096 el.style.display =
"none";
1101 ConfigurationAPI.setPopUpPosition(el,w ,h-gh*2 );
1123 var modTblCount = 0;
1125 var modifiedTablesListStr =
"";
1127 for(var j=0;j<modifiedTables.length;++j)
1128 if((modifiedTables[j].tableVersion|0) < -1)
1132 modTblStr += modifiedTables[j].tableName;
1134 if(modifiedTablesListStr.length)
1135 modifiedTablesListStr +=
",";
1136 modifiedTablesListStr += modifiedTables[j].tableName;
1137 modifiedTablesListStr +=
",";
1138 modifiedTablesListStr += modifiedTables[j].tableVersion;
1141 var str =
"<a id='" +
1142 ConfigurationAPI._POP_UP_DIALOG_ID +
1143 "-cancel' href='#'>Cancel</a><br><br>";
1145 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-div'>";
1146 str +=
"Saving will create new persistent versions of each modified table." +
1148 "Here is the list of modified tables (count=" + modTblCount +
1154 str +=
"<div style='white-space:nowrap; width:" + w +
"px; height:40px; " +
1155 "overflow:auto; font-weight: bold;'>";
1162 DesktopContent.XMLHttpRequest(
"Request?RequestType=getAffectedActiveGroups" +
1165 "&modifiedTables=" + modifiedTablesListStr,
1168 var err = DesktopContent.getXMLValue(req,
"Error");
1171 Debug.log(err,Debug.HIGH_PRIORITY);
1178 var groups = req.responseXML.getElementsByTagName(
"AffectedActiveGroup");
1179 var memberNames, memberVersions;
1182 for(var i=0;i<groups.length;++i)
1184 xmlGroupName = DesktopContent.getXMLValue(groups[i],
"GroupName");
1185 str +=
"<div style='display:none' class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1186 "-affectedGroups' >";
1187 str += xmlGroupName;
1188 str +=
"," + DesktopContent.getXMLValue(groups[i],
"GroupKey");
1190 memberNames = groups[i].getElementsByTagName(
"MemberName");
1191 memberVersions = groups[i].getElementsByTagName(
"MemberVersion");
1192 Debug.log(
"memberNames.length " + memberNames.length);
1193 for(var j=0;j<memberNames.length;++j)
1194 str +=
"," + DesktopContent.getXMLValue(memberNames[j]) +
1195 "," + DesktopContent.getXMLValue(memberVersions[j]);
1199 if(modTblStr.length)
1203 modTblStr +=
"<a style='color:black' href='#' onclick='javascript:" +
1204 "var forFirefox = ConfigurationAPI.handleGroupCommentToggle(\"" +
1205 xmlGroupName +
"\");" +
1206 " ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
");'>";
1207 modTblStr += xmlGroupName;
1208 modTblStr +=
"</a>";
1211 modTblStr +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1212 xmlGroupName +
"' " +
1213 "class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-cache' " +
1214 "style='display:none'>" +
1215 decodeURIComponent(DesktopContent.getXMLValue(groups[i],
"GroupComment")) +
1219 str +=
"Please choose the options you want and click 'Save':" +
1223 str +=
"<input type='checkbox' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1224 "-bumpGroupVersions' checked " +
1225 "onclick='ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
");'>";
1227 str +=
"<a href='#' onclick='javascript:" +
1228 "var el = document.getElementById(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1229 "-bumpGroupVersions\");" +
1230 "var forFirefox = (el.checked = !el.checked);" +
1231 " ConfigurationAPI.handlePopUpHeightToggle(" + h +
"," + gh +
"); return false;'>";
1232 str +=
"Save Affected Groups as New Keys";
1234 str +=
"</input><br>";
1237 str +=
"<input type='checkbox' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1238 "-activateBumpedGroupVersions' checked " +
1241 str +=
"<a href='#' onclick='javascript:" +
1242 "var el = document.getElementById(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1243 "-activateBumpedGroupVersions\");" +
1244 "if(el.disabled) return false; " +
1245 "var forFirefox = (el.checked = !el.checked);" +
1247 str +=
"Also Activate New Groups";
1249 str +=
"</input><br>";
1251 str +=
"Here is the list of affected groups (count=" + groups.length +
1256 str +=
"<div style='white-space:nowrap; width:" + w +
"px; margin-bottom:20px; " +
1257 "overflow:auto; font-weight: bold;'>";
1259 str +=
"<div id='clearDiv'></div>";
1262 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-header'></div>";
1264 str +=
"<div id='clearDiv'></div>";
1266 str +=
"<textarea id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1267 "-groupComment' rows='4' cols='50' " +
1268 "style='width:417px;height:68px;display:none;margin:0;'>";
1269 str += ConfigurationAPI._DEFAULT_COMMENT;
1270 str +=
"</textarea>";
1275 str +=
"<div id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1276 "-groupAliasArea' ><center>";
1280 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
1285 var err = DesktopContent.getXMLValue(req,
"Error");
1288 Debug.log(err,Debug.HIGH_PRIORITY);
1293 var aliases = req.responseXML.getElementsByTagName(
"GroupAlias");
1294 var aliasGroupNames = req.responseXML.getElementsByTagName(
"GroupName");
1295 var aliasGroupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
1302 var alias, aliasGroupName, aliasGroupKey;
1303 var groupName, groupKey;
1304 var groupOptionIndex = [];
1305 for(var i=0;i<groups.length;++i)
1307 groupOptionIndex.push([-1,0]);
1309 groupName = DesktopContent.getXMLValue(groups[i],
"GroupName");
1310 groupKey = DesktopContent.getXMLValue(groups[i],
"GroupKey");
1314 for(var j=0;j<aliasGroupNames.length;++j)
1316 alias = DesktopContent.getXMLValue(aliases[j]);
1317 aliasGroupName = DesktopContent.getXMLValue(aliasGroupNames[j]);
1318 aliasGroupKey = DesktopContent.getXMLValue(aliasGroupKeys[j]);
1324 modTblStr +=
"<option value='" + alias +
"' ";
1327 if(aliasGroupName == groupName)
1329 if(groupOptionIndex[i][0] == -1 ||
1330 Math.abs(groupKey - aliasGroupKey) < groupOptionIndex[i][1])
1332 Debug.log(
"found alias");
1333 groupOptionIndex[i][0] = j;
1334 groupOptionIndex[i][1] = Math.abs(groupKey - aliasGroupKey);
1339 modTblStr +=
"</option>";
1342 str +=
"<input type='checkbox' class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias' " +
1343 (groupOptionIndex[i][0] >= 0?
"checked":
"") +
1346 str +=
"<a href='#' onclick='javascript:" +
1347 "var el = document.getElementsByClassName(\"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias\");" +
1348 "var forFirefox = (el[" + i +
"].checked = !el[" + i +
"].checked);" +
1350 str +=
"Set '<b style='font-size:16px'>" + groupName +
"</b>' to System Alias:";
1353 str +=
"<table cellpadding='0' cellspacing='0' border='0'><tr><td>";
1355 "id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" + (i) +
"' " +
1356 "style='margin:2px; height:" + (25) +
"px'>";
1360 str +=
"<input type='text' " +
1361 "id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-" + (i) +
"' " +
1362 "style='display:none; margin:2px; width:150px; height:" +
1368 str +=
"<div style='display:block' " +
1369 "class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editIcon' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1372 "onclick='ConfigurationAPI.handlePopUpAliasEditToggle(" +
1375 "title='Toggle free-form system alias editing' " +
1378 str +=
"<div class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1379 "-preloadImage' id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1380 "-preloadImage-editIconHover'></div>";
1382 str +=
"</td></tr></table>";
1388 el.style.height = h +
"px";
1391 str +=
"</center></div>";
1397 str +=
"</div><br>";
1405 str +=
"<input id='" + ConfigurationAPI._POP_UP_DIALOG_ID +
1406 "-submitButton' type='button' " +
1408 "value='Save' title='" +
1409 "Save new versions of every modified table\n" +
1410 "(Optionally, save new active groups and assign system aliases)" +
1415 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
1416 "-submitButton").onmouseup =
function() {
1417 Debug.log(
"Submit mouseup");
1418 this.disabled =
true;
1419 ConfigurationAPI.handleGroupCommentToggle(0,1);
1420 ConfigurationAPI.handlePopUpHeightToggle(h,gh);
1423 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1424 "-bumpGroupVersions").checked;
1425 var activatingSavedGroups =
1426 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1427 "-activateBumpedGroupVersions").checked;
1429 ConfigurationAPI.saveModifiedTables(modifiedTables,responseHandler,
1435 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
1436 "-cancel").onclick =
function(event) {
1437 Debug.log(
"Cancel click");
1438 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
1439 if(el) el.parentNode.removeChild(el);
1440 if(responseHandler) responseHandler([],[],[]);
1446 for(var i=0;i<groups.length;++i)
1447 if(groupOptionIndex[i][0] != -1)
1448 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" +
1449 i).selectedIndex = groupOptionIndex[i][0];
1458 document.body.appendChild(el);
1459 el.style.display =
"block";
1467 ConfigurationAPI.handleGroupCommentToggle =
function(groupName,setHideVal)
1469 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment");
1470 var hel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-header");
1473 var doHide = el.style.display !=
"none";
1474 if(setHideVal !== undefined)
1475 doHide = setHideVal;
1479 if(hel.textContent ==
"")
return;
1482 var gn = hel.textContent.split(
"'")[1];
1483 Debug.log(
"gn " + gn);
1484 cel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1487 cel.appendChild(document.createTextNode(el.value));
1491 el.style.display =
"none";
1494 if(gn == groupName || setHideVal !== undefined)
1501 cel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment-" +
1503 el.value = cel.textContent;
1504 el.style.display =
"block";
1505 ConfigurationAPI.setCaretPosition(el,0,cel.textContent.length);
1507 hel.innerHTML = (
"'" + groupName +
"' group comment:");
1517 ConfigurationAPI.handlePopUpHeightToggle =
function(h,gh)
1519 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-bumpGroupVersions");
1520 Debug.log(
"ConfigurationAPI.handlePopUpHeightToggle " + el.checked);
1522 var ael = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-activateBumpedGroupVersions");
1524 var groupCommentEl = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupComment");
1525 var groupCommentHeight = 0;
1527 if(groupCommentEl && groupCommentEl.style.display !=
"none")
1528 groupCommentHeight += 100;
1530 var popEl = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1535 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupAliasArea").style.display =
"none";
1536 popEl.style.height = (h + groupCommentHeight) +
"px";
1537 ael.disabled =
true;
1544 var grps = document.getElementsByClassName(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-affectedGroups");
1545 popEl.style.height = (h + grps.length*gh + groupCommentHeight) +
"px";
1546 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-groupAliasArea").style.display =
"block";
1547 ael.disabled =
false;
1553 ConfigurationAPI.handlePopUpAliasEditToggle =
function(i)
1555 Debug.log(
"handlePopUpAliasEditToggle " + i);
1557 var sel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-"+i);
1558 var tel = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-"+i);
1559 Debug.log(
"sel.style.display " + sel.style.display);
1560 if(sel.style.display ==
"none")
1562 sel.style.display =
"block";
1563 tel.style.display =
"none";
1567 tel.style.width = (sel.offsetWidth-2) +
"px";
1568 sel.style.display =
"none";
1569 tel.style.display =
"block";
1570 ConfigurationAPI.setCaretPosition(tel,0,tel.value.length);
1611 ConfigurationAPI.saveModifiedTables =
function(modifiedTables,responseHandler,
1612 doNotIgnoreWarnings,doNotSaveAffectedGroups,
1613 doNotActivateAffectedGroups,doNotSaveAliases,
1614 doNotIgnoreGroupActivationWarnings,
1619 var savedTables = [];
1620 var savedGroups = [];
1621 var savedAliases = [];
1623 if(!modifiedTables.length)
1625 Debug.log(
"No tables were modified. Nothing to do.", Debug.WARN_PRIORITY);
1626 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1642 var numberOfRequests = 0;
1643 var numberOfReturns = 0;
1644 var allRequestsSent =
false;
1648 function localHandleAffectedGroups()
1650 Debug.log(
"Done with table saving.");
1654 var activatingSavedGroups;
1655 var doRequestAffectedGroups =
false;
1659 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-bumpGroupVersions").checked;
1661 activatingSavedGroups =
1662 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-activateBumpedGroupVersions").checked;
1666 savingGroups = !doNotSaveAffectedGroups;
1667 activatingSavedGroups = !doNotActivateAffectedGroups;
1668 doRequestAffectedGroups =
true;
1674 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1675 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
1676 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1686 Debug.log(
"On to saving groups");
1688 numberOfRequests = 0;
1689 numberOfReturns = 0;
1690 allRequestsSent =
false;
1692 var affectedGroupNames = [];
1693 var affectedGroupComments = [];
1694 var affectedGroupConfigMap = [];
1696 var affectedGroupKeys = [];
1698 if(doRequestAffectedGroups)
1701 var modifiedTablesListStr =
"";
1702 var modTblCount = 0;
1704 for(var j=0;j<modifiedTables.length;++j)
1705 if((modifiedTables[j].tableVersion|0) < -1)
1709 modTblStr += modifiedTables[j].tableName;
1711 if(modifiedTablesListStr.length)
1712 modifiedTablesListStr +=
",";
1713 modifiedTablesListStr += modifiedTables[j].tableName;
1714 modifiedTablesListStr +=
",";
1715 modifiedTablesListStr += modifiedTables[j].tableVersion;
1721 DesktopContent.XMLHttpRequest(
"Request?RequestType=getAffectedActiveGroups" +
1724 "&modifiedTables=" + modifiedTablesListStr,
1727 var err = DesktopContent.getXMLValue(req,
"Error");
1730 Debug.log(err,Debug.HIGH_PRIORITY);
1732 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1737 var groups = req.responseXML.getElementsByTagName(
"AffectedActiveGroup");
1738 var memberNames, memberVersions;
1741 for(var i=0;i<groups.length;++i)
1743 affectedGroupNames.push( DesktopContent.getXMLValue(groups[i],
"GroupName"));
1744 affectedGroupComments.push(decodeURIComponent(DesktopContent.getXMLValue(groups[i],
"GroupComment")));
1746 memberNames = groups[i].getElementsByTagName(
"MemberName");
1747 memberVersions = groups[i].getElementsByTagName(
"MemberVersion");
1749 Debug.log(
"memberNames.length " + memberNames.length);
1752 affectedGroupConfigMap[i] =
"configList=";
1753 var memberVersion, memberName;
1754 for(var j=0;j<memberNames.length;++j)
1756 memberVersion = DesktopContent.getXMLValue(memberVersions[j])|0;
1757 memberName = DesktopContent.getXMLValue(memberNames[j]);
1758 if(memberVersion < -1)
1760 Debug.log(
"affectedArr " + memberName +
"-v" + memberVersion);
1762 for(var k=0;k<savedTables.length;++k)
1763 if(memberName == savedTables[k].tableName)
1765 Debug.log(
"found " + savedTables[k].tableName +
"-v" +
1766 savedTables[k].tableVersion);
1767 affectedGroupConfigMap[i] += memberName +
"," +
1768 savedTables[k].tableVersion +
",";
1773 affectedGroupConfigMap[i] += memberName +
1774 "," + memberVersion +
",";
1778 localHandleSavingAffectedGroups();
1784 var affectedGroupEls =
1785 document.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
1787 var affectedGroupCommentEls =
1788 document.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
1789 "-groupComment-cache");
1792 for(var i=0;i<affectedGroupEls.length;++i)
1794 Debug.log(affectedGroupEls[i].textContent);
1795 Debug.log(
"group comment: " + affectedGroupCommentEls[i].textContent);
1797 var affectedArr = affectedGroupEls[i].textContent.split(
',');
1799 affectedGroupComments.push(affectedGroupCommentEls[i].textContent);
1800 affectedGroupNames.push(affectedArr[0]);
1803 affectedGroupConfigMap[i] =
"configList=";
1805 for(var a=2;a<affectedArr.length;a+=2)
1806 if((affectedArr[a+1]|0) < -1)
1808 Debug.log(
"affectedArr " + affectedArr[a] +
"-v" + affectedArr[a+1]);
1810 for(var k=0;k<savedTables.length;++k)
1811 if(affectedArr[a] == savedTables[k].tableName)
1813 Debug.log(
"found " + savedTables[k].tableName +
"-v" +
1814 savedTables[k].tableVersion);
1815 affectedGroupConfigMap[i] += affectedArr[a] +
"," +
1816 savedTables[k].tableVersion +
",";
1821 affectedGroupConfigMap[i] += affectedArr[a] +
"," + affectedArr[a+1] +
",";
1824 localHandleSavingAffectedGroups();
1829 function localHandleSavingAffectedGroups()
1832 for(var i=0;i<affectedGroupNames.length;++i)
1835 reqStr =
"Request?RequestType=saveNewConfigurationGroup" +
1836 "&groupName=" + affectedGroupNames[i] +
1837 "&allowDuplicates=0" +
1838 "&lookForEquivalent=1" +
1839 "&ignoreWarnings=" + (doNotIgnoreWarnings?0:1) +
1840 "&groupComment=" + encodeURIComponent(affectedGroupComments[i]);
1842 Debug.log(affectedGroupConfigMap[i]);
1846 DesktopContent.XMLHttpRequest(reqStr, affectedGroupConfigMap[i],
1847 function(req,affectedGroupIndex)
1850 var attemptedNewGroupName = DesktopContent.getXMLValue(req,
"AttemptedNewGroupName");
1851 var treeErr = DesktopContent.getXMLValue(req,
"TreeErrors");
1854 Debug.log(treeErr,Debug.HIGH_PRIORITY);
1855 Debug.log(
"There were problems identified in the tree view of the " +
1856 "attempted new group '" +
1857 attemptedNewGroupName +
1858 "'.\nThe new group was not created.\n" +
1859 "(Note: Other tables and groups may have been successfully created, " +
1860 "and would have success indications below this error info)\n\n" +
1861 "You can save the group anyway (if you think it is a good idea) by clicking " +
1862 "the button in the pop-up dialog " +
1863 "'<u>Save Groups with Warnings Ignored</u>.' " +
1864 "\n\nOtherwise, you can hit '<u>Cancel</u>.' and fix the tree. " +
1865 "Below you will find the description of the problem:",
1866 Debug.HIGH_PRIORITY);
1869 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-submitButton");
1872 el.onmouseup =
function() {
1873 Debug.log(
"Submit mouseup");
1874 this.disabled =
true;
1875 ConfigurationAPI.handleGroupCommentToggle(0,1);
1876 ConfigurationAPI.handlePopUpHeightToggle(h,gh);
1879 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1880 "-bumpGroupVersions").checked;
1881 var activatingSavedGroups =
1882 document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
1883 "-activateBumpedGroupVersions").checked;
1885 ConfigurationAPI.saveModifiedTables(modifiedTables,responseHandler,
1887 doNotSaveAffectedGroups,
1888 doNotActivateAffectedGroups,doNotSaveAliases
1891 el.value =
"Save Groups with Warnings Ignored";
1892 el.disabled =
false;
1897 var err = DesktopContent.getXMLValue(req,
"Error");
1900 Debug.log(err,Debug.HIGH_PRIORITY);
1903 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
1904 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
1905 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
1911 var newGroupKey = DesktopContent.getXMLValue(req,
"ConfigurationGroupKey");
1912 affectedGroupKeys.push(newGroupKey);
1916 obj.groupName = attemptedNewGroupName;
1917 obj.groupKey = newGroupKey;
1918 obj.groupComment = affectedGroupComments[affectedGroupIndex];
1919 savedGroups.push(obj);
1923 var foundEquivalentKey = DesktopContent.getXMLValue(req,
"foundEquivalentKey");
1924 if(foundEquivalentKey)
1925 Debug.log(
"Using existing group '" + attemptedNewGroupName +
1926 " (" + newGroupKey +
")'", Debug.INFO_PRIORITY);
1928 Debug.log(
"Successfully created new group '" + attemptedNewGroupName +
1929 " (" + newGroupKey +
")'", Debug.INFO_PRIORITY);
1934 if(activatingSavedGroups)
1935 ConfigurationAPI.activateGroup(attemptedNewGroupName,newGroupKey,
1936 doNotIgnoreGroupActivationWarnings?
false:
true );
1939 if(allRequestsSent &&
1940 numberOfReturns == numberOfRequests)
1942 Debug.log(
"Done with group saving.");
1944 Debug.log(
"Moving on to Alias creation...");
1952 var setAliasCheckboxes;
1954 var groupAlias, groupName, groupKey;
1955 var setAliasCheckboxIndex = -1;
1956 var groupAliasName, groupAliasVersion;
1958 var affectedGroupAliases = [];
1971 setAliasCheckboxes =
1972 document.getElementsByClassName(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-setGroupAlias");
1975 if(setAliasCheckboxes.length != affectedGroupNames.length)
1979 localNextAliasHandler();
1980 Debug.log(
"Aliases set in motion");
1985 setAliasCheckboxes = [];
1986 for(var i in affectedGroupNames)
1987 setAliasCheckboxes.push({
"checked" : ((!doNotSaveAliases)?1:0) });
1997 DesktopContent.XMLHttpRequest(
"Request?RequestType=getGroupAliases" +
2002 var err = DesktopContent.getXMLValue(req,
"Error");
2005 Debug.log(err,Debug.HIGH_PRIORITY);
2006 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2010 var aliases = req.responseXML.getElementsByTagName(
"GroupAlias");
2011 var aliasGroupNames = req.responseXML.getElementsByTagName(
"GroupName");
2012 var aliasGroupKeys = req.responseXML.getElementsByTagName(
"GroupKey");
2017 var alias, aliasGroupName, aliasGroupKey;
2018 var groupName, groupKey;
2019 var groupOptionIndex = [];
2020 for(var i=0;i<affectedGroupNames.length;++i)
2022 groupOptionIndex.push([-1,0]);
2024 groupName = affectedGroupNames[i];
2025 groupKey = affectedGroupKeys[i];
2028 for(var j=0;j<aliasGroupNames.length;++j)
2030 alias = DesktopContent.getXMLValue(aliases[j]);
2031 aliasGroupName = DesktopContent.getXMLValue(aliasGroupNames[j]);
2032 aliasGroupKey = DesktopContent.getXMLValue(aliasGroupKeys[j]);
2038 if(aliasGroupName == groupName)
2040 if(groupOptionIndex[i][0] == -1 ||
2041 Math.abs(groupKey - aliasGroupKey) < groupOptionIndex[i][1])
2043 Debug.log(
"found alias");
2044 groupOptionIndex[i][0] = j;
2045 groupOptionIndex[i][1] = Math.abs(groupKey - aliasGroupKey);
2051 setAliasCheckboxes[i].checked = (groupOptionIndex[i][0] >= 0?1:0);
2053 affectedGroupAliases.push(groupOptionIndex[i][0] >= 0?
2054 DesktopContent.getXMLValue(aliases[groupOptionIndex[i][0]]):
"");
2058 localNextAliasHandler();
2059 Debug.log(
"Aliases set in motion");
2072 function localNextAliasHandler(retParams)
2075 if(setAliasCheckboxIndex >= 0)
2079 if(retParams.newGroupCreated)
2081 Debug.log(
"Successfully modified the active Backbone group " +
2082 " to set the System Alias '" + groupAlias +
"' to " +
2083 " refer to the current group '" + groupName +
2084 " (" + groupKey +
").'" +
2086 "Backbone group '" + retParams.groupName +
" (" +
2087 retParams.groupKey +
")' was created and activated.",
2088 Debug.INFO_PRIORITY);
2092 obj.groupName = groupName;
2093 obj.groupKey = groupKey;
2094 obj.groupAlias = groupAlias;
2095 savedAliases.push(obj);
2099 Debug.log(
"Success, but no need to create a new Backbone group. " +
2100 "An existing Backbone group " +
2101 " already has the System Alias '" + groupAlias +
"' " +
2102 " referring to the current group '" + groupName +
2103 " (" + groupKey +
").'" +
2105 "Backbone group '" + retParams.groupName +
" (" +
2106 retParams.groupKey +
")' was activated.",
2107 Debug.INFO_PRIORITY);
2111 Debug.log(
"Process interrupted. Failed to modify the currently active Backbone!",Debug.HIGH_PRIORITY);
2114 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2115 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2116 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2120 ++setAliasCheckboxIndex;
2123 setAliasCheckboxIndex = 0;
2126 while(setAliasCheckboxIndex < setAliasCheckboxes.length &&
2127 !setAliasCheckboxes[setAliasCheckboxIndex].checked)
2128 Debug.log(
"Skipping checkbox " + (++setAliasCheckboxIndex));
2130 if(setAliasCheckboxIndex >= setAliasCheckboxes.length)
2132 Debug.log(
"Done with alias checkboxes ");
2136 Debug.log(
"No System Aliases were changed, so Backbone was not modified. Done.");
2139 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2140 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2141 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2145 Debug.log(
"Saving and activating Backbone done.");
2148 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2149 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2150 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2157 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasSelect-" +
2158 setAliasCheckboxIndex);
2159 if(el.style.display ==
"none")
2162 el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"-editAliasTextBox-" +
2163 setAliasCheckboxIndex);
2165 groupAlias = el.value;
2171 groupAlias = affectedGroupAliases[setAliasCheckboxIndex];
2174 groupName = affectedGroupNames[setAliasCheckboxIndex];
2175 groupKey = affectedGroupKeys[setAliasCheckboxIndex];
2177 Debug.log(
"groupAlias = " + groupAlias);
2178 Debug.log(
"groupName = " + groupName);
2179 Debug.log(
"groupKey = " + groupKey);
2181 ConfigurationAPI.setGroupAliasInActiveBackbone(groupAlias,groupName,groupKey,
2183 localNextAliasHandler,
2193 allRequestsSent =
true;
2194 if(numberOfRequests == 0)
2197 Debug.log(
"There were no groups to save!", Debug.INFO_PRIORITY);
2200 var el = document.getElementById(
"" + ConfigurationAPI._POP_UP_DIALOG_ID +
"");
2201 if(el && !doNotKillPopUpEl) el.parentNode.removeChild(el);
2211 for(var j=0;j<modifiedTables.length;++j)
2212 if((modifiedTables[j].tableVersion|0) < -1)
2214 var reqStr =
"Request?RequestType=saveSpecificConfiguration" +
2215 "&dataOffset=0&chunkSize=0" +
2216 "&configName=" + modifiedTables[j].tableName +
2217 "&version="+modifiedTables[j].tableVersion +
2220 encodeURIComponent(modifiedTables[j].tableComment?modifiedTables[j].tableComment:
"") +
2221 "&sourceTableAsIs=1" +
2222 "&lookForEquivalent=1";
2229 DesktopContent.XMLHttpRequest(reqStr,
"",
2230 function(req,modifiedTableIndex)
2232 var err = DesktopContent.getXMLValue(req,
"Error");
2235 Debug.log(err,Debug.HIGH_PRIORITY);
2238 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2240 if(responseHandler) responseHandler(savedTables,savedGroups,savedAliases);
2244 var configName = DesktopContent.getXMLValue(req,
"savedName");
2245 var version = DesktopContent.getXMLValue(req,
"savedVersion");
2246 var foundEquivalentVersion = DesktopContent.getXMLValue(req,
"foundEquivalentVersion") | 0;
2248 if(foundEquivalentVersion)
2249 Debug.log(
"Using existing table '" + configName +
"-v" +
2250 version +
"'",Debug.INFO_PRIORITY);
2252 Debug.log(
"Successfully created new table '" + configName +
"-v" +
2253 version +
"'",Debug.INFO_PRIORITY);
2258 obj.tableName = configName;
2259 obj.tableVersion = version;
2260 obj.tableComment = modifiedTables[modifiedTableIndex].tableComment;
2261 savedTables.push(obj);
2266 if(allRequestsSent &&
2267 numberOfReturns == numberOfRequests)
2269 if(!doNotSaveAffectedGroups)
2270 localHandleAffectedGroups();
2276 allRequestsSent =
true;
2277 if(numberOfRequests == 0)
2280 Debug.log(
"No tables were modified. Should be impossible to get here.", Debug.HIGH_PRIORITY);
2287 ConfigurationAPI.activateGroup =
function(groupName, groupKey,
2288 ignoreWarnings, doneHandler)
2290 DesktopContent.XMLHttpRequest(
"Request?RequestType=activateConfigGroup" +
2291 "&groupName=" + groupName +
2292 "&groupKey=" + groupKey +
2293 "&ignoreWarnings=" + (ignoreWarnings?
"1":
"0") +
2299 var err = DesktopContent.getXMLValue(req,
"Error");
2302 Debug.log(err,Debug.HIGH_PRIORITY);
2310 str +=
" <a href='#' onclick='javascript:ConfigurationAPI.activateGroup(\"" +
2312 "\",\"" + groupKey +
"\",true); return false;'>";
2313 str +=
"Activate " +
2314 groupName +
"(" + groupKey +
") w/warnings ignored</a>";
2316 Debug.log(
"If you are are sure it is a good idea you can try to " +
2317 "activate the group with warnings ignored: " +
2318 str,Debug.HIGH_PRIORITY);
2322 if(doneHandler) doneHandler();
2340 ConfigurationAPI.setGroupAliasInActiveBackbone =
function(groupAlias,groupName,groupKey,
2341 newBackboneNameAdd,doneHandler,doReturnParams)
2343 Debug.log(
"setGroupAliasInActiveBackbone groupAlias=" + groupAlias);
2344 Debug.log(
"setGroupAliasInActiveBackbone groupName=" + groupName);
2345 Debug.log(
"setGroupAliasInActiveBackbone groupKey=" + groupKey);
2347 if(!groupAlias || groupAlias.trim() ==
"")
2349 Debug.log(
"Process interrupted. Invalid empty alias given!",Debug.HIGH_PRIORITY);
2350 if(doneHandler) doneHandler();
2354 if(!groupName || groupName.trim() ==
"" || !groupKey || groupKey.trim() ==
"")
2356 Debug.log(
"Process interrupted. Invalid group name and key given!",Debug.HIGH_PRIORITY);
2357 if(doneHandler) doneHandler();
2361 if(!newBackboneNameAdd || newBackboneNameAdd ==
"")
2362 newBackboneNameAdd =
"Wiz";
2363 newBackboneNameAdd +=
"Backbone";
2364 Debug.log(
"setGroupAliasInActiveBackbone newBackboneNameAdd=" + newBackboneNameAdd);
2366 DesktopContent.XMLHttpRequest(
"Request?RequestType=setGroupAliasInActiveBackbone" +
2367 "&groupAlias=" + groupAlias +
2368 "&groupName=" + groupName +
2369 "&groupKey=" + groupKey,
"",
2370 ConfigurationAPI.newWizBackboneMemberHandler,
2371 [(
"GroupAlias" + newBackboneNameAdd),doneHandler,doReturnParams],
2383 ConfigurationAPI.newWizBackboneMemberHandler =
function(req,params)
2385 var err = DesktopContent.getXMLValue(req,
"Error");
2388 Debug.log(err,Debug.HIGH_PRIORITY);
2389 Debug.log(
"Process interrupted. Failed to modify the currently active Backbone!",Debug.HIGH_PRIORITY);
2396 var groupAliasName = DesktopContent.getXMLValue(req,
"savedName");
2397 var groupAliasVersion = DesktopContent.getXMLValue(req,
"savedVersion");
2399 Debug.log(
"groupAliasName=" + groupAliasName);
2400 Debug.log(
"groupAliasVersion=" + groupAliasVersion);
2402 var configNames = req.responseXML.getElementsByTagName(
"oldBackboneName");
2403 var configVersions = req.responseXML.getElementsByTagName(
"oldBackboneVersion");
2406 var configMap =
"configList=";
2408 for(var i=0;i<configNames.length;++i)
2410 name = configNames[i].getAttribute(
"value");
2412 if(name == groupAliasName)
2414 configMap += name +
"," +
2415 groupAliasVersion +
",";
2419 configMap += name +
"," +
2420 configVersions[i].getAttribute(
"value") +
",";
2423 ConfigurationAPI.saveGroupAndActivate(params[0],configMap,params[1],params[2],
2429 ConfigurationAPI.saveGroupAndActivate =
function(groupName,configMap,doneHandler,doReturnParams,
2432 DesktopContent.XMLHttpRequest(
"Request?RequestType=saveNewConfigurationGroup&groupName=" +
2434 "&allowDuplicates=" + (lookForEquivalent?
"0":
"1") +
2435 "&lookForEquivalent=" + (lookForEquivalent?
"1":
"0") +
2440 var err = DesktopContent.getXMLValue(req,
"Error");
2441 var name = DesktopContent.getXMLValue(req,
"ConfigurationGroupName");
2442 var key = DesktopContent.getXMLValue(req,
"ConfigurationGroupKey");
2443 var newGroupCreated =
true;
2448 Debug.log(err,Debug.HIGH_PRIORITY);
2449 Debug.log(
"Process interrupted. Failed to create a new group!" +
2450 " Please see details below.",
2451 Debug.HIGH_PRIORITY);
2453 if(doneHandler) doneHandler();
2458 Debug.log(err,Debug.WARN_PRIORITY);
2459 Debug.log(
"Process interrupted. Failed to create a new group!" +
2460 " (Likely the currently active group already represents what is being requested)\n\n" +
2461 "Going on with existing backbone group, name=" + name +
" & key=" + key,
2462 Debug.WARN_PRIORITY);
2463 newGroupCreated =
false;
2469 DesktopContent.XMLHttpRequest(
"Request?RequestType=activateConfigGroup" +
2470 "&groupName=" + name +
2471 "&groupKey=" + key,
"",
2476 activateSystemConfigHandler(req);
2490 "newGroupCreated" : newGroupCreated
2492 doneHandler(retParams);
2510 ConfigurationAPI.getGroupTypeMemberNames =
function(groupType,responseHandler)
2512 DesktopContent.XMLHttpRequest(
"Request?RequestType=get" + groupType +
"MemberNames",
"",
2517 var err = DesktopContent.getXMLValue(req,
"Error");
2520 Debug.log(err,Debug.HIGH_PRIORITY);
2521 if(responseHandler) responseHandler(retArr);
2524 var memberNames = req.responseXML.getElementsByTagName(groupType +
"Member");
2526 for(var i=0;i<memberNames.length;++i)
2527 retArr[i] = memberNames[i].getAttribute(
"value");
2529 Debug.log(
"Members found for group type " + groupType +
" = " + retArr.length);
2530 if(responseHandler) responseHandler(retArr);
2546 ConfigurationAPI.bitMapDialog =
function(fieldName,bitMapParams,initBitMapValue,okHandler,cancelHandler)
2548 Debug.log(
"ConfigurationAPI bitMapDialog");
2552 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2555 el = document.createElement(
"div");
2556 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
2558 el.style.display =
"none";
2559 el.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmapDialog");
2625 var minValue, maxValue;
2629 var forcedAspectH, forcedAspectW;
2631 var minValueColor, midValueColor, maxValueColor;
2632 var ceilValueColor, floorValueColor;
2634 var doDisplayRowsAscending, doDisplayColsAscending;
2635 var doSnakeColumns, doSnakeRows;
2638 if(!localValidateInputs())
2640 Debug.log(
"Input parameters array to the Bitmap Dialog was as follows:\n " +
2641 bitMapParams, Debug.HIGH_PRIORITY);
2642 Debug.log(
"Input parameters to the Bitmap Dialog are invalid. Aborting.", Debug.HIGH_PRIORITY);
2643 return cancelHandler();
2647 var numberDigitW = 8, numberDigitH = 12;
2648 var axisPaddingExtra = numberDigitW;
2649 function localCalcExtraAxisPadding() {
2651 while((lrows /= 10) > 1) axisPaddingExtra += numberDigitW;
2652 } localCalcExtraAxisPadding();
2654 var axisPaddingMargin = 5;
2655 var axisPadding = axisPaddingMargin + axisPaddingExtra + axisPaddingMargin + butttonSz + axisPaddingMargin;
2656 var bmpGridThickness = 1;
2657 var bmpBorderSize = 1;
2668 var allRowBtns, allColBtns, allBtn;
2669 var rowLeftNums, rowRightNums, colTopNums, colBottomNums;
2670 var bmpCanvas, bmpContext;
2678 var cursorInfo, hdrCursorInfo;
2683 var clickColors = [];
2684 var clickValues = [];
2687 localCreateHeader();
2688 localCreateBitmap();
2689 localCreateGridButtons();
2691 localInitBitmapData();
2694 window.addEventListener(
"resize",localPaint);
2696 document.body.appendChild(el);
2697 el.style.display =
"block";
2703 function localCreateCancelClickHandler()
2705 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2706 "-cancel").onclick =
function(event) {
2707 Debug.log(
"Cancel click");
2708 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2709 if(el) el.parentNode.removeChild(el);
2710 window.removeEventListener(
"resize",localPaint);
2714 } localCreateCancelClickHandler();
2719 function localCreateOkClickHandler()
2721 var convertFunc = localConvertFullGridToRowCol;
2722 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2723 "-ok").onclick =
function(event) {
2724 Debug.log(
"OK click");
2725 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2726 if(el) el.parentNode.removeChild(el);
2727 window.removeEventListener(
"resize",localPaint);
2729 var transGrid = convertFunc();
2730 var dataJsonStr =
"[\n";
2731 for(var r=0;r<transGrid.length;++r)
2733 if(r) dataJsonStr +=
",\n";
2734 dataJsonStr +=
"\t[";
2735 for(var c=0;c<transGrid[0].length;++c)
2737 if(c) dataJsonStr +=
",";
2738 dataJsonStr += transGrid[r][c];
2742 dataJsonStr +=
"\n]";
2743 okHandler(dataJsonStr);
2746 } localCreateOkClickHandler();
2751 function localCreateMouseHandler()
2753 var stopProp =
false;
2754 var rLast = -1, cLast = -1;
2756 var buttonDown = -1;
2763 function localGetRowCol(x,y) {
2764 x -= popSz.x + bmpX + 1;
2765 y -= popSz.y + bmpY + 1;
2766 var r = (y/cellH)|0;
2768 var c = (x/cellW)|0;
2770 var inRowBtnsX = (x >= - axisPaddingMargin - bmpBorderSize - butttonSz) &&
2771 (x <= - axisPaddingMargin - bmpBorderSize);
2772 var inColBtnsY = (y >= bmpH + axisPaddingMargin) &&
2773 (y <= bmpH + axisPaddingMargin + butttonSz + bmpBorderSize*2);
2781 if(inRowBtnsX && r >= 0 && r < rows)
2782 return {
"r":r,
"c":-2};
2783 else if(inColBtnsY && c >= 0 && c < cols)
2784 return {
"r":-2,
"c":c};
2785 else if(inRowBtnsX && inColBtnsY)
2786 return {
"r":-2,
"c":-2};
2787 else if(r < 0 || c < 0 || r >= rows || c >= cols)
2788 return {
"r":-1,
"c":-1};
2789 return {
"r":r,
"c":c};
2794 el.onmousemove =
function(event) {
2795 var cell = localGetRowCol(event.pageX,event.pageY);
2796 var r = cell.r, c = cell.c;
2798 var cursorT = (
event.pageX - popSz.x - bmpX);
2799 if(cursorT < 0) cursorT = 0;
2800 if(cursorT > bmpW) cursorT = bmpW;
2802 cursorInfo.style.left = (
event.pageX - popSz.x +
2805 (cursorT)/bmpW*(-cursorInfo.innerHTML.length*8-20) + (bmpW-cursorT)/bmpW*(2))+
2807 cursorInfo.style.top = (
event.pageY - popSz.y - 35) +
"px";
2810 hdrCursorInfo.style.left = (bmpX + bmpW/2 +
2812 hdrCursorInfo.style.top = (bmpY - 45) +
"px";
2815 if(rLast == r && cLast == c)
2817 rLast = r; cLast = c;
2819 if(r == -1 || c == -1)
2822 rLast = -1; cLast = -1;
2823 bmpOverlay.style.display =
"none";
2824 cursorInfo.style.display =
"none";
2825 hdrCursorInfo.style.display =
"none";
2829 cursorInfo.style.display =
"block";
2836 if(r != -2 && c == -2)
2839 transRC = localConvertGridToRowCol(r,
2840 doDisplayColsAscending?0:cols-1);
2842 transRC = localConvertGridToRowCol(r,0);
2846 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2848 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2849 bmpOverlay.style.top = (bmpY + r*cellH - 1 + (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2850 bmpOverlay.style.width = (butttonSz) +
"px";
2851 bmpOverlay.style.height = (cellH - (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2852 bmpOverlay.style.display =
"block";
2855 infoStr =
"Set all pixels in row " + transRC[0] +
".";
2857 else if(r == -2 && c != -2)
2860 transRC = localConvertGridToRowCol(
2861 doDisplayRowsAscending?0:rows-1,c);
2863 transRC = localConvertGridToRowCol(0,c);
2868 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2870 bmpOverlay.style.left = (bmpX + c*cellW - 1 + (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2871 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2872 bmpOverlay.style.width = (cellW + 1 - (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2873 bmpOverlay.style.height = (butttonSz) +
"px";
2874 bmpOverlay.style.display =
"block";
2877 infoStr =
"Set all pixels in column " + transRC[1] +
".";
2879 else if(r == -2 && c == -2)
2883 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2885 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2886 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2887 bmpOverlay.style.width = (butttonSz) +
"px";
2888 bmpOverlay.style.height = (butttonSz) +
"px";
2889 bmpOverlay.style.display =
"block";
2892 infoStr =
"Set all pixels.";
2896 transRC = localConvertGridToRowCol(r,c);
2902 var overClr = (bmpDataImage.data[(r*cols+c)*4+0] +
2903 bmpDataImage.data[(r*cols+c)*4+1] +
2904 bmpDataImage.data[(r*cols+c)*4+2]) < (256+128)?255:0;
2906 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData(
2907 [overClr,overClr,overClr,100]);
2909 bmpOverlay.style.left = (bmpX + c*cellW) +
"px";
2910 bmpOverlay.style.top = (bmpY + r*cellH) +
"px";
2911 bmpOverlay.style.width = (cellW) +
"px";
2912 bmpOverlay.style.height = (cellH) +
"px";
2913 bmpOverlay.style.display =
"block";
2917 infoStr =
"Value = " + bmpData[r][c] +
" @ (Row,Col) = (" +
2918 transRC[0] +
"," + transRC[1] +
")";
2920 cursorInfo.innerHTML = infoStr;
2921 hdrCursorInfo.innerHTML = infoStr;
2924 if(r == -2 && c == -2)
2930 localSetBitMap(r,c);
2937 el.onmousedown =
function(event) {
2939 var cell = localGetRowCol(event.pageX,event.pageY);
2940 var r = cell.r, c = cell.c;
2944 buttonDown =
event.button;
2946 if(r == -1 || c == -1)
2948 rLast = -1; cLast = -1;
2953 rLast = r; cLast = c;
2954 localSetBitMap(r,c);
2957 event.stopPropagation();
2963 el.onmouseup =
function(event) {
2970 el.oncontextmenu =
function(event) {
2976 event.stopPropagation();
2983 function localSetBitMap(r,c) {
2985 Debug.log(
"set r,c " + buttonDown +
" @ " + r +
"," + c );
2986 buttonDown = buttonDown?1:0;
2988 var maxr = r==-2?rows-1:r;
2989 var minr = r==-2?0:r;
2990 var maxc = c==-2?cols-1:c;
2991 var minc = c==-2?0:c;
2993 for(r=minr;r<=maxr;++r)
2994 for(c=minc;c<=maxc;++c)
2996 bmpData[r][c] = clickValues[buttonDown];
2997 bmpDataImage.data[(r*cols + c)*4 + 0] =
2998 clickColors[buttonDown][0];
2999 bmpDataImage.data[(r*cols + c)*4 + 1] =
3000 clickColors[buttonDown][1];
3001 bmpDataImage.data[(r*cols + c)*4 + 2] =
3002 clickColors[buttonDown][2];
3003 bmpDataImage.data[(r*cols + c)*4 + 3] =
3004 clickColors[buttonDown][3];
3007 bmpContext.putImageData(bmpDataImage,0,0);
3008 bmp.src = bmpCanvas.toDataURL();
3011 } localCreateMouseHandler();
3017 function localValidateInputs() {
3020 if(bitMapParams.length != 16)
3022 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)." +
3023 "\nHere is a printout of the input parameters: " + bitMapParams,Debug.HIGH_PRIORITY);
3026 var DEFAULT =
"DEFAULT";
3028 rows = bitMapParams[0]|0;
3029 cols = bitMapParams[1]|0;
3030 bitFieldSize = bitMapParams[2]|0;
3034 if(rows < 1 || rows >= 1<<30)
3036 Debug.log(
"Illegal input parameters, rows of " + rows +
" is illegal. " +
3037 "(rows possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3040 if(cols < 1 || cols >= 1<<30)
3042 Debug.log(
"Illegal input parameters, cols of " + cols +
" is illegal. " +
3043 "(cols possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3046 if(bitFieldSize < 1 || bitFieldSize > 31)
3048 Debug.log(
"Illegal input parameters, bitFieldSize of " + bitFieldSize +
" is illegal. " +
3049 "(bitFieldSize possible values are from 1 to " + (31) +
".)",Debug.HIGH_PRIORITY);
3054 if(bitFieldSize > 30)
3057 for(var i=0;i<bitFieldSize;++i)
3061 bitMask = (1<<bitFieldSize) - 1;
3063 minValue = bitMapParams[3] ==
"DEFAULT" || bitMapParams[3] ==
""?0:(bitMapParams[3]|0);
3064 maxValue = bitMapParams[4] ==
"DEFAULT" || bitMapParams[4] ==
""?bitMask:(bitMapParams[4]|0);
3065 if(maxValue < minValue)
3067 midValue = (maxValue + minValue)/2;
3068 stepValue = bitMapParams[5] ==
"DEFAULT" || bitMapParams[5] ==
""?1:(bitMapParams[5]|0);
3070 if(minValue < 0 || minValue > bitMask)
3072 Debug.log(
"Illegal input parameters, minValue of " + minValue +
" is illegal. " +
3073 "(minValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3076 if(maxValue < 0 || maxValue > bitMask)
3078 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
" is illegal. " +
3079 "(maxValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3082 if(minValue > maxValue)
3084 Debug.log(
"Illegal input parameters, minValue > maxValue is illegal.",Debug.HIGH_PRIORITY);
3087 if(stepValue < 1 || stepValue > maxValue - minValue)
3089 Debug.log(
"Illegal input parameters, stepValue of " + stepValue +
" is illegal. " +
3090 "(stepValue possible values are from 1 to " + (maxValue - minValue) +
".)",Debug.HIGH_PRIORITY);
3093 if((((maxValue-minValue)/stepValue)|0) != (maxValue-minValue)/stepValue)
3095 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
3096 " must be an integer number of stepValue (stepValue=" + stepValue +
3097 ") steps away from minValue (minValue=" + minValue +
").",Debug.HIGH_PRIORITY);
3101 if(bitMapParams[6] !=
"" &&
3102 bitMapParams[6] != DEFAULT)
3104 forcedAspectH = bitMapParams[6].split(
':');
3105 if(forcedAspectH.length != 2)
3107 Debug.log(
"Illegal input parameter, expecting ':' in string defining cell display aspect ratio " +
3108 "Height:Width (e.g. 100:150)." +
3109 "\nInput aspect ratio string '" + bitMapParams[6] +
"' is invalid.",Debug.HIGH_PRIORITY);
3112 forcedAspectW = forcedAspectH[1].trim()|0;
3113 forcedAspectH = forcedAspectH[0].trim()|0;
3116 forcedAspectW = forcedAspectH = 1;
3120 minValueColor = bitMapParams[7] == DEFAULT || bitMapParams[7] ==
""?
"red":bitMapParams[7];
3121 midValueColor = bitMapParams[8] == DEFAULT || bitMapParams[8] ==
""?
"yellow":bitMapParams[8];
3122 maxValueColor = bitMapParams[9] == DEFAULT || bitMapParams[9] ==
""?
"green":bitMapParams[9];
3123 floorValueColor = bitMapParams[10] == DEFAULT || bitMapParams[10] ==
""?minValueColor:bitMapParams[10];
3124 ceilValueColor = bitMapParams[11] == DEFAULT || bitMapParams[11] ==
""?maxValueColor:bitMapParams[11];
3127 minValueColor = DesktopContent.getColorAsRGBA(minValueColor).split(
"(")[1].split(
")")[0].split(
",");
3128 midValueColor = DesktopContent.getColorAsRGBA(midValueColor).split(
"(")[1].split(
")")[0].split(
",");
3129 maxValueColor = DesktopContent.getColorAsRGBA(maxValueColor).split(
"(")[1].split(
")")[0].split(
",");
3130 ceilValueColor = DesktopContent.getColorAsRGBA(ceilValueColor).split(
"(")[1].split(
")")[0].split(
",");
3131 floorValueColor = DesktopContent.getColorAsRGBA(floorValueColor).split(
"(")[1].split(
")")[0].split(
",");
3134 doDisplayRowsAscending = bitMapParams[12] ==
"Yes"?1:0;
3135 doDisplayColsAscending = bitMapParams[13] ==
"Yes"?1:0;
3136 doSnakeColumns = bitMapParams[14] ==
"Yes"?1:0;
3137 doSnakeRows = bitMapParams[15] ==
"Yes"?1:0;
3139 if(doSnakeColumns && doSnakeRows)
3141 Debug.log(
"Can not have a bitmap that snakes both rows and columns, please choose one or the other (or neither).",Debug.HIGH_PRIORITY);
3154 function localInitBitmapData()
3161 var jsonMatrix = JSON.parse(initBitMapValue);
3164 for(var r=0;r<rows;++r)
3168 for(var c=0;c<cols;++c)
3171 localConvertFullRowColToGrid(jsonMatrix);
3175 Debug.log(
"The input initial value of the bitmap is illegal JSON format. " +
3176 "See error below: \n\n" + err,Debug.HIGH_PRIORITY);
3177 Debug.log(
"Defaulting to initial bitmap with min-value fill.",Debug.HIGH_PRIORITY);
3181 for(var r=0;r<rows;++r)
3185 for(var c=0;c<cols;++c)
3187 bmpData[r][c] = minValue;
3189 color = localConvertValueToRGBA(bmpData[r][c]);
3190 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3191 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3192 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3193 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3197 bmpContext.putImageData(bmpDataImage,0,0);
3198 bmp.src = bmpCanvas.toDataURL();
3209 function localConvertGridToRowCol(r,c)
3212 if(!doDisplayRowsAscending)
3213 retVal[0] = rows - 1 - retVal[0];
3214 if(!doDisplayColsAscending)
3215 retVal[1] = cols - 1 - retVal[1];
3216 if(doSnakeRows && retVal[0]%2 == 1)
3217 retVal[1] = cols + (cols - 1 - retVal[1]);
3218 if(doSnakeColumns && retVal[1]%2 == 1)
3219 retVal[0] = rows + (rows - 1 - retVal[0]);
3227 function localConvertValueToRGBA(val)
3230 return [ceilValueColor[0],
3236 return [floorValueColor[0],
3242 return [midValueColor[0],
3251 t = (val - minValue)/(midValue - minValue);
3252 return [minValueColor[0]*(1-t) + t*midValueColor[0],
3253 minValueColor[1]*(1-t) + t*midValueColor[1],
3254 minValueColor[2]*(1-t) + t*midValueColor[2],
3260 t = (val - midValue)/(maxValue - midValue);
3261 return [midValueColor[0]*(1-t) + t*maxValueColor[0],
3262 midValueColor[1]*(1-t) + t*maxValueColor[1],
3263 midValueColor[2]*(1-t) + t*maxValueColor[2],
3272 function localConvertFullGridToRowCol()
3276 for(var r=0;r<rows;++r)
3277 for(var c=0;c<cols;++c)
3279 convertedRC = localConvertGridToRowCol(r,c);
3282 convertedRC[1] = (convertedRC[1]/2)|0;
3285 convertedRC[0] = (convertedRC[0]/2)|0;
3287 if(retArr[convertedRC[0]] === undefined)
3288 retArr[convertedRC[0]] = [];
3289 retArr[convertedRC[0]][convertedRC[1]] = bmpData[r][c];
3298 function localConvertFullRowColToGrid(srcMatrix)
3302 var noErrors =
true;
3303 for(var r=0;r<rows;++r)
3304 for(var c=0;c<cols;++c)
3306 convertedRC = localConvertGridToRowCol(r,c);
3310 convertedRC[1] = (convertedRC[1]/2)|0;
3313 convertedRC[0] = (convertedRC[0]/2)|0;
3316 bmpData[r][c] = srcMatrix[convertedRC[0]][convertedRC[1]]|0;
3317 if(bmpData[r][c] < minValue)
3318 throw(
"There was an illegal value less than minValue: " +
3319 bmpData[r][c] +
" < " + minValue +
" @ (row,col) = (" +
3320 convertedRC[0] +
"," + convertedRC[0] +
")");
3321 if(bmpData[r][c] > maxValue)
3322 throw(
"There was an illegal value greater than maxValue: " +
3323 bmpData[r][c] +
" > " + maxValue +
" @ (row,col) = (" +
3324 convertedRC[0] +
"," + convertedRC[0] +
")");
3325 if((((bmpData[r][c]-minValue)/stepValue)|0) != (bmpData[r][c]-minValue)/stepValue)
3326 throw(
"There was an illegal value not following stepValue from minValue: " +
3327 bmpData[r][c] +
" != " +
3328 (stepValue*(((bmpData[r][c]-minValue)/stepValue)|0)) +
3329 " @ (row,col) = (" +
3330 convertedRC[0] +
"," + convertedRC[0] +
")");
3331 color = localConvertValueToRGBA(bmpData[r][c]);
3332 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3333 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3334 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3335 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3340 bmpContext.putImageData(bmpDataImage,0,0);
3341 bmp.src = bmpCanvas.toDataURL();
3344 throw(
"There was a mismatch in row/col dimensions. Input matrix was " +
3345 "dimension [row,col] = [" + srcMatrix.length +
"," +
3346 (srcMatrix.length?srcMatrix[0].length:0) +
"]");
3352 function localCreateBitmap()
3354 bmp = document.createElement(
"img");
3355 bmp.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap");
3357 bmpGrid = document.createElement(
"div");
3358 bmpGrid.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid");
3360 bmpOverlay = document.createElement(
"img");
3361 bmpOverlay.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-overlay");
3363 cursorInfo = document.createElement(
"div");
3364 cursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-info");
3365 hdrCursorInfo = document.createElement(
"div");
3366 hdrCursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-hdrInfo");
3369 rowLeftNums = document.createElement(
"div");
3370 rowRightNums = document.createElement(
"div");
3371 colTopNums = document.createElement(
"div");
3372 colBottomNums = document.createElement(
"div");
3373 rowLeftNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowLeft");
3374 rowRightNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowRight");
3375 colTopNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colTop");
3376 colBottomNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colBottom");
3382 bmpCanvas=document.createElement(
"canvas");
3383 bmpCanvas.width = cols;
3384 bmpCanvas.height = rows;
3385 bmpContext = bmpCanvas.getContext(
"2d");
3387 if(bmpDataImage)
delete bmpDataImage;
3388 bmpDataImage = bmpContext.createImageData(cols,rows);
3391 tmpEl = document.createElement(
"div");
3392 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-box");
3393 bmpGrid.appendChild(tmpEl);
3395 for(var i=0;i<rows;++i)
3399 tmpEl = document.createElement(
"div");
3400 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row-dark");
3401 bmpGrid.appendChild(tmpEl);
3402 tmpEl = document.createElement(
"div");
3403 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row");
3404 bmpGrid.appendChild(tmpEl);
3407 for(var j=0;j<cols;++j)
3409 if(i == rows-1 & j < cols-1)
3411 tmpEl = document.createElement(
"div");
3412 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col-dark");
3413 bmpGrid.appendChild(tmpEl);
3414 tmpEl = document.createElement(
"div");
3415 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col");
3416 bmpGrid.appendChild(tmpEl);
3421 bmpContext.putImageData(bmpDataImage,0,0);
3422 bmp.src = bmpCanvas.toDataURL();
3425 bmp.style.position =
"absolute";
3426 bmp.draggable =
false;
3428 bmpGrid.style.position =
"absolute";
3430 bmpOverlay.style.display =
"none";
3431 bmpOverlay.style.position =
"absolute";
3432 bmpOverlay.draggable =
false;
3434 cursorInfo.style.position =
"absolute";
3435 cursorInfo.style.display =
"none";
3436 hdrCursorInfo.style.position =
"absolute";
3437 hdrCursorInfo.style.display =
"none";
3438 hdrCursorInfo.style.width =
"320px";
3440 rowLeftNums.style.position =
"absolute";
3441 rowRightNums.style.position =
"absolute";
3442 colTopNums.style.position =
"absolute";
3443 colBottomNums.style.position =
"absolute";
3445 el.appendChild(bmp);
3446 el.appendChild(bmpGrid);
3447 el.appendChild(bmpOverlay);
3449 el.appendChild(hdrCursorInfo);
3450 el.appendChild(cursorInfo);
3452 el.appendChild(rowLeftNums);
3453 el.appendChild(rowRightNums);
3454 el.appendChild(colTopNums);
3455 el.appendChild(colBottomNums);
3461 function localCreateGridButtons()
3463 allRowBtns = document.createElement(
"div");
3465 allColBtns = document.createElement(
"div");
3467 allBtn = document.createElement(
"div");
3468 allBtn.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3471 for(var i=0;i<rows;++i)
3473 tmpEl = document.createElement(
"div");
3474 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3475 tmpEl.style.position =
"absolute";
3476 allRowBtns.appendChild(tmpEl);
3478 for(var i=0;i<cols;++i)
3480 tmpEl = document.createElement(
"div");
3481 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3482 tmpEl.style.position =
"absolute";
3483 allColBtns.appendChild(tmpEl);
3486 allRowBtns.style.position =
"absolute";
3487 el.appendChild(allRowBtns);
3488 allColBtns.style.position =
"absolute";
3489 el.appendChild(allColBtns);
3490 allBtn.style.position =
"absolute";
3491 el.appendChild(allBtn);
3497 function localCreateHeader()
3499 hdr = document.createElement(
"div");
3500 hdr.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-header");
3504 str +=
"<div style='float:left; margin: 0 0 20px 0;'>";
3505 str +=
"<div style='float:left; '>";
3513 str +=
"<div style='float:left; margin-left: 50px;'>";
3514 str +=
"Number of [Rows,Cols]: " +
"[" + rows +
"," + cols +
"]";
3518 str +=
"<div style='float:right; '>";
3520 ConfigurationAPI._POP_UP_DIALOG_ID +
3521 "-cancel' href='#'>Cancel</a>";
3524 str +=
"<div id='clearDiv'></div>";
3526 str +=
"<div style='float:right; margin: 40px 20px -50px 0;'>";
3528 ConfigurationAPI._POP_UP_DIALOG_ID +
3529 "-ok' href='#'>OK</a>";
3532 str +=
"<div style='float:left; margin: 0 0 0 0;'>";
3533 for(var clickIndex=0;clickIndex<2;++clickIndex)
3535 str +=
"<div style='float:left; margin: 5px 0 0 0;'>";
3536 str +=
"<div style='float:left; width:180px; text-align:right; margin-top: 3px;'>";
3537 str += (clickIndex?
"Right":
"Left") +
"-Click Value:";
3539 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3540 "-bitmap-scrollbar' style='float:left;' " +
3541 "type='range' min='" + minValue +
3542 "' max='" + maxValue +
"' value='" + (clickIndex?maxValue:minValue) +
3543 "' step='" + stepValue +
3544 "' oninput='ConfigurationAPI.bitMapDialog.localUpdateScroll(" + clickIndex +
")' />";
3545 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3546 "-bitmap-btnInput' style='float:left; margin: 0 1px 0 5px;' " +
3547 "type='button' value='<' " +
3548 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,0)' " +
3549 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,1)' " +
3551 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3552 "-bitmap-btnInput' style='float:left;' " +
3553 "type='button' value='>' " +
3554 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,0)' " +
3555 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,1)' " +
3557 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3558 "-bitmap-textInput' style='float:left; margin: 0 5px 0 5px; width: 50px;' " +
3560 "onchange='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",1)' " +
3561 "onkeydown='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3562 "onkeyup='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3564 str +=
"<img class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3565 "-bitmap-colorSample' style='float:left;width:25px; height:25px; margin: -2px 0 2px 0;' " +
3566 "ondragstart='return false;' " +
3567 "draggable='false'" +
3573 str +=
"<div id='clearDiv'></div>";
3578 str +=
"<div style='float:left; margin: 5px 0 0 40px;'>";
3579 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3580 "-bitmap-btnCsv' style='float:left;' " +
3581 "type='button' value='Download as CSV' " +
3582 "onclick='ConfigurationAPI.bitMapDialog.localDownloadCSV()' " +
3584 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3585 "-bitmap-btnCsv' style='float:left; margin: 0 0 0 10px;' " +
3586 "type='button' value='Upload CSV' " +
3587 "onclick='ConfigurationAPI.bitMapDialog.locaPopupUploadCSV()' " +
3591 hdr.innerHTML = str;
3592 hdr.style.overflowY =
"auto";
3593 hdr.style.position =
"absolute";
3595 var scrollEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-scrollbar");
3596 var textInputEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-textInput");
3597 var colorSampleEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-colorSample");
3602 ConfigurationAPI.bitMapDialog.localUpdateScroll =
function(i)
3604 Debug.log(
"localUpdateScroll " + i);
3606 clickValues[i] = scrollEls[i].value|0;
3607 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3609 textInputEls[i].value = clickValues[i];
3610 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3615 ConfigurationAPI.bitMapDialog.localUpdateTextInput =
function(i,finalChange)
3617 Debug.log(
"localUpdateTextInput " + textInputEls[i].value +
" " + finalChange);
3619 clickValues[i] = textInputEls[i].value|0;
3623 if(clickValues[i] < minValue) clickValues[i] = minValue;
3624 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3625 clickValues[i] = (((clickValues[i]-minValue)/stepValue)|0)*stepValue + minValue;
3626 textInputEls[i].value = clickValues[i];
3630 if(clickValues[i] < minValue)
return;
3631 if(clickValues[i] > maxValue)
return;
3632 if((((clickValues[i]-minValue)/stepValue)|0) != (clickValues[i]-minValue)/stepValue)
3634 Debug.log(
"displaying change");
3636 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3638 scrollEls[i].value = clickValues[i];
3639 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3644 var mouseDownTimer = 0;
3645 ConfigurationAPI.bitMapDialog.localUpdateButtonInput =
function(i,dir,mouseUp,delay)
3647 window.clearInterval(mouseDownTimer);
3650 Debug.log(
"cancel mouse down");
3654 mouseDownTimer = window.setInterval(
function()
3657 if(delay > 50) delay -= 50;
3658 ConfigurationAPI.bitMapDialog.localUpdateButtonInput(i,dir,0,50);
3659 },delay!==undefined?delay:300);
3661 Debug.log(
"localUpdateButtonInput " + textInputEls[i].value +
" " + dir);
3663 clickValues[i] = clickValues[i] + (dir?stepValue:-stepValue);
3664 if(clickValues[i] < minValue) clickValues[i] = minValue;
3665 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3667 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3669 textInputEls[i].value = clickValues[i];
3670 scrollEls[i].value = clickValues[i];
3671 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3681 ConfigurationAPI.bitMapDialog.localDownloadCSV =
function()
3683 var transGrid = localConvertFullGridToRowCol();
3684 console.log(transGrid);
3686 var dataStr =
"data:text/csv;charset=utf-8,";
3688 for(var r=0;r<transGrid.length;++r)
3690 if(r) dataStr += encodeURI(
"\n");
3691 for(var c=0;c<transGrid[0].length;++c)
3693 if(c) dataStr +=
",";
3694 dataStr += transGrid[r][c];
3698 Debug.log(
"ConfigurationAPI.bitMapDialog.localDownloadCSV dataStr=" + dataStr);
3700 var link = document.createElement(
"a");
3701 link.setAttribute(
"href", dataStr);
3702 link.setAttribute(
"style",
"display:none");
3703 link.setAttribute(
"download", _currentConfigName +
"_" +
3704 fieldName +
"_download.csv");
3705 document.body.appendChild(link);
3709 link.parentNode.removeChild(link);
3716 ConfigurationAPI.bitMapDialog._csvUploadDataStr;
3717 ConfigurationAPI.bitMapDialog.locaUploadCSV =
function()
3719 Debug.log(
"locaUploadCSV ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3720 var srcDataStr = ConfigurationAPI.bitMapDialog._csvUploadDataStr.split(
'\n');
3722 for(var i=0;i<srcDataStr.length;++i)
3723 src.push(srcDataStr[i].split(
','));
3728 localConvertFullRowColToGrid(src);
3730 Debug.log(
"Successfully uploaded CSV file to bitmap!", Debug.INFO_PRIORITY);
3733 el = document.getElementById(
"popUpDialog");
3734 if(el) el.parentNode.removeChild(el);
3738 Debug.log(
"Errors occured during upload. Bitmap may not reflect contents of CSV file." +
3739 "\nHere is the error description: \n" + err, Debug.HIGH_PRIORITY);
3742 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3748 ConfigurationAPI.bitMapDialog.locaPopupUploadCSV =
function()
3750 Debug.log(
"ConfigurationAPI.bitMapDialog.locaPopupUploadCSV");
3751 ConfigurationAPI.bitMapDialog._csvUploadDataStr =
"";
3755 var pel = document.getElementById(
"popUpDialog");
3758 pel = document.createElement(
"div");
3759 pel.setAttribute(
"id",
"popUpDialog");
3761 pel.style.display =
"none";
3766 ConfigurationAPI.setPopUpPosition(pel,w ,h );
3768 var str =
"<a id='" +
3770 "-header' href='#' onclick='javascript:ConfigurationAPI.bitMapDialog._csvUploadDataStr = \"\"; var pel = document.getElementById(" +
3771 "\"popUpDialog\"); if(pel) pel.parentNode.removeChild(pel); return false;'>Cancel</a><br><br>";
3773 str +=
"<div id='popUpDialog-div'>";
3775 str +=
"Please choose a CSV formatted data file (i.e. commas for columns, and new lines for rows) " +
3776 "to upload:<br><br>";
3780 str +=
"<input type='file' id='popUpDialog-fileUpload' " +
3781 "accept='.csv' enctype='multipart/form-data' />";
3785 str +=
"</center></div><br><br>";
3787 var onmouseupJS =
"";
3788 onmouseupJS +=
"document.getElementById(\"popUpDialog-submitButton\").disabled = true;";
3789 onmouseupJS +=
"ConfigurationAPI.bitMapDialog.locaUploadCSV();";
3791 str +=
"<input id='popUpDialog-submitButton' disabled type='button' onmouseup='" +
3792 onmouseupJS +
"' " +
3793 "value='Upload File' title='" +
3794 "Upload the chosen file to replace the row,col data in the current bitmap." +
3797 pel.innerHTML = str;
3798 el.appendChild(pel);
3799 pel.style.display =
"block";
3801 document.getElementById(
'popUpDialog-fileUpload').addEventListener(
3802 'change',
function(evt) {
3803 var files = evt.target.files;
3804 var file = files[0];
3805 var reader =
new FileReader();
3806 reader.onload =
function() {
3808 ConfigurationAPI.bitMapDialog._csvUploadDataStr = this.result;
3809 Debug.log(
"ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3810 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3812 reader.readAsText(file);
3818 el.appendChild(hdr);
3820 ConfigurationAPI.bitMapDialog.localUpdateScroll(0);
3821 ConfigurationAPI.bitMapDialog.localUpdateScroll(1);
3828 function localPaint()
3830 Debug.log(
"localPaint");
3832 popSz = ConfigurationAPI.setPopUpPosition(el,undefined,undefined,padding,undefined,
3842 bmpY = hdrY+hdrH+padding;
3843 bmpW = popSz.w - 2*axisPadding;
3844 bmpH = popSz.h - hdrH - padding - 2*axisPadding;
3849 localOptimizeAspectRatio();
3852 hdr.style.left = hdrX +
"px";
3853 hdr.style.top = hdrY +
"px";
3854 hdr.style.width = hdrW +
"px";
3855 hdr.style.height = hdrH +
"px";
3858 bmp.style.left = bmpX +
"px";
3859 bmp.style.top = bmpY +
"px";
3860 bmp.style.width = bmpW +
"px";
3861 bmp.style.height = bmpH +
"px";
3867 bmpGrid.style.left = (bmpX-bmpBorderSize) +
"px";
3868 bmpGrid.style.top = (bmpY-bmpBorderSize) +
"px";
3869 bmpGrid.style.width = (bmpW) +
"px";
3870 bmpGrid.style.height = (bmpH) +
"px";
3872 var bmpGridChildren = bmpGrid.childNodes;
3875 allRowBtns.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3876 allRowBtns.style.top = (bmpY - bmpBorderSize) +
"px";
3878 allColBtns.style.left = (bmpX - bmpBorderSize) +
"px";
3879 allColBtns.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3881 allBtn.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3882 allBtn.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3883 allBtn.style.width = butttonSz +
"px";
3884 allBtn.style.height = butttonSz +
"px";
3886 var allRowsChildren = allRowBtns.childNodes;
3887 var allColsChildren = allColBtns.childNodes;
3891 rowLeftNums.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz + (- bmpBorderSize - axisPaddingMargin - axisPaddingExtra)) +
"px";
3892 rowLeftNums.style.top = (bmpY - bmpBorderSize) +
"px";
3893 rowRightNums.style.left = (bmpX + bmpW + axisPaddingMargin + bmpBorderSize) +
"px";
3894 rowRightNums.style.top = (bmpY - bmpBorderSize) +
"px";
3895 colTopNums.style.left = (bmpX - bmpBorderSize) +
"px";
3896 colTopNums.style.top = (bmpY - bmpBorderSize*2 - numberDigitH) +
"px";
3897 colBottomNums.style.left = (bmpX - bmpBorderSize) +
"px";
3898 colBottomNums.style.top = (bmpY + bmpH + bmpBorderSize + axisPaddingMargin + bmpBorderSize + butttonSz + bmpBorderSize) +
"px";
3899 rowLeftNums.innerHTML =
"";
3900 rowRightNums.innerHTML =
"";
3901 colTopNums.innerHTML =
"";
3902 colBottomNums.innerHTML =
"";
3904 var thresholdNumberSpacing = 100;
3906 var oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
3911 bmpGridChildren[0].style.left = 0 +
"px";
3912 bmpGridChildren[0].style.top = 0 +
"px";
3913 bmpGridChildren[0].style.width = (bmpW) +
"px";
3914 bmpGridChildren[0].style.height = (bmpH) +
"px";
3917 for(var i=0;i<rows;++i)
3922 bmpGridChildren[1+i*2].style.left = bmpBorderSize +
"px";
3923 bmpGridChildren[1+i*2].style.top = ((i+1)*cellH) +
"px";
3924 bmpGridChildren[1+i*2].style.width = (bmpW) +
"px";
3925 bmpGridChildren[1+i*2].style.height = (bmpGridThickness+bmpBorderSize*2) +
"px";
3928 bmpGridChildren[1+i*2+1].style.left = 0 +
"px";
3929 bmpGridChildren[1+i*2+1].style.top = ((i+1)*cellH + bmpBorderSize) +
"px";
3930 bmpGridChildren[1+i*2+1].style.width = (bmpW + bmpBorderSize*2) +
"px";
3931 bmpGridChildren[1+i*2+1].style.height = bmpGridThickness +
"px";
3933 bmpGridChildren[1+i*2+1].style.backgroundColor =
3934 (doSnakeRows && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
3938 allRowsChildren[i].style.left = 0 +
"px";
3939 allRowsChildren[i].style.top = (i*cellH + (i?bmpGridThickness+bmpBorderSize*2-1:0)) +
"px";
3940 allRowsChildren[i].style.width = (butttonSz) +
"px";
3941 allRowsChildren[i].style.height = (cellH - 1 + (i?-bmpBorderSize*2:0)) +
"px";
3945 numberLoc[0] = (i*cellH - 1 + cellH/2 - numberDigitH/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
3948 translatedRC = localConvertGridToRowCol(i,0);
3949 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
3950 translatedRC[0]%5 == 0)
3953 numberEl = document.createElement(
"div");
3954 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
3955 numberEl.innerHTML = translatedRC[0];
3956 numberEl.style.top = numberLoc[0] +
"px";
3957 numberEl.style.width = axisPaddingExtra +
"px";
3958 rowLeftNums.appendChild(numberEl);
3959 oldNumberLoc[0] = numberLoc[0];
3963 translatedRC = localConvertGridToRowCol(i,cols>1?1:0);
3964 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
3965 translatedRC[0]%5 == 0)
3968 numberEl = document.createElement(
"div");
3969 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
3970 numberEl.innerHTML = translatedRC[0];
3971 numberEl.style.top = numberLoc[0] +
"px";
3972 numberEl.style.width = axisPaddingExtra +
"px";
3973 rowRightNums.appendChild(numberEl);
3974 oldNumberLoc[1] = numberLoc[0];
3979 oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
3981 for(var i=0;i<cols;++i)
3989 bmpGridChildren[1+(rows-1)*2+i*2].style.top = bmpBorderSize +
"px";
3990 bmpGridChildren[1+(rows-1)*2+i*2].style.left = ((i+1)*cellW + bmpBorderSize) +
"px";
3991 bmpGridChildren[1+(rows-1)*2+i*2].style.height = (bmpH) +
"px";
3992 bmpGridChildren[1+(rows-1)*2+i*2].style.width = (bmpGridThickness+bmpBorderSize*2) +
"px";
3995 bmpGridChildren[1+(rows-1)*2+i*2+1].style.top = 0 +
"px";
3996 bmpGridChildren[1+(rows-1)*2+i*2+1].style.left = ((i+1)*cellW + bmpBorderSize*2) +
"px";
3997 bmpGridChildren[1+(rows-1)*2+i*2+1].style.height = (bmpH + bmpBorderSize*2) +
"px";
3998 bmpGridChildren[1+(rows-1)*2+i*2+1].style.width = bmpGridThickness +
"px";
4000 bmpGridChildren[1+(rows-1)*2+i*2+1].style.backgroundColor =
4001 (doSnakeColumns && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
4005 allColsChildren[i].style.left = (i*cellW - 1 + (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4006 allColsChildren[i].style.top = 0 +
"px";
4007 allColsChildren[i].style.width = (cellW + 1 - (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4008 allColsChildren[i].style.height = (butttonSz) +
"px";
4012 numberLoc[0] = (i*cellW + cellW/2 - axisPaddingExtra/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
4015 translatedRC = localConvertGridToRowCol(0,i);
4016 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
4017 translatedRC[1]%5 == 0)
4020 numberEl = document.createElement(
"div");
4021 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4022 numberEl.innerHTML = translatedRC[1];
4023 numberEl.style.left = numberLoc[0] +
"px";
4024 numberEl.style.width = axisPaddingExtra +
"px";
4025 colTopNums.appendChild(numberEl);
4026 oldNumberLoc[0] = numberLoc[0];
4030 translatedRC = localConvertGridToRowCol(rows>1?1:0,i);
4031 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
4032 translatedRC[1]%5 == 0)
4035 numberEl = document.createElement(
"div");
4036 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4037 numberEl.innerHTML = translatedRC[1];
4038 numberEl.style.left = numberLoc[0] +
"px";
4039 numberEl.style.width = axisPaddingExtra +
"px";
4040 colBottomNums.appendChild(numberEl);
4041 oldNumberLoc[1] = numberLoc[0];
4060 function localOptimizeAspectRatio()
4062 var cellSkew = (cellW>cellH)?cellW/cellH:cellH/cellW;
4066 if(forcedAspectH !== undefined)
4068 var offAspectH = forcedAspectH/cellH;
4069 var offAspectW = forcedAspectW/cellW;
4071 Debug.log(
"Adjusting skew factor = " + forcedAspectH +
"-" + forcedAspectW);
4073 if(offAspectH < offAspectW)
4074 bmpH = bmpW/cols*forcedAspectH/forcedAspectW*rows;
4076 bmpW = bmpH/rows*forcedAspectW/forcedAspectH*cols;
4078 else if(cellSkew > MAX_SKEW)
4080 var adj = cellSkew/MAX_SKEW;
4082 Debug.log(
"Adjusting skew factor = " + adj);
4095 bmpX = padding + (popSz.w-bmpW)/2;
4096 bmpY = bmpY + (popSz.h-bmpY-bmpH)/2;
4097 hdrY = bmpY - padding - hdrH;
4106 ConfigurationAPI.getDateString;
4108 ConfigurationAPI.getDateStringDayArr_ = [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"];
4109 ConfigurationAPI.getDateStringMonthArr_ = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"];
4110 ConfigurationAPI.getDateString =
function(date)
4114 dateStr += ConfigurationAPI.getDateStringDayArr_[date.getDay()];
4116 dateStr += ConfigurationAPI.getDateStringMonthArr_[date.getMonth()];
4118 dateStr += date.getDate();
4120 dateStr += date.getHours();
4122 dateStr += ((date.getMinutes()<10)?
"0":
"") + date.getMinutes();
4124 dateStr += ((date.getSeconds()<10)?
"0":
"") + date.getSeconds();
4126 dateStr += date.getFullYear();
4128 dateStr += date.toLocaleTimeString([],{timeZoneName:
"short"}).split(
" ")[2];
4135 ConfigurationAPI.setCaretPosition =
function(elem, caretPos, endPos)
4138 elem.setSelectionRange(caretPos, endPos);
4149 ConfigurationAPI.setPopUpPosition =
function(el,w,h,padding,border,margin,doNotResize,offsetUp)
4151 Debug.log(
"ConfigurationAPI.setPopUpPosition");
4153 if(padding === undefined) padding = 10;
4154 if(border === undefined) border = 1;
4155 if(margin === undefined) margin = 0;
4162 ConfigurationAPI.setPopUpPosition.stopPropagation =
function(event) {
4164 event.stopPropagation();
4170 ConfigurationAPI.setPopUpPosition.popupResize =
function() {
4176 window.removeEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4177 window.removeEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4181 catch(err) {
return;}
4187 var ww = DesktopContent.getWindowWidth()-(padding+border)*2;
4188 var wh = DesktopContent.getWindowHeight()-(padding+border)*2;
4192 var ah = el.offsetHeight;
4194 if(w === undefined || h === undefined)
4201 x = (DesktopContent.getWindowScrollLeft() + ((ww-w)/2));
4202 y = (DesktopContent.getWindowScrollTop() + ((wh-h)/2)) - (offsetUp|0) - 100;
4204 if(y<DesktopContent.getWindowScrollTop()+margin+padding)
4205 y = DesktopContent.getWindowScrollTop()+margin+padding;
4208 if(w > ww-margin-padding)
4209 x = -DesktopContent.getWindowScrollLeft();
4210 if(ah > wh-margin-padding)
4211 y = -DesktopContent.getWindowScrollTop();
4213 el.style.left = x +
"px";
4214 el.style.top = y +
"px";
4216 ConfigurationAPI.setPopUpPosition.popupResize();
4219 el.style.width = w +
"px";
4220 el.style.height = h +
"px";
4224 window.addEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4225 window.addEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4227 el.addEventListener(
"keydown",ConfigurationAPI.setPopUpPosition.stopPropagation);
4228 el.addEventListener(
"mousemove",ConfigurationAPI.setPopUpPosition.stopPropagation);
4229 el.addEventListener(
"mousemove",DesktopContent.mouseMove);
4231 el.style.overflow =
"auto";
4233 return {
"w" : w,
"h" : h,
"x" : x,
"y" : y};
4240 ConfigurationAPI.getOnePixelPngData =
function(rgba)
4242 if(ConfigurationAPI.getOnePixelPngData.canvas === undefined)
4245 ConfigurationAPI.getOnePixelPngData.canvas = document.createElement(
"canvas");
4246 ConfigurationAPI.getOnePixelPngData.canvas.width = 1;
4247 ConfigurationAPI.getOnePixelPngData.canvas.height = 1;
4248 ConfigurationAPI.getOnePixelPngData.ctx = ConfigurationAPI.getOnePixelPngData.canvas.getContext(
"2d");
4249 ConfigurationAPI.getOnePixelPngData.bmpOverlayData = ConfigurationAPI.getOnePixelPngData.ctx.createImageData(1,1);
4252 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[0]=rgba[0];
4253 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[1]=rgba[1];
4254 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[2]=rgba[2];
4255 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[3]=rgba[3]!==undefined?rgba[3]:255;
4257 ConfigurationAPI.getOnePixelPngData.ctx.putImageData(
4258 ConfigurationAPI.getOnePixelPngData.bmpOverlayData,0,0);
4259 return ConfigurationAPI.getOnePixelPngData.canvas.toDataURL();
4285 ConfigurationAPI.editableFieldEditingCell_ = 0;
4286 ConfigurationAPI.editableFieldEditingIdString_;
4287 ConfigurationAPI.editableFieldEditingNodeType_;
4288 ConfigurationAPI.editableFieldEditingOldValue_;
4289 ConfigurationAPI.editableFieldEditingInitValue_;
4290 ConfigurationAPI.editableFieldHoveringCell_ = 0;
4291 ConfigurationAPI.editableFieldHoveringIdString_;
4292 ConfigurationAPI.editableFieldSelectedIdString_ = 0;
4293 ConfigurationAPI.editableFieldHandlersSubscribed_ =
false;
4294 ConfigurationAPI.editableFieldMouseIsSelecting_ =
false;
4295 ConfigurationAPI.editableField_SELECTED_COLOR_ =
"rgb(251, 245, 53)";
4296 ConfigurationAPI.createEditableFieldElement =
function(fieldObj,fieldIndex,
4300 var depth = depthIndex|0;
4301 var uid = fieldIndex|0;
4303 if(!ConfigurationAPI.editableFieldHandlersSubscribed_)
4305 ConfigurationAPI.editableFieldHandlersSubscribed_ =
true;
4308 DesktopContent.mouseMoveSubscriber(ConfigurationAPI.handleEditableFieldBodyMouseMove);
4311 var fieldEl = document.createElement(
"div");
4312 fieldEl.setAttribute(
"class",
"ConfigurationAPI-EditableField");
4313 fieldEl.setAttribute(
"id",
"ConfigurationAPI-EditableField-" +
4314 ( depth +
"-" + uid ));
4316 Debug.log(
"Field type " + fieldObj.fieldColumnType);
4319 var valueType = fieldObj.fieldColumnType;
4320 var choices = fieldObj.fieldColumnDataChoicesArr;
4321 var value = fieldObj.fieldColumnDefaultValue;
4322 var path = fieldObj.fieldRelativePath;
4323 var nodeName = fieldObj.fieldColumnName;
4325 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4326 depth,nodeName,value,valueType,choices,path);
4333 ConfigurationAPI.getEditableFieldValue =
function(fieldObj,fieldIndex,depthIndex )
4338 ConfigurationAPI.handleEditableFieldEditOK();
4340 var depth = depthIndex|0;
4341 var uid = fieldIndex|0;
4342 var fieldEl = document.getElementById(
"editableFieldNode-Value-leafNode-" +
4343 ( depth +
"-" + uid ));
4346 Debug.log(
"getEditableFieldValue Error! Invalid target field element '" +
4347 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4351 var valueType = fieldObj.fieldColumnType;
4352 var value = fieldEl.textContent;
4366 ConfigurationAPI.setEditableFieldValue =
function(fieldObj,value,fieldIndex,depthIndex )
4370 var depth = depthIndex|0;
4371 var uid = fieldIndex|0;
4372 var fieldEl = document.getElementById(
"ConfigurationAPI-EditableField-" +
4373 ( depth +
"-" + uid ));
4376 Debug.log(
"setEditableFieldValue Error! Invalid target field element '" +
4377 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4380 var valueType = fieldObj.fieldColumnType;
4381 var choices = fieldObj.fieldColumnDataChoicesArr;
4382 var path = fieldObj.fieldRelativePath;
4383 var nodeName = fieldObj.fieldColumnName;
4385 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4386 depth,nodeName,value,valueType,choices,path);
4392 ConfigurationAPI.fillEditableFieldElement =
function(fieldEl,uid,
4393 depth,nodeName,value,valueType,choices,path)
4397 var pathHTML = path;
4399 pathHTML = pathHTML.replace(/</g,
"<");
4400 pathHTML = pathHTML.replace(/>/g,
">");
4402 str +=
"<div class='editableFieldNode-Path' style='display:none' id='editableFieldNode-path-" +
4403 ( depth +
"-" + uid ) +
"'>" +
4407 if(valueType ==
"FixedChoiceData")
4411 "<div class='editableFieldNode-FixedChoice-CSV' style='display:none' " +
4412 "id='editableFieldNode-FixedChoice-CSV-" +
4413 ( depth +
"-" + uid ) +
"'>";
4415 for(var j=0;j<choices.length;++j)
4422 else if(valueType ==
"BitMap")
4426 "<div class='editableFieldNode-BitMap-Params' style='display:none' " +
4427 "id='editableFieldNode-BitMap-Params-" +
4428 ( depth +
"-" + uid ) +
"'>";
4430 for(var j=1;j<choices.length;++j)
4433 str += choices[j].replace(/;/g,
",");
4442 "<div class='editableFieldNode-Value editableFieldNode-ValueType-" + valueType +
4444 "id='editableFieldNode-Value-" +
4445 (depth +
"-" + uid) +
"' " +
4447 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4448 depth +
"," + uid +
"," +
4451 "onmousemove='ConfigurationAPI.handleEditableFieldHover(" +
4452 depth +
"," + uid +
"," +
4457 titleStr =
"~ Leaf Value Node ~\n";
4458 titleStr +=
"Path: \t" + path + nodeName +
"\n";
4462 "<div style='float:left' title='" + titleStr +
"'>" +
4463 "<b class='editableFieldNode-Value-leafNode-fieldName bold-header'>" +
4465 "</div><div style='float:left'> :</div>";
4469 "<div class='editableFieldNode-Value-editIcon' id='editableFieldNode-Value-editIcon-" +
4470 (depth +
"-" + uid) +
"' " +
4471 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4472 depth +
"," + uid +
"," +
4473 "1,\"value\"); event.stopPropagation();' " +
4474 "title='Edit the value of this node.' " +
4478 str +=
"<div style='float:left; margin-left:9px;' id='editableFieldNode-Value-leafNode-" +
4479 (depth +
"-" + uid) +
4481 "editableFieldNode-Value-leafNode-ColumnName-" + nodeName +
4485 if(valueType ==
"OnOff" ||
4486 valueType ==
"YesNo" ||
4487 valueType ==
"TrueFalse")
4490 str +=
"<div style='float:left'>";
4494 var color = (value ==
"On" || value ==
"Yes" || value ==
"True")?
4495 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
4496 str +=
"<div style='width:10px;height:10px;" +
4497 "background-color:" + color +
";" +
4499 "border-radius: 7px;" +
4500 "border: 2px solid white;" +
4501 "margin: 2px 0 0 6px;" +
4504 else if(valueType ==
"Timestamp")
4505 str += ConfigurationAPI.getDateString(
new Date((value|0)*1000));
4512 fieldEl.innerHTML = str;
4516 if(ConfigurationAPI.editableFieldSelectedIdString_ == (depth +
"-" + uid))
4517 fieldEl.getElementsByClassName(
"editableFieldNode-Value")[0].style.backgroundColor =
4518 ConfigurationAPI.editableField_SELECTED_COLOR_;
4529 ConfigurationAPI.handleEditableFieldClick =
function(depth,uid,editClick,type)
4531 var idString = depth +
"-" + uid;
4532 ConfigurationAPI.editableFieldEditingIdString_ = idString;
4534 Debug.log(
"handleEditableFieldClick editClick " + editClick);
4535 Debug.log(
"handleEditableFieldClick idString " + idString);
4537 var el = document.getElementById(
"editableFieldNode-Value-" + idString);
4541 Debug.log(
"Invalid element pointed to by idString. Ignoring and exiting.");
4545 if(ConfigurationAPI.editableFieldHoveringCell_)
4548 ConfigurationAPI.handleEditableFieldBodyMouseMove();
4551 if(ConfigurationAPI.editableFieldEditingCell_)
4553 if(ConfigurationAPI.editableFieldEditingCell_ == el)
4555 ConfigurationAPI.handleEditableFieldEditOK();
4558 var path = document.getElementById(
"editableFieldNode-path-" + idString).textContent;
4564 Debug.log(
"handleEditableFieldClick path " + path);
4566 Debug.log(
"handleEditableFieldClick type " + type);
4597 Debug.log(
"edit value mode");
4599 selectThisTreeNode(idString,type);
4600 function selectThisTreeNode(idString,type)
4604 var el = document.getElementById(
"editableFieldNode-Value-leafNode-" + idString);
4605 var vel = document.getElementById(
"editableFieldNode-Value-" + idString);
4608 var colType = vel.className.split(
' ')[1].split(
'-');
4609 if(colType[1] ==
"ValueType")
4610 colType = colType[2];
4612 var fieldName = el.className.substr((
"editableFieldNode-Value-leafNode-ColumnName-").length);
4614 Debug.log(
"fieldName=" + fieldName);
4615 Debug.log(
"colType=" + colType);
4617 if(colType ==
"Author" ||
4618 colType ==
"Timestamp")
4620 Debug.log(
"Can not edit Author or Timestamp fields.",
4621 Debug.WARN_PRIORITY);
4627 var optionIndex = -1;
4630 if(colType ==
"YesNo" ||
4631 colType ==
"TrueFalse" ||
4635 ConfigurationAPI.editableFieldEditingOldValue_ = el.innerHTML;
4637 var initVal = el.childNodes[0].textContent;
4638 ConfigurationAPI.editableFieldEditingInitValue_ = initVal;
4641 if(colType ==
"YesNo")
4642 boolVals = [
"No",
"Yes"];
4643 else if(colType ==
"TrueFalse")
4644 boolVals = [
"False",
"True"];
4645 else if(colType ==
"OnOff")
4646 boolVals = [
"Off",
"On"];
4649 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4650 "onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4651 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_); event.stopPropagation();' " +
4652 "onclick='event.stopPropagation();'" +
4653 "style='margin:-8px -2px -2px -1px; height:" + (el.offsetHeight+6) +
"px'>";
4654 for(var i=0;i<boolVals.length;++i)
4656 str +=
"<option value='" + boolVals[i] +
"'>";
4659 if(boolVals[i] == initVal)
4663 if(optionIndex == -1) optionIndex = 0;
4665 else if(colType ==
"FixedChoiceData")
4667 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4668 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4670 var allowFixedChoiceArbitraryEdit =
false;
4671 var optionCount = -1;
4674 str +=
"<div onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4675 "onmouseup='event.stopPropagation();' " +
4676 "onclick='event.stopPropagation();' " +
4678 "white-space:nowrap;" +
4679 "margin:-3px -2px -2px -1px;" +
4680 "height:" + (el.offsetHeight+6) +
"px'>";
4682 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4683 "id='fixedChoice-editSelectBox' " +
4684 "onmouseup='event.stopPropagation();' " +
4685 "onclick='event.stopPropagation();' " +
4688 "margin:-2px -2px -2px -1px; height:" +
4689 (el.offsetHeight+6) +
"px'>";
4693 var vel = document.getElementById(
"editableFieldNode-FixedChoice-CSV-" +
4695 var choices = vel.textContent.split(
',');
4697 for(var i=0;i<choices.length;++i)
4701 if(choices[i].indexOf(
"arbitraryBool=") == 0)
4704 allowFixedChoiceArbitraryEdit =
4705 choices[i][(
"arbitraryBool=").length] ==
"1"?
4707 Debug.log(
"allowFixedChoiceArbitraryEdit " + allowFixedChoiceArbitraryEdit);
4721 str += decodeURIComponent(choices[i]);
4723 if(decodeURIComponent(choices[i])
4724 == ConfigurationAPI.editableFieldEditingOldValue_)
4725 optionIndex = optionCount;
4729 if(allowFixedChoiceArbitraryEdit)
4731 var ww = (el.offsetWidth-6);
4732 if(ww < 150) ww = 150;
4733 str +=
"<input type='text' " +
4734 "id='fixedChoice-editTextBox' " +
4735 "style='display:none;" +
4737 "margin:-2px 0 -" + (el.offsetHeight+6) +
"px 0;" +
4739 ww +
"px; height:" + (el.offsetHeight+6) +
"px" +
4744 str +=
"<div style='display:block;" +
4745 "margin: -2px 0 -7px 14px;" +
4747 "class='editableFieldNode-Value-editIcon' id='fixedChoice-editIcon" +
4749 "onclick='ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle();' " +
4750 "title='Toggle free-form editing' " +
4755 else if(colType ==
"BitMap")
4757 Debug.log(
"Handling bitmap select");
4759 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4762 ConfigurationAPI.bitMapDialog(
4764 "Target Field: "" +
4765 fieldName_ +
""",
4766 document.getElementById(
"editableFieldNode-BitMap-Params-" +
4767 idString).textContent.split(
';'),
4768 ConfigurationAPI.editableFieldEditingOldValue_,
4771 Debug.log(
"yes " + val);
4773 el.appendChild(document.createTextNode(val));
4774 ConfigurationAPI.editableFieldEditingCell_ = el;
4783 Debug.log(
"cancel bitmap");
4784 ConfigurationAPI.editableFieldEditingCell_ = 0;
4788 else if(colType ==
"MultilineData")
4790 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4791 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4793 str +=
"<textarea rows='4' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' cols='50' style='font-size: 14px; " +
4794 "margin:-8px -2px -2px -1px;width:" +
4795 (el.offsetWidth-6) +
"px; height:" + (el.offsetHeight-8) +
"px' ";
4796 str +=
" onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4797 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
4798 "onclick='event.stopPropagation();'" +
4800 str += ConfigurationAPI.editableFieldEditingOldValue_;
4801 str +=
"</textarea>";
4805 if(colType ==
"GroupID")
4808 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4809 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4811 var ow = el.offsetWidth+6;
4814 str +=
"<input type='text' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' style='margin:-8px -2px -2px -1px;width:" +
4815 (ow) +
"px; height:" + (el.offsetHeight>20?el.offsetHeight:20) +
"px' value='";
4816 str += ConfigurationAPI.editableFieldEditingOldValue_;
4817 str +=
"' onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4818 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
4819 "onclick='event.stopPropagation();'" +
4824 str += ConfigurationAPI._OK_CANCEL_DIALOG_STR;
4829 if(colType ==
"YesNo" ||
4830 colType ==
"TrueFalse" ||
4833 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
4834 el.getElementsByTagName(
"select")[0].focus();
4836 else if(colType ==
"FixedChoiceData")
4838 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
4839 el.getElementsByTagName(
"select")[0].focus();
4841 else if(colType ==
"MultilineData")
4842 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"textarea")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
4844 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"input")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
4848 ConfigurationAPI.editableFieldEditingCell_ = el;
4849 ConfigurationAPI.editableFieldEditingNodeType_ = type;
4854 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
4863 Debug.log(
"Toggling selection of target field " + idString);
4867 if(ConfigurationAPI.editableFieldSelectedIdString_ &&
4868 (vel = document.getElementById(
"editableFieldNode-Value-" +
4869 ConfigurationAPI.editableFieldSelectedIdString_)))
4870 vel.style.backgroundColor =
"transparent";
4873 vel = document.getElementById(
"editableFieldNode-Value-" +
4875 if(ConfigurationAPI.editableFieldSelectedIdString_ == idString)
4879 ConfigurationAPI.editableFieldSelectedIdString_ = undefined;
4882 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
4883 ConfigurationAPI.editableFieldSelectedIdString_ = idString;
4887 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
4898 ConfigurationAPI.getSelectedEditableFieldIndex =
function()
4900 if(!ConfigurationAPI.editableFieldSelectedIdString_)
4903 var idStr = ConfigurationAPI.editableFieldSelectedIdString_;
4904 return idStr.split(
'-')[1];
4910 ConfigurationAPI.handleEditableFieldHover =
function(depth,uid,event)
4912 var idString = depth +
"-" + uid;
4916 event.stopPropagation();
4917 DesktopContent.mouseMove(event);
4920 if(ConfigurationAPI.editableFieldEditingCell_)
return;
4922 var el = document.getElementById(
"editableFieldNode-Value-editIcon-" + idString);
4923 if(ConfigurationAPI.editableFieldHoveringCell_ == el)
return;
4925 if(ConfigurationAPI.editableFieldHoveringCell_)
4928 bodyMouseMoveHandler();
4932 ConfigurationAPI.editableFieldHoveringIdString_ = idString;
4933 ConfigurationAPI.editableFieldHoveringCell_ = el;
4934 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"block";
4935 var vel = document.getElementById(
"editableFieldNode-Value-" +
4936 ConfigurationAPI.editableFieldHoveringIdString_);
4937 vel.style.backgroundColor =
"rgb(218, 194, 194)";
4942 ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle =
function()
4944 Debug.log(
"handleEditableFieldFixedChoiceEditToggle");
4946 var sel = document.getElementById(
"fixedChoice-editSelectBox");
4947 var tel = document.getElementById(
"fixedChoice-editTextBox");
4949 Debug.log(
"sel.style.display " + sel.style.display);
4950 if(sel.style.display ==
"none")
4952 sel.style.display =
"block";
4953 tel.style.display =
"none";
4957 tel.style.width = (sel.offsetWidth-2) +
"px";
4958 sel.style.display =
"none";
4959 tel.style.display =
"block";
4960 ConfigurationAPI.setCaretPosition(tel,0,tel.value.length);
4966 ConfigurationAPI.handleEditableFieldBodyMouseMove =
function(e)
4968 if(ConfigurationAPI.editableFieldHoveringCell_)
4971 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"none";
4972 ConfigurationAPI.editableFieldHoveringCell_ = 0;
4974 var vel = document.getElementById(
"editableFieldNode-Value-" +
4975 ConfigurationAPI.editableFieldHoveringIdString_);
4978 if(ConfigurationAPI.editableFieldHoveringIdString_ ==
4979 ConfigurationAPI.editableFieldSelectedIdString_)
4980 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
4982 vel.style.backgroundColor =
"transparent";
4990 ConfigurationAPI.handleEditableFieldKeyDown =
function(e,keyEl)
5002 key = window.event.keyCode;
5003 shiftIsDown = !!window.event.shiftKey;
5008 shiftIsDown = !!e.shiftKey;
5017 if(ConfigurationAPI.editableFieldEditingCell_ &&
5018 (tel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"textarea")).length)
5022 if(e.keyCode == TABKEY)
5025 if(e.preventDefault)
5028 var i = tel.selectionStart;
5029 var j = tel.selectionEnd;
5030 tel.value = tel.value.substr(0,i) +
5031 '\t' + tel.value.substr(j);
5032 tel.selectionStart = tel.selectionEnd = j+1;
5041 if(e.keyCode == TABKEY || e.keyCode == ENTERKEY ||
5042 e.keyCode == UPKEY || e.keyCode == DNKEY)
5045 if(e.preventDefault)
5049 var idString = ConfigurationAPI.editableFieldEditingIdString_;
5051 ConfigurationAPI.handleEditableFieldEditOK();
5059 if(e.keyCode == ENTERKEY)
5062 var depth = idString.split(
'-')[0];
5063 var uid = idString.split(
'-')[1];
5065 if((!shiftIsDown && e.keyCode == TABKEY) || e.keyCode == DNKEY)
5067 else if((shiftIsDown && e.keyCode == TABKEY) || e.keyCode == UPKEY)
5069 if(uid < 0)
return false;
5072 ConfigurationAPI.handleEditableFieldClick(depth,uid,1,
"value");
5073 Debug.log(
"new uid=" + uid);
5077 else if(e.keyCode == ESCKEY)
5079 if(e.preventDefault)
5081 ConfigurationAPI.handleEditableFieldEditCancel();
5084 else if((e.keyCode >= 48 && e.keyCode <= 57) ||
5085 (e.keyCode >= 96 && e.keyCode <= 105))
5089 if((sel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"select")).length)
5094 sel = sel[sel.length-1];
5099 selNum = e.keyCode - 96;
5101 selNum = e.keyCode - 48;
5103 sel.selectedIndex = selNum % (sel.options.length);
5106 Debug.log(
"number select =" + sel.selectedIndex);
5116 ConfigurationAPI.handleEditableFieldEditCancel =
function()
5118 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5119 Debug.log(
"handleEditableFieldEditCancel type " + ConfigurationAPI.editableFieldEditingNodeType_);
5121 if(ConfigurationAPI.editableFieldEditingNodeType_ ==
"value-bool")
5124 ConfigurationAPI.editableFieldEditingCell_.innerHTML = ConfigurationAPI.editableFieldEditingOldValue_;
5128 ConfigurationAPI.editableFieldEditingCell_.innerHTML =
"";
5129 ConfigurationAPI.editableFieldEditingCell_.appendChild(
5130 document.createTextNode(ConfigurationAPI.editableFieldEditingOldValue_));
5133 ConfigurationAPI.editableFieldEditingCell_ = 0;
5139 ConfigurationAPI.handleEditableFieldEditOK =
function()
5141 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5142 Debug.log(
"handleEditableFieldEditOK type " + ConfigurationAPI.editableFieldEditingNodeType_);
5145 var el = ConfigurationAPI.editableFieldEditingCell_;
5146 var type = ConfigurationAPI.editableFieldEditingNodeType_;
5150 function localEditTreeNodeOKRequestsComplete(newValue)
5156 if(type ==
"value" ||
5157 type ==
"value-bitmap")
5163 el.appendChild(document.createTextNode(decodeURIComponent(newValue)));
5166 else if(type ==
"value-bool")
5171 str +=
"<div style='float:left'>";
5175 var color = (newValue ==
"On" || newValue ==
"Yes" || newValue ==
"True")?
5176 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
5177 str +=
"<div style='width:10px;height:10px;" +
5178 "background-color:" + color +
";" +
5180 "border-radius: 7px;" +
5181 "border: 2px solid white;" +
5182 "margin: 2px 0 0 6px;" +
5186 else if(type ==
"value-groupid")
5188 el.appendChild(document.createTextNode(newValue));
5192 Debug.log(
"Unrecognizd tree edit type! Should be impossible!",Debug.HIGH_PRIORITY);
5193 ConfigurationAPI.handleEditableFieldEditCancel();
return;
5197 ConfigurationAPI.editableFieldEditingCell_ = 0;
5204 type ==
"value-bool" ||
5205 type ==
"value-bitmap" ||
5206 type ==
"value-groupid")
5211 if(type ==
"value-bool")
5213 var sel = el.getElementsByTagName(
"select")[0];
5214 newValue = sel.options[sel.selectedIndex].value;
5216 else if(type ==
"value-bitmap")
5218 newValue = encodeURIComponent(el.textContent);
5223 if((sel = el.getElementsByTagName(
"textarea")).length)
5224 newValue = sel[0].value;
5225 else if((sel = el.getElementsByTagName(
"select")).length)
5228 if(sel[0].style.display ==
"none")
5232 newValue = el.getElementsByTagName(
"input")[0].value;
5235 newValue = sel[0].options[sel[0].selectedIndex].value;
5238 newValue = el.getElementsByTagName(
"input")[0].value;
5240 newValue = encodeURIComponent(newValue.trim());
5243 Debug.log(
"CfgGUI editTreeNodeOK editing " + type +
" node = " +
5246 if(ConfigurationAPI.editableFieldEditingInitValue_ == newValue)
5248 Debug.log(
"No change. Do nothing.");
5249 ConfigurationAPI.handleEditableFieldEditCancel();
5257 localEditTreeNodeOKRequestsComplete(newValue);
5262 Debug.log(
"Unrecognizd tree edit type! Should be impossible!",Debug.HIGH_PRIORITY);
5263 editCellCancel();
return;
5270 ConfigurationAPI.hasClass =
function(ele,cls)
5272 return !!ele.className.match(
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)'));
5277 ConfigurationAPI.addClass =
function(ele,cls)
5279 if (!ConfigurationAPI.hasClass(ele,cls)) ele.className +=
" "+cls;
5284 ConfigurationAPI.removeClass =
function(ele,cls)
5286 if (ConfigurationAPI.hasClass(ele,cls))
5288 var reg =
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)');
5289 ele.className=ele.className.replace(reg,
'');
5309 ConfigurationAPI.addSubsetRecords =
function(subsetBasePath,
5310 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
5312 var modifiedTablesListStr =
"";
5313 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
5315 if(i) modifiedTablesListStr +=
",";
5316 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
5317 modifiedTablesIn[i].tableVersion;
5320 var recordListStr =
"";
5321 if(Array.isArray(recordArr))
5322 for(var i=0;i<recordArr.length;++i)
5324 if(i) recordListStr +=
",";
5325 recordListStr += encodeURIComponent(recordArr[i]);
5328 recordListStr = encodeURIComponent(recordArr);
5330 DesktopContent.XMLHttpRequest(
"Request?RequestType=addTreeNodeRecords" +
5332 "&configGroupKey=-1",
5333 "startPath=/" + subsetBasePath +
5334 "&recordList=" + recordListStr +
5335 "&modifiedTables=" + modifiedTablesListStr,
5338 var modifiedTables = [];
5340 var err = DesktopContent.getXMLValue(req,
"Error");
5344 Debug.log(err,Debug.HIGH_PRIORITY);
5345 responseHandler(modifiedTables,err);
5352 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
5353 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
5354 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
5358 for(var i=0;i<tableNames.length;++i)
5360 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
5361 if(tableVersion >= -1)
continue;
5363 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
5364 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
5365 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
5366 modifiedTables.push(obj);
5368 responseHandler(modifiedTables);
5392 ConfigurationAPI.deleteSubsetRecords =
function(subsetBasePath,
5393 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
5395 var modifiedTablesListStr =
"";
5396 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
5398 if(i) modifiedTablesListStr +=
",";
5399 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
5400 modifiedTablesIn[i].tableVersion;
5403 var recordListStr =
"";
5404 var recordCount = 1;
5405 if(Array.isArray(recordArr))
5407 for(var i=0;i<recordArr.length;++i)
5409 if(i) recordListStr +=
",";
5410 recordListStr += encodeURIComponent(recordArr[i]);
5412 recordCount = recordArr.length;
5415 recordListStr = encodeURIComponent(recordArr);
5417 DesktopContent.XMLHttpRequest(
"Request?RequestType=deleteTreeNodeRecords" +
5419 "&configGroupKey=-1",
5420 "startPath=/" + subsetBasePath +
5421 "&recordList=" + recordListStr +
5422 "&modifiedTables=" + modifiedTablesListStr,
5426 var err = DesktopContent.getXMLValue(req,
"Error");
5427 var modifiedTables = [];
5431 Debug.log(err,Debug.HIGH_PRIORITY);
5432 responseHandler(modifiedTables,err);
5439 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
5440 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
5441 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
5445 for(var i=0;i<tableNames.length;++i)
5447 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
5448 if(tableVersion >= -1)
continue;
5450 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
5451 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
5452 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
5453 modifiedTables.push(obj);
5455 responseHandler(modifiedTables,undefined,subsetBasePath,recordCount);
5465 ConfigurationAPI.incrementName =
function(name)
5468 for(var i=name.length-1;i>=0;--i)
5469 if(!(name[i] >=
'0' && name[i] <=
'9'))
5472 var num = (name.substr(i+1)|0) + 1;
5473 name = name.substr(0,i+1);
5479 ConfigurationAPI.createNewRecordName =
function(startingName,existingArr)
5481 var retVal = startingName;
5485 var apps = existingArr;
5488 retVal = ConfigurationAPI.incrementName(retVal);
5490 for(i=0;i<apps.length;++i)
5491 if(apps[i] == retVal)
5492 {found =
true;
break;}
5494 Debug.log(
"createNewRecordName " + retVal);
5499 return ConfigurationAPI.incrementName(retVal);