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=getActiveTableGroups",
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=getTableGroups"
288 +
"&doNotReturnMembers=1",
292 Debug.log(
"getTableGroups handler");
294 retObj.activeGroups = {};
295 retObj.activeGroups = ConfigurationAPI.extractActiveGroups(req);
297 var groupNames = req.responseXML.getElementsByTagName(
"TableGroupName");
298 var groupKeys = req.responseXML.getElementsByTagName(
"TableGroupKey");
299 var groupTypes = req.responseXML.getElementsByTagName(
"TableGroupType");
300 var groupComments = req.responseXML.getElementsByTagName(
"TableGroupComment");
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 "&tableGroupKey=-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 "&tableGroupKey=-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 ==
"LinkTableName")
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 ==
"LinkTableName")
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 "&tableGroupKey=-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" +
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" +
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 "&tableGroupKey=-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 affectedGroupTableMap = [];
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 affectedGroupTableMap[i] =
"tableList=";
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 affectedGroupTableMap[i] += memberName +
"," +
1768 savedTables[k].tableVersion +
",";
1773 affectedGroupTableMap[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 affectedGroupTableMap[i] =
"tableList=";
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 affectedGroupTableMap[i] += affectedArr[a] +
"," +
1816 savedTables[k].tableVersion +
",";
1821 affectedGroupTableMap[i] += affectedArr[a] +
"," + affectedArr[a+1] +
",";
1824 localHandleSavingAffectedGroups();
1829 function localHandleSavingAffectedGroups()
1832 for(var i=0;i<affectedGroupNames.length;++i)
1835 reqStr =
"Request?RequestType=saveNewTableGroup" +
1836 "&groupName=" + affectedGroupNames[i] +
1837 "&allowDuplicates=0" +
1838 "&lookForEquivalent=1" +
1839 "&ignoreWarnings=" + (doNotIgnoreWarnings?0:1) +
1840 "&groupComment=" + encodeURIComponent(affectedGroupComments[i]);
1842 Debug.log(affectedGroupTableMap[i]);
1846 DesktopContent.XMLHttpRequest(reqStr, affectedGroupTableMap[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,
"TableGroupKey");
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=saveSpecificTable" +
2215 "&dataOffset=0&chunkSize=0" +
2216 "&tableName=" + 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 tableName = 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 '" + tableName +
"-v" +
2250 version +
"'",Debug.INFO_PRIORITY);
2252 Debug.log(
"Successfully created new table '" + tableName +
"-v" +
2253 version +
"'",Debug.INFO_PRIORITY);
2258 obj.tableName = tableName;
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=activateTableGroup" +
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 tableVersions = req.responseXML.getElementsByTagName(
"oldBackboneVersion");
2406 var tableMap =
"tableList=";
2408 for(var i=0;i<configNames.length;++i)
2410 name = configNames[i].getAttribute(
"value");
2412 if(name == groupAliasName)
2414 tableMap += name +
"," +
2415 groupAliasVersion +
",";
2419 tableMap += name +
"," +
2420 tableVersions[i].getAttribute(
"value") +
",";
2423 console.log(
"backbone tableMap",tableMap);
2425 ConfigurationAPI.saveGroupAndActivate(params[0],tableMap,params[1],params[2],
2431 ConfigurationAPI.saveGroupAndActivate =
function(groupName,tableMap,doneHandler,doReturnParams,
2434 DesktopContent.XMLHttpRequest(
"Request?RequestType=saveNewTableGroup&groupName=" +
2436 "&allowDuplicates=" + (lookForEquivalent?
"0":
"1") +
2437 "&lookForEquivalent=" + (lookForEquivalent?
"1":
"0") +
2442 var err = DesktopContent.getXMLValue(req,
"Error");
2443 var name = DesktopContent.getXMLValue(req,
"TableGroupName");
2444 var key = DesktopContent.getXMLValue(req,
"TableGroupKey");
2445 var newGroupCreated =
true;
2450 Debug.log(err,Debug.HIGH_PRIORITY);
2451 Debug.log(
"Process interrupted. Failed to create a new group!" +
2452 " Please see details below.",
2453 Debug.HIGH_PRIORITY);
2455 if(doneHandler) doneHandler();
2460 Debug.log(err,Debug.WARN_PRIORITY);
2461 Debug.log(
"Process interrupted. Failed to create a new group!" +
2462 " (Likely the currently active group already represents what is being requested)\n\n" +
2463 "Going on with existing backbone group, name=" + name +
" & key=" + key,
2464 Debug.WARN_PRIORITY);
2465 newGroupCreated =
false;
2471 DesktopContent.XMLHttpRequest(
"Request?RequestType=activateTableGroup" +
2472 "&groupName=" + name +
2473 "&groupKey=" + key,
"",
2478 activateSystemConfigHandler(req);
2492 "newGroupCreated" : newGroupCreated
2494 doneHandler(retParams);
2512 ConfigurationAPI.getGroupTypeMemberNames =
function(groupType,responseHandler)
2514 DesktopContent.XMLHttpRequest(
"Request?RequestType=get" + groupType +
"MemberNames",
"",
2519 var err = DesktopContent.getXMLValue(req,
"Error");
2522 Debug.log(err,Debug.HIGH_PRIORITY);
2523 if(responseHandler) responseHandler(retArr);
2526 var memberNames = req.responseXML.getElementsByTagName(groupType +
"Member");
2528 for(var i=0;i<memberNames.length;++i)
2529 retArr[i] = memberNames[i].getAttribute(
"value");
2531 Debug.log(
"Members found for group type " + groupType +
" = " + retArr.length);
2532 if(responseHandler) responseHandler(retArr);
2548 ConfigurationAPI.bitMapDialog =
function(fieldName,bitMapParams,initBitMapValue,okHandler,cancelHandler)
2550 Debug.log(
"ConfigurationAPI bitMapDialog");
2554 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2557 el = document.createElement(
"div");
2558 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
2560 el.style.display =
"none";
2561 el.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmapDialog");
2627 var minValue, maxValue;
2631 var forcedAspectH, forcedAspectW;
2633 var minValueColor, midValueColor, maxValueColor;
2634 var ceilValueColor, floorValueColor;
2636 var doDisplayRowsAscending, doDisplayColsAscending;
2637 var doSnakeColumns, doSnakeRows;
2640 if(!localValidateInputs())
2642 Debug.log(
"Input parameters array to the Bitmap Dialog was as follows:\n " +
2643 bitMapParams, Debug.HIGH_PRIORITY);
2644 Debug.log(
"Input parameters to the Bitmap Dialog are invalid. Aborting.", Debug.HIGH_PRIORITY);
2645 return cancelHandler();
2649 var numberDigitW = 8, numberDigitH = 12;
2650 var axisPaddingExtra = numberDigitW;
2651 function localCalcExtraAxisPadding() {
2653 while((lrows /= 10) > 1) axisPaddingExtra += numberDigitW;
2654 } localCalcExtraAxisPadding();
2656 var axisPaddingMargin = 5;
2657 var axisPadding = axisPaddingMargin + axisPaddingExtra + axisPaddingMargin + butttonSz + axisPaddingMargin;
2658 var bmpGridThickness = 1;
2659 var bmpBorderSize = 1;
2670 var allRowBtns, allColBtns, allBtn;
2671 var rowLeftNums, rowRightNums, colTopNums, colBottomNums;
2672 var bmpCanvas, bmpContext;
2680 var cursorInfo, hdrCursorInfo;
2685 var clickColors = [];
2686 var clickValues = [];
2689 localCreateHeader();
2690 localCreateBitmap();
2691 localCreateGridButtons();
2693 localInitBitmapData();
2696 window.addEventListener(
"resize",localPaint);
2698 document.body.appendChild(el);
2699 el.style.display =
"block";
2705 function localCreateCancelClickHandler()
2707 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2708 "-cancel").onclick =
function(event) {
2709 Debug.log(
"Cancel click");
2710 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2711 if(el) el.parentNode.removeChild(el);
2712 window.removeEventListener(
"resize",localPaint);
2716 } localCreateCancelClickHandler();
2721 function localCreateOkClickHandler()
2723 var convertFunc = localConvertFullGridToRowCol;
2724 document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID +
2725 "-ok").onclick =
function(event) {
2726 Debug.log(
"OK click");
2727 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2728 if(el) el.parentNode.removeChild(el);
2729 window.removeEventListener(
"resize",localPaint);
2731 var transGrid = convertFunc();
2732 var dataJsonStr =
"[\n";
2733 for(var r=0;r<transGrid.length;++r)
2735 if(r) dataJsonStr +=
",\n";
2736 dataJsonStr +=
"\t[";
2737 for(var c=0;c<transGrid[0].length;++c)
2739 if(c) dataJsonStr +=
",";
2740 dataJsonStr += transGrid[r][c];
2744 dataJsonStr +=
"\n]";
2745 okHandler(dataJsonStr);
2748 } localCreateOkClickHandler();
2753 function localCreateMouseHandler()
2755 var stopProp =
false;
2756 var rLast = -1, cLast = -1;
2758 var buttonDown = -1;
2765 function localGetRowCol(x,y) {
2766 x -= popSz.x + bmpX + 1;
2767 y -= popSz.y + bmpY + 1;
2768 var r = (y/cellH)|0;
2770 var c = (x/cellW)|0;
2772 var inRowBtnsX = (x >= - axisPaddingMargin - bmpBorderSize - butttonSz) &&
2773 (x <= - axisPaddingMargin - bmpBorderSize);
2774 var inColBtnsY = (y >= bmpH + axisPaddingMargin) &&
2775 (y <= bmpH + axisPaddingMargin + butttonSz + bmpBorderSize*2);
2783 if(inRowBtnsX && r >= 0 && r < rows)
2784 return {
"r":r,
"c":-2};
2785 else if(inColBtnsY && c >= 0 && c < cols)
2786 return {
"r":-2,
"c":c};
2787 else if(inRowBtnsX && inColBtnsY)
2788 return {
"r":-2,
"c":-2};
2789 else if(r < 0 || c < 0 || r >= rows || c >= cols)
2790 return {
"r":-1,
"c":-1};
2791 return {
"r":r,
"c":c};
2796 el.onmousemove =
function(event) {
2797 var cell = localGetRowCol(event.pageX,event.pageY);
2798 var r = cell.r, c = cell.c;
2800 var cursorT = (
event.pageX - popSz.x - bmpX);
2801 if(cursorT < 0) cursorT = 0;
2802 if(cursorT > bmpW) cursorT = bmpW;
2804 cursorInfo.style.left = (
event.pageX - popSz.x +
2807 (cursorT)/bmpW*(-cursorInfo.innerHTML.length*8-20) + (bmpW-cursorT)/bmpW*(2))+
2809 cursorInfo.style.top = (
event.pageY - popSz.y - 35) +
"px";
2812 hdrCursorInfo.style.left = (bmpX + bmpW/2 +
2814 hdrCursorInfo.style.top = (bmpY - 45) +
"px";
2817 if(rLast == r && cLast == c)
2819 rLast = r; cLast = c;
2821 if(r == -1 || c == -1)
2824 rLast = -1; cLast = -1;
2825 bmpOverlay.style.display =
"none";
2826 cursorInfo.style.display =
"none";
2827 hdrCursorInfo.style.display =
"none";
2831 cursorInfo.style.display =
"block";
2838 if(r != -2 && c == -2)
2841 transRC = localConvertGridToRowCol(r,
2842 doDisplayColsAscending?0:cols-1);
2844 transRC = localConvertGridToRowCol(r,0);
2848 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2850 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2851 bmpOverlay.style.top = (bmpY + r*cellH - 1 + (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2852 bmpOverlay.style.width = (butttonSz) +
"px";
2853 bmpOverlay.style.height = (cellH - (r?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2854 bmpOverlay.style.display =
"block";
2857 infoStr =
"Set all pixels in row " + transRC[0] +
".";
2859 else if(r == -2 && c != -2)
2862 transRC = localConvertGridToRowCol(
2863 doDisplayRowsAscending?0:rows-1,c);
2865 transRC = localConvertGridToRowCol(0,c);
2870 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2872 bmpOverlay.style.left = (bmpX + c*cellW - 1 + (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2873 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2874 bmpOverlay.style.width = (cellW + 1 - (c?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
2875 bmpOverlay.style.height = (butttonSz) +
"px";
2876 bmpOverlay.style.display =
"block";
2879 infoStr =
"Set all pixels in column " + transRC[1] +
".";
2881 else if(r == -2 && c == -2)
2885 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData([216,188,188]);
2887 bmpOverlay.style.left = (bmpX - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
2888 bmpOverlay.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize) +
"px";
2889 bmpOverlay.style.width = (butttonSz) +
"px";
2890 bmpOverlay.style.height = (butttonSz) +
"px";
2891 bmpOverlay.style.display =
"block";
2894 infoStr =
"Set all pixels.";
2898 transRC = localConvertGridToRowCol(r,c);
2904 var overClr = (bmpDataImage.data[(r*cols+c)*4+0] +
2905 bmpDataImage.data[(r*cols+c)*4+1] +
2906 bmpDataImage.data[(r*cols+c)*4+2]) < (256+128)?255:0;
2908 bmpOverlay.src = ConfigurationAPI.getOnePixelPngData(
2909 [overClr,overClr,overClr,100]);
2911 bmpOverlay.style.left = (bmpX + c*cellW) +
"px";
2912 bmpOverlay.style.top = (bmpY + r*cellH) +
"px";
2913 bmpOverlay.style.width = (cellW) +
"px";
2914 bmpOverlay.style.height = (cellH) +
"px";
2915 bmpOverlay.style.display =
"block";
2919 infoStr =
"Value = " + bmpData[r][c] +
" @ (Row,Col) = (" +
2920 transRC[0] +
"," + transRC[1] +
")";
2922 cursorInfo.innerHTML = infoStr;
2923 hdrCursorInfo.innerHTML = infoStr;
2926 if(r == -2 && c == -2)
2932 localSetBitMap(r,c);
2939 el.onmousedown =
function(event) {
2941 var cell = localGetRowCol(event.pageX,event.pageY);
2942 var r = cell.r, c = cell.c;
2946 buttonDown =
event.button;
2948 if(r == -1 || c == -1)
2950 rLast = -1; cLast = -1;
2955 rLast = r; cLast = c;
2956 localSetBitMap(r,c);
2959 event.stopPropagation();
2965 el.onmouseup =
function(event) {
2972 el.oncontextmenu =
function(event) {
2978 event.stopPropagation();
2985 function localSetBitMap(r,c) {
2987 Debug.log(
"set r,c " + buttonDown +
" @ " + r +
"," + c );
2988 buttonDown = buttonDown?1:0;
2990 var maxr = r==-2?rows-1:r;
2991 var minr = r==-2?0:r;
2992 var maxc = c==-2?cols-1:c;
2993 var minc = c==-2?0:c;
2995 for(r=minr;r<=maxr;++r)
2996 for(c=minc;c<=maxc;++c)
2998 bmpData[r][c] = clickValues[buttonDown];
2999 bmpDataImage.data[(r*cols + c)*4 + 0] =
3000 clickColors[buttonDown][0];
3001 bmpDataImage.data[(r*cols + c)*4 + 1] =
3002 clickColors[buttonDown][1];
3003 bmpDataImage.data[(r*cols + c)*4 + 2] =
3004 clickColors[buttonDown][2];
3005 bmpDataImage.data[(r*cols + c)*4 + 3] =
3006 clickColors[buttonDown][3];
3009 bmpContext.putImageData(bmpDataImage,0,0);
3010 bmp.src = bmpCanvas.toDataURL();
3013 } localCreateMouseHandler();
3019 function localValidateInputs() {
3022 if(bitMapParams.length != 16)
3024 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)." +
3025 "\nHere is a printout of the input parameters: " + bitMapParams,Debug.HIGH_PRIORITY);
3028 var DEFAULT =
"DEFAULT";
3030 rows = bitMapParams[0]|0;
3031 cols = bitMapParams[1]|0;
3032 bitFieldSize = bitMapParams[2]|0;
3036 if(rows < 1 || rows >= 1<<30)
3038 Debug.log(
"Illegal input parameters, rows of " + rows +
" is illegal. " +
3039 "(rows possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3042 if(cols < 1 || cols >= 1<<30)
3044 Debug.log(
"Illegal input parameters, cols of " + cols +
" is illegal. " +
3045 "(cols possible values are from 1 to " + ((1<<30)-1) +
".)",Debug.HIGH_PRIORITY);
3048 if(bitFieldSize < 1 || bitFieldSize > 31)
3050 Debug.log(
"Illegal input parameters, bitFieldSize of " + bitFieldSize +
" is illegal. " +
3051 "(bitFieldSize possible values are from 1 to " + (31) +
".)",Debug.HIGH_PRIORITY);
3056 if(bitFieldSize > 30)
3059 for(var i=0;i<bitFieldSize;++i)
3063 bitMask = (1<<bitFieldSize) - 1;
3065 minValue = bitMapParams[3] ==
"DEFAULT" || bitMapParams[3] ==
""?0:(bitMapParams[3]|0);
3066 maxValue = bitMapParams[4] ==
"DEFAULT" || bitMapParams[4] ==
""?bitMask:(bitMapParams[4]|0);
3067 if(maxValue < minValue)
3069 midValue = (maxValue + minValue)/2;
3070 stepValue = bitMapParams[5] ==
"DEFAULT" || bitMapParams[5] ==
""?1:(bitMapParams[5]|0);
3072 if(minValue < 0 || minValue > bitMask)
3074 Debug.log(
"Illegal input parameters, minValue of " + minValue +
" is illegal. " +
3075 "(minValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3078 if(maxValue < 0 || maxValue > bitMask)
3080 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
" is illegal. " +
3081 "(maxValue possible values are from 0 to " + bitMask +
".)",Debug.HIGH_PRIORITY);
3084 if(minValue > maxValue)
3086 Debug.log(
"Illegal input parameters, minValue > maxValue is illegal.",Debug.HIGH_PRIORITY);
3089 if(stepValue < 1 || stepValue > maxValue - minValue)
3091 Debug.log(
"Illegal input parameters, stepValue of " + stepValue +
" is illegal. " +
3092 "(stepValue possible values are from 1 to " + (maxValue - minValue) +
".)",Debug.HIGH_PRIORITY);
3095 if((((maxValue-minValue)/stepValue)|0) != (maxValue-minValue)/stepValue)
3097 Debug.log(
"Illegal input parameters, maxValue of " + maxValue +
3098 " must be an integer number of stepValue (stepValue=" + stepValue +
3099 ") steps away from minValue (minValue=" + minValue +
").",Debug.HIGH_PRIORITY);
3103 if(bitMapParams[6] !=
"" &&
3104 bitMapParams[6] != DEFAULT)
3106 forcedAspectH = bitMapParams[6].split(
':');
3107 if(forcedAspectH.length != 2)
3109 Debug.log(
"Illegal input parameter, expecting ':' in string defining cell display aspect ratio " +
3110 "Height:Width (e.g. 100:150)." +
3111 "\nInput aspect ratio string '" + bitMapParams[6] +
"' is invalid.",Debug.HIGH_PRIORITY);
3114 forcedAspectW = forcedAspectH[1].trim()|0;
3115 forcedAspectH = forcedAspectH[0].trim()|0;
3118 forcedAspectW = forcedAspectH = 1;
3122 minValueColor = bitMapParams[7] == DEFAULT || bitMapParams[7] ==
""?
"red":bitMapParams[7];
3123 midValueColor = bitMapParams[8] == DEFAULT || bitMapParams[8] ==
""?
"yellow":bitMapParams[8];
3124 maxValueColor = bitMapParams[9] == DEFAULT || bitMapParams[9] ==
""?
"green":bitMapParams[9];
3125 floorValueColor = bitMapParams[10] == DEFAULT || bitMapParams[10] ==
""?minValueColor:bitMapParams[10];
3126 ceilValueColor = bitMapParams[11] == DEFAULT || bitMapParams[11] ==
""?maxValueColor:bitMapParams[11];
3129 minValueColor = DesktopContent.getColorAsRGBA(minValueColor).split(
"(")[1].split(
")")[0].split(
",");
3130 midValueColor = DesktopContent.getColorAsRGBA(midValueColor).split(
"(")[1].split(
")")[0].split(
",");
3131 maxValueColor = DesktopContent.getColorAsRGBA(maxValueColor).split(
"(")[1].split(
")")[0].split(
",");
3132 ceilValueColor = DesktopContent.getColorAsRGBA(ceilValueColor).split(
"(")[1].split(
")")[0].split(
",");
3133 floorValueColor = DesktopContent.getColorAsRGBA(floorValueColor).split(
"(")[1].split(
")")[0].split(
",");
3136 doDisplayRowsAscending = bitMapParams[12] ==
"Yes"?1:0;
3137 doDisplayColsAscending = bitMapParams[13] ==
"Yes"?1:0;
3138 doSnakeColumns = bitMapParams[14] ==
"Yes"?1:0;
3139 doSnakeRows = bitMapParams[15] ==
"Yes"?1:0;
3141 if(doSnakeColumns && doSnakeRows)
3143 Debug.log(
"Can not have a bitmap that snakes both rows and columns, please choose one or the other (or neither).",Debug.HIGH_PRIORITY);
3156 function localInitBitmapData()
3163 var jsonMatrix = JSON.parse(initBitMapValue);
3166 for(var r=0;r<rows;++r)
3170 for(var c=0;c<cols;++c)
3173 localConvertFullRowColToGrid(jsonMatrix);
3177 Debug.log(
"The input initial value of the bitmap is illegal JSON format. " +
3178 "See error below: \n\n" + err,Debug.HIGH_PRIORITY);
3179 Debug.log(
"Defaulting to initial bitmap with min-value fill.",Debug.HIGH_PRIORITY);
3183 for(var r=0;r<rows;++r)
3187 for(var c=0;c<cols;++c)
3189 bmpData[r][c] = minValue;
3191 color = localConvertValueToRGBA(bmpData[r][c]);
3192 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3193 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3194 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3195 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3199 bmpContext.putImageData(bmpDataImage,0,0);
3200 bmp.src = bmpCanvas.toDataURL();
3211 function localConvertGridToRowCol(r,c)
3214 if(!doDisplayRowsAscending)
3215 retVal[0] = rows - 1 - retVal[0];
3216 if(!doDisplayColsAscending)
3217 retVal[1] = cols - 1 - retVal[1];
3218 if(doSnakeRows && retVal[0]%2 == 1)
3219 retVal[1] = cols + (cols - 1 - retVal[1]);
3220 if(doSnakeColumns && retVal[1]%2 == 1)
3221 retVal[0] = rows + (rows - 1 - retVal[0]);
3229 function localConvertValueToRGBA(val)
3232 return [ceilValueColor[0],
3238 return [floorValueColor[0],
3244 return [midValueColor[0],
3253 t = (val - minValue)/(midValue - minValue);
3254 return [minValueColor[0]*(1-t) + t*midValueColor[0],
3255 minValueColor[1]*(1-t) + t*midValueColor[1],
3256 minValueColor[2]*(1-t) + t*midValueColor[2],
3262 t = (val - midValue)/(maxValue - midValue);
3263 return [midValueColor[0]*(1-t) + t*maxValueColor[0],
3264 midValueColor[1]*(1-t) + t*maxValueColor[1],
3265 midValueColor[2]*(1-t) + t*maxValueColor[2],
3274 function localConvertFullGridToRowCol()
3278 for(var r=0;r<rows;++r)
3279 for(var c=0;c<cols;++c)
3281 convertedRC = localConvertGridToRowCol(r,c);
3284 convertedRC[1] = (convertedRC[1]/2)|0;
3287 convertedRC[0] = (convertedRC[0]/2)|0;
3289 if(retArr[convertedRC[0]] === undefined)
3290 retArr[convertedRC[0]] = [];
3291 retArr[convertedRC[0]][convertedRC[1]] = bmpData[r][c];
3300 function localConvertFullRowColToGrid(srcMatrix)
3304 var noErrors =
true;
3305 for(var r=0;r<rows;++r)
3306 for(var c=0;c<cols;++c)
3308 convertedRC = localConvertGridToRowCol(r,c);
3312 convertedRC[1] = (convertedRC[1]/2)|0;
3315 convertedRC[0] = (convertedRC[0]/2)|0;
3318 bmpData[r][c] = srcMatrix[convertedRC[0]][convertedRC[1]]|0;
3319 if(bmpData[r][c] < minValue)
3320 throw(
"There was an illegal value less than minValue: " +
3321 bmpData[r][c] +
" < " + minValue +
" @ (row,col) = (" +
3322 convertedRC[0] +
"," + convertedRC[0] +
")");
3323 if(bmpData[r][c] > maxValue)
3324 throw(
"There was an illegal value greater than maxValue: " +
3325 bmpData[r][c] +
" > " + maxValue +
" @ (row,col) = (" +
3326 convertedRC[0] +
"," + convertedRC[0] +
")");
3327 if((((bmpData[r][c]-minValue)/stepValue)|0) != (bmpData[r][c]-minValue)/stepValue)
3328 throw(
"There was an illegal value not following stepValue from minValue: " +
3329 bmpData[r][c] +
" != " +
3330 (stepValue*(((bmpData[r][c]-minValue)/stepValue)|0)) +
3331 " @ (row,col) = (" +
3332 convertedRC[0] +
"," + convertedRC[0] +
")");
3333 color = localConvertValueToRGBA(bmpData[r][c]);
3334 bmpDataImage.data[(r*cols + c)*4+0]=color[0];
3335 bmpDataImage.data[(r*cols + c)*4+1]=color[1];
3336 bmpDataImage.data[(r*cols + c)*4+2]=color[2];
3337 bmpDataImage.data[(r*cols + c)*4+3]=color[3];
3342 bmpContext.putImageData(bmpDataImage,0,0);
3343 bmp.src = bmpCanvas.toDataURL();
3346 throw(
"There was a mismatch in row/col dimensions. Input matrix was " +
3347 "dimension [row,col] = [" + srcMatrix.length +
"," +
3348 (srcMatrix.length?srcMatrix[0].length:0) +
"]");
3354 function localCreateBitmap()
3356 bmp = document.createElement(
"img");
3357 bmp.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap");
3359 bmpGrid = document.createElement(
"div");
3360 bmpGrid.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid");
3362 bmpOverlay = document.createElement(
"img");
3363 bmpOverlay.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-overlay");
3365 cursorInfo = document.createElement(
"div");
3366 cursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-info");
3367 hdrCursorInfo = document.createElement(
"div");
3368 hdrCursorInfo.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-cursor-hdrInfo");
3371 rowLeftNums = document.createElement(
"div");
3372 rowRightNums = document.createElement(
"div");
3373 colTopNums = document.createElement(
"div");
3374 colBottomNums = document.createElement(
"div");
3375 rowLeftNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowLeft");
3376 rowRightNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-rowRight");
3377 colTopNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colTop");
3378 colBottomNums.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-numbers-colBottom");
3384 bmpCanvas=document.createElement(
"canvas");
3385 bmpCanvas.width = cols;
3386 bmpCanvas.height = rows;
3387 bmpContext = bmpCanvas.getContext(
"2d");
3389 if(bmpDataImage)
delete bmpDataImage;
3390 bmpDataImage = bmpContext.createImageData(cols,rows);
3393 tmpEl = document.createElement(
"div");
3394 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-box");
3395 bmpGrid.appendChild(tmpEl);
3397 for(var i=0;i<rows;++i)
3401 tmpEl = document.createElement(
"div");
3402 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row-dark");
3403 bmpGrid.appendChild(tmpEl);
3404 tmpEl = document.createElement(
"div");
3405 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-row");
3406 bmpGrid.appendChild(tmpEl);
3409 for(var j=0;j<cols;++j)
3411 if(i == rows-1 & j < cols-1)
3413 tmpEl = document.createElement(
"div");
3414 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col-dark");
3415 bmpGrid.appendChild(tmpEl);
3416 tmpEl = document.createElement(
"div");
3417 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-grid-col");
3418 bmpGrid.appendChild(tmpEl);
3423 bmpContext.putImageData(bmpDataImage,0,0);
3424 bmp.src = bmpCanvas.toDataURL();
3427 bmp.style.position =
"absolute";
3428 bmp.draggable =
false;
3430 bmpGrid.style.position =
"absolute";
3432 bmpOverlay.style.display =
"none";
3433 bmpOverlay.style.position =
"absolute";
3434 bmpOverlay.draggable =
false;
3436 cursorInfo.style.position =
"absolute";
3437 cursorInfo.style.display =
"none";
3438 hdrCursorInfo.style.position =
"absolute";
3439 hdrCursorInfo.style.display =
"none";
3440 hdrCursorInfo.style.width =
"320px";
3442 rowLeftNums.style.position =
"absolute";
3443 rowRightNums.style.position =
"absolute";
3444 colTopNums.style.position =
"absolute";
3445 colBottomNums.style.position =
"absolute";
3447 el.appendChild(bmp);
3448 el.appendChild(bmpGrid);
3449 el.appendChild(bmpOverlay);
3451 el.appendChild(hdrCursorInfo);
3452 el.appendChild(cursorInfo);
3454 el.appendChild(rowLeftNums);
3455 el.appendChild(rowRightNums);
3456 el.appendChild(colTopNums);
3457 el.appendChild(colBottomNums);
3463 function localCreateGridButtons()
3465 allRowBtns = document.createElement(
"div");
3467 allColBtns = document.createElement(
"div");
3469 allBtn = document.createElement(
"div");
3470 allBtn.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3473 for(var i=0;i<rows;++i)
3475 tmpEl = document.createElement(
"div");
3476 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3477 tmpEl.style.position =
"absolute";
3478 allRowBtns.appendChild(tmpEl);
3480 for(var i=0;i<cols;++i)
3482 tmpEl = document.createElement(
"div");
3483 tmpEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-btn-all");
3484 tmpEl.style.position =
"absolute";
3485 allColBtns.appendChild(tmpEl);
3488 allRowBtns.style.position =
"absolute";
3489 el.appendChild(allRowBtns);
3490 allColBtns.style.position =
"absolute";
3491 el.appendChild(allColBtns);
3492 allBtn.style.position =
"absolute";
3493 el.appendChild(allBtn);
3499 function localCreateHeader()
3501 hdr = document.createElement(
"div");
3502 hdr.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-header");
3506 str +=
"<div style='float:left; margin: 0 0 20px 0;'>";
3507 str +=
"<div style='float:left; '>";
3515 str +=
"<div style='float:left; margin-left: 50px;'>";
3516 str +=
"Number of [Rows,Cols]: " +
"[" + rows +
"," + cols +
"]";
3520 str +=
"<div style='float:right; '>";
3522 ConfigurationAPI._POP_UP_DIALOG_ID +
3523 "-cancel' href='#'>Cancel</a>";
3526 str +=
"<div id='clearDiv'></div>";
3528 str +=
"<div style='float:right; margin: 40px 20px -50px 0;'>";
3530 ConfigurationAPI._POP_UP_DIALOG_ID +
3531 "-ok' href='#'>OK</a>";
3534 str +=
"<div style='float:left; margin: 0 0 0 0;'>";
3535 for(var clickIndex=0;clickIndex<2;++clickIndex)
3537 str +=
"<div style='float:left; margin: 5px 0 0 0;'>";
3538 str +=
"<div style='float:left; width:180px; text-align:right; margin-top: 3px;'>";
3539 str += (clickIndex?
"Right":
"Left") +
"-Click Value:";
3541 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3542 "-bitmap-scrollbar' style='float:left;' " +
3543 "type='range' min='" + minValue +
3544 "' max='" + maxValue +
"' value='" + (clickIndex?maxValue:minValue) +
3545 "' step='" + stepValue +
3546 "' oninput='ConfigurationAPI.bitMapDialog.localUpdateScroll(" + clickIndex +
")' />";
3547 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3548 "-bitmap-btnInput' style='float:left; margin: 0 1px 0 5px;' " +
3549 "type='button' value='<' " +
3550 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,0)' " +
3551 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",0,1)' " +
3553 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3554 "-bitmap-btnInput' style='float:left;' " +
3555 "type='button' value='>' " +
3556 "onmousedown='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,0)' " +
3557 "onmouseup='ConfigurationAPI.bitMapDialog.localUpdateButtonInput(" + clickIndex +
",1,1)' " +
3559 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3560 "-bitmap-textInput' style='float:left; margin: 0 5px 0 5px; width: 50px;' " +
3562 "onchange='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",1)' " +
3563 "onkeydown='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3564 "onkeyup='ConfigurationAPI.bitMapDialog.localUpdateTextInput(" + clickIndex +
",0)' " +
3566 str +=
"<img class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3567 "-bitmap-colorSample' style='float:left;width:25px; height:25px; margin: -2px 0 2px 0;' " +
3568 "ondragstart='return false;' " +
3569 "draggable='false'" +
3575 str +=
"<div id='clearDiv'></div>";
3580 str +=
"<div style='float:left; margin: 5px 0 0 40px;'>";
3581 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3582 "-bitmap-btnCsv' style='float:left;' " +
3583 "type='button' value='Download as CSV' " +
3584 "onclick='ConfigurationAPI.bitMapDialog.localDownloadCSV()' " +
3586 str +=
"<input class='" + ConfigurationAPI._POP_UP_DIALOG_ID +
3587 "-bitmap-btnCsv' style='float:left; margin: 0 0 0 10px;' " +
3588 "type='button' value='Upload CSV' " +
3589 "onclick='ConfigurationAPI.bitMapDialog.locaPopupUploadCSV()' " +
3593 hdr.innerHTML = str;
3594 hdr.style.overflowY =
"auto";
3595 hdr.style.position =
"absolute";
3597 var scrollEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-scrollbar");
3598 var textInputEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-textInput");
3599 var colorSampleEls = hdr.getElementsByClassName(ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-colorSample");
3604 ConfigurationAPI.bitMapDialog.localUpdateScroll =
function(i)
3606 Debug.log(
"localUpdateScroll " + i);
3608 clickValues[i] = scrollEls[i].value|0;
3609 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3611 textInputEls[i].value = clickValues[i];
3612 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3617 ConfigurationAPI.bitMapDialog.localUpdateTextInput =
function(i,finalChange)
3619 Debug.log(
"localUpdateTextInput " + textInputEls[i].value +
" " + finalChange);
3621 clickValues[i] = textInputEls[i].value|0;
3625 if(clickValues[i] < minValue) clickValues[i] = minValue;
3626 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3627 clickValues[i] = (((clickValues[i]-minValue)/stepValue)|0)*stepValue + minValue;
3628 textInputEls[i].value = clickValues[i];
3632 if(clickValues[i] < minValue)
return;
3633 if(clickValues[i] > maxValue)
return;
3634 if((((clickValues[i]-minValue)/stepValue)|0) != (clickValues[i]-minValue)/stepValue)
3636 Debug.log(
"displaying change");
3638 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3640 scrollEls[i].value = clickValues[i];
3641 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3646 var mouseDownTimer = 0;
3647 ConfigurationAPI.bitMapDialog.localUpdateButtonInput =
function(i,dir,mouseUp,delay)
3649 window.clearInterval(mouseDownTimer);
3652 Debug.log(
"cancel mouse down");
3656 mouseDownTimer = window.setInterval(
function()
3659 if(delay > 50) delay -= 50;
3660 ConfigurationAPI.bitMapDialog.localUpdateButtonInput(i,dir,0,50);
3661 },delay!==undefined?delay:300);
3663 Debug.log(
"localUpdateButtonInput " + textInputEls[i].value +
" " + dir);
3665 clickValues[i] = clickValues[i] + (dir?stepValue:-stepValue);
3666 if(clickValues[i] < minValue) clickValues[i] = minValue;
3667 if(clickValues[i] > maxValue) clickValues[i] = maxValue;
3669 clickColors[i] = localConvertValueToRGBA(clickValues[i]);
3671 textInputEls[i].value = clickValues[i];
3672 scrollEls[i].value = clickValues[i];
3673 colorSampleEls[i].src = ConfigurationAPI.getOnePixelPngData(clickColors[i]);
3683 ConfigurationAPI.bitMapDialog.localDownloadCSV =
function()
3685 var transGrid = localConvertFullGridToRowCol();
3686 console.log(transGrid);
3688 var dataStr =
"data:text/csv;charset=utf-8,";
3690 for(var r=0;r<transGrid.length;++r)
3692 if(r) dataStr += encodeURI(
"\n");
3693 for(var c=0;c<transGrid[0].length;++c)
3695 if(c) dataStr +=
",";
3696 dataStr += transGrid[r][c];
3700 Debug.log(
"ConfigurationAPI.bitMapDialog.localDownloadCSV dataStr=" + dataStr);
3702 var link = document.createElement(
"a");
3703 link.setAttribute(
"href", dataStr);
3704 link.setAttribute(
"style",
"display:none");
3705 link.setAttribute(
"download", _currentConfigName +
"_" +
3706 fieldName +
"_download.csv");
3707 document.body.appendChild(link);
3711 link.parentNode.removeChild(link);
3718 ConfigurationAPI.bitMapDialog._csvUploadDataStr;
3719 ConfigurationAPI.bitMapDialog.locaUploadCSV =
function()
3721 Debug.log(
"locaUploadCSV ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3722 var srcDataStr = ConfigurationAPI.bitMapDialog._csvUploadDataStr.split(
'\n');
3724 for(var i=0;i<srcDataStr.length;++i)
3725 src.push(srcDataStr[i].split(
','));
3730 localConvertFullRowColToGrid(src);
3732 Debug.log(
"Successfully uploaded CSV file to bitmap!", Debug.INFO_PRIORITY);
3735 el = document.getElementById(
"popUpDialog");
3736 if(el) el.parentNode.removeChild(el);
3740 Debug.log(
"Errors occured during upload. Bitmap may not reflect contents of CSV file." +
3741 "\nHere is the error description: \n" + err, Debug.HIGH_PRIORITY);
3744 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3750 ConfigurationAPI.bitMapDialog.locaPopupUploadCSV =
function()
3752 Debug.log(
"ConfigurationAPI.bitMapDialog.locaPopupUploadCSV");
3753 ConfigurationAPI.bitMapDialog._csvUploadDataStr =
"";
3757 var pel = document.getElementById(
"popUpDialog");
3760 pel = document.createElement(
"div");
3761 pel.setAttribute(
"id",
"popUpDialog");
3763 pel.style.display =
"none";
3768 ConfigurationAPI.setPopUpPosition(pel,w ,h );
3770 var str =
"<a id='" +
3772 "-header' href='#' onclick='javascript:ConfigurationAPI.bitMapDialog._csvUploadDataStr = \"\"; var pel = document.getElementById(" +
3773 "\"popUpDialog\"); if(pel) pel.parentNode.removeChild(pel); return false;'>Cancel</a><br><br>";
3775 str +=
"<div id='popUpDialog-div'>";
3777 str +=
"Please choose a CSV formatted data file (i.e. commas for columns, and new lines for rows) " +
3778 "to upload:<br><br>";
3782 str +=
"<input type='file' id='popUpDialog-fileUpload' " +
3783 "accept='.csv' enctype='multipart/form-data' />";
3787 str +=
"</center></div><br><br>";
3789 var onmouseupJS =
"";
3790 onmouseupJS +=
"document.getElementById(\"popUpDialog-submitButton\").disabled = true;";
3791 onmouseupJS +=
"ConfigurationAPI.bitMapDialog.locaUploadCSV();";
3793 str +=
"<input id='popUpDialog-submitButton' disabled type='button' onmouseup='" +
3794 onmouseupJS +
"' " +
3795 "value='Upload File' title='" +
3796 "Upload the chosen file to replace the row,col data in the current bitmap." +
3799 pel.innerHTML = str;
3800 el.appendChild(pel);
3801 pel.style.display =
"block";
3803 document.getElementById(
'popUpDialog-fileUpload').addEventListener(
3804 'change',
function(evt) {
3805 var files = evt.target.files;
3806 var file = files[0];
3807 var reader =
new FileReader();
3808 reader.onload =
function() {
3810 ConfigurationAPI.bitMapDialog._csvUploadDataStr = this.result;
3811 Debug.log(
"ConfigurationAPI.bitMapDialog._csvUploadDataStr = " + ConfigurationAPI.bitMapDialog._csvUploadDataStr);
3812 document.getElementById(
'popUpDialog-submitButton').disabled =
false;
3814 reader.readAsText(file);
3820 el.appendChild(hdr);
3822 ConfigurationAPI.bitMapDialog.localUpdateScroll(0);
3823 ConfigurationAPI.bitMapDialog.localUpdateScroll(1);
3830 function localPaint()
3832 Debug.log(
"localPaint");
3834 popSz = ConfigurationAPI.setPopUpPosition(el,undefined,undefined,padding,undefined,
3844 bmpY = hdrY+hdrH+padding;
3845 bmpW = popSz.w - 2*axisPadding;
3846 bmpH = popSz.h - hdrH - padding - 2*axisPadding;
3851 localOptimizeAspectRatio();
3854 hdr.style.left = hdrX +
"px";
3855 hdr.style.top = hdrY +
"px";
3856 hdr.style.width = hdrW +
"px";
3857 hdr.style.height = hdrH +
"px";
3860 bmp.style.left = bmpX +
"px";
3861 bmp.style.top = bmpY +
"px";
3862 bmp.style.width = bmpW +
"px";
3863 bmp.style.height = bmpH +
"px";
3869 bmpGrid.style.left = (bmpX-bmpBorderSize) +
"px";
3870 bmpGrid.style.top = (bmpY-bmpBorderSize) +
"px";
3871 bmpGrid.style.width = (bmpW) +
"px";
3872 bmpGrid.style.height = (bmpH) +
"px";
3874 var bmpGridChildren = bmpGrid.childNodes;
3877 allRowBtns.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3878 allRowBtns.style.top = (bmpY - bmpBorderSize) +
"px";
3880 allColBtns.style.left = (bmpX - bmpBorderSize) +
"px";
3881 allColBtns.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3883 allBtn.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz) +
"px";
3884 allBtn.style.top = (bmpY + bmpH + axisPaddingMargin - bmpBorderSize*2) +
"px";
3885 allBtn.style.width = butttonSz +
"px";
3886 allBtn.style.height = butttonSz +
"px";
3888 var allRowsChildren = allRowBtns.childNodes;
3889 var allColsChildren = allColBtns.childNodes;
3893 rowLeftNums.style.left = (bmpX - bmpBorderSize - axisPaddingMargin - bmpBorderSize - butttonSz + (- bmpBorderSize - axisPaddingMargin - axisPaddingExtra)) +
"px";
3894 rowLeftNums.style.top = (bmpY - bmpBorderSize) +
"px";
3895 rowRightNums.style.left = (bmpX + bmpW + axisPaddingMargin + bmpBorderSize) +
"px";
3896 rowRightNums.style.top = (bmpY - bmpBorderSize) +
"px";
3897 colTopNums.style.left = (bmpX - bmpBorderSize) +
"px";
3898 colTopNums.style.top = (bmpY - bmpBorderSize*2 - numberDigitH) +
"px";
3899 colBottomNums.style.left = (bmpX - bmpBorderSize) +
"px";
3900 colBottomNums.style.top = (bmpY + bmpH + bmpBorderSize + axisPaddingMargin + bmpBorderSize + butttonSz + bmpBorderSize) +
"px";
3901 rowLeftNums.innerHTML =
"";
3902 rowRightNums.innerHTML =
"";
3903 colTopNums.innerHTML =
"";
3904 colBottomNums.innerHTML =
"";
3906 var thresholdNumberSpacing = 100;
3908 var oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
3913 bmpGridChildren[0].style.left = 0 +
"px";
3914 bmpGridChildren[0].style.top = 0 +
"px";
3915 bmpGridChildren[0].style.width = (bmpW) +
"px";
3916 bmpGridChildren[0].style.height = (bmpH) +
"px";
3919 for(var i=0;i<rows;++i)
3924 bmpGridChildren[1+i*2].style.left = bmpBorderSize +
"px";
3925 bmpGridChildren[1+i*2].style.top = ((i+1)*cellH) +
"px";
3926 bmpGridChildren[1+i*2].style.width = (bmpW) +
"px";
3927 bmpGridChildren[1+i*2].style.height = (bmpGridThickness+bmpBorderSize*2) +
"px";
3930 bmpGridChildren[1+i*2+1].style.left = 0 +
"px";
3931 bmpGridChildren[1+i*2+1].style.top = ((i+1)*cellH + bmpBorderSize) +
"px";
3932 bmpGridChildren[1+i*2+1].style.width = (bmpW + bmpBorderSize*2) +
"px";
3933 bmpGridChildren[1+i*2+1].style.height = bmpGridThickness +
"px";
3935 bmpGridChildren[1+i*2+1].style.backgroundColor =
3936 (doSnakeRows && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
3940 allRowsChildren[i].style.left = 0 +
"px";
3941 allRowsChildren[i].style.top = (i*cellH + (i?bmpGridThickness+bmpBorderSize*2-1:0)) +
"px";
3942 allRowsChildren[i].style.width = (butttonSz) +
"px";
3943 allRowsChildren[i].style.height = (cellH - 1 + (i?-bmpBorderSize*2:0)) +
"px";
3947 numberLoc[0] = (i*cellH - 1 + cellH/2 - numberDigitH/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
3950 translatedRC = localConvertGridToRowCol(i,0);
3951 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
3952 translatedRC[0]%5 == 0)
3955 numberEl = document.createElement(
"div");
3956 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
3957 numberEl.innerHTML = translatedRC[0];
3958 numberEl.style.top = numberLoc[0] +
"px";
3959 numberEl.style.width = axisPaddingExtra +
"px";
3960 rowLeftNums.appendChild(numberEl);
3961 oldNumberLoc[0] = numberLoc[0];
3965 translatedRC = localConvertGridToRowCol(i,cols>1?1:0);
3966 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
3967 translatedRC[0]%5 == 0)
3970 numberEl = document.createElement(
"div");
3971 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
3972 numberEl.innerHTML = translatedRC[0];
3973 numberEl.style.top = numberLoc[0] +
"px";
3974 numberEl.style.width = axisPaddingExtra +
"px";
3975 rowRightNums.appendChild(numberEl);
3976 oldNumberLoc[1] = numberLoc[0];
3981 oldNumberLoc = [-thresholdNumberSpacing,-thresholdNumberSpacing];
3983 for(var i=0;i<cols;++i)
3991 bmpGridChildren[1+(rows-1)*2+i*2].style.top = bmpBorderSize +
"px";
3992 bmpGridChildren[1+(rows-1)*2+i*2].style.left = ((i+1)*cellW + bmpBorderSize) +
"px";
3993 bmpGridChildren[1+(rows-1)*2+i*2].style.height = (bmpH) +
"px";
3994 bmpGridChildren[1+(rows-1)*2+i*2].style.width = (bmpGridThickness+bmpBorderSize*2) +
"px";
3997 bmpGridChildren[1+(rows-1)*2+i*2+1].style.top = 0 +
"px";
3998 bmpGridChildren[1+(rows-1)*2+i*2+1].style.left = ((i+1)*cellW + bmpBorderSize*2) +
"px";
3999 bmpGridChildren[1+(rows-1)*2+i*2+1].style.height = (bmpH + bmpBorderSize*2) +
"px";
4000 bmpGridChildren[1+(rows-1)*2+i*2+1].style.width = bmpGridThickness +
"px";
4002 bmpGridChildren[1+(rows-1)*2+i*2+1].style.backgroundColor =
4003 (doSnakeColumns && i%2 == 1)?
"rgb(100,100,100)":
"#efeaea";
4007 allColsChildren[i].style.left = (i*cellW - 1 + (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4008 allColsChildren[i].style.top = 0 +
"px";
4009 allColsChildren[i].style.width = (cellW + 1 - (i?bmpGridThickness+bmpBorderSize*2:0)) +
"px";
4010 allColsChildren[i].style.height = (butttonSz) +
"px";
4014 numberLoc[0] = (i*cellW + cellW/2 - axisPaddingExtra/2 + (i?bmpGridThickness+bmpBorderSize*2:0));
4017 translatedRC = localConvertGridToRowCol(0,i);
4018 if(numberLoc[0] - oldNumberLoc[0] >= thresholdNumberSpacing &&
4019 translatedRC[1]%5 == 0)
4022 numberEl = document.createElement(
"div");
4023 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4024 numberEl.innerHTML = translatedRC[1];
4025 numberEl.style.left = numberLoc[0] +
"px";
4026 numberEl.style.width = axisPaddingExtra +
"px";
4027 colTopNums.appendChild(numberEl);
4028 oldNumberLoc[0] = numberLoc[0];
4032 translatedRC = localConvertGridToRowCol(rows>1?1:0,i);
4033 if(numberLoc[0] - oldNumberLoc[1] >= thresholdNumberSpacing &&
4034 translatedRC[1]%5 == 0)
4037 numberEl = document.createElement(
"div");
4038 numberEl.setAttribute(
"class", ConfigurationAPI._POP_UP_DIALOG_ID +
"-bitmap-number");
4039 numberEl.innerHTML = translatedRC[1];
4040 numberEl.style.left = numberLoc[0] +
"px";
4041 numberEl.style.width = axisPaddingExtra +
"px";
4042 colBottomNums.appendChild(numberEl);
4043 oldNumberLoc[1] = numberLoc[0];
4062 function localOptimizeAspectRatio()
4064 var cellSkew = (cellW>cellH)?cellW/cellH:cellH/cellW;
4068 if(forcedAspectH !== undefined)
4070 var offAspectH = forcedAspectH/cellH;
4071 var offAspectW = forcedAspectW/cellW;
4073 Debug.log(
"Adjusting skew factor = " + forcedAspectH +
"-" + forcedAspectW);
4075 if(offAspectH < offAspectW)
4076 bmpH = bmpW/cols*forcedAspectH/forcedAspectW*rows;
4078 bmpW = bmpH/rows*forcedAspectW/forcedAspectH*cols;
4080 else if(cellSkew > MAX_SKEW)
4082 var adj = cellSkew/MAX_SKEW;
4084 Debug.log(
"Adjusting skew factor = " + adj);
4097 bmpX = padding + (popSz.w-bmpW)/2;
4098 bmpY = bmpY + (popSz.h-bmpY-bmpH)/2;
4099 hdrY = bmpY - padding - hdrH;
4108 ConfigurationAPI.getDateString;
4110 ConfigurationAPI.getDateStringDayArr_ = [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"];
4111 ConfigurationAPI.getDateStringMonthArr_ = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"];
4112 ConfigurationAPI.getDateString =
function(date)
4116 dateStr += ConfigurationAPI.getDateStringDayArr_[date.getDay()];
4118 dateStr += ConfigurationAPI.getDateStringMonthArr_[date.getMonth()];
4120 dateStr += date.getDate();
4122 dateStr += date.getHours();
4124 dateStr += ((date.getMinutes()<10)?
"0":
"") + date.getMinutes();
4126 dateStr += ((date.getSeconds()<10)?
"0":
"") + date.getSeconds();
4128 dateStr += date.getFullYear();
4130 dateStr += date.toLocaleTimeString([],{timeZoneName:
"short"}).split(
" ")[2];
4137 ConfigurationAPI.setCaretPosition =
function(elem, caretPos, endPos)
4140 elem.setSelectionRange(caretPos, endPos);
4151 ConfigurationAPI.setPopUpPosition =
function(el,w,h,padding,border,margin,doNotResize,offsetUp)
4153 Debug.log(
"ConfigurationAPI.setPopUpPosition");
4155 if(padding === undefined) padding = 10;
4156 if(border === undefined) border = 1;
4157 if(margin === undefined) margin = 0;
4164 ConfigurationAPI.setPopUpPosition.stopPropagation =
function(event) {
4166 event.stopPropagation();
4172 ConfigurationAPI.setPopUpPosition.popupResize =
function() {
4178 window.removeEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4179 window.removeEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4183 catch(err) {
return;}
4189 var ww = DesktopContent.getWindowWidth()-(padding+border)*2;
4190 var wh = DesktopContent.getWindowHeight()-(padding+border)*2;
4194 var ah = el.offsetHeight;
4196 if(w === undefined || h === undefined)
4203 x = (DesktopContent.getWindowScrollLeft() + ((ww-w)/2));
4204 y = (DesktopContent.getWindowScrollTop() + ((wh-h)/2)) - (offsetUp|0) - 100;
4206 if(y<DesktopContent.getWindowScrollTop()+margin+padding)
4207 y = DesktopContent.getWindowScrollTop()+margin+padding;
4210 if(w > ww-margin-padding)
4211 x = -DesktopContent.getWindowScrollLeft();
4212 if(ah > wh-margin-padding)
4213 y = -DesktopContent.getWindowScrollTop();
4215 el.style.left = x +
"px";
4216 el.style.top = y +
"px";
4218 ConfigurationAPI.setPopUpPosition.popupResize();
4221 el.style.width = w +
"px";
4222 el.style.height = h +
"px";
4226 window.addEventListener(
"resize",ConfigurationAPI.setPopUpPosition.popupResize);
4227 window.addEventListener(
"scroll",ConfigurationAPI.setPopUpPosition.popupResize);
4229 el.addEventListener(
"keydown",ConfigurationAPI.setPopUpPosition.stopPropagation);
4230 el.addEventListener(
"mousemove",ConfigurationAPI.setPopUpPosition.stopPropagation);
4231 el.addEventListener(
"mousemove",DesktopContent.mouseMove);
4233 el.style.overflow =
"auto";
4235 return {
"w" : w,
"h" : h,
"x" : x,
"y" : y};
4242 ConfigurationAPI.getOnePixelPngData =
function(rgba)
4244 if(ConfigurationAPI.getOnePixelPngData.canvas === undefined)
4247 ConfigurationAPI.getOnePixelPngData.canvas = document.createElement(
"canvas");
4248 ConfigurationAPI.getOnePixelPngData.canvas.width = 1;
4249 ConfigurationAPI.getOnePixelPngData.canvas.height = 1;
4250 ConfigurationAPI.getOnePixelPngData.ctx = ConfigurationAPI.getOnePixelPngData.canvas.getContext(
"2d");
4251 ConfigurationAPI.getOnePixelPngData.bmpOverlayData = ConfigurationAPI.getOnePixelPngData.ctx.createImageData(1,1);
4254 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[0]=rgba[0];
4255 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[1]=rgba[1];
4256 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[2]=rgba[2];
4257 ConfigurationAPI.getOnePixelPngData.bmpOverlayData.data[3]=rgba[3]!==undefined?rgba[3]:255;
4259 ConfigurationAPI.getOnePixelPngData.ctx.putImageData(
4260 ConfigurationAPI.getOnePixelPngData.bmpOverlayData,0,0);
4261 return ConfigurationAPI.getOnePixelPngData.canvas.toDataURL();
4287 ConfigurationAPI.editableFieldEditingCell_ = 0;
4288 ConfigurationAPI.editableFieldEditingIdString_;
4289 ConfigurationAPI.editableFieldEditingNodeType_;
4290 ConfigurationAPI.editableFieldEditingOldValue_;
4291 ConfigurationAPI.editableFieldEditingInitValue_;
4292 ConfigurationAPI.editableFieldHoveringCell_ = 0;
4293 ConfigurationAPI.editableFieldHoveringIdString_;
4294 ConfigurationAPI.editableFieldSelectedIdString_ = 0;
4295 ConfigurationAPI.editableFieldHandlersSubscribed_ =
false;
4296 ConfigurationAPI.editableFieldMouseIsSelecting_ =
false;
4297 ConfigurationAPI.editableField_SELECTED_COLOR_ =
"rgb(251, 245, 53)";
4298 ConfigurationAPI.createEditableFieldElement =
function(fieldObj,fieldIndex,
4302 var depth = depthIndex|0;
4303 var uid = fieldIndex|0;
4305 if(!ConfigurationAPI.editableFieldHandlersSubscribed_)
4307 ConfigurationAPI.editableFieldHandlersSubscribed_ =
true;
4310 DesktopContent.mouseMoveSubscriber(ConfigurationAPI.handleEditableFieldBodyMouseMove);
4313 var fieldEl = document.createElement(
"div");
4314 fieldEl.setAttribute(
"class",
"ConfigurationAPI-EditableField");
4315 fieldEl.setAttribute(
"id",
"ConfigurationAPI-EditableField-" +
4316 ( depth +
"-" + uid ));
4318 Debug.log(
"Field type " + fieldObj.fieldColumnType);
4321 var valueType = fieldObj.fieldColumnType;
4322 var choices = fieldObj.fieldColumnDataChoicesArr;
4323 var value = fieldObj.fieldColumnDefaultValue;
4324 var path = fieldObj.fieldRelativePath;
4325 var nodeName = fieldObj.fieldColumnName;
4327 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4328 depth,nodeName,value,valueType,choices,path);
4335 ConfigurationAPI.getEditableFieldValue =
function(fieldObj,fieldIndex,depthIndex )
4340 ConfigurationAPI.handleEditableFieldEditOK();
4342 var depth = depthIndex|0;
4343 var uid = fieldIndex|0;
4344 var fieldEl = document.getElementById(
"editableFieldNode-Value-leafNode-" +
4345 ( depth +
"-" + uid ));
4348 Debug.log(
"getEditableFieldValue Error! Invalid target field element '" +
4349 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4353 var valueType = fieldObj.fieldColumnType;
4354 var value = fieldEl.textContent;
4368 ConfigurationAPI.setEditableFieldValue =
function(fieldObj,value,fieldIndex,depthIndex )
4372 var depth = depthIndex|0;
4373 var uid = fieldIndex|0;
4374 var fieldEl = document.getElementById(
"ConfigurationAPI-EditableField-" +
4375 ( depth +
"-" + uid ));
4378 Debug.log(
"setEditableFieldValue Error! Invalid target field element '" +
4379 ( depth +
"-" + uid ), Debug.HIGH_PRIORITY);
4382 var valueType = fieldObj.fieldColumnType;
4383 var choices = fieldObj.fieldColumnDataChoicesArr;
4384 var path = fieldObj.fieldRelativePath;
4385 var nodeName = fieldObj.fieldColumnName;
4387 return ConfigurationAPI.fillEditableFieldElement(fieldEl,uid,
4388 depth,nodeName,value,valueType,choices,path);
4394 ConfigurationAPI.fillEditableFieldElement =
function(fieldEl,uid,
4395 depth,nodeName,value,valueType,choices,path)
4399 var pathHTML = path;
4401 pathHTML = pathHTML.replace(/</g,
"<");
4402 pathHTML = pathHTML.replace(/>/g,
">");
4404 str +=
"<div class='editableFieldNode-Path' style='display:none' id='editableFieldNode-path-" +
4405 ( depth +
"-" + uid ) +
"'>" +
4410 var childLinkFixedChoice =
false;
4411 var isChildLink = valueType.indexOf(
"ChildLink") == 0;
4413 if(valueType ==
"FixedChoiceData" ||
4414 (isChildLink && choices.length > 1))
4417 childLinkFixedChoice = valueType.indexOf(
"ChildLink") == 0;
4421 "<div class='editableFieldNode-FixedChoice-CSV' style='display:none' " +
4422 "id='editableFieldNode-FixedChoice-CSV-" +
4423 ( depth +
"-" + uid ) +
"'>";
4425 for(var j=0;j<choices.length;++j)
4434 else if(valueType ==
"BitMap")
4438 "<div class='editableFieldNode-BitMap-Params' style='display:none' " +
4439 "id='editableFieldNode-BitMap-Params-" +
4440 ( depth +
"-" + uid ) +
"'>";
4442 for(var j=1;j<choices.length;++j)
4445 str += choices[j].replace(/;/g,
",");
4454 "<div class='editableFieldNode-Value editableFieldNode-ValueType-" +
4456 (childLinkFixedChoice?
"ChildLinkFixedChoice":valueType) +
4458 "id='editableFieldNode-Value-" +
4459 (depth +
"-" + uid) +
"' " +
4461 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4462 depth +
"," + uid +
"," +
4465 "onmousemove='ConfigurationAPI.handleEditableFieldHover(" +
4466 depth +
"," + uid +
"," +
4471 titleStr =
"~ Leaf Value Node ~\n";
4472 titleStr +=
"Path: \t" + path + nodeName +
"\n";
4476 "<div style='float:left' title='" + titleStr +
"'>" +
4477 "<b class='editableFieldNode-Value-leafNode-fieldName bold-header'>" +
4479 "</div><div style='float:left'> :</div>";
4483 "<div class='editableFieldNode-Value-editIcon' id='editableFieldNode-Value-editIcon-" +
4484 (depth +
"-" + uid) +
"' " +
4485 "onclick='ConfigurationAPI.handleEditableFieldClick(" +
4486 depth +
"," + uid +
"," +
4487 "1,\"value\"); event.stopPropagation();' " +
4488 "title='Edit the value of this node.' " +
4492 str +=
"<div style='float:left; margin-left:9px;' id='editableFieldNode-Value-leafNode-" +
4493 (depth +
"-" + uid) +
4495 "editableFieldNode-Value-leafNode-ColumnName-" + nodeName +
4500 if(valueType ==
"OnOff" ||
4501 valueType ==
"YesNo" ||
4502 valueType ==
"TrueFalse")
4505 str +=
"<div style='float:left'>";
4509 var color = (value ==
"On" || value ==
"Yes" || value ==
"True")?
4510 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
4511 str +=
"<div style='width:10px;height:10px;" +
4512 "background-color:" + color +
";" +
4514 "border-radius: 7px;" +
4515 "border: 2px solid white;" +
4516 "margin: 2px 0 0 6px;" +
4519 else if(valueType ==
"Timestamp")
4520 str += ConfigurationAPI.getDateString(
new Date((value|0)*1000));
4528 value.indexOf(
"Table") == value.length - (
"Table").length)
4532 var recordAlias =
"";
4533 for(var c=0;c<value.length - (
"Table").length;++c)
4535 if(c && c+1 < value.length &&
4538 (value[c+1] >=
'a' &&
4541 recordAlias += value[c];
4544 var newWindowStr =
"/WebPath/html/ConfigurationGUI_subset.html?urn=" +
4545 DesktopContent._localUrnLid +
4546 "&subsetBasePath=" + value +
4547 "&groupingFieldList=AUTO" +
4548 "&recordAlias=" + recordAlias +
4549 "&editableFieldList=" +
"!*CommentDescription";
4551 str +=
"<div style='float:left; margin-left:9px;' " +
4552 " id='editableFieldNode-ChildLink-SubConfigLinkWindow-" +
4553 (depth +
"-" + uid) +
"' " +
4555 "editableFieldNode-ChildLink-SubConfigLink" +
4558 "DesktopContent.openNewWindow(" +
4560 " Subset-Configuration\",\"\",\"" +
4563 "\",false /*unique*/);" +
4565 " title='Open " + value +
" subset configuration in a new desktop window.' " +
4566 ">Open Window</div>";
4568 str +=
"<div style='float:left; margin-left:9px;' " +
4569 " id='editableFieldNode-ChildLink-SubConfigLinkTab-" +
4570 (depth +
"-" + uid) +
"' " +
4572 "editableFieldNode-ChildLink-SubConfigLink" +
4575 "DesktopContent.openNewBrowserTab(" +
4577 " Subset-Configuration\",\"\",\"" +
4580 "\",false /*unique*/);" +
4582 " title='Open " + value +
" subset configuration in a new browser tab.' " +
4588 fieldEl.innerHTML = str;
4592 if(ConfigurationAPI.editableFieldSelectedIdString_ == (depth +
"-" + uid))
4593 fieldEl.getElementsByClassName(
"editableFieldNode-Value")[0].style.backgroundColor =
4594 ConfigurationAPI.editableField_SELECTED_COLOR_;
4605 ConfigurationAPI.handleEditableFieldClick =
function(depth,uid,editClick,type)
4607 var idString = depth +
"-" + uid;
4608 ConfigurationAPI.editableFieldEditingIdString_ = idString;
4610 Debug.log(
"handleEditableFieldClick editClick " + editClick);
4611 Debug.log(
"handleEditableFieldClick idString " + idString);
4613 var el = document.getElementById(
"editableFieldNode-Value-" + idString);
4617 Debug.log(
"Invalid element pointed to by idString. Ignoring and exiting.");
4621 if(ConfigurationAPI.editableFieldHoveringCell_)
4624 ConfigurationAPI.handleEditableFieldBodyMouseMove();
4627 if(ConfigurationAPI.editableFieldEditingCell_)
4629 if(ConfigurationAPI.editableFieldEditingCell_ == el)
4631 ConfigurationAPI.handleEditableFieldEditOK();
4634 var path = document.getElementById(
"editableFieldNode-path-" + idString).textContent;
4640 Debug.log(
"handleEditableFieldClick path " + path);
4642 Debug.log(
"handleEditableFieldClick type " + type);
4673 Debug.log(
"edit value mode");
4675 selectThisTreeNode(idString,type);
4677 function selectThisTreeNode(idString,type)
4681 var el = document.getElementById(
"editableFieldNode-Value-leafNode-" + idString);
4682 var vel = document.getElementById(
"editableFieldNode-Value-" + idString);
4685 var colType = vel.className.split(
' ')[1].split(
'-');
4686 if(colType[1] ==
"ValueType")
4687 colType = colType[2];
4689 var fieldName = el.className.substr((
"editableFieldNode-Value-leafNode-ColumnName-").length);
4691 Debug.log(
"fieldName=" + fieldName);
4692 Debug.log(
"colType=" + colType);
4694 if(colType ==
"Author" ||
4695 colType ==
"Timestamp")
4697 Debug.log(
"Can not edit Author or Timestamp fields.",
4698 Debug.WARN_PRIORITY);
4704 var optionIndex = -1;
4707 if(colType ==
"YesNo" ||
4708 colType ==
"TrueFalse" ||
4712 ConfigurationAPI.editableFieldEditingOldValue_ = el.innerHTML;
4714 var initVal = el.childNodes[0].textContent;
4715 ConfigurationAPI.editableFieldEditingInitValue_ = initVal;
4718 if(colType ==
"YesNo")
4719 boolVals = [
"No",
"Yes"];
4720 else if(colType ==
"TrueFalse")
4721 boolVals = [
"False",
"True"];
4722 else if(colType ==
"OnOff")
4723 boolVals = [
"Off",
"On"];
4726 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4727 "onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4728 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_); event.stopPropagation();' " +
4729 "onclick='event.stopPropagation();'" +
4730 "style='margin:-8px -2px -2px -1px; height:" + (el.offsetHeight+6) +
"px'>";
4731 for(var i=0;i<boolVals.length;++i)
4733 str +=
"<option value='" + boolVals[i] +
"'>";
4736 if(boolVals[i] == initVal)
4740 if(optionIndex == -1) optionIndex = 0;
4742 else if(colType ==
"FixedChoiceData" ||
4743 colType ==
"ChildLinkFixedChoice")
4745 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4746 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4748 var allowFixedChoiceArbitraryEdit =
false;
4749 var optionCount = -1;
4752 str +=
"<div onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4753 "onmouseup='event.stopPropagation();' " +
4754 "onclick='event.stopPropagation();' " +
4756 "white-space:nowrap;" +
4757 "margin:-3px -2px -2px -1px;" +
4758 "height:" + (el.offsetHeight+6) +
"px'>";
4760 str +=
"<select onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' " +
4761 "id='fixedChoice-editSelectBox' " +
4762 "onmouseup='event.stopPropagation();' " +
4763 "onclick='event.stopPropagation();' " +
4766 "margin:-2px -2px -2px -1px; height:" +
4767 (el.offsetHeight+6) +
"px'>";
4771 var vel = document.getElementById(
"editableFieldNode-FixedChoice-CSV-" +
4773 var choices = vel.textContent.split(
',');
4775 var isChildLinkFixedChoice = colType ==
"ChildLinkFixedChoice";
4777 if(isChildLinkFixedChoice)
4781 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
4782 (depth +
"-" + uid) ).style.display =
"none";
4783 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
4784 (depth +
"-" + uid) ).style.display =
"none";
4789 if(choices.length > 1 &&
4790 choices[1].indexOf(
"arbitraryBool=") == 0)
4793 allowFixedChoiceArbitraryEdit =
4794 choices[1][(
"arbitraryBool=").length] ==
"1"?
4796 Debug.log(
"allowFixedChoiceArbitraryEdit " + allowFixedChoiceArbitraryEdit);
4799 for(var i=0;i<choices.length;++i)
4801 if(i == 0 && isChildLinkFixedChoice && !allowFixedChoiceArbitraryEdit)
4808 if(choices[i].indexOf(
"arbitraryBool=") == 0)
4824 str += decodeURIComponent(choices[i]);
4826 if(decodeURIComponent(choices[i])
4827 == ConfigurationAPI.editableFieldEditingOldValue_)
4828 optionIndex = optionCount;
4832 if(allowFixedChoiceArbitraryEdit)
4834 var ww = (el.offsetWidth-6);
4835 if(ww < 150) ww = 150;
4836 str +=
"<input type='text' " +
4837 "id='fixedChoice-editTextBox' " +
4838 "style='display:none;" +
4840 "margin:-2px 0 -" + (el.offsetHeight+6) +
"px 0;" +
4842 ww +
"px; height:" + (el.offsetHeight+6) +
"px" +
4846 str +=
"<div style='display:block;" +
4847 "margin: -2px 0 -7px 14px;" +
4849 "class='editableFieldNode-Value-editIcon' id='fixedChoice-editIcon" +
4851 "onclick='ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle();' " +
4852 "title='Toggle free-form editing' " +
4857 else if(colType ==
"BitMap")
4859 Debug.log(
"Handling bitmap select");
4861 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4864 ConfigurationAPI.bitMapDialog(
4866 "Target Field: "" +
4867 fieldName_ +
""",
4868 document.getElementById(
"editableFieldNode-BitMap-Params-" +
4869 idString).textContent.split(
';'),
4870 ConfigurationAPI.editableFieldEditingOldValue_,
4873 Debug.log(
"yes " + val);
4875 el.appendChild(document.createTextNode(val));
4876 ConfigurationAPI.editableFieldEditingCell_ = el;
4885 Debug.log(
"cancel bitmap");
4886 ConfigurationAPI.editableFieldEditingCell_ = 0;
4890 else if(colType ==
"MultilineData")
4892 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4893 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4895 str +=
"<textarea rows='4' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' cols='50' style='font-size: 14px; " +
4896 "margin:-8px -2px -2px -1px;width:" +
4897 (el.offsetWidth-6) +
"px; height:" + (el.offsetHeight-8) +
"px' ";
4898 str +=
" onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4899 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
4900 "onclick='event.stopPropagation();'" +
4902 str += ConfigurationAPI.editableFieldEditingOldValue_;
4903 str +=
"</textarea>";
4907 if(colType ==
"GroupID")
4910 ConfigurationAPI.editableFieldEditingOldValue_ = el.textContent;
4911 ConfigurationAPI.editableFieldEditingInitValue_ = ConfigurationAPI.editableFieldEditingOldValue_;
4913 var ow = el.offsetWidth+6;
4916 str +=
"<input type='text' onkeydown='ConfigurationAPI.handleEditableFieldKeyDown(event)' style='margin:-8px -2px -2px -1px;width:" +
4917 (ow) +
"px; height:" + (el.offsetHeight>20?el.offsetHeight:20) +
"px' value='";
4918 str += ConfigurationAPI.editableFieldEditingOldValue_;
4919 str +=
"' onmousedown='ConfigurationAPI.editableFieldMouseIsSelecting_ = true; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);' " +
4920 "onmouseup='ConfigurationAPI.editableFieldMouseIsSelecting_ = false; Debug.log(ConfigurationAPI.editableFieldMouseIsSelecting_);event.stopPropagation();' " +
4921 "onclick='event.stopPropagation();'" +
4926 str += ConfigurationAPI._OK_CANCEL_DIALOG_STR;
4931 if(colType ==
"YesNo" ||
4932 colType ==
"TrueFalse" ||
4935 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
4936 el.getElementsByTagName(
"select")[0].focus();
4938 else if(colType ==
"FixedChoiceData" ||
4939 colType ==
"ChildLinkFixedChoice")
4941 el.getElementsByTagName(
"select")[0].selectedIndex = optionIndex;
4942 el.getElementsByTagName(
"select")[0].focus();
4945 else if(colType ==
"MultilineData")
4946 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"textarea")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
4948 ConfigurationAPI.setCaretPosition(el.getElementsByTagName(
"input")[0],0,ConfigurationAPI.editableFieldEditingOldValue_.length);
4952 ConfigurationAPI.editableFieldEditingCell_ = el;
4953 ConfigurationAPI.editableFieldEditingNodeType_ = type;
4958 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
4967 Debug.log(
"Toggling selection of target field " + idString);
4971 if(ConfigurationAPI.editableFieldSelectedIdString_ &&
4972 (vel = document.getElementById(
"editableFieldNode-Value-" +
4973 ConfigurationAPI.editableFieldSelectedIdString_)))
4974 vel.style.backgroundColor =
"transparent";
4977 vel = document.getElementById(
"editableFieldNode-Value-" +
4979 if(ConfigurationAPI.editableFieldSelectedIdString_ == idString)
4983 ConfigurationAPI.editableFieldSelectedIdString_ = undefined;
4986 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
4987 ConfigurationAPI.editableFieldSelectedIdString_ = idString;
4991 Debug.log(
"This should be impossible - tell a developer how you got here!", Debug.HIGH_PRIORITY);
5002 ConfigurationAPI.getSelectedEditableFieldIndex =
function()
5004 if(!ConfigurationAPI.editableFieldSelectedIdString_)
5007 var idStr = ConfigurationAPI.editableFieldSelectedIdString_;
5008 return idStr.split(
'-')[1];
5014 ConfigurationAPI.handleEditableFieldHover =
function(depth,uid,event)
5016 var idString = depth +
"-" + uid;
5020 event.stopPropagation();
5021 DesktopContent.mouseMove(event);
5024 if(ConfigurationAPI.editableFieldEditingCell_)
return;
5026 var el = document.getElementById(
"editableFieldNode-Value-editIcon-" + idString);
5027 if(ConfigurationAPI.editableFieldHoveringCell_ == el)
return;
5029 if(ConfigurationAPI.editableFieldHoveringCell_)
5032 bodyMouseMoveHandler();
5036 ConfigurationAPI.editableFieldHoveringIdString_ = idString;
5037 ConfigurationAPI.editableFieldHoveringCell_ = el;
5038 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"block";
5039 var vel = document.getElementById(
"editableFieldNode-Value-" +
5040 ConfigurationAPI.editableFieldHoveringIdString_);
5041 vel.style.backgroundColor =
"rgb(218, 194, 194)";
5046 ConfigurationAPI.handleEditableFieldFixedChoiceEditToggle =
function()
5048 Debug.log(
"handleEditableFieldFixedChoiceEditToggle");
5050 var sel = document.getElementById(
"fixedChoice-editSelectBox");
5051 var tel = document.getElementById(
"fixedChoice-editTextBox");
5053 Debug.log(
"sel.style.display " + sel.style.display);
5054 if(sel.style.display ==
"none")
5056 sel.style.display =
"block";
5057 tel.style.display =
"none";
5061 tel.style.width = ((sel.offsetWidth>150?sel.offsetWidth:150)-2) +
"px";
5062 tel.parentNode.style.width = ((sel.offsetWidth>150?sel.offsetWidth:150)+50) +
"px";
5063 sel.style.display =
"none";
5066 tel.value = ConfigurationAPI.editableFieldEditingOldValue_;
5068 tel.style.display =
"block";
5069 ConfigurationAPI.setCaretPosition(tel,0,tel.value.length);
5075 ConfigurationAPI.handleEditableFieldBodyMouseMove =
function(e)
5077 if(ConfigurationAPI.editableFieldHoveringCell_)
5080 ConfigurationAPI.editableFieldHoveringCell_.style.display =
"none";
5081 ConfigurationAPI.editableFieldHoveringCell_ = 0;
5083 var vel = document.getElementById(
"editableFieldNode-Value-" +
5084 ConfigurationAPI.editableFieldHoveringIdString_);
5087 if(ConfigurationAPI.editableFieldHoveringIdString_ ==
5088 ConfigurationAPI.editableFieldSelectedIdString_)
5089 vel.style.backgroundColor = ConfigurationAPI.editableField_SELECTED_COLOR_;
5091 vel.style.backgroundColor =
"transparent";
5099 ConfigurationAPI.handleEditableFieldKeyDown =
function(e,keyEl)
5111 key = window.event.keyCode;
5112 shiftIsDown = !!window.event.shiftKey;
5117 shiftIsDown = !!e.shiftKey;
5126 if(ConfigurationAPI.editableFieldEditingCell_ &&
5127 (tel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"textarea")).length)
5131 if(e.keyCode == TABKEY)
5134 if(e.preventDefault)
5137 var i = tel.selectionStart;
5138 var j = tel.selectionEnd;
5139 tel.value = tel.value.substr(0,i) +
5140 '\t' + tel.value.substr(j);
5141 tel.selectionStart = tel.selectionEnd = j+1;
5150 if(e.keyCode == TABKEY || e.keyCode == ENTERKEY ||
5151 e.keyCode == UPKEY || e.keyCode == DNKEY)
5154 if(e.preventDefault)
5158 var idString = ConfigurationAPI.editableFieldEditingIdString_;
5160 ConfigurationAPI.handleEditableFieldEditOK();
5168 if(e.keyCode == ENTERKEY)
5171 var depth = idString.split(
'-')[0];
5172 var uid = idString.split(
'-')[1];
5174 if((!shiftIsDown && e.keyCode == TABKEY) || e.keyCode == DNKEY)
5176 else if((shiftIsDown && e.keyCode == TABKEY) || e.keyCode == UPKEY)
5178 if(uid < 0)
return false;
5181 ConfigurationAPI.handleEditableFieldClick(depth,uid,1,
"value");
5182 Debug.log(
"new uid=" + uid);
5186 else if(e.keyCode == ESCKEY)
5188 if(e.preventDefault)
5190 ConfigurationAPI.handleEditableFieldEditCancel();
5193 else if((e.keyCode >= 48 && e.keyCode <= 57) ||
5194 (e.keyCode >= 96 && e.keyCode <= 105))
5198 if((sel = ConfigurationAPI.editableFieldEditingCell_.getElementsByTagName(
"select")).length)
5203 sel = sel[sel.length-1];
5208 selNum = e.keyCode - 96;
5210 selNum = e.keyCode - 48;
5212 sel.selectedIndex = selNum % (sel.options.length);
5215 Debug.log(
"number select =" + sel.selectedIndex);
5225 ConfigurationAPI.handleEditableFieldEditCancel =
function()
5227 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5228 Debug.log(
"handleEditableFieldEditCancel type " + ConfigurationAPI.editableFieldEditingNodeType_);
5232 var idSplit = ConfigurationAPI.editableFieldEditingCell_.id.split(
'-');
5233 var depth = idSplit[idSplit.length-2];
5234 var uid = idSplit[idSplit.length-1];
5235 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
5236 (depth +
"-" + uid) ).style.display =
"block";
5237 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
5238 (depth +
"-" + uid) ).style.display =
"block";
5243 if(ConfigurationAPI.editableFieldEditingNodeType_ ==
"value-bool")
5246 ConfigurationAPI.editableFieldEditingCell_.innerHTML = ConfigurationAPI.editableFieldEditingOldValue_;
5250 ConfigurationAPI.editableFieldEditingCell_.innerHTML =
"";
5251 ConfigurationAPI.editableFieldEditingCell_.appendChild(
5252 document.createTextNode(ConfigurationAPI.editableFieldEditingOldValue_));
5255 ConfigurationAPI.editableFieldEditingCell_ = 0;
5261 ConfigurationAPI.handleEditableFieldEditOK =
function()
5263 if(!ConfigurationAPI.editableFieldEditingCell_)
return;
5264 Debug.log(
"handleEditableFieldEditOK type " + ConfigurationAPI.editableFieldEditingNodeType_);
5268 var idSplit = ConfigurationAPI.editableFieldEditingCell_.id.split(
'-');
5269 var depth = idSplit[idSplit.length-2];
5270 var uid = idSplit[idSplit.length-1];
5271 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkTab-" +
5272 (depth +
"-" + uid) ).style.display =
"block";
5273 document.getElementById(
"editableFieldNode-ChildLink-SubConfigLinkWindow-" +
5274 (depth +
"-" + uid) ).style.display =
"block";
5278 var el = ConfigurationAPI.editableFieldEditingCell_;
5279 var type = ConfigurationAPI.editableFieldEditingNodeType_;
5283 function localEditTreeNodeOKRequestsComplete(newValue)
5289 if(type ==
"value" ||
5290 type ==
"value-bitmap")
5296 el.appendChild(document.createTextNode(decodeURIComponent(newValue)));
5299 else if(type ==
"value-bool")
5304 str +=
"<div style='float:left'>";
5308 var color = (newValue ==
"On" || newValue ==
"Yes" || newValue ==
"True")?
5309 "rgb(16, 204, 16)":
"rgb(255, 0, 0);";
5310 str +=
"<div style='width:10px;height:10px;" +
5311 "background-color:" + color +
";" +
5313 "border-radius: 7px;" +
5314 "border: 2px solid white;" +
5315 "margin: 2px 0 0 6px;" +
5319 else if(type ==
"value-groupid")
5321 el.appendChild(document.createTextNode(newValue));
5325 Debug.log(
"Unrecognizd tree edit type! Should be impossible!",Debug.HIGH_PRIORITY);
5326 ConfigurationAPI.handleEditableFieldEditCancel();
return;
5330 ConfigurationAPI.editableFieldEditingCell_ = 0;
5337 type ==
"value-bool" ||
5338 type ==
"value-bitmap" ||
5339 type ==
"value-groupid")
5344 if(type ==
"value-bool")
5346 var sel = el.getElementsByTagName(
"select")[0];
5347 newValue = sel.options[sel.selectedIndex].value;
5349 else if(type ==
"value-bitmap")
5351 newValue = encodeURIComponent(el.textContent);
5356 if((sel = el.getElementsByTagName(
"textarea")).length)
5357 newValue = sel[0].value;
5358 else if((sel = el.getElementsByTagName(
"select")).length)
5361 if(sel[0].style.display ==
"none")
5365 newValue = el.getElementsByTagName(
"input")[0].value;
5368 newValue = sel[0].options[sel[0].selectedIndex].value;
5371 newValue = el.getElementsByTagName(
"input")[0].value;
5373 newValue = encodeURIComponent(newValue.trim());
5376 Debug.log(
"CfgGUI editTreeNodeOK editing " + type +
" node = " +
5379 if(ConfigurationAPI.editableFieldEditingInitValue_ == newValue)
5381 Debug.log(
"No change. Do nothing.");
5382 ConfigurationAPI.handleEditableFieldEditCancel();
5390 localEditTreeNodeOKRequestsComplete(newValue);
5395 Debug.log(
"Unrecognizd tree edit type! Should be impossible!",Debug.HIGH_PRIORITY);
5396 editCellCancel();
return;
5403 ConfigurationAPI.hasClass =
function(ele,cls)
5405 return !!ele.className.match(
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)'));
5410 ConfigurationAPI.addClass =
function(ele,cls)
5412 if (!ConfigurationAPI.hasClass(ele,cls)) ele.className +=
" "+cls;
5417 ConfigurationAPI.removeClass =
function(ele,cls)
5419 if (ConfigurationAPI.hasClass(ele,cls))
5421 var reg =
new RegExp(
'(\\s|^)'+cls+
'(\\s|$)');
5422 ele.className=ele.className.replace(reg,
'');
5442 ConfigurationAPI.addSubsetRecords =
function(subsetBasePath,
5443 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
5445 var modifiedTablesListStr =
"";
5446 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
5448 if(i) modifiedTablesListStr +=
",";
5449 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
5450 modifiedTablesIn[i].tableVersion;
5453 var recordListStr =
"";
5454 if(Array.isArray(recordArr))
5455 for(var i=0;i<recordArr.length;++i)
5457 if(i) recordListStr +=
",";
5458 recordListStr += encodeURIComponent(recordArr[i]);
5461 recordListStr = encodeURIComponent(recordArr);
5463 DesktopContent.XMLHttpRequest(
"Request?RequestType=addTreeNodeRecords" +
5465 "&tableGroupKey=-1",
5466 "startPath=/" + subsetBasePath +
5467 "&recordList=" + recordListStr +
5468 "&modifiedTables=" + modifiedTablesListStr,
5471 var modifiedTables = [];
5473 var err = DesktopContent.getXMLValue(req,
"Error");
5477 Debug.log(err,Debug.HIGH_PRIORITY);
5478 responseHandler(modifiedTables,err);
5485 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
5486 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
5487 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
5491 for(var i=0;i<tableNames.length;++i)
5493 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
5494 if(tableVersion >= -1)
continue;
5496 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
5497 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
5498 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
5499 modifiedTables.push(obj);
5501 responseHandler(modifiedTables);
5525 ConfigurationAPI.deleteSubsetRecords =
function(subsetBasePath,
5526 recordArr,responseHandler,modifiedTablesIn,silenceErrors)
5528 var modifiedTablesListStr =
"";
5529 for(var i=0;modifiedTablesIn && i<modifiedTablesIn.length;++i)
5531 if(i) modifiedTablesListStr +=
",";
5532 modifiedTablesListStr += modifiedTablesIn[i].tableName +
"," +
5533 modifiedTablesIn[i].tableVersion;
5536 var recordListStr =
"";
5537 var recordCount = 1;
5538 if(Array.isArray(recordArr))
5540 for(var i=0;i<recordArr.length;++i)
5542 if(i) recordListStr +=
",";
5543 recordListStr += encodeURIComponent(recordArr[i]);
5545 recordCount = recordArr.length;
5548 recordListStr = encodeURIComponent(recordArr);
5550 DesktopContent.XMLHttpRequest(
"Request?RequestType=deleteTreeNodeRecords" +
5552 "&tableGroupKey=-1",
5553 "startPath=/" + subsetBasePath +
5554 "&recordList=" + recordListStr +
5555 "&modifiedTables=" + modifiedTablesListStr,
5559 var err = DesktopContent.getXMLValue(req,
"Error");
5560 var modifiedTables = [];
5564 Debug.log(err,Debug.HIGH_PRIORITY);
5565 responseHandler(modifiedTables,err);
5572 var tableNames = req.responseXML.getElementsByTagName(
"NewActiveTableName");
5573 var tableVersions = req.responseXML.getElementsByTagName(
"NewActiveTableVersion");
5574 var tableComments = req.responseXML.getElementsByTagName(
"NewActiveTableComment");
5578 for(var i=0;i<tableNames.length;++i)
5580 tableVersion = DesktopContent.getXMLValue(tableVersions[i])|0;
5581 if(tableVersion >= -1)
continue;
5583 obj.tableName = DesktopContent.getXMLValue(tableNames[i]);
5584 obj.tableVersion = DesktopContent.getXMLValue(tableVersions[i]);
5585 obj.tableComment = DesktopContent.getXMLValue(tableComments[i]);
5586 modifiedTables.push(obj);
5588 responseHandler(modifiedTables,undefined,subsetBasePath,recordCount);
5598 ConfigurationAPI.incrementName =
function(name)
5601 for(var i=name.length-1;i>=0;--i)
5602 if(!(name[i] >=
'0' && name[i] <=
'9'))
5605 var num = (name.substr(i+1)|0) + 1;
5606 name = name.substr(0,i+1);
5612 ConfigurationAPI.createNewRecordName =
function(startingName,existingArr)
5614 var retVal = startingName;
5618 var apps = existingArr;
5621 retVal = ConfigurationAPI.incrementName(retVal);
5623 for(i=0;i<apps.length;++i)
5624 if(apps[i] == retVal)
5625 {found =
true;
break;}
5627 Debug.log(
"createNewRecordName " + retVal);
5632 return ConfigurationAPI.incrementName(retVal);