1// DFB-HTML5.js 2// Author: Matthew F. Egan 3// 4// This .js file is used to encapsulate the DictionaryFormBuilder-HTML5 main functions. 5// 6 7/// <reference path="Globals.js" /> 8/// <reference path="Thread.js" /> 9/// <reference path="Support.js" /> 10/// <reference path="Support-UI.js" /> 11/// <reference path="Validation.js" /> 12/// <reference path="Debug.js" /> 13/// <reference path="Canvas.js" /> 14/// <reference path="Overlay.js" /> 15/// <reference path="Worker.js" /> 16/// <reference path="Layout.js" /> 17/// <reference path="Events.js" /> 18 19 20// DEVELOPERS: PLEASE REMEMBER TO CHANGE THE VERSIONING PRIOR TO PUBLISH! IT IS VERY IMPORTANT WE KNOW THE VERSIONS OF JAVASCRIPT FILES ON LIVE! 21//Version nomenclature 22// Major (If a major revision is made that changes the functionality) 23// Minor (If a minor revision is made that requires backwards compatability) 24// Revision (Month of the year of the change) 25// System (Day of the Month of the change) 26// Iteration (Number of iterations in the same day of changes) 27// Year (Year of the change) 28// 29// Name is the name of the file 30// Requires is an array of names that represent files the current file needs, right now only used for JavaScripts. 31 32try { 33 versioning.reportVersion({ 34 major: 1, 35 minor: 0, 36 revision: 2, 37 system: 14, 38 iteration: 1, 39 year: 2019, 40 name: 'DFB-HTML5.js', 41 requires: ['NOAH.Include.Config.js', 'NOAH.Include.js'] 42 }); 43} catch (ex) { console.log(ex.message); } 44 45 46// DEFINITIONS 47try { 48 var doClientSideValidation = false; // DO CLIENT-SIDE VALIDATIONS? 49 var preservedDoClientSideValidation = doClientSideValidation; // PRESERVE THE LAST VALIDATION ATTEMPT VALUES? 50} 51catch (ex) 52{ 53 handleLogException({ message: "Initialization DFB-HTML5", messageType: messageTypes.Error, isInitialization: true }); 54} 55 56 57function doValidateElements(sender, e) { 58 // ------------------------------------------ 59 // FUNCTION DESCRIPTION: DO VALIDATION WORK 60 // ------------------------------------------ 61 62 handleLogException({ sender: doValidateElements, message: "Entering", isWorkFlow: true }); 63 try 64 { 65 if (doClientSideValidation) { 66 var parameters = workOnElementParameters(); // IN WORKER.JS 67 68 // SET PARAMETER VALUES TO USE (GROUPCODES) 69 parameters.activationAttribute = _ValidateGroupCode; // IN GLOBALS.JS 70 parameters.workOnAttribute = _GroupCode; // IN GLOBALS.JS 71 parameters.workToDo = workTypes.Validate; // IN WORKER.JS 72 parameters.collectionToUse = everyGCCollection; // IN GLOBALS.JS 73 parameters.e = e; 74 parameters.workOnGroupCodes = true; 75 parameters.workOnMasterCodes = false; 76 parameters.doFormSubmitCheck = true; 77 parameters.showMessages = true; 78 79 doWorkOnElements(sender, parameters); // IN WORKER.JS (DO THE WORK FOR THIS ITEM; SPECIFIC FOR GROUPCODE > VALIDATIONS) 80 81 //// SET PARAMETER VALUES TO USE (MASTERCODES) 82 //parameters.activationAttribute = _ValidateMasterCode; // IN GLOBALS.JS 83 //parameters.workOnAttribute = _MasterCode; // IN GLOBALS.JS 84 //parameters.workToDo = workTypes.Validate; // IN WORKER.JS 85 //parameters.collectionToUse = everyMCCollection; // IN GLOBALS.JS 86 //parameters.e = e; 87 //parameters.workOnGroupCodes = false; 88 //parameters.workOnMasterCodes = true; 89 //parameters.doFormSubmitCheck = false; 90 91 //doWorkOnElements(sender, parameters); // IN WORKER.JS (DO THE WORK FOR THIS ITEM; SPECIFIC FOR MASTERCODE > VALIDATIONS) 92 } 93 } 94 catch (ex) 95 { 96 handleLogException({ sender: doValidateElements, message: "Error", isWorkFlow: fal
96se }); 97 } 98 handleLogException({ sender: doValidateElements, message: "Exiting", isWorkFlow: true }); 99} 100 101function doRequiredElements(sender, e) { 102 // ------------------------------------------------ 103 // FUNCTION DESCRIPTION: DO REQUIRED ELEMENT WORK 104 // ------------------------------------------------ 105 106 handleLogException({ sender: doRequiredElements, message: "Entering", isWorkFlow: true }); 107 try 108 { 109 var parameters = workOnElementParameters(); // IN WORKER.JS 110 111 // SET PARAMETER VALUES TO USE (GROUPCODES) 112 parameters.activationAttribute = _RequiredGroupCode; // IN GLOBALS.JS 113 parameters.workOnAttribute = _GroupCode; // IN GLOBALS.JS 114 parameters.workToDo = workTypes.Required; // IN WORKER.JS 115 parameters.collectionToUse = everyRequiredGCCollection; // IN GLOBALS.JS 116 parameters.e = e; 117 parameters.workOnGroupCodes = true; 118 parameters.workOnMasterCodes = false; 119 120 doWorkOnElements(sender, parameters); // IN WORKER.JS (DO THE WORK FOR THIS ITEM; SPECIFIC FOR GROUPCODE > REQUIRED) 121 122 //// SET PARAMETER VALUES TO USE (MASTERCODES) 123 //parameters.activationAttribute = _RequiredMasterCode; // IN GLOBALS.JS 124 //parameters.workOnAttribute = _MasterCode; // IN GLOBALS.JS 125 //parameters.workToDo = workTypes.Required; // IN WORKER.JS 126 //parameters.collectionToUse = everyRequiredMCCollection; // IN GLOBALS.JS 127 //parameters.e = e; 128 //parameters.workOnGroupCodes = false; 129 //parameters.workOnMasterCodes = true; 130 131 //if (!isNull(sender)) { 132 // doWorkOnElements(sender, parameters); // IN WORKER.JS (DO THE WORK FOR THIS ITEM; SPECIFIC FOR GROUPCODE > REQUIRED) 133 //} 134 135 //redrawExistingBrackets(null); // IN CANVAS.JS 136 } 137 catch (ex) { 138 handleLogException({ sender: doRequiredElements, message: "Error", isWorkFlow: false }); 139 } 140 handleLogException({ sender: doRequiredElements, message: "Exiting", isWorkFlow: true }); 141} 142 143function doHideShowElements(sender, e) 144{ 145 // ------------------------------------------------- 146 // FUNCTION DESCRIPTION: DO HIDE/SHOW ELEMENT WORK 147 // ------------------------------------------------- 148 149 handleLogException({ sender: doHideShowElements, message: "Entering", isWorkFlow: true }); 150 try 151 { 152 var parameters = workOnElementParameters(); // IN WORKER.JS 153 // SET PARAMETER VALUES TO USE (GROUPCODES) 154 parameters.activationAttribute = _HideShowGroupCode; // IN GLOBALS.JS 155 parameters.workOnAttribute = _GroupCode; // IN GLOBALS.JS 156 parameters.workToDo = workTypes.HideShow; // IN WORKER.JS 157 parameters.collectionToUse = everyHideShowGCCollection; // IN GLOBALS.JS 158 parameters.e = e; 159 parameters.workOnGroupCodes = true; 160 parameters.workOnMasterCodes = false; 161 162 doWorkOnElements(sender, parameters); // IN WORKER.JS (DO THE WORK FOR THIS ITEM; SPECIFIC FOR GROUPCODE > HIDE OR SHOW) 163 164 // SET PARAMETER VALUES TO USE (MASTERCODES) 165 parameters.activationAttribute = _HideShowMasterCode; // IN GLOBALS.JS 166 parameters.workOnAttribute = _MasterCode; // IN GLOBALS.JS 167 parameters.workToDo = workTypes.HideShow; // IN WORKER.JS 168 parameters.collectionToUse = everyHideShowMCCollection; // IN GLOBALS.JS 169 parameters.e = e; 170 parameters.workOnGroupCodes = false; 171 parameters.workOnMasterCodes = true; 172 173 doWorkOnElements(sender, parameters); // IN WORKER.JS (DO THE WORK FOR THIS ITEM; SPECIFIC FOR MASTERCODE > HIDE OR SHOW) 174 175 //redrawExistingBrackets(null); // IN CANVAS.JS 176 } 177 catch (ex) 178 { 179 handleLogException({ sender: doHideShowElements, message: "Error", isWorkFlow: fal
179se }); 180 } 181 handleLogException({ sender: doHideShowElements, message: "Exiting", isWorkFlow: true }); 182} 183 184function doWorkOnOtherElements(sender, e) { 185 // --------------------------------------------------- 186 // FUNCTION DESCRIPTION: DO ELEMENT (OTHER BOX) WORK 187 // --------------------------------------------------- 188 189 handleLogException({ sender: doWorkOnOtherElements, message: "Entering", isWorkFlow: true }); 190 try 191 { 192 var parameters = workOnElementParameters(); // IN WORKER.JS 193 194 // SET PARAMETER VALUES TO USE (MASTERCODES) 195 parameters.activationAttribute = _OtherAttribute; // IN GLOBALS.JS 196 parameters.workOnAttribute = _OtherAttribute; // IN GLOBALS.JS 197 parameters.workToDo = workTypes.OtherControl; // IN WORKER.JS 198 parameters.collectionToUse = everyOtherCollection; // IN GLOBALS.JS 199 parameters.e = e; 200 parameters.workOnGroupCodes = true; 201 parameters.workOnMasterCodes = true; 202 203 doWorkOnElements(sender, parameters); // IN WORKER.JS (DO THE WORK FOR THIS ITEM; SPECIFIC FOR GROUPCODE > OTHER ELEMENT BOXES) 204 } 205 catch (ex) 206 { 207 handleLogException({ sender: doWorkOnOtherElements, message: "Error", isWorkFlow: false }); 208 } 209 handleLogException({ sender: doWorkOnOtherElements, message: "Exiting", isWorkFlow: true }); 210} 211 212function doOtherElements(sender, e) 213{ 214 // ------------------------------------------------------------ 215 // FUNCTION DESCRIPTION: DO ELEMENT (OTHER BOX CREATION) WORK 216 // ------------------------------------------------------------ 217 218 handleLogException({ sender: doOtherElements, message: "Entering", isWorkFlow: true }); 219 try 220 { 221 var _defaults = { createOther: true }; 222 var _settings = $.extend({}, _defaults, e); 223 224 // SET OTHER BOXES (DO ALL AT ONCE) 225 var elementsToWorkOn = $(sender).find('[isotherparent]'); 226 var treatSenderAsParent = false; 227 228 elementsToWorkOn = $(sender).closest('.FormRow').find('[isotherparent]:not([id*=hf])'); 229 230 elementsToWorkOn.each(function () { 231 try { 232 //$('.IsOther').remove(); 233 var thisOther = $(this); 234 var groupType = thisOther.attr('grouptype'); 235 var groupCode = thisOther.attr('groupcode'); 236 var masterCode = thisOther.attr('mastercode'); 237 var name = groupType + '-' + groupCode + '-' + masterCode; 238 var text = thisOther.text(); 239 var otherValue = ''; 240 var value = ''; 241 var tieToMasterCodes = "grouptype?='" + groupType + "' groupcode?='" + groupCode + "' mastercode?='" + masterCode + "'"; 242 243 var parentOther = thisOther.parent(); 244 treatSenderAsParent = false; 245 switch (true) { 246 case thisOther.hasClass('HTML5-RadioButton'): 247 treatSenderAsParent = true; 248 break; 249 case thisOther.hasClass('HTML5-CheckBox'): 250 treatSenderAsParent = true; 251 break; 252 } 253 254 if (treatSenderAsParent) { parentOther = thisOther; } 255 256 var wrapperParent = null; 257 var createOtherAt = thisOther 258 var addOtherBox = false; 259 var startHiddenOther = _settings.createOther; 260 261 var otherToWorkOn = null; 262 wrapperParent = parentOther.parent(); 263 // var wrapperParent = $(wrapperParent); 264 var exceptionCaseForParent = false; 265 266 switch (true) { 267 case parentOther.hasClass('HTML5-TextBox'): 268 break; 269 case parentOther.hasClass('HTML5-Range-Slider.Circular'): 270 break; 271 case parentOther.not('.Circular').hasClass('HTML5-Range-Slider'): 272 break; 273 case parentOther.hasClass('HTML5-RadioButton'): 274 addOtherBox = true; 275 createOtherAt = parentOther.parent().parent(); 276 wrapperParent = parentOther.parent().parent().parent(); 277 break; 278 case parentOther.hasClass('HTML5-CheckBox'): 279 addOtherBox = true; 280 createOtherAt = parentOther.parent().parent(); 281 wrapperParent = parentOther.parent().parent().parent(); 282 break; 283 case parentOther.hasClass('HTML5-DatePicker'): 284 break; 285 case parentOther.hasClass('HTML5-TimePicker'): 286 break; 287 case parentOther.hasClass('HTML5-DropDownList'): 288 addOtherBox = true; 289 createOtherAt = parentOther.parent().parent(); 290 wrapperParent = parentOther.parent().parent().parent(); 291 break; 292 case parentOther.hasClass('HTML5-Stars'): 293 break; 294 } 295 296 var otherTextBoxTemplate = ''; 297 otherTextBoxTemplate += '<div class="IsOther row col-lg-8 col-md-8 col-sm-12 col-xs-12" {5} {3}>'; 298 otherTextBoxTemplate += ' <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">'; 299 otherTextBoxTemplate += ' <div class="FormLabel Indicator-Label-Col">'; 300 otherTextBoxTemplate += ' <label id="lbl_{0}_Other" class="HTML5-Label {2}" {3}>{4}</label>'; 301 otherTextBoxTemplate += ' </div>';
302 otherTextBoxTemplate += ' </div>'; 303 otherTextBoxTemplate += ' <div class="FormControlCol Indicator-Control-Col col-lg-8 col-md-8 col-sm-8 col-xs-12">'; 304 otherTextBoxTemplate += ' <textarea id="tb_{0}_Other" class="FormControl HTML5-TextBox {2}" {3} placeholder="Please specify ...">{1}</textarea>'; 305 otherTextBoxTemplate += ' <input id="hfData_{0}_Other_Storage" controldatatype="Storage" type="hidden" value="{1}" {3} />'; 306 otherTextBoxTemplate += ' </div>'; 307 otherTextBoxTemplate += '</div>'; 308 309 // ONLY SHOW IF A VALUE IS ASSIGNED; CHECK IF WE DO NOT HAVE ONE 310 if (otherValue.toString().trim() == '') { 311 var selectedValue = $("[" + tieToMasterCodes.replace(/\?/g, "*").replace(/' /g, "'][") + "]"); 312 313 var checkOptions = false; 314 var checkValue = false; 315 316 switch (true) { 317 case parentOther.hasClass('HTML5-TextBox'): 318 checkValue = true; 319 break; 320 case parentOther.hasClass('HTML5-Range-Slider.Circular'): 321 checkValue = true; 322 break; 323 case parentOther.not('.Circular').hasClass('HTML5-Range-Slider'): 324 checkValue = true; 325 break; 326 case parentOther.hasClass('HTML5-RadioButton'): 327 addOtherBox = true; 328 createOtherAt = parentOther.parent(); 329 checkOptions = true; 330 exceptionCaseForParent = true; 331 console.log('----> RADIOBUTTON'); 332 break; 333 case parentOther.hasClass('HTML5-CheckBox'): 334 addOtherBox = true; 335 createOtherAt = parentOther.parent(); 336 checkOptions = true; 337 exceptionCaseForParent = true; 338 console.log('----> CHECKBOX'); 339 break; 340 case parentOther.hasClass('HTML5-DatePicker'): 341 checkValue = true; 342 break; 343 case parentOther.hasClass('HTML5-TimePicker'): 344 checkValue = true; 345 break; 346 case parentOther.hasClass('HTML5-DropDownList'): 347 addOtherBox = true; 348 createOtherAt = parentOther.parent(); 349 checkOptions = true; 350 exceptionCaseForParent = true; 351 console.log('----> DropDownList'); 352 break; 353 case parentOther.hasClass('HTML5-Stars'): 354 checkValue = true; 355 break; 356 } 357 358 switch (true) { 359 case (checkOptions): 360 var isChecked = false; 361 switch (true) { 362 case parentOther.hasClass('HTML5-RadioButton'): 363 isChecked = $(selectedValue).not('[id*=hf]').is(':checked'); 364 break; 365 case parentOther.hasClass('HTML5-CheckBox'): 366 isChecked = $(selectedValue).not('[id*=hf]').is(':checked'); 367 break; 368 case parentOther.hasClass('HTML5-DropDownList'): 369 isChecked = ($(parentOther).find('.HTML5-Options[isotherparent]:checked').length > 0); 370 break; 371 } 372 373 if (isChecked) { startHiddenOther = false; } 374 break; 375 case (checkValue): 376 if (otherValue.toString().trim() != '') { startHiddenOther = false; } 377 break; 378 } 379 } 380 381 try { 382 // debugger; 383 if (wrapperParent) { 384 var wrapperParentParent = $(wrapperParent.find("[" + tieToMasterCodes.replace(/\?/g, "*").replace(/' /g, "'][") + "]")[0]).parent(); 385 if (wrapperParentParent) { 386 var wrapperParentParentOther = wrapperParentParent.find('[isother]'); 387 // ONLY APPLIES FOR THE DROPDOWNLIST (CHOOSEN CONTROL) 388 if (wrapperParentParentOther.length == 0 && exceptionCaseForParent) { wrapperParentParentOther = wrapperParentParent.find('[othervalue]'); } 389 if (wrapperParentParentOther.length > 0) { 390 var wrapperParentParentOtherAttr = $(wrapperParentParentOther).attr('othervalue'); 391 if (wrapperParentParentOtherAttr) { 392 otherValue = wrapperParentParentOtherAttr.toString().trim(); 393 console.log(' -> otherValue = ' + otherValue); 394 } 395 } 396 } 397 } 398 } catch (ex) { console.log(ex.message); } 399 400 otherTextBoxTemplate = otherTextBoxTemplate.replace(/\{0}/g, name).replace(/\{1}/g, otherValue).replace(/\{2}/g, "") 401 .replace(/\{3}/g, tieToMasterCodes.replace(/\?/g, "")).replace(/\{4}/g, text + " <i class='fa fa-question Other-Indicator' aria-hidden='true' title='Please describe this other response.'></i>"); 402 403 if (startHiddenOther) { otherTextBoxTemplate = otherTextBoxTemplate.replace(/\{5}/g, 'style="display:none;"'); } 404 otherToWorkOn = $($(wrapperParent).find('.IsOther[' + tieToMasterCodes.replace(/\?/g, "*").replace(/' /g, "'][") + ']')[0]); 405 406 if ((otherToWorkOn && otherToWorkOn.length > 0)) 407 { 408 // for other text box, hide or add clienttest depending on if it is displayed 409 if (startHiddenOther) { otherToWorkOn.hide().find('textarea').removeAttr('clienttest'); } 410 else { otherToWorkOn.show().find('textarea').attr('clienttest', 'required'); } 411 } 412 413 if (addOtherBox) { 414 if (_settings.createOther) { 415 if ($('[id*=' + "hfData_{0}_Other_Storage".replace(/\{0}/g, name) + ']').length <= 0) { 416 createOtherAt.after(otherTextBoxTemplate); 417 418 // OTHER CONTROLS 419 createOtherAt.parent().find('.IsOther textarea').change(function () { $(this).closest('.FormRow').find('[controltype]').not('[id*=hfData]').change(); }); 420 } 421 } 422 } 423 424 425 } 426 catch (ex) { 427 handleLogException({ sender: doOtherElements, message: "Error", ex: ex, isWorkFlow: fal
427se }); 428 } 429 }); 430 } 431 catch (ex) 432 { 433 handleLogException({ sender: doWorkOnOtherElements, message: "Error", isWorkFlow: false }); 434 } 435 handleLogException({ sender: doOtherElements, message: "Exiting", isWorkFlow: true }); 436}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.