1var CommonFunction = function () { 2 var Editor = ""; 3 return { 4 ConvertDate: function (jsonDate) { 5 var dateString = jsonDate.substr(6); 6 var currentTime = new Date(parseInt(dateString)); 7 var month = currentTime.getMonth() + 1; 8 var day = currentTime.getDate(); 9 var year = currentTime.getFullYear(); 10 var date = day + "/" + month + "/" + year; 11 return date; 12 }, 13 onChangeAffiliationNumber: function (element) { 14 var flying_club_name = element.closest("form").find(".txtFlyingClubName"); 15 if (element.val().length > 0 && flying_club_name.val().length == 0) { 16 flying_club_name.addClass("error"); 17 return false; 18 } 19 flying_club_name.removeClass("error"); 20 return true 21 }, 22 showSession: function (message, callbackFunction) { 23 $.alert({ 24 title: '', 25 content: message, 26 boxWidth: '60%', 27 useBootstrap: false, 28 closeIcon: true, 29 type: 'blue', 30 typeAnimated: true, 31 theme: 'modern', 32 buttons: { 33 submit: { 34 text: "EXPORT CSV", 35 btnClass: 'btn exportCSV', 36 action: function () { 37 callbackFunction(); 38 } 39 } 40 } 41 }); 42 }, 43 44 showMessage: function (message) { 45 $.alert({ 46 title: 'Message Notice!', 47 content: message, 48 boxWidth: '20%', 49 useBootstrap: false, 50 closeIcon: true, 51 type: 'blue', 52 typeAnimated: true, 53 theme: 'modern', 54 buttons: { 55 tryAgain: { 56 text: 'Close', 57 btnClass: 'btn-blue', 58 action: function () { 59 } 60 } 61 } 62 }); 63 }, 64 showMessageWithCallBack: function (message, callback) { 65 //var showMessage = $.alert({ 66 // title: 'Message Notice!', 67 // content: message, 68 // boxWidth: '20%', 69 // useBootstrap: false, 70 // closeIcon: true, 71 // type: 'blue', 72 // typeAnimated: true, 73 // theme: 'modern', 74 // buttons: { 75 // tryAgain: { 76 // text: 'Close', 77 // btnClass: 'btn-blue', 78 // action: function () { 79 // callback(); 80 // } 81 // } 82 // } 83 //}); 84 85 //setTimeout(function () { 86 // callback(); 87 // showMessage.close(); 88 //}, 1000); 89 callback(); 90 var element = $(".data-saved-confirmation"); 91 element.html(message).fadeIn(1000); 92 setTimeout(function () { 93 element.fadeOut(1000); 94 }, 1000); 95 }, 96 showConfirm: function (message, callbackFunction, nameButtonSubmit, nameButtonCancel) { 97 if (nameButtonSubmit === undefined || nameButtonSubmit === "" || nameButtonSubmit === null) { 98 nameButtonSubmit = "Submit"; 99 }; 100 if (nameButtonCancel === undefined || nameButtonCancel === "" || nameButtonCancel === null) { 101 nameButtonCancel = "Close"; 102 } 103 $.alert({ 104 title: 'Message Confirm!', 105 content: message, 106 boxWidth: '20%', 107 useBootstrap: false, 108 closeIcon: true, 109 type: 'red', 110 typeAnimated: true, 111 theme: 'modern', 112 buttons: { 113 tryAgain: { 114 text: nameButtonCancel, 115 btnClass: 'btn-blue', 116 action: function () { 117 } 118 }, 119 submit: { 120 text: nameButtonSubmit, 121 btnClass: 'btn-red', 122 action: function () { 123 callbackFunction(); 124 } 125 } 126 } 127 }); 128 }, 129 showConfirmTextConfirmAndCancel: function (message, callbackFunction) { 130 $.alert({ 131 title: 'Message Confirm!', 132 content: message, 133 boxWidth: '20%', 134 useBootstrap: false, 135 closeIcon: true, 136 type: 'red', 137 typeAnimated: true, 138 theme: 'modern', 139 buttons: { 140 tryAgain: { 141 text: 'Cancel', 142 btnClass: 'btn-blue', 143 action: function () { 144 } 145 }, 146 submit: { 147 text: 'Confirm', 148 btnClass: 'btn-red', 149 action: function () { 150 callbackFunction(); 151 } 152 } 153 } 154 }); 155 }, 156 setCurrentLanguageToDllLanguage: function () { 157 $(".selectInputLanguage").val(GlobalUser.Language); 158 }, 159 initRichTextBox: function () { 160 var editor = new Simditor({ 161 textarea: $('.editor'), 162 toolbar: [ 163 'title',
164 'bold', 165 'italic', 166 'underline', 167 'strikethrough', 168 'fontScale', 169 'color', 170 'ol', 171 'ul', 172 'table', 173 'link', 174 'image', 175 'hr', 176 'indent', 177 'outdent', 178 'alignment' 179 ], 180 allowedTags: ['br', 'span', 'a', 'img', 'strong', 'i', 'strike', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'h1', 'h2', 'h3', 'h4', 'hr'] 181 }); 182 Editor = editor; 183 }, 184 returnEditor: function (listContext) { 185 if (listContext == null || listContext.length < 1) { 186 return false; 187 } 188 for (var i = 0; i < listContext.length; i++) { 189 var editor = new Simditor({ 190 textarea: listContext[i], 191 toolbar: [ 192 'title', 193 'bold', 194 'italic', 195 'underline', 196 'strikethrough', 197 'fontScale', 198 'color', 199 'ol', 200 'ul', 201 'table', 202 'link', 203 'image', 204 'hr', 205 'indent', 206 'outdent', 207 'alignment' 208 ], 209 allowedTags: ['br', 'span', 'a', 'img', 'strong', 'i', 'strike', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'h1', 'h2', 'h3', 'h4', 'hr'] 210 }); 211 } 212 return true; 213 }, 214 validatePhone: function (value) { 215 var filter = /^(?:0|\(?\+33\)?\s?|0033\s?)[1-79](?:[\.\-\s]?\d\d){4}$/; 216 if (filter.test(value)) { 217 return true; 218 } 219 else { 220 return false; 221 } 222 }, 223 validateHourTime: function (value) { 224 var filter = /^\d{2,}:(?:[0-5]\d)$/; 225 if (filter.test(value)) { 226 return true; 227 } 228 else { 229 return false; 230 } 231 }, 232 parseFiletoBase64: function (filesSelected, callBack) { 233 if (filesSelected.size > 0) { 234 var fileReader = new FileReader(); 235 fileReader.onload = (function (fileLoadedEvent) { 236 return function (e) { 237 var srcData = e.target.result; // <--- data: base64 238 callBack(srcData); 239 }; 240 })(filesSelected); 241 fileReader.readAsText(filesSelected); 242 } 243 }, 244 getCurrentDateTime: function () { 245 var currentDateTime = jQuery.now(); 246 return currentDateTime; 247 }, 248 copyComponentImage: function () { 249 var index = parseInt($("div.controlImage").length) + 1; 250 var element = "<div class='margin-top-25 controlImage controlComponent hideControl genControl genImage' data-componenttype='IMAGE'><div><label><strong>IMAGE</strong></label><div class='pull-left'><a class='hideControlComponent'><img class='iconNormal' src='../Content/img/remove.png' /></a></div></div><div class='margin-top-10'><div class='pull-left margin-right-small'><div class='inputfile-box'><input type='file' id='fileImage_" + index + "' class='inputfile fImage' onchange='QuestionModule.userFunctions.uploadFileByComponent($(this))'><label for='fileImage_" + index + "'><span id='file-name' class='file-box'><span class='file-name'></span></span><span class='file-button'><i class='fa fa-upload' aria-hidden='true'></i>Select File</span></label></div></div><div class='pull-left margin-right-small'></div><div class='pull-left margin-right-small margin-top-25'></div></div><div class='clearfix'></div><div><a target='_blank' class='linkViewFile' style='display: none'>
250Review file</a></div><div class='clearfix'></div>"; 251 return element; 252 }, 253 copyComponentAudio: function () { 254 var index = parseInt($("div.controlAudio").length) + 1; 255 var element = "<div class='margin-top-25 controlAudio controlComponent hideControl genControl genAudio' data-componenttype='AUDIO'><div><label><strong>AUDIO</strong></label><div class='pull-left'><a class='hideControlComponent'><img class='iconNormal' src='../Content/img/remove.png' /></a></div></div><div class='margin-top-10'><div class='pull-left margin-right-small'><div class='inputfile-box'><input type='file' id='fileAudio_" + index + "' class='inputfile fAudio' onchange='QuestionModule.userFunctions.uploadFileByComponent($(this))'><label for='fileAudio_" + index + "'><span id='file-name' class='file-box'><span class='file-name'></span></span><span class='file-button'><i class='fa fa-upload' aria-hidden='true'></i>Select File</span></label></div></div><div class='pull-left margin-right-small'><div><label><strong>Number of plays allowed</strong></label></div><div><input type='text' placeholder='2' maxlength='2' class='txtNumber txtNumberAllowed txtNumberAllowedAudio' style='width: 170px; height: 25px'/></div></div><div class='pull-left margin-right-small margin-top-25'><label><span class='pull-right'>Auto Play</span><input type='checkbox' class='chkAutoPlay chkAutoPlayAudio'></label></div></div><div class='clearfix'></div><div><a target='_blank' class='linkViewFile' style='display: none'>Review file</a></div><div class='clearfix'></div></div>"; 256 return element; 257 }, 258 copyComponentVideo: function () { 259 var index = parseInt($("div.controlVideo").length) + 1; 260 var element = "<div class='margin-top-25 controlVideo controlComponent hideControl genControl genVideo' data-componenttype='VIDEO'><div><label><strong>VIDEO</strong></label><div class='pull-left'><a class='hideControlComponent'><img class='iconNormal' src='../Content/img/remove.png' /></a></div></div><div class='margin-top-10'><div class='pull-left margin-right-small'><div class='inputfile-box'><input type='file' id='fileVideo_" + index + "' class='inputfile fVideo' onchange='QuestionModule.userFunctions.uploadFileByComponent($(this))'><label for='fileVideo_" + index + "'><span id='file-name' class='file-box'><span class='file-name'></span></span><span class='file-button'><i class='fa fa-upload' aria-hidden='true'></i>Select File</span></label></div></div><div class='pull-left margin-right-small'><div><label><strong>Number of plays allowed</strong></label></div><div><input type='text' placeholder='2' maxlength='2' class='txtNumber txtNumberAllowed txtNumberAllowedVideo' style='width: 170px; height: 25px'/></div></div><div class='pull-left margin-right-small margin-top-25'><label><span class='pull-right'>Auto Play</span><input type='checkbox' class='chkAutoPlay chkAutoPlayVideo'></label></div></div><div class='clearfix'></div><div><a target='_blank' class='linkViewFile' style='display: none'>Review file</a></div><div class='clearfix'></div>"; 261 return element; 262 }, 263 showLoading: function () { 264 $(".contentBody").addClass("overlay"); 265 $(".contentBody").attr('disabled', 'disabled'); 266 $(".contentBody").find('input, textarea, button, select').attr('disabled', 'disabled'); 267 $(".loader").show(); 268 269 }, 270 hideLoading: function () { 271 $(".contentBody").removeClass("overlay"); 272 $(".contentBody").removeAttr('disabled', 'disabled'); 273 $(".contentBody").find('input, textarea, button, select').removeAttr('disabled', 'disabled'); 274 $(".loader").hide(); 275 }, 276 defautDateFormat: function () { 277 return "dd/mm/yy"; 278 }, 279 convertDateToTimeStamp: function (dateStr) { 280 var dateArr = dateStr.split('/'); 281 var newDateStr = dateArr[2] + "/" + (parseInt(dateArr[1]) + 1) + "/" + dateArr[0]; 282 var date = new Date(newDateStr); 283 var timeStamp = date.getTime(); 284 return timeStamp; 285 }, 286 initCKEditor: function (listContextClassName) { 287 //if (listContextClassName == null || listContextClassName.length < 1) { 288 // return false; 289 //} 290 for (var i = 0; i < listContextClassName.length; i++) { 291 //var editor = CKEDITOR.instances[listContextClassName[i]];
292 //if (editor) { 293 // editor.destroy(true); 294 //} 295 setTimeout("CKEDITOR.replace('" + listContextClassName[i] + "',{ filebrowserBrowseUrl: '/ckfinder/ckfinder.html', filebrowserUploadUrl: '/ckfinder/connector?command=QuickUpload&type=Files' });", 555); 296 297 } 298 return true; 299 }, 300 destroyCkEditor: function (className) { 301 if (CKEDITOR.instances[className]) { 302 CKEDITOR.instances[className].destroy(); 303 } 304 }, 305 getValueCKEditor: function (className) { 306 var value = CKEDITOR.instances[className].getData(); 307 return value; 308 }, 309 setValueCKEditor: function (className, data) { 310 CKEDITOR.instances[className].setData(data); 311 }, 312 formatNameOnUrl: function (name) { 313 if (name == null || name === "") { 314 return ""; 315 } 316 //var nameFormat = name.toLowerCase().replace(" ","-").trim().replace(/[^a-zA-Z0-9 ]/g, "-"); 317 var nameFormat = name.toLowerCase().replace(/[' '`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '-'); 318 var lastedCharacter = nameFormat.substring(nameFormat.length - 1, nameFormat.length); 319 if (lastedCharacter === "-") { 320 nameFormat = nameFormat.substring(0, nameFormat.length - 1); 321 } 322 //var nameFormat = name.replace(/(?!\w|\s)./g, '').replace(/\s+/g, ' ').replace(/^(\s*)([\W\w]*)(\b\s*$)/g, '$2').replace(" ", "-"); 323 return nameFormat; 324 }, 325 getMaximumValue: function (context, value) { 326 if (value != null && value !== "") { 327 // var valueFormat = parseFloat(value.replace(Config.ConvertDecimalFrom, Config.ConvertDecimalTo)); 328 return value; 329 } 330 }, 331 getMaximumValueMarkRating: function (context) { 332 if (context == null || context === "" || context === "undefined") { 333 return 0; 334 } 335 var value = context.val(); 336 if (value === "" || value === "undefined") { 337 return 0; 338 } 339 var valueData = parseInt(context); 340 if (valueData < 0) { 341 return 0; 342 } 343 if (valueData > 6) { 344 return 6; 345 } 346 return 0; 347 }, 348 checkPressKeyRanking: function (e) { 349 if (e.which !== 8 && ((e.which < 48 || e.which > 54))) { 350 e.preventDefault(); 351 } 352 }, 353 checkNumberInput: function (e) { 354 if (e.which !== 8 && e.which !== 0 && ((e.which < 48 || e.which > 57) && e.which !== 99) && e.which !== 32) { 355 e.preventDefault(); 356 } 357 }, 358 validDate: function (strDate) { 359 var currVal = strDate; 360 if (currVal === '') 361 return false; 362 //Declare Regex 363 var rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/; 364 var dtArray = currVal.match(rxDatePattern); // is format OK? 365 if (dtArray == null) 366 return false; 367 //Checks for mm/dd/yyyy format. 368 var dtMonth = parseInt(dtArray[3]); 369 var dtDay = parseInt(dtArray[1]); 370 var dtYear = parseInt(dtArray[5]); 371 if (dtMonth < 1 || dtMonth > 12) 372 return false; 373 else if (dtDay < 1 || dtDay > 31) 374 return false; 375 else if ((dtMonth === 4 || dtMonth === 6 || dtMonth === 9 || dtMonth === 11) && dtDay === 31) 376 return false; 377 else if (dtMonth === 2) { 378 var isleap = (dtYear % 4 === 0 && (dtYear % 100 !== 0 || dtYear % 400 === 0)); 379 if (dtDay > 29 || (dtDay === 29 && !isleap)) 380 return false; 381 } 382 return true; 383 }, 384 validPriceInput: function () { 385 jQuery.validator.addMethod("validPrice", function (value, element) { 386 var pattern = /^\d{1,10}([\,\.]\d{2})?$/; 387 if (this.optional(element) || pattern.test(value)) { 388 return true; 389 } 390 return false; 391 }); 392 }, 393 isNullEmpty: function (param) { 394 if (param === null || param === undefined || param === "undefined") { 395 return true; 396 } 397 398 if ($.trim(param) === "") { 399 return true; 400 } 401 402 return false; 403 }, 404 parseBoolean: function (text) { 405 if (text == undefined || text == null || text.length == 0) { 406 return false; 407 } 408 409 if (text == "True" || text == "true" || text == true) { 410 return true; 411 } 412 413 return false; 414 }, 415 getRandomString: function () { 416 var rand = Math.random(); 417 return (rand + "").replace(".", "").replace("-", ""); 418 } 419 } 420}
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.