1/** 2 * 3 */ 4 5var Evrim = Evrim || new Object(); 6 7/** 8@param period: saniye cinsinden timeout 9@param doFunction: timeout handler function 10*/ 11function EvrimTimeoutHandler(period, doFunction) { 12 this.period = period; 13 this.doFunction = doFunction; 14 this.toHandler = null; 15 16 var refThis = this; 17 18 this.start = function() { 19 this.toHandler = window.setTimeout(this._doFunction, this.period*1000); 20 }; 21 22 this._doFunction = function() { 23 try { 24 refThis.doFunction(); 25 } catch(exc) { 26 console.log('Do function call error', exc); 27 } 28 29 refThis.toHandler = window.setTimeout(refThis._doFunction, refThis.period*1000); 30 }; 31 32 this.reset = function() { 33 if(this.toHandler) 34 window.clearTimeout(this.toHandler); 35 36 this.toHandler = window.setTimeout(this._doFunction, this.period*1000); 37 }; 38} 39 40Evrim.Commons = { 41 MIN_DATE : new Date(), 42 DATE_PATTERN : "DD.MM.YYYY", 43 44 //************* JQuery 3 escape functionality ***************** 45 rcssescape : /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, 46 fcssescape : function( ch, asCodePoint ) { 47 if ( asCodePoint ) { 48 49 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 50 if ( ch === "\0" ) { 51 return "\uFFFD"; 52 } 53 54 // Control characters and (dependent upon position) numbers get escaped as code points 55 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 56 } 57 58 // Other potentially-special ASCII characters get backslash-escaped 59 return "\\" + ch; 60 }, 61 62 escape : function( sel ) { 63 return (sel + "").replace( Evrim.Commons.rcssescape, Evrim.Commons.fcssescape ); 64 }, 65 // ********* JQuery 3 escape functionality END *************** 66 67 replaceAll : function(str, find, replace) { 68 return str.replace(new RegExp(find, 'g'), replace); 69 }, 70 71 validateEmail: function(email) { 72 //var re = /\S+@\S+\.\S+/; 73 var re = /^("(?:[!#-\[\]-\u{10FFFF}]|\\[\t -\u{10FFFF}])*"|[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*)@([!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*|\[[!-Z\^-\u{10FFFF}]*\])$/u; 74 return re.test(email); 75 }, 76 77 minDateCheck : function(minDateElement) { 78 var inputDate = new moment(minDateElement.value, this.DATE_PATTERN); 79 80 if(inputDate.isBefore(this.MIN_DATE)) { 81 this.showWarningMessage("BaÅlangıç tarihi kullanıcı baÅlangıç tarihinden("+this.MIN_DATE.format(this.DATE_PATTERN)+") küçük olamaz !"); 82 minDateElement.value = this.MIN_DATE.format(this.DATE_PATTERN); 83 } 84 }, 85 86 minDateCheckWithFormat : function(minDateElement, dateFormat) { 87 var inputDate = new moment(minDateElement.value, dateFormat); 88 89 if(inputDate.isBefore(this.MIN_DATE)) { 90 this.showWarningMessage("BaÅlangıç tarihi kullanıcı baÅlangıç tarihinden("+this.MIN_DATE.format(dateFormat)+") küçük olamaz !"); 91 minDateElement.value = this.MIN_DATE.format(dateFormat); 92 } 93 }, 94 95 minDateCheckWithMonthSlashYear : function(minDateElement) { 96 var dateFormat = 'dd.MM.yyyy'; 97 var minDate = this.MIN_DATE.toISOString().split('T')[0]; 98 var _minDate = minDate.split('-'); 99 var minDateElementValue = minDateElement.value; 100 var _minDateElementValue = minDateElementValue.split('/'); 101 var minDateValue = _minDate[2] + '.' + _minDateElementValue[0] + '.' + _minDateElementValue[1];
102 var inputDate = new moment(minDateValue, this.DATE_PATTERN); 103 if(inputDate.isBefore(this.MIN_DATE)) { 104 this.showWarningMessage("BaÅlangıç tarihi kullanıcı baÅlangıç tarihinden("+ _minDate[2] + '.' + _minDate[1] + '.' + _minDate[0] +") küçük olamaz !"); 105 minDateElement.value = _minDate[1] + '/' + _minDate[0]; 106 } 107 }, 108 109 showErrorMessage : function(message) { 110 this.showMessage("error", message,""); 111 }, 112 113 showWarningMessage : function(message) { 114 this.showMessage("warn", message,""); 115 }, 116 117 showInfoMessage : function(message) { 118 this.showMessage("info", message,""); 119 }, 120 121 showMessage : function(severity, summary, detail) { 122 PF('growl').renderMessage({ 123 "summary" : summary, 124 "detail" : detail, 125 "severity" : severity 126 }); 127 }, 128 129 omReportComplete : function(tableWidgetWar, xhr, status, args) { 130 PF(tableWidgetWar).clearFilters(); 131 132 if(args.errorMessage != null) { 133 this.showErrorMessage(args.errorMessage); 134 } 135 }, 136 137 isMobile: function() { 138 var bMobile = // will be true if running on a mobile device 139 navigator.userAgent.indexOf( "Mobile" ) !== -1 || 140 navigator.userAgent.indexOf( "iPhone" ) !== -1 || 141 navigator.userAgent.indexOf( "Android" ) !== -1 || 142 navigator.userAgent.indexOf( "Windows Phone" ) !== -1 ; 143 144 return bMobile; 145 }, 146 147 getBrowser : function() { 148 var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; 149 if(/trident/i.test(M[1])){ 150 tem=/\brv[ :]+(\d+)/g.exec(ua) || []; 151 return {name:'IE',version:(tem[1]||'')}; 152 } 153 if(M[1]==='Chrome'){ 154 tem=ua.match(/\bOPR\/(\d+)/) 155 if(tem!=null) {return {name:'Opera', version:tem[1]};} 156 } 157 if(M[1]==='Chrome'){ 158 tem=ua.match(/\bEdge\/(\d+)/) 159 if(tem!=null) {return {name:'Edge', version:tem[1]};} 160 } 161 M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; 162 if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);} 163 return { 164 name: M[0], 165 version: M[1] 166 }; 167 }, 168 169 openWindow : function(url, target) { 170 var popUpEvrak = window.open(url, target); 171 172 if (popUpEvrak === null || typeof (popUpEvrak) === undefined || popUpEvrak === 'NaN') { 173 return false; 174 } else { 175 return true; 176 } 177 }, 178 179 openWindowAndShowDialogIfFail : function(url, target) { 180 var opened = this.openWindow(url, target); 181 182 if(! opened) { 183 var browser = this.getBrowser(); 184 185 if(browser.name === 'Opera') { 186 PF('dlgOpera').show(); 187 } else if (browser.name === 'Edge') { 188 PF('dlgEdge').show(); 189 } else if (browser.name === 'IE') { 190 PF('dlgIE').show(); 191 } else if (browser.name === 'Firefox') { 192 PF('dlgFirefox').show(); 193 } else if (browser.name === 'Chrome') { 194 PF('dlgChrome').show(); 195 } else if (browser.name === 'Safari') { 196 PF('dlgSafari').show(); 197 } 198 } 199 }, 200 201 somFocus: function (item) { 202 var id = this.replaceAll(item.attr('id').replace('_focus','_label'), ':', '\\:'); 203 var panelId = this.replaceAll(item.attr('id').replace('_focus','_panel'), ':', '\\:'); 204 205 if(id && panelId) { 206 if($('#'+panelId).css('display') === 'none') { 207 $('#' + id).click(); 208 } 209 } 210 }, 211 212 disableScroll: function () { 213 $("body").addClass("modal-open"); 214 }, 215 216 letScroll: function () { 217 $("body").removeClass("modal-open"); 218 }, 219 220 _excelCreateSheet: function(workbook, data, callback) { 221 setTimeout(function() { 222 var worksheet = workbook.addWorksheet(data.name); 223 224 if(data && data.header) { 225 var cols = []; 226 227 for(var i=0;i<data.header.length;i++) { 228 var colInfo = data.header[i]; 229 // TODO: define format if exist 230 var col = { 231 header: colInfo.title, key: colInfo.title, hidden: !colInfo.visible 232 }; 233 234 cols.push(col); 235 } 236 237 worksheet.columns = cols; 238 239 var firstRow = worksheet.getRow(1); 240 firstRow.font = { name: 'New Times Roman', family: 4, size: 10, bold: true, color: {argb:'00000000'} }; 241 firstRow.alignment = { vertical: 'middle', horizontal: 'center'}; 242 firstRow.height = 20; 243 } 244 245 if(data && data.data && data.data.length) { 246 for(var i=0;i<data.data.length;i++) { 247 var orjRow = data.data[i]; 248 var row = []; 249 250 for(var hi=0;hi<data.header.length;hi++) { 251 var val = orjRow[data.header[hi].index]; 252 var colTip = data.header[hi].tip; 253 254 if(val && (colTip.indexOf("Date") >= 0 || colTip.indexOf("Timestamp") >= 0)) { 255 try { 256 val = moment(val).utc("Europe/Istanbul").toDate(); 257 } catch(exc) { 258 console.log('date convert error, index:'+ i + ', data:' + val); 259 } 260 } 261 else if(Number(val)){ 262 val=Number(val); 263 } 264 else if(val=="0"){ 265 val=Number(val); 266 } 267 else if(val && val.startsWith("https://webgumruk.com/archives/previewall/")){ 268 val = { text: 'ArÅiv İndir', hyperlink: val } 269 } 270 271 row.push(val); 272 } 273 274 worksheet.addRow(row); 275 } 276 } 277 278 callback(worksheet) 279 }, 0); 280 281 282 }, 283 284 _setDialogVisible: function(value) { 285 setTimeout(function() { 286 if(value) { 287 PF('statusDialog').show(); 288 } else { 289 PF('statusDialog').hide(); 290 } 291 }, value ? 1 : 100); 292 }, 293
294 csvExport: function(filename, jsonData) { 295 try { 296 var workbook = new ExcelJS.Workbook(); 297 298 workbook.creator = ''; 299 workbook.lastModifiedBy = ''; 300 workbook.created = new Date(); 301 workbook.modified = new Date(); 302 workbook.lastPrinted = new Date(); 303 304 if(jsonData) { 305 if(jsonData.length) { // multiple 306 307 for(var i=0;i<jsonData.length;i++) { 308 Evrim.Commons._excelCreateSheet(workbook, jsonData[i]); 309 } 310 } else { 311 Evrim.Commons._excelCreateSheet(workbook, jsonData, function(worksheet) { 312 313 var buff = workbook.csv.writeBuffer().then(function (data) { 314 315 var blob = new Blob([data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}); 316 console.log("blob data length: ",data.length); 317 filename=filename.replace('.xlsx','.csv'); 318 saveAs(blob, filename).onwriteend = function() { 319 Evrim.Commons._setDialogVisible(false); 320 }; 321 322 }); 323 }); 324 } 325 326 } else { 327 Evrim.Commons.showWarningMessage('Excel dosya bilgileri boÅ'); 328 console.error('Excel dosya bilgileri boÅ'); 329 Evrim.Commons._setDialogVisible(false); 330 } 331 } catch (exc) { 332 Evrim.Commons.showWarningMessage('Excel oluÅturulamadı'); 333 console.error('Excel oluÅturulamadı:', exc); 334 Evrim.Commons._setDialogVisible(false); 335 } 336 }, 337 338 excelExport: function(filename, jsonData) { 339 try { 340 var workbook = new ExcelJS.Workbook(); 341 342 workbook.creator = ''; 343 workbook.lastModifiedBy = ''; 344 workbook.created = new Date(); 345 workbook.modified = new Date(); 346 workbook.lastPrinted = new Date(); 347 348 if(jsonData) { 349 if(jsonData.length) { // multiple 350 351 for(var i=0;i<jsonData.length;i++) { 352 Evrim.Commons._excelCreateSheet(workbook, jsonData[i]); 353 } 354 } else { 355 Evrim.Commons._excelCreateSheet(workbook, jsonData, function(worksheet) { 356 357 var buff = workbook.xlsx.writeBuffer().then(function (data) { 358 359 var blob = new Blob([data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}); 360 console.log("blob data length: ",data.length); 361 saveAs(blob, filename).onwriteend = function() { 362 Evrim.Commons._setDialogVisible(false); 363 }; 364 365 }); 366 }); 367 } 368 369 } else { 370 Evrim.Commons.showWarningMessage('Excel dosya bilgileri boÅ'); 371 console.error('Excel dosya bilgileri boÅ'); 372 Evrim.Commons._setDialogVisible(false); 373 } 374 } catch (exc) { 375 Evrim.Commons.showWarningMessage('Excel oluÅturulamadı'); 376 console.error('Excel oluÅturulamadı:', exc); 377 Evrim.Commons._setDialogVisible(false); 378 } 379 }, 380 381 onExcelComplete: function(filename, xhr, status, args) { 382 try { 383 Evrim.Commons._setDialogVisible(true); 384 385 setTimeout(function() { 386 var jsonObj = JSON.parse(xhr.responseText); 387 388 if(jsonObj) {
389 Evrim.Commons.excelExport(filename , jsonObj); 390 } else { 391 Evrim.Commons.showWarningMessage('Excel oluÅturulamadı, veri boÅ'); 392 } 393 }, 500); 394 } catch (exc) { 395 Evrim.Commons.showWarningMessage('Excel oluÅturmada hata oldu'); 396 console.log('Excel oluÅturmada hata oldu', exc); 397 } 398 }, 399 400 onCsvComplete: function(filename, xhr, status, args) { 401 try { 402 Evrim.Commons._setDialogVisible(true); 403 404 setTimeout(function() { 405 var jsonObj = JSON.parse(xhr.responseText); 406 407 if(jsonObj) { 408 Evrim.Commons.csvExport(filename , jsonObj); 409 } else { 410 Evrim.Commons.showWarningMessage('CSV oluÅturulamadı, veri boÅ'); 411 } 412 }, 500); 413 } catch (exc) { 414 Evrim.Commons.showWarningMessage('CSV oluÅturmada hata oldu'); 415 console.log('CSV oluÅturmada hata oldu', exc); 416 } 417 } 418}
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.