Download Monitor - Version 4.6.1

Version Description

  • 26.09.2022 = Fixed: User reports user fetching and displaying was broken ( #1040 ). Fixed: Versions did not add the meta to the count ( #1041 ). Fixed: Increase meta count if user wants ( #1042 ) Fixed: Add ordering to tables ( #1044 ) Fixed: XHR loader animation and visibility ( #1045 )
Download this release

Release Info

Developer raldea89
Plugin Icon 128x128 Download Monitor
Version 4.6.1
Comparing to
See all releases

Code changes from version 4.6.0 to 4.6.1

assets/css/frontend.css CHANGED
@@ -305,16 +305,14 @@ data.dlm-hidden-info span {
305
  display: inline-block;
306
  visibility: visible;
307
  }
308
- html body a.download-button,
309
- html body a.download-link {
310
  position: relative;
311
  }
312
- html body a.download-button.dlm-download-started,
313
- html body a.download-link.dlm-download-started {
314
  text-decoration: none;
315
  }
316
- html body a.download-button.dlm-download-complete::after,
317
- html body a.download-link.dlm-download-complete::after {
318
  content: '✓';
319
  width: 20px;
320
  right: -30px;
@@ -326,60 +324,48 @@ html body a.download-link.dlm-download-complete::after {
326
  bottom: 0;
327
  left: auto;
328
  }
329
- html body a.download-button::before,
330
- html body a.download-link::before {
331
  content: '';
332
  position: absolute;
333
- height: 100%;
334
- z-index: -1;
335
  bottom: -2px;
336
- left: -5px;
337
  width: 0;
338
  background: red;
339
  transition: width 0.5s;
340
- top: 0;
341
- box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.8);
342
  border-radius: 5px;
343
  }
344
- html body a.download-button.download-10:before,
345
- html body a.download-link.download-10:before {
346
  width: 10%;
347
  }
348
- html body a.download-button.download-20:before,
349
- html body a.download-link.download-20:before {
350
  width: 20%;
351
  }
352
- html body a.download-button.download-30:before,
353
- html body a.download-link.download-30:before {
354
  width: 30%;
355
  }
356
- html body a.download-button.download-40:before,
357
- html body a.download-link.download-40:before {
358
  width: 40%;
359
  }
360
- html body a.download-button.download-50:before,
361
- html body a.download-link.download-50:before {
362
  width: 50%;
363
  }
364
- html body a.download-button.download-60:before,
365
- html body a.download-link.download-60:before {
366
  width: 60%;
367
  }
368
- html body a.download-button.download-70:before,
369
- html body a.download-link.download-70:before {
370
  width: 70%;
371
  }
372
- html body a.download-button.download-80:before,
373
- html body a.download-link.download-80:before {
374
  width: 80%;
375
  }
376
- html body a.download-button.download-90:before,
377
- html body a.download-link.download-90:before {
378
  width: 90%;
379
  }
380
- html body a.download-button.download-100:before,
381
- html body a.download-link.download-100:before {
382
- width: calc(100% + 10px);
383
  }
384
  a.download-button.dlm-download-complete::after {
385
  height: auto;
@@ -393,7 +379,74 @@ a.download-button > * {
393
  z-index: 2;
394
  position: relative;
395
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  .dlm-xhr-error {
397
  font-size: 12px;
398
  color: red;
399
  }
 
 
 
 
 
305
  display: inline-block;
306
  visibility: visible;
307
  }
308
+ /* Comment below lines for the new XHR loader so that we know where to rever*/
309
+ html body a.download-button {
310
  position: relative;
311
  }
312
+ html body a.download-button.dlm-download-started {
 
313
  text-decoration: none;
314
  }
315
+ html body a.download-button.dlm-download-complete::after {
 
316
  content: '✓';
317
  width: 20px;
318
  right: -30px;
324
  bottom: 0;
325
  left: auto;
326
  }
327
+ html body a.download-button::before {
 
328
  content: '';
329
  position: absolute;
330
+ height: 2px;
331
+ z-index: 3;
332
  bottom: -2px;
333
+ left: 0;
334
  width: 0;
335
  background: red;
336
  transition: width 0.5s;
337
+ box-shadow: 0px 0px 3px rgba(255, 0, 0, 0.8);
 
338
  border-radius: 5px;
339
  }
340
+ html body a.download-button.download-10:before {
 
341
  width: 10%;
342
  }
343
+ html body a.download-button.download-20:before {
 
344
  width: 20%;
345
  }
346
+ html body a.download-button.download-30:before {
 
347
  width: 30%;
348
  }
349
+ html body a.download-button.download-40:before {
 
350
  width: 40%;
351
  }
352
+ html body a.download-button.download-50:before {
 
353
  width: 50%;
354
  }
355
+ html body a.download-button.download-60:before {
 
356
  width: 60%;
357
  }
358
+ html body a.download-button.download-70:before {
 
359
  width: 70%;
360
  }
361
+ html body a.download-button.download-80:before {
 
362
  width: 80%;
363
  }
364
+ html body a.download-button.download-90:before {
 
365
  width: 90%;
366
  }
367
+ html body a.download-button.download-100:before {
368
+ width: 100%;
 
369
  }
370
  a.download-button.dlm-download-complete::after {
371
  height: auto;
379
  z-index: 2;
380
  position: relative;
381
  }
382
+ html body a.download-link {
383
+ position: relative;
384
+ }
385
+ html body a.download-link::before,
386
+ html body a.download-link::after {
387
+ content: '';
388
+ position: absolute;
389
+ right: -40px;
390
+ border-radius: 5px;
391
+ display: block;
392
+ background: red;
393
+ height: 10px;
394
+ width: 10px;
395
+ opacity: 0;
396
+ z-index: -1;
397
+ transform: translateY(-50%);
398
+ top: calc(50% - 5px);
399
+ }
400
+ html body a.download-link::before {
401
+ animation: lds-ellipsis1 0.6s infinite;
402
+ }
403
+ html body a.download-link::after {
404
+ animation: lds-ellipsis2 0.6s infinite;
405
+ }
406
+ html body a.download-link.dlm-download-started {
407
+ text-decoration: none;
408
+ }
409
+ html body a.download-link.dlm-download-started::before,
410
+ html body a.download-link.dlm-download-started::after {
411
+ opacity: 1;
412
+ z-index: 99;
413
+ }
414
+ html body a.download-link.dlm-download-complete::after {
415
+ content: '✓';
416
+ opacity: 1;
417
+ z-index: 99;
418
+ background: transparent;
419
+ animation: none;
420
+ transform: translateY(-50%);
421
+ top: calc(50% - 5px);
422
+ line-height: initial;
423
+ }
424
+ html body a.download-link.dlm-download-complete::before {
425
+ opacity: 0;
426
+ z-index: -1;
427
+ }
428
+ @keyframes lds-ellipsis1 {
429
+ 0% {
430
+ transform: scale(0);
431
+ }
432
+ 100% {
433
+ transform: scale(1);
434
+ }
435
+ }
436
+ @keyframes lds-ellipsis2 {
437
+ 0% {
438
+ transform: translate(0, 0);
439
+ }
440
+ 100% {
441
+ transform: translate(24px, 0);
442
+ }
443
+ }
444
  .dlm-xhr-error {
445
  font-size: 12px;
446
  color: red;
447
  }
448
+ .dlm-xhr-progress {
449
+ width: 75px;
450
+ display: inline-block;
451
+ position: relative;
452
+ }
assets/css/frontend.less CHANGED
@@ -266,9 +266,8 @@ data.dlm-hidden-info {
266
  }
267
  }
268
  }
269
-
270
- html body a.download-button,
271
- html body a.download-link {
272
  position: relative;
273
 
274
  &.dlm-download-started {
@@ -293,15 +292,14 @@ html body a.download-link {
293
  &::before {
294
  content: '';
295
  position: absolute;
296
- height: 100%;
297
- z-index:-1;
298
  bottom: -2px;
299
- left: -5px;
300
  width: 0;
301
  background: red;
302
  transition: width .5s;
303
- top:0;
304
- box-shadow:0px 0px 3px rgba(0, 0, 0, 0.8);
305
  border-radius:5px;
306
  }
307
 
@@ -342,7 +340,7 @@ html body a.download-link {
342
  }
343
 
344
  &.download-100:before {
345
- width: calc(100% + 10px);
346
  }
347
  }
348
 
@@ -366,7 +364,84 @@ a.download-button {
366
  position: relative;
367
  }
368
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
  .dlm-xhr-error {
370
  font-size:12px;
371
  color:red;
372
  }
 
 
 
 
 
 
266
  }
267
  }
268
  }
269
+ /* Comment below lines for the new XHR loader so that we know where to rever*/
270
+ html body a.download-button{
 
271
  position: relative;
272
 
273
  &.dlm-download-started {
292
  &::before {
293
  content: '';
294
  position: absolute;
295
+ height: 2px;
296
+ z-index:3;
297
  bottom: -2px;
298
+ left: 0;
299
  width: 0;
300
  background: red;
301
  transition: width .5s;
302
+ box-shadow:0px 0px 3px rgba(255, 0, 0, 0.8);
 
303
  border-radius:5px;
304
  }
305
 
340
  }
341
 
342
  &.download-100:before {
343
+ width:100%;
344
  }
345
  }
346
 
364
  position: relative;
365
  }
366
  }
367
+
368
+
369
+ html body a.download-link {
370
+ position: relative;
371
+
372
+ &::before, &::after {
373
+ content: '';
374
+ position: absolute;
375
+ right: -40px;
376
+ border-radius: 5px;
377
+ display: block;
378
+ background: red;
379
+ height: 10px;
380
+ width: 10px;
381
+ opacity:0;
382
+ z-index:-1;
383
+ transform: translateY(-50%);
384
+ top:calc( 50% - 5px );
385
+ }
386
+
387
+ &::before {
388
+ animation: lds-ellipsis1 0.6s infinite;
389
+ }
390
+
391
+ &::after {
392
+ animation: lds-ellipsis2 0.6s infinite;
393
+ }
394
+
395
+ &.dlm-download-started {
396
+ text-decoration: none;
397
+
398
+ &::before, &::after {
399
+ opacity:1;
400
+ z-index:99;
401
+ }
402
+ }
403
+
404
+ &.dlm-download-complete {
405
+ &::after {
406
+ content: '✓';
407
+ opacity:1;
408
+ z-index:99;
409
+ background:transparent;
410
+ animation:none;
411
+ transform: translateY(-50%);
412
+ top:calc( 50% - 5px );
413
+ line-height: initial;
414
+ }
415
+
416
+ &::before {
417
+ opacity:0;
418
+ z-index:-1;
419
+ }
420
+ }
421
+ }
422
+ @keyframes lds-ellipsis1 {
423
+ 0% {
424
+ transform: scale(0);
425
+ }
426
+ 100% {
427
+ transform: scale(1);
428
+ }
429
+ }
430
+ @keyframes lds-ellipsis2 {
431
+ 0% {
432
+ transform: translate(0, 0);
433
+ }
434
+ 100% {
435
+ transform: translate(24px, 0);
436
+ }
437
+ }
438
  .dlm-xhr-error {
439
  font-size:12px;
440
  color:red;
441
  }
442
+
443
+ .dlm-xhr-progress {
444
+ width:75px;
445
+ display:inline-block;
446
+ position:relative;
447
+ }
assets/css/frontend.min.css CHANGED
@@ -1 +1 @@
1
- .download-box{width:250px;border:1px solid #ccc;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-align:center;position:relative;margin:1em auto;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4)}.download-box h1{margin:.5em 0!important}.download-box img.wp-post-image{margin:0;padding:0;display:block;width:100%;-moz-border-radius:0;-webkit-border-radius:0;-moz-border-top-left-radius:3px;-moz-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;border-radius:0;border-top-left-radius:3px;border-top-right-radius:3px;box-shadow:inset 0 1px 0 rgba(255,255,255,.4)}.download-box .download-box-content{padding:0 1em 1em}.download-box .download-count{-moz-border-radius:1em;-webkit-border-radius:1em;border-radius:1em;color:#777;text-shadow:0 1px 0 rgba(255,255,255,.5);background:#ddd;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4);position:absolute;top:0;right:0;padding:.6em;width:auto;min-width:1em;font-size:1em;text-align:center;vertical-align:middle;line-height:1em;border:1px solid #bbb;margin:-.5em -.5em 0 0}.download-button{text-align:center;text-decoration:none!important;padding:.75em 1em;color:#fff;display:block;font-size:1.2em;line-height:1.5em;background-color:#09c;background-image:-webkit-linear-gradient(#009fd4,#09c,#0086b2);background-image:-moz-linear-gradient(#009fd4,#09c,#0086b2);-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-shadow:0 -1px 0 rgba(0,0,0,.5);box-shadow:0 2px 4px rgba(0,0,0,.3),inset 0 1px 0 rgba(255,255,255,.4);border:1px solid #0086b2;cursor:pointer}.download-button:hover{color:#fff;background-color:#09c;background-image:-webkit-linear-gradient(#09c,#0086b2);background-image:-moz-linear-gradient(#09c,#0086b2)}.download-button:visited{color:#fff;text-decoration:none}.download-button small{font-size:.8em;opacity:.8;display:block}.filetype-icon{padding-left:19px;background-repeat:no-repeat;background-position:left;background-image:url(../images/filetypes/document.png)}.filetype-pdf{background-image:url(../images/filetypes/document-pdf.png)}.filetype-aif,.filetype-aifc,.filetype-aiff,.filetype-au,.filetype-kar,.filetype-m3u,.filetype-m4r,.filetype-mid,.filetype-midi,.filetype-mp2,.filetype-mp3,.filetype-mpga,.filetype-ra,.filetype-ram,.filetype-rm,.filetype-rpm,.filetype-snd,.filetype-wav,.filetype-wave{background-image:url(../images/filetypes/document-music.png)}.filetype-avi,.filetype-divx,.filetype-mov,.filetype-movie,.filetype-mp4,.filetype-mpe,.filetype-mpeg,.filetype-mpg,.filetype-mxu,.filetype-qt,.filetype-wmv{background-image:url(../images/filetypes/document-film.png)}.filetype-7z,.filetype-gz,.filetype-rar,.filetype-sit,.filetype-tar,.filetype-zip{background-image:url(../images/filetypes/document-zipper.png)}.filetype-csv,.filetype-tsv,.filetype-xls,.filetype-xlsx{background-image:url(../images/filetypes/document-excel.png)}.filetype-doc,.filetype-docx{background-image:url(../images/filetypes/document-word-text.png)}.filetype-ai{background-image:url(../images/filetypes/document-illustrator.png)}.filetype-swf{background-image:url(../images/filetypes/document-flash-movie.png)}.filetype-bmp,.filetype-djv,.filetype-eps,.filetype-gif,.filetype-ief,.filetype-jpe,.filetype-jpeg,.filetype-jpg,.filetype-pbm,.filetype-pgm,.filetype-png,.filetype-pnm,.filetype-ppm,.filetype-ps,.filetype-ras,.filetype-rgb,.filetype-tif,.filetype-tiff,.filetype-wbmp,.filetype-xbm,.filetype-xpm,.filetype-xwd{background-image:url(../images/filetypes/document-image.png)}.filetype-psd{background-image:url(../images/filetypes/document-photoshop.png)}.filetype-ppt,.filetype-pptx{background-image:url(../images/filetypes/document-powerpoint.png)}.filetype-as,.filetype-css,.filetype-htaccess,.filetype-htm,.filetype-html,.filetype-js,.filetype-php,.filetype-sql,.filetype-xml,.filetype-xsl{background-image:url(../images/filetypes/document-code.png)}.filetype-rtf,.filetype-rtx{background-image:url(../images/filetypes/document-text-image.png)}.filetype-txt{background-image:url(../images/filetypes/document-text.png)}#content nav.download-monitor-pagination,nav.download-monitor-pagination{text-align:center}#content nav.download-monitor-pagination ul,nav.download-monitor-pagination ul{display:inline-block;white-space:nowrap;padding:0;clear:both;border:1px solid #eee;border-right:0;margin:1px}#content nav.download-monitor-pagination ul li,nav.download-monitor-pagination ul li{border-right:1px solid #eee;padding:0;margin:0;float:left;display:inline;overflow:hidden}#content nav.download-monitor-pagination ul li a,#content nav.download-monitor-pagination ul li span,nav.download-monitor-pagination ul li a,nav.download-monitor-pagination ul li span{margin:0;text-decoration:none;padding:0;line-height:1em;font-size:1em;font-weight:400;padding:.5em;min-width:1em;display:block}#content nav.download-monitor-pagination ul li a:focus,#content nav.download-monitor-pagination ul li a:hover,#content nav.download-monitor-pagination ul li span.current,nav.download-monitor-pagination ul li a:focus,nav.download-monitor-pagination ul li a:hover,nav.download-monitor-pagination ul li span.current{background:#eee;color:#888}.dlm_widget_downloads ul,.dlm_widget_downloads ul li{list-style:none}.dlm-hidden-info{visibility:hidden}@keyframes infinite-spinning{from{transform:rotate(0)}to{transform:rotate(360deg)}}data.dlm-hidden-info{position:relative}data.dlm-hidden-info span{font-weight:700;color:green}.dlm-hidden-info .progress.dlm-visible-spinner{display:inline-block;visibility:visible}.dlm-hidden-info .progress.box{width:100%}.dlm-hidden-info .progress.box span.download-done::after{content:'✓'}.dlm-hidden-info .progress.box .progress-inner{height:6px;top:0;width:0%;-webkit-transition:width .3s,opacity .3s;transition:width .3s,opacity .3s;position:absolute;left:0;background:#006080;animation:none}.dlm-hidden-info .progress .progress-inner{display:none;width:75px;position:relative;margin-left:15px}.dlm-hidden-info .progress .progress-inner .dlm-visible-spinner{display:inline-block;visibility:visible}html body a.download-button,html body a.download-link{position:relative}html body a.download-button.dlm-download-started,html body a.download-link.dlm-download-started{text-decoration:none}html body a.download-button.dlm-download-complete::after,html body a.download-link.dlm-download-complete::after{content:'✓';width:20px;right:-30px;position:absolute;height:100%;z-index:3;background:0 0;color:green;bottom:0;left:auto}html body a.download-button::before,html body a.download-link::before{content:'';position:absolute;height:100%;z-index:-1;bottom:-2px;left:-5px;width:0;background:red;transition:width .5s;top:0;box-shadow:0 0 3px rgba(0,0,0,.8);border-radius:5px}html body a.download-button.download-10:before,html body a.download-link.download-10:before{width:10%}html body a.download-button.download-20:before,html body a.download-link.download-20:before{width:20%}html body a.download-button.download-30:before,html body a.download-link.download-30:before{width:30%}html body a.download-button.download-40:before,html body a.download-link.download-40:before{width:40%}html body a.download-button.download-50:before,html body a.download-link.download-50:before{width:50%}html body a.download-button.download-60:before,html body a.download-link.download-60:before{width:60%}html body a.download-button.download-70:before,html body a.download-link.download-70:before{width:70%}html body a.download-button.download-80:before,html body a.download-link.download-80:before{width:80%}html body a.download-button.download-90:before,html body a.download-link.download-90:before{width:90%}html body a.download-button.download-100:before,html body a.download-link.download-100:before{width:calc(100% + 10px)}a.download-button.dlm-download-complete::after{height:auto;top:50%;transform:translateY(-50%)}a.download-button::before{z-index:0}a.download-button>*{z-index:2;position:relative}.dlm-xhr-error{font-size:12px;color:red}
1
+ .download-box{width:250px;border:1px solid #ccc;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-align:center;position:relative;margin:1em auto;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4)}.download-box h1{margin:.5em 0!important}.download-box img.wp-post-image{margin:0;padding:0;display:block;width:100%;-moz-border-radius:0;-webkit-border-radius:0;-moz-border-top-left-radius:3px;-moz-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;border-radius:0;border-top-left-radius:3px;border-top-right-radius:3px;box-shadow:inset 0 1px 0 rgba(255,255,255,.4)}.download-box .download-box-content{padding:0 1em 1em}.download-box .download-count{-moz-border-radius:1em;-webkit-border-radius:1em;border-radius:1em;color:#777;text-shadow:0 1px 0 rgba(255,255,255,.5);background:#ddd;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4);position:absolute;top:0;right:0;padding:.6em;width:auto;min-width:1em;font-size:1em;text-align:center;vertical-align:middle;line-height:1em;border:1px solid #bbb;margin:-.5em -.5em 0 0}.download-button{text-align:center;text-decoration:none!important;padding:.75em 1em;color:#fff;display:block;font-size:1.2em;line-height:1.5em;background-color:#09c;background-image:-webkit-linear-gradient(#009fd4,#09c,#0086b2);background-image:-moz-linear-gradient(#009fd4,#09c,#0086b2);-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-shadow:0 -1px 0 rgba(0,0,0,.5);box-shadow:0 2px 4px rgba(0,0,0,.3),inset 0 1px 0 rgba(255,255,255,.4);border:1px solid #0086b2;cursor:pointer}.download-button:hover{color:#fff;background-color:#09c;background-image:-webkit-linear-gradient(#09c,#0086b2);background-image:-moz-linear-gradient(#09c,#0086b2)}.download-button:visited{color:#fff;text-decoration:none}.download-button small{font-size:.8em;opacity:.8;display:block}.filetype-icon{padding-left:19px;background-repeat:no-repeat;background-position:left;background-image:url(../images/filetypes/document.png)}.filetype-pdf{background-image:url(../images/filetypes/document-pdf.png)}.filetype-aif,.filetype-aifc,.filetype-aiff,.filetype-au,.filetype-kar,.filetype-m3u,.filetype-m4r,.filetype-mid,.filetype-midi,.filetype-mp2,.filetype-mp3,.filetype-mpga,.filetype-ra,.filetype-ram,.filetype-rm,.filetype-rpm,.filetype-snd,.filetype-wav,.filetype-wave{background-image:url(../images/filetypes/document-music.png)}.filetype-avi,.filetype-divx,.filetype-mov,.filetype-movie,.filetype-mp4,.filetype-mpe,.filetype-mpeg,.filetype-mpg,.filetype-mxu,.filetype-qt,.filetype-wmv{background-image:url(../images/filetypes/document-film.png)}.filetype-7z,.filetype-gz,.filetype-rar,.filetype-sit,.filetype-tar,.filetype-zip{background-image:url(../images/filetypes/document-zipper.png)}.filetype-csv,.filetype-tsv,.filetype-xls,.filetype-xlsx{background-image:url(../images/filetypes/document-excel.png)}.filetype-doc,.filetype-docx{background-image:url(../images/filetypes/document-word-text.png)}.filetype-ai{background-image:url(../images/filetypes/document-illustrator.png)}.filetype-swf{background-image:url(../images/filetypes/document-flash-movie.png)}.filetype-bmp,.filetype-djv,.filetype-eps,.filetype-gif,.filetype-ief,.filetype-jpe,.filetype-jpeg,.filetype-jpg,.filetype-pbm,.filetype-pgm,.filetype-png,.filetype-pnm,.filetype-ppm,.filetype-ps,.filetype-ras,.filetype-rgb,.filetype-tif,.filetype-tiff,.filetype-wbmp,.filetype-xbm,.filetype-xpm,.filetype-xwd{background-image:url(../images/filetypes/document-image.png)}.filetype-psd{background-image:url(../images/filetypes/document-photoshop.png)}.filetype-ppt,.filetype-pptx{background-image:url(../images/filetypes/document-powerpoint.png)}.filetype-as,.filetype-css,.filetype-htaccess,.filetype-htm,.filetype-html,.filetype-js,.filetype-php,.filetype-sql,.filetype-xml,.filetype-xsl{background-image:url(../images/filetypes/document-code.png)}.filetype-rtf,.filetype-rtx{background-image:url(../images/filetypes/document-text-image.png)}.filetype-txt{background-image:url(../images/filetypes/document-text.png)}#content nav.download-monitor-pagination,nav.download-monitor-pagination{text-align:center}#content nav.download-monitor-pagination ul,nav.download-monitor-pagination ul{display:inline-block;white-space:nowrap;padding:0;clear:both;border:1px solid #eee;border-right:0;margin:1px}#content nav.download-monitor-pagination ul li,nav.download-monitor-pagination ul li{border-right:1px solid #eee;padding:0;margin:0;float:left;display:inline;overflow:hidden}#content nav.download-monitor-pagination ul li a,#content nav.download-monitor-pagination ul li span,nav.download-monitor-pagination ul li a,nav.download-monitor-pagination ul li span{margin:0;text-decoration:none;padding:0;line-height:1em;font-size:1em;font-weight:400;padding:.5em;min-width:1em;display:block}#content nav.download-monitor-pagination ul li a:focus,#content nav.download-monitor-pagination ul li a:hover,#content nav.download-monitor-pagination ul li span.current,nav.download-monitor-pagination ul li a:focus,nav.download-monitor-pagination ul li a:hover,nav.download-monitor-pagination ul li span.current{background:#eee;color:#888}.dlm_widget_downloads ul,.dlm_widget_downloads ul li{list-style:none}.dlm-hidden-info{visibility:hidden}@keyframes infinite-spinning{from{transform:rotate(0)}to{transform:rotate(360deg)}}data.dlm-hidden-info{position:relative}data.dlm-hidden-info span{font-weight:700;color:green}.dlm-hidden-info .progress.dlm-visible-spinner{display:inline-block;visibility:visible}.dlm-hidden-info .progress.box{width:100%}.dlm-hidden-info .progress.box span.download-done::after{content:'✓'}.dlm-hidden-info .progress.box .progress-inner{height:6px;top:0;width:0%;-webkit-transition:width .3s,opacity .3s;transition:width .3s,opacity .3s;position:absolute;left:0;background:#006080;animation:none}.dlm-hidden-info .progress .progress-inner{display:none;width:75px;position:relative;margin-left:15px}.dlm-hidden-info .progress .progress-inner .dlm-visible-spinner{display:inline-block;visibility:visible}html body a.download-button{position:relative}html body a.download-button.dlm-download-started{text-decoration:none}html body a.download-button.dlm-download-complete::after{content:'✓';width:20px;right:-30px;position:absolute;height:100%;z-index:3;background:0 0;color:green;bottom:0;left:auto}html body a.download-button::before{content:'';position:absolute;height:2px;z-index:3;bottom:-2px;left:0;width:0;background:red;transition:width .5s;box-shadow:0 0 3px rgba(255,0,0,.8);border-radius:5px}html body a.download-button.download-10:before{width:10%}html body a.download-button.download-20:before{width:20%}html body a.download-button.download-30:before{width:30%}html body a.download-button.download-40:before{width:40%}html body a.download-button.download-50:before{width:50%}html body a.download-button.download-60:before{width:60%}html body a.download-button.download-70:before{width:70%}html body a.download-button.download-80:before{width:80%}html body a.download-button.download-90:before{width:90%}html body a.download-button.download-100:before{width:100%}a.download-button.dlm-download-complete::after{height:auto;top:50%;transform:translateY(-50%)}a.download-button::before{z-index:0}a.download-button>*{z-index:2;position:relative}html body a.download-link{position:relative}html body a.download-link::after,html body a.download-link::before{content:'';position:absolute;right:-40px;border-radius:5px;display:block;background:red;height:10px;width:10px;opacity:0;z-index:-1;transform:translateY(-50%);top:calc(50% - 5px)}html body a.download-link::before{animation:lds-ellipsis1 .6s infinite}html body a.download-link::after{animation:lds-ellipsis2 .6s infinite}html body a.download-link.dlm-download-started{text-decoration:none}html body a.download-link.dlm-download-started::after,html body a.download-link.dlm-download-started::before{opacity:1;z-index:99}html body a.download-link.dlm-download-complete::after{content:'✓';opacity:1;z-index:99;background:0 0;animation:none;transform:translateY(-50%);top:calc(50% - 5px);line-height:initial}html body a.download-link.dlm-download-complete::before{opacity:0;z-index:-1}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis2{0%{transform:translate(0,0)}100%{transform:translate(24px,0)}}.dlm-xhr-error{font-size:12px;color:red}.dlm-xhr-progress{width:75px;display:inline-block;position:relative}
assets/js/dlm-progress.js DELETED
@@ -1,159 +0,0 @@
1
- // Function to attach events for the download buttons
2
- function attachButtonEvent() {
3
-
4
- // Create the classes that we will target
5
- let xhr_links = '';
6
- let $i = '';
7
- jQuery.each(dlmProgressVar.xhr_links.class, function ($key, $value) {
8
- xhr_links += $i + ' .' + $value;
9
- $i = ',';
10
-
11
- });
12
-
13
- //
14
- jQuery('html, body').on('click', xhr_links, function (e) {
15
- handleDownloadClick(this, e);
16
- });
17
- }
18
-
19
- // Attach the first event
20
- attachButtonEvent();
21
-
22
- function handleDownloadClick(obj, e) {
23
-
24
- e.stopPropagation();
25
- const button = obj;
26
- const href = button.getAttribute('href');
27
-
28
- let triggerObject = {
29
- button: obj,
30
- href: href,
31
- buttonObj: jQuery(obj),
32
- };
33
-
34
- // Show the progress bar after complete download also
35
- if (triggerObject.href.indexOf('blob:http') !== -1) {
36
-
37
- triggerObject.buttonObj.addClass('download-100');
38
- setTimeout(function () {
39
- triggerObject.buttonObj.removeClass('download-100');
40
- }, 1500);
41
-
42
- return;
43
- }
44
-
45
- e.preventDefault();
46
- retrieveBlob(triggerObject);
47
- }
48
-
49
- function retrieveBlob(triggerObject) {
50
- const {
51
- button,
52
- href,
53
- buttonObj,
54
- } = triggerObject;
55
-
56
- // This will hold the the file as a local object URL
57
- let _OBJECT_URL;
58
-
59
- const request = new XMLHttpRequest();
60
- const buttonClass = buttonObj.attr('class');
61
-
62
- button.setAttribute('href', '#');
63
- button.removeAttribute('download');
64
- button.setAttribute('disabled', 'disabled');
65
-
66
- // Trigger the `dlm_download_triggered` action
67
- jQuery(document).trigger('dlm_download_triggered', [this, button, _OBJECT_URL]);
68
-
69
- request.responseType = 'blob';
70
- request.onreadystatechange = function () {
71
- let {
72
- status,
73
- readyState,
74
- statusText
75
- } = request;
76
-
77
- if (request.readyState == 2 && request.status == 200) {
78
- // Download is being started
79
- //button.parent().append('<span>Download started</span>');
80
- }
81
-
82
- if (status == 404 && readyState == 2) {
83
- let p = document.createElement('p');
84
- p.innerHTML = statusText;
85
- button.parentNode.appendChild(p);
86
- }
87
-
88
- if (status == 401 && readyState == 2) {
89
- window.location.href = statusText;
90
- }
91
-
92
- if (status == 403 && readyState == 2) {
93
- let p = document.createElement('p');
94
- p.innerHTML = statusText;
95
- button.parentNode.appendChild(p);
96
- }
97
-
98
- if ('undefined' !== typeof request.getResponseHeader('dlm-redirect') && '' !== request.getResponseHeader('dlm-redirect') && null !== request.getResponseHeader('dlm-redirect')) {
99
- window.location.href = request.getResponseHeader('dlm-redirect');
100
- return;
101
- }
102
-
103
- if (status == 200 && readyState == 4) {
104
-
105
-
106
- let blob = request.response;
107
- let file_name = request.getResponseHeader('Content-Disposition').split('filename=')[1];
108
- file_name = file_name.replace(/\"/g, '').replace(';', '');
109
-
110
- _OBJECT_URL = URL.createObjectURL(blob);
111
-
112
- // Remove event listener
113
- button.removeEventListener('click', handleDownloadClick);
114
-
115
- // Set the href of the a.download-complete to the object URL
116
- button.setAttribute('href', _OBJECT_URL);
117
- // Set the download attribute of the a.download-complete to the file name
118
- button.setAttribute('download', `${file_name}`);
119
- // Trigger click on a.download-complete
120
- button.click();
121
- setTimeout(function () {
122
- buttonObj.removeClass().addClass(buttonClass + ' dlm-download-complete');
123
- }, 600);
124
- // Trigger the `dlm_download_complete` action
125
- jQuery(document).trigger('dlm_download_downloaded', [this, button, _OBJECT_URL]);
126
-
127
- attachButtonEvent();
128
-
129
- // Append the paragraph to the download-contaner
130
- // Trigger the `dlm_download_complete` action
131
- jQuery(document).trigger('dlm_download_complete', [this, button, _OBJECT_URL]);
132
-
133
- // Recommended : Revoke the object URL after some time to free up resources
134
- // There is no way to find out whether user finished downloading
135
- setTimeout(function () {
136
- window.URL.revokeObjectURL(_OBJECT_URL);
137
- }, 60 * 1000);
138
- }
139
- };
140
-
141
- request.addEventListener('progress', function (e) {
142
- let percent_complete = (e.loaded / e.total) * 100;
143
- // Force perfect complete to have 2 digits
144
- percent_complete = Math.round(percent_complete);
145
- let $class = 'download-' + Math.ceil(percent_complete / 10) * 10;
146
-
147
- // Show spinner
148
- buttonObj.removeClass().addClass(buttonClass + ' ' + $class);
149
- // Trigger the `dlm_download_progress` action
150
- jQuery(document).trigger('dlm_download_progress', [this, button, _OBJECT_URL, e, percent_complete]);
151
- });
152
-
153
- request.onerror = function () {
154
- console.log('** An error occurred during the transaction');
155
- };
156
- request.open('GET', href, true);
157
- request.setRequestHeader('dlm-request', 'dlm_XMLHttpRequest');
158
- request.send();
159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/dlm-progress.min.js DELETED
@@ -1 +0,0 @@
1
- function attachButtonEvent(){let o="",n="";jQuery.each(dlmProgressVar.xhr_links.class,function(e,t){o+=n+" ."+t,n=","}),jQuery("html, body").on("click",o,function(e){handleDownloadClick(this,e)})}function handleDownloadClick(e,t){t.stopPropagation();const o=e;let n={button:e,href:o.getAttribute("href"),buttonObj:jQuery(e)};if(-1!==n.href.indexOf("blob:http"))return n.buttonObj.addClass("download-100"),void setTimeout(function(){n.buttonObj.removeClass("download-100")},1500);t.preventDefault(),retrieveBlob(n)}function retrieveBlob(e){const{button:n,href:t,buttonObj:r}=e;let d;const a=new XMLHttpRequest,l=r.attr("class");n.setAttribute("href","#"),n.removeAttribute("download"),n.setAttribute("disabled","disabled"),jQuery(document).trigger("dlm_download_triggered",[this,n,d]),a.responseType="blob",a.onreadystatechange=function(){var{status:e,readyState:t,statusText:o}=a;if(2==a.readyState&&a.status,404==e&&2==t){let e=document.createElement("p");e.innerHTML=o,n.parentNode.appendChild(e)}if(401==e&&2==t&&(window.location.href=o),403==e&&2==t){let e=document.createElement("p");e.innerHTML=o,n.parentNode.appendChild(e)}if(void 0===a.getResponseHeader("dlm-redirect")||""===a.getResponseHeader("dlm-redirect")||null===a.getResponseHeader("dlm-redirect")){if(200==e&&4==t){t=a.response;let e=a.getResponseHeader("Content-Disposition").split("filename=")[1];e=e.replace(/\"/g,"").replace(";",""),d=URL.createObjectURL(t),n.removeEventListener("click",handleDownloadClick),n.setAttribute("href",d),n.setAttribute("download",""+e),n.click(),setTimeout(function(){r.removeClass().addClass(l+" dlm-download-complete")},600),jQuery(document).trigger("dlm_download_downloaded",[this,n,d]),attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,n,d]),setTimeout(function(){window.URL.revokeObjectURL(d)},6e4)}}else window.location.href=a.getResponseHeader("dlm-redirect")},a.addEventListener("progress",function(e){var t=e.loaded/e.total*100,t=Math.round(t),o="download-"+10*Math.ceil(t/10);r.removeClass().addClass(l+" "+o),jQuery(document).trigger("dlm_download_progress",[this,n,d,e,t])}),a.onerror=function(){console.log("** An error occurred during the transaction")},a.open("GET",t,!0),a.setRequestHeader("dlm-request","dlm_XMLHttpRequest"),a.send()}attachButtonEvent();
 
assets/js/dlm-xhr.js CHANGED
@@ -50,10 +50,10 @@ class DLM_XHR_Download {
50
  // Show the progress bar after complete download also
51
  if (triggerObject.href.indexOf('blob:http') !== -1) {
52
 
53
- triggerObject.buttonObj.addClass('download-100');
54
  setTimeout(function () {
55
  triggerObject.buttonObj.removeClass('download-100');
56
- }, 1500);
57
 
58
  return;
59
  }
@@ -75,9 +75,10 @@ class DLM_XHR_Download {
75
 
76
  // This will hold the file as a local object URL
77
  let _OBJECT_URL;
78
- const request = new XMLHttpRequest(),
79
- buttonClass = buttonObj.attr('class'),
80
- $setCookie = dlmXHR.prevent_duplicates;
 
81
 
82
  buttonObj.addClass('dlm-download-started');
83
  button.setAttribute('href', '#');
@@ -176,24 +177,30 @@ class DLM_XHR_Download {
176
  jQuery(document).trigger('dlm_download_complete', [this, button, buttonObj, _OBJECT_URL]);
177
  dlmXHRinstance.dlmLogDownload(responseHeaders['dlm-download-id'], responseHeaders['dlm-version-id'], 'completed', $setCookie);
178
  // Recommended : Revoke the object URL after some time to free up resources
 
 
 
 
179
  // There is no way to find out whether user finished downloading
180
  setTimeout(function () {
181
- window.URL.revokeObjectURL(_OBJECT_URL);
182
- button.removeAttribute('download');
183
- button.setAttribute('href', href);
184
- }, 60 * 1000);
185
  }
186
  };
187
 
188
  request.addEventListener('progress', function (e) {
189
  let percent_complete = (e.loaded / e.total) * 100;
190
  // Force perfect complete to have 2 digits
191
- percent_complete = Math.round(percent_complete);
192
- let $class = 'download-' + Math.ceil(percent_complete / 10) * 10;
193
-
194
- if ('100' !== percent_complete) {
195
- $class = $class + ' dlm-download-started';
 
 
 
196
  }
 
197
  // Show spinner
198
  buttonObj.removeClass().addClass(buttonClass + ' ' + $class);
199
  // Trigger the `dlm_download_progress` action
@@ -236,10 +243,11 @@ class DLM_XHR_Download {
236
  }
237
 
238
  dlmExternalDownload(headers, button, buttonObj, file_name, href) {
239
- const request = new XMLHttpRequest(),
240
- uri = headers['dlm-external-download'],
241
- buttonClass = buttonObj.attr('class');
242
- let _OBJECT_URL;
 
243
 
244
  buttonObj.addClass('dlm-download-started');
245
  button.setAttribute('href', '#');
@@ -272,7 +280,6 @@ class DLM_XHR_Download {
272
  buttonObj.append('<span class="dlm-xhr-error">Acces Denied to file.</span>');
273
  return;
274
  }
275
-
276
  if (status == 200 && readyState == 4) {
277
 
278
  let blob = request.response;
@@ -295,12 +302,13 @@ class DLM_XHR_Download {
295
  jQuery(document).trigger('dlm_download_complete', [this, button, buttonObj, _OBJECT_URL]);
296
  dlmXHRinstance.dlmLogDownload(headers['dlm-download-id'], headers['dlm-version-id'], 'completed', false);
297
  // Recommended : Revoke the object URL after some time to free up resources
 
 
 
298
  // There is no way to find out whether user finished downloading
299
  setTimeout(function () {
300
- window.URL.revokeObjectURL(_OBJECT_URL);
301
- button.removeAttribute('download');
302
- button.setAttribute('href', href);
303
- }, 60 * 1000);
304
  }
305
  };
306
 
50
  // Show the progress bar after complete download also
51
  if (triggerObject.href.indexOf('blob:http') !== -1) {
52
 
53
+ /*triggerObject.buttonObj.addClass('download-100');
54
  setTimeout(function () {
55
  triggerObject.buttonObj.removeClass('download-100');
56
+ }, 1500);*/
57
 
58
  return;
59
  }
75
 
76
  // This will hold the file as a local object URL
77
  let _OBJECT_URL;
78
+ const request = new XMLHttpRequest(),
79
+ $setCookie = dlmXHR.prevent_duplicates;
80
+ let buttonClass = buttonObj.attr('class');
81
+ buttonClass = buttonClass.replace('dlm-download-started', '').replace('dlm-download-completed','');
82
 
83
  buttonObj.addClass('dlm-download-started');
84
  button.setAttribute('href', '#');
177
  jQuery(document).trigger('dlm_download_complete', [this, button, buttonObj, _OBJECT_URL]);
178
  dlmXHRinstance.dlmLogDownload(responseHeaders['dlm-download-id'], responseHeaders['dlm-version-id'], 'completed', $setCookie);
179
  // Recommended : Revoke the object URL after some time to free up resources
180
+ window.URL.revokeObjectURL(_OBJECT_URL);
181
+ button.removeAttribute('download');
182
+ button.setAttribute('href', href);
183
+
184
  // There is no way to find out whether user finished downloading
185
  setTimeout(function () {
186
+ buttonObj.removeClass().addClass(buttonClass).find('span.dlm-xhr-progress').remove();
187
+ }, 4000);
 
 
188
  }
189
  };
190
 
191
  request.addEventListener('progress', function (e) {
192
  let percent_complete = (e.loaded / e.total) * 100;
193
  // Force perfect complete to have 2 digits
194
+ percent_complete = percent_complete.toFixed(2);
195
+ let $class = 'dlm-download-started';
196
+ buttonObj.find('span.dlm-xhr-progress').remove();
197
+ // Comment below lines for the new XHR loader so that we know where to rever
198
+ $class = $class + ' download-' + Math.ceil(percent_complete / 10) * 10;
199
+
200
+ if (Infinity != percent_complete) {
201
+ buttonObj.append('<span class="dlm-xhr-progress">&nbsp;' + percent_complete + '%</span>');
202
  }
203
+
204
  // Show spinner
205
  buttonObj.removeClass().addClass(buttonClass + ' ' + $class);
206
  // Trigger the `dlm_download_progress` action
243
  }
244
 
245
  dlmExternalDownload(headers, button, buttonObj, file_name, href) {
246
+ const request = new XMLHttpRequest(),
247
+ uri = headers['dlm-external-download'];
248
+ let buttonClass = buttonObj.attr('class'),
249
+ _OBJECT_URL;
250
+ buttonClass = buttonClass.replace('dlm-download-started', '').replace('dlm-download-completed','');
251
 
252
  buttonObj.addClass('dlm-download-started');
253
  button.setAttribute('href', '#');
280
  buttonObj.append('<span class="dlm-xhr-error">Acces Denied to file.</span>');
281
  return;
282
  }
 
283
  if (status == 200 && readyState == 4) {
284
 
285
  let blob = request.response;
302
  jQuery(document).trigger('dlm_download_complete', [this, button, buttonObj, _OBJECT_URL]);
303
  dlmXHRinstance.dlmLogDownload(headers['dlm-download-id'], headers['dlm-version-id'], 'completed', false);
304
  // Recommended : Revoke the object URL after some time to free up resources
305
+ window.URL.revokeObjectURL(_OBJECT_URL);
306
+ button.removeAttribute('download');
307
+ button.setAttribute('href', href);
308
  // There is no way to find out whether user finished downloading
309
  setTimeout(function () {
310
+ buttonObj.removeClass().addClass(buttonClass).find('span.dlm-xhr-progress').remove();
311
+ }, 1000);
 
 
312
  }
313
  };
314
 
assets/js/dlm-xhr.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){new DLM_XHR_Download});class DLM_XHR_Download{constructor(){(dlmXHRinstance=this).init()}init(){dlmXHRinstance.attachButtonEvent()}attachButtonEvent(){let d="",o="";jQuery.each(dlmXHR.xhr_links.class,function(e,t){-1<t.indexOf("[class")||-1<t.indexOf("[id")?d+=o+" "+t:d+=o+" ."+t,o=","}),jQuery("html, body").on("click",d,function(e){dlmXHRinstance.handleDownloadClick(this,e)})}handleDownloadClick(e,t){t.stopPropagation();var d=e.getAttribute("href");let o={button:e,href:d,buttonObj:jQuery(e)};if(-1!==o.href.indexOf("blob:http"))return o.buttonObj.addClass("download-100"),void setTimeout(function(){o.buttonObj.removeClass("download-100")},1500);"#"!==o.href&&(t.preventDefault(),dlmXHRinstance.retrieveBlob(o))}retrieveBlob(e){let{button:l,href:r,buttonObj:a}=e,i;const s=new XMLHttpRequest,c=a.attr("class"),m=dlmXHR.prevent_duplicates;a.addClass("dlm-download-started"),l.setAttribute("href","#"),l.removeAttribute("download"),l.setAttribute("disabled","disabled");e=0<r.indexOf("?")?r+"&nonce="+dlmXHR.nonce:r+"?nonce="+dlmXHR.nonce;jQuery(document).trigger("dlm_download_triggered",[this,l,a,i]),s.responseType="blob",s.onreadystatechange=function(){var{status:e,readyState:t,statusText:d}=s;let o=s.getAllResponseHeaders().split("\r\n").reduce((e,t)=>{var[t,d]=t.split(": ");return e[t]=d,e},{});if(void 0!==o["dlm-no-waypoints"]&&(s.abort(),window.location.href=r),void 0!==o["dlm-external-download"])return s.abort(),n=o["dlm-file-name"].replace(/\"/g,"").replace(";",""),void dlmXHRinstance.dlmExternalDownload(o,l,a,n,r);if(2==s.readyState&&void 0!==o["dlm-error"]&&""!==o["dlm-error"]&&null!==o["dlm-error"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"failed",!1),s.abort(),void a.append('<span class="dlm-xhr-error">'+o["dlm-error"]+"</span>");if(2==s.readyState&&void 0!==o["dlm-redirect"]&&""!==o["dlm-redirect"]&&null!==o["dlm-redirect"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"redirected",!1,o["dlm-redirect"],o["dlm-no-access"]),void s.abort();if(2==s.readyState&&s.status,404==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(401==e&&2==t&&(window.location.href=d),403==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(200==e&&4==t){var n=s.response;let e=o["content-disposition"].split("filename=")[1];e=e.replace(/\"/g,"").replace(";",""),i=URL.createObjectURL(n),l.removeEventListener("click",dlmXHRinstance.handleDownloadClick),l.setAttribute("download",""+e),l.setAttribute("href",i),l.click(),a.removeClass().addClass(c+" dlm-download-complete"),dlmXHRinstance.attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,l,a,i]),dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"completed",m),setTimeout(function(){window.URL.revokeObjectURL(i),l.removeAttribute("download"),l.setAttribute("href",r)},6e4)}},s.addEventListener("progress",function(e){var t=e.loaded/e.total*100,t=Math.round(t);let d="download-"+10*Math.ceil(t/10);"100"!==t&&(d+=" dlm-download-started"),a.removeClass().addClass(c+" "+d),jQuery(document).trigger("dlm_download_progress",[this,l,a,i,e,t])}),s.onerror=function(){console.log("** An error occurred during the transaction")},s.open("GET",e,!0),s.setRequestHeader("dlm-xhr-request","dlm_XMLHttpRequest"),s.send()}dlmLogDownload(e,t,d,o,n=null,l=null){null!==l?window.location.href=n:(l={download_id:e,version_id:t,status:d,cookie:o,currentURL:window.location.href,action:"log_dlm_xhr_download",nonce:dlmXHR.nonce},jQuery.post(dlmXHR.ajaxUrl,l,function(e){null!==n&&(window.location.href=n)}))}dlmExternalDownload(d,o,n,l,r){const a=new XMLHttpRequest,e=d["dlm-external-download"],i=n.attr("class");let s;n.addClass("dlm-download-started"),o.setAttribute("href","#"),o.removeAttribute("download"),o.setAttribute("disabled","disabled"),jQuery(document).trigger("dlm_download_triggered",[this,o,n,void 0]),a.responseType="blob",a.onreadystatechange=function(){var{status:e,readyState:t}=a;a.getAllResponseHeaders().split("\r\n").reduce((e,t)=>{var[t,d]=t.split(": ");return e[t]=d,e},{});if(403===e)return dlmXHRinstance.dlmLogDownload(d["dlm-download-id"],d["dlm-version-id"],"failed",!1),a.abort(),void n.append('<span class="dlm-xhr-error">Acces Denied to file.</span>');200==e&&4==t&&(e=a.response,s=URL.createObjectURL(e),o.removeEventListener("click",dlmXHRinstance.handleDownloadClick),o.setAttribute("download",""+l),o.setAttribute("href",s),o.click(),n.removeClass().addClass(i+" dlm-download-complete"),dlmXHRinstance.attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,o,n,s]),dlmXHRinstance.dlmLogDownload(d["dlm-download-id"],d["dlm-version-id"],"completed",!1),setTimeout(function(){window.URL.revokeObjectURL(s),o.removeAttribute("download"),o.setAttribute("href",r)},6e4))},a.onerror=function(){console.log("** An error occurred during the transaction")},a.open("GET",e,!0),a.setRequestHeader("dlm-xhr-request","dlm_XMLHttpRequest"),a.send()}}
1
+ jQuery(function(e){new DLM_XHR_Download});class DLM_XHR_Download{constructor(){(dlmXHRinstance=this).init()}init(){dlmXHRinstance.attachButtonEvent()}attachButtonEvent(){let d="",o="";jQuery.each(dlmXHR.xhr_links.class,function(e,t){-1<t.indexOf("[class")||-1<t.indexOf("[id")?d+=o+" "+t:d+=o+" ."+t,o=","}),jQuery("html, body").on("click",d,function(e){dlmXHRinstance.handleDownloadClick(this,e)})}handleDownloadClick(e,t){t.stopPropagation();var d=e.getAttribute("href");let o={button:e,href:d,buttonObj:jQuery(e)};-1===o.href.indexOf("blob:http")&&"#"!==o.href&&(t.preventDefault(),dlmXHRinstance.retrieveBlob(o))}retrieveBlob(e){let{button:l,href:r,buttonObj:a}=e,s;const i=new XMLHttpRequest,c=dlmXHR.prevent_duplicates;let m=a.attr("class");m=m.replace("dlm-download-started","").replace("dlm-download-completed",""),a.addClass("dlm-download-started"),l.setAttribute("href","#"),l.removeAttribute("download"),l.setAttribute("disabled","disabled");e=0<r.indexOf("?")?r+"&nonce="+dlmXHR.nonce:r+"?nonce="+dlmXHR.nonce;jQuery(document).trigger("dlm_download_triggered",[this,l,a,s]),i.responseType="blob",i.onreadystatechange=function(){var{status:e,readyState:t,statusText:d}=i;let o=i.getAllResponseHeaders().split("\r\n").reduce((e,t)=>{var[t,d]=t.split(": ");return e[t]=d,e},{});if(void 0!==o["dlm-no-waypoints"]&&(i.abort(),window.location.href=r),void 0!==o["dlm-external-download"])return i.abort(),n=o["dlm-file-name"].replace(/\"/g,"").replace(";",""),void dlmXHRinstance.dlmExternalDownload(o,l,a,n,r);if(2==i.readyState&&void 0!==o["dlm-error"]&&""!==o["dlm-error"]&&null!==o["dlm-error"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"failed",!1),i.abort(),void a.append('<span class="dlm-xhr-error">'+o["dlm-error"]+"</span>");if(2==i.readyState&&void 0!==o["dlm-redirect"]&&""!==o["dlm-redirect"]&&null!==o["dlm-redirect"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"redirected",!1,o["dlm-redirect"],o["dlm-no-access"]),void i.abort();if(2==i.readyState&&i.status,404==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(401==e&&2==t&&(window.location.href=d),403==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(200==e&&4==t){var n=i.response;let e=o["content-disposition"].split("filename=")[1];e=e.replace(/\"/g,"").replace(";",""),s=URL.createObjectURL(n),l.removeEventListener("click",dlmXHRinstance.handleDownloadClick),l.setAttribute("download",""+e),l.setAttribute("href",s),l.click(),a.removeClass().addClass(m+" dlm-download-complete"),dlmXHRinstance.attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,l,a,s]),dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"completed",c),window.URL.revokeObjectURL(s),l.removeAttribute("download"),l.setAttribute("href",r),setTimeout(function(){a.removeClass().addClass(m).find("span.dlm-xhr-progress").remove()},4e3)}},i.addEventListener("progress",function(e){let t=e.loaded/e.total*100;t=t.toFixed(2);var d;a.find("span.dlm-xhr-progress").remove(),d="dlm-download-started download-"+10*Math.ceil(t/10),1/0!=t&&a.append('<span class="dlm-xhr-progress">&nbsp;'+t+"%</span>"),a.removeClass().addClass(m+" "+d),jQuery(document).trigger("dlm_download_progress",[this,l,a,s,e,t])}),i.onerror=function(){console.log("** An error occurred during the transaction")},i.open("GET",e,!0),i.setRequestHeader("dlm-xhr-request","dlm_XMLHttpRequest"),i.send()}dlmLogDownload(e,t,d,o,n=null,l=null){null!==l?window.location.href=n:(l={download_id:e,version_id:t,status:d,cookie:o,currentURL:window.location.href,action:"log_dlm_xhr_download",nonce:dlmXHR.nonce},jQuery.post(dlmXHR.ajaxUrl,l,function(e){null!==n&&(window.location.href=n)}))}dlmExternalDownload(d,o,n,l,r){const a=new XMLHttpRequest,e=d["dlm-external-download"];let s=n.attr("class"),i;s=s.replace("dlm-download-started","").replace("dlm-download-completed",""),n.addClass("dlm-download-started"),o.setAttribute("href","#"),o.removeAttribute("download"),o.setAttribute("disabled","disabled"),jQuery(document).trigger("dlm_download_triggered",[this,o,n,void 0]),a.responseType="blob",a.onreadystatechange=function(){var{status:e,readyState:t}=a;a.getAllResponseHeaders().split("\r\n").reduce((e,t)=>{var[t,d]=t.split(": ");return e[t]=d,e},{});if(403===e)return dlmXHRinstance.dlmLogDownload(d["dlm-download-id"],d["dlm-version-id"],"failed",!1),a.abort(),void n.append('<span class="dlm-xhr-error">Acces Denied to file.</span>');200==e&&4==t&&(e=a.response,i=URL.createObjectURL(e),o.removeEventListener("click",dlmXHRinstance.handleDownloadClick),o.setAttribute("download",""+l),o.setAttribute("href",i),o.click(),n.removeClass().addClass(s+" dlm-download-complete"),dlmXHRinstance.attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,o,n,i]),dlmXHRinstance.dlmLogDownload(d["dlm-download-id"],d["dlm-version-id"],"completed",!1),window.URL.revokeObjectURL(i),o.removeAttribute("download"),o.setAttribute("href",r),setTimeout(function(){n.removeClass().addClass(s).find("span.dlm-xhr-progress").remove()},1e3))},a.onerror=function(){console.log("** An error occurred during the transaction")},a.open("GET",e,!0),a.setRequestHeader("dlm-xhr-request","dlm_XMLHttpRequest"),a.send()}}
assets/js/reports/reports.js CHANGED
@@ -217,8 +217,7 @@ class DLM_Reports {
217
  dlmReportsInstance.fetchUsersReportsData();
218
  // Trigger action so others can hook into this
219
  jQuery(document).trigger('dlm_reports_init', [dlmReportsInstance]);
220
-
221
- //dlmReportsInstance.phpReportsNavigation();
222
  }
223
 
224
  /**
@@ -250,7 +249,6 @@ class DLM_Reports {
250
  if (0 === Object.values(dlmReportsInstance.dlmUsersStats).length) {
251
  return;
252
  }
253
-
254
  dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date, dlmReportsInstance.dates.downloads.end_date);
255
  dlmReportsInstance.handleUserDownloads();
256
  dlmReportsInstance.filterDownloads();
@@ -907,9 +905,7 @@ class DLM_Reports {
907
  });
908
  });
909
 
910
- dlmReportsInstance.mostDownloaded = Object.values(mostDownloaded).sort((a, b) => {
911
- return a.downloads - b.downloads;
912
- }).reverse();
913
 
914
  dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads);
915
  dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads / parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0));
@@ -1527,7 +1523,6 @@ class DLM_Reports {
1527
  let endTimestamp = new Date(endDate);
1528
  endTimestamp.setDate(endTimestamp.getDate() + 1);
1529
  endTimestamp = endTimestamp.getTime();
1530
-
1531
  dlmReportsInstance.userDownloads = dlmReportsInstance.userDownloads.filter((element, index) => {
1532
  let currentElement = dlmReportsInstance.createDateElement(new Date(element.download_date));
1533
  currentElement = new Date(currentElement).getTime();
@@ -1535,6 +1530,7 @@ class DLM_Reports {
1535
  });
1536
 
1537
  dlmReportsInstance.createUserRelatedData();
 
1538
  dlmReportsInstance.setMostActiveUser();
1539
  dlmReportsInstance.setLoggedOutDownloads();
1540
  dlmReportsInstance.setLoggedInDownloads();
@@ -1579,12 +1575,18 @@ class DLM_Reports {
1579
  if (!user_id || '0' === user_id) {
1580
  return null;
1581
  }
1582
-
1583
  let $user = Object.values(dlmReportsInstance.dlmUsersStats.users).filter(user => {
1584
- return parseInt(user_id) === parseInt(user.ID);
1585
  });
1586
 
1587
- return ($user.length > 0) ? $user[0] : null;
 
 
 
 
 
 
 
1588
  }
1589
 
1590
  /**
@@ -1692,7 +1694,7 @@ class DLM_Reports {
1692
 
1693
  let itemObject = {
1694
  key : i,
1695
- user : ('0' !== dataResponse[i].user_id && 'undefined' !== typeof user && null !== user) ? user['user_nicename'] : '--',
1696
  ip : dataResponse[i].user_ip,
1697
  role : (null !== user && null !== user.role ? user.role : '--'),
1698
  download : ('undefined' !== typeof download) ? download.title : '--',
@@ -1727,8 +1729,8 @@ class DLM_Reports {
1727
  * Filter our downloads
1728
  */
1729
  filterDownloads() {
1730
- dlmReportsInstance.tempDownloads = JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads));
1731
 
 
1732
  if (!dlmReportsInstance.currentFilters.length) {
1733
  dlmReportsInstance.setUserDownloads();
1734
  return;
@@ -1952,7 +1954,7 @@ class DLM_Reports {
1952
  getDownloadCPT($id) {
1953
  let download = dlmReportsInstance.mostDownloaded.filter((item) => {
1954
  return item.id === $id;
1955
- },0)[0];
1956
 
1957
  jQuery(document).trigger('dlm_download_cpt', [dlmReportsInstance, download]);
1958
 
@@ -1975,4 +1977,55 @@ class DLM_Reports {
1975
  stopSpinner(target) {
1976
  target.find('.dlm-reports-spinner').remove();
1977
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1978
  }
217
  dlmReportsInstance.fetchUsersReportsData();
218
  // Trigger action so others can hook into this
219
  jQuery(document).trigger('dlm_reports_init', [dlmReportsInstance]);
220
+ dlmReportsInstance.eventsFunctions();
 
221
  }
222
 
223
  /**
249
  if (0 === Object.values(dlmReportsInstance.dlmUsersStats).length) {
250
  return;
251
  }
 
252
  dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date, dlmReportsInstance.dates.downloads.end_date);
253
  dlmReportsInstance.handleUserDownloads();
254
  dlmReportsInstance.filterDownloads();
905
  });
906
  });
907
 
908
+ dlmReportsInstance.mostDownloaded = dlmReportsInstance.orderItems(Object.values(mostDownloaded), 'desc', 'downloads');
 
 
909
 
910
  dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads);
911
  dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads / parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0));
1523
  let endTimestamp = new Date(endDate);
1524
  endTimestamp.setDate(endTimestamp.getDate() + 1);
1525
  endTimestamp = endTimestamp.getTime();
 
1526
  dlmReportsInstance.userDownloads = dlmReportsInstance.userDownloads.filter((element, index) => {
1527
  let currentElement = dlmReportsInstance.createDateElement(new Date(element.download_date));
1528
  currentElement = new Date(currentElement).getTime();
1530
  });
1531
 
1532
  dlmReportsInstance.createUserRelatedData();
1533
+ dlmReportsInstance.filterDownloads()
1534
  dlmReportsInstance.setMostActiveUser();
1535
  dlmReportsInstance.setLoggedOutDownloads();
1536
  dlmReportsInstance.setLoggedInDownloads();
1575
  if (!user_id || '0' === user_id) {
1576
  return null;
1577
  }
 
1578
  let $user = Object.values(dlmReportsInstance.dlmUsersStats.users).filter(user => {
1579
+ return parseInt(user_id) === parseInt(user.id);
1580
  });
1581
 
1582
+ if (Array.isArray($user)) {
1583
+ if (0 === $user.length) {
1584
+ return null;
1585
+ }
1586
+ return $user[0];
1587
+ }
1588
+
1589
+ return $user;
1590
  }
1591
 
1592
  /**
1694
 
1695
  let itemObject = {
1696
  key : i,
1697
+ user : ('0' !== dataResponse[i].user_id && 'undefined' !== typeof user && null !== user) ? user['display_name'] : '--',
1698
  ip : dataResponse[i].user_ip,
1699
  role : (null !== user && null !== user.role ? user.role : '--'),
1700
  download : ('undefined' !== typeof download) ? download.title : '--',
1729
  * Filter our downloads
1730
  */
1731
  filterDownloads() {
 
1732
 
1733
+ dlmReportsInstance.tempDownloads = JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads));
1734
  if (!dlmReportsInstance.currentFilters.length) {
1735
  dlmReportsInstance.setUserDownloads();
1736
  return;
1954
  getDownloadCPT($id) {
1955
  let download = dlmReportsInstance.mostDownloaded.filter((item) => {
1956
  return item.id === $id;
1957
+ }, 0)[0];
1958
 
1959
  jQuery(document).trigger('dlm_download_cpt', [dlmReportsInstance, download]);
1960
 
1977
  stopSpinner(target) {
1978
  target.find('.dlm-reports-spinner').remove();
1979
  }
1980
+ eventsFunctions() {
1981
+ jQuery('body').on('click', '.total_downloads_table_filters_total_downloads > a', function (e) {
1982
+ e.preventDefault();
1983
+ jQuery(this).parent().find('span.dashicons').toggleClass('dashicons-arrow-down dashicons-arrow-up');
1984
+ dlmReportsInstance.orderOverviewItemsByTotal();
1985
+ });
1986
+
1987
+ jQuery('body').on('click', '.total_downloads_table_filters_download_date > a', function (e) {
1988
+ e.preventDefault();
1989
+ jQuery(this).parent().find('span.dashicons').toggleClass('dashicons-arrow-down dashicons-arrow-up');
1990
+ dlmReportsInstance.orderUserReportsItemsByDate();
1991
+ });
1992
+ }
1993
+ /**
1994
+ * Set order of items
1995
+ *
1996
+ * @since 4.6.1
1997
+ */
1998
+ orderItems(items, order, key, setUploads = false) {
1999
+
2000
+ items.sort((a, b) => {
2001
+ switch (order) {
2002
+ case 'asc':
2003
+ return a[key] - b[key];
2004
+ case 'desc':
2005
+ return b[key] - a[key];
2006
+ default:
2007
+ return b[key] - a[key];
2008
+ }
2009
+ });
2010
+
2011
+ return items;
2012
+ }
2013
+ /**
2014
+ * Revert the current set order of the Overview tab Top Downloads table
2015
+ *
2016
+ * @since 4.6.1
2017
+ */
2018
+ orderOverviewItemsByTotal(){
2019
+ dlmReportsInstance.mostDownloaded = dlmReportsInstance.mostDownloaded.reverse();
2020
+ dlmReportsInstance.setTopDownloads();
2021
+ }
2022
+ /**
2023
+ * Revert the current set order of the User Reports tab Logs tabel
2024
+ *
2025
+ * @since 4.6.1
2026
+ */
2027
+ orderUserReportsItemsByDate(){
2028
+ dlmReportsInstance.tempDownloads = dlmReportsInstance.tempDownloads.reverse();
2029
+ dlmReportsInstance.setUserDownloads();
2030
+ }
2031
  }
assets/js/reports/reports.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){const t=new DLM_Reports;dlmReportsInstance.fetchReportsData(),e(document).on("dlm_downloads_report_fetched",function(){t.init()})});class DLM_Reports{dlmReportsStats=[];dlmUsersStats={logs:[],users:[]};currentFilters=[];tempDownloads=null;templates={};totalDownloads=0;constructor(){(dlmReportsInstance=this).chartContainer=document.getElementById("total_downloads_chart");const e=dlmReportsInstance.chartContainer.getContext("2d");dlmReportsInstance.chartColors={purple:{default:"rgba(149, 76, 233, 1)",threesome:"rgba(149, 76, 233, 0.75)",half:"rgba(149, 76, 233, 0.5)",quarter:"rgba(149, 76, 233, 0.5)",zero:"rgba(149, 76, 233, 0.05)"},blue:{default:"rgba(67, 56, 202, 1)",threesome:"rgba(67, 56, 202, 0.75)",half:"rgba(67, 56, 202, 0.5)",quarter:"rgba(67, 56, 202, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},green:{default:"rgba(00, 255, 00, 1)",threesome:"rgba(00, 255, 00, 0.75)",half:"rgba(00, 255, 00, 0.5)",quarter:"rgba(00, 255, 00, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},royalBlue:{default:"rgba(65, 105, 225, 1)",threesome:"rgba(65, 105, 225, 0.75)",half:"rgba(65, 105, 225, 0.5)",quarter:"rgba(65, 105, 225, 0.25)",zero:"rgba(65, 105, 225, 0.05)"},persianBlue:{default:"rgba(28, 57, 187, 1)",threesome:"rgba(28, 57, 187, 0.75)",half:"rgba(28, 57, 187, 0.5)",quarter:"rgba(28, 57, 187, 0.25)",zero:"rgba(28, 57, 187, 0.05)"},darkCyan:{default:"rgba(0,129,167, 1)",threesome:"rgba(0,129,167, 0.75)",half:"rgba(0,129,167, 0.5)",quarter:"rgba(0,129,167, 0.25)",zero:"rgba(0,129,167, 0.05)"},strongCyan:{default:"rgba(0, 175, 185, 1)",threesome:"rgba(0, 175, 185, 0.75)",half:"rgba(0, 175, 185, 0.5)",quarter:"rgba(0, 175, 185, 0.25)",zero:"rgba(0, 175, 185, 0.05)"}},dlmReportsInstance.chartGradient=e.createLinearGradient(0,25,0,300),dlmReportsInstance.chartGradient.addColorStop(0,dlmReportsInstance.chartColors.darkCyan.half),dlmReportsInstance.chartGradient.addColorStop(.45,dlmReportsInstance.chartColors.darkCyan.quarter),dlmReportsInstance.chartGradient.addColorStop(1,dlmReportsInstance.chartColors.darkCyan.zero),dlmReportsInstance.datePickerContainer=document.getElementById("dlm-date-range-picker"),dlmReportsInstance.dataSets=[];let t=new Date;dlmReportsInstance.dates={downloads:{start_date:new Date(t.setMonth(t.getMonth()-1)),end_date:new Date}},dlmReportsInstance.chartDataObject={}}async fetchReportsData(){const e=jQuery('div[data-id="general_info"]'),t=await fetch(dlmDownloadReportsAPI);if(!t.ok){const a=document.createElement("div"),n=(a.className="dlm-loading-data",document.createTextNode("Seems like we bumped into an error! ")),s=document.createTextNode("Data fetching returned a status text of : "+fetchedData.statusText),o=document.createElement("h1"),r=document.createElement("h3");throw o.appendChild(n),r.appendChild(s),a.appendChild(o),a.appendChild(r),e.find(".dlm-loading-data").remove(),e.append(a),new Error("Something went wrong! Reports response did not come OK - "+fetchedData.statusText)}dlmReportsInstance.dlmReportsStats=await t.json(),dlmReportsInstance.mostDownloaded=!1,dlmReportsInstance.stats=!1,dlmReportsInstance.chartType="day",0<window.location.href.indexOf("dlm_time")&&(dlmReportsInstance.dates.downloads.start_date=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,dlmReportsInstance.dates.downloads.end_date=new Date,jQuery("#dlm-date-range-picker .date-range-info").html(dlmReportsInstance.dates.downloads.start_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"})+" - "+dlmReportsInstance.dates.downloads.end_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}))),dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.datePicker={opened:!1},jQuery(document).trigger("dlm_downloads_report_fetched",[dlmReportsInstance,dlmReportsInstance.dlmReportsStats])}async fetchUsersReportsData(e=0,t=dlmPHPinfo.retrieved_rows){const a=jQuery('div[data-id="user_reports"]');let n=dlmUserReportsAPI+"?offset="+e+"&limit="+t;0<dlmUserReportsAPI.indexOf("index.php?")&&(n=dlmUserReportsAPI+"&offset="+e+"&limit="+t);const s=await fetch(n);if(!s.ok)throw new Error("Something went wrong! Reports response did not come OK - "+s.statusText);e=await s.json();dlmReportsInstance.dlmUsersStats.logs=dlmReportsInstance.dlmUsersStats.logs.concat(e.logs),!0===e.done?(dlmReportsInstance.userDownloads=void 0!==dlmReportsInstance.dlmUsersStats.logs?JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs)):{},a.find(".dlm-loading-data").remove(),dlmReportsInstance.userReportsTab(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))):dlmReportsInstance.fetchUsersReportsData(e.offset)}async fetchUserData(){const e=await fetch(dlmUserDataAPI);if(!e.ok)throw new Error("Something went wrong! Reports response did not come OK - "+e.statusText);var t=await e.json();dlmReportsInstance.dlmUsersStats.users=dlmReportsInstance.dlmUsersStats.users.concat(t)}init(){dlmReportsInstance.tabNagivation(),dlmReportsInstance.overViewTab(),dlmReportsInstance.togglePageSettings(),dlmReportsInstance.fetchUserData(),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2")),dlmReportsInstance.fetchUsersReportsData(),jQuery(document).trigger("dlm_reports_init",[dlmReportsInstance])}overViewTab(){dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer),dlmReportsInstance.dlmDownloadsSummary(),dlmReportsInstance.datePickerContainer.addEventListener("click",dlmReportsInstance.toggleDatepicker.bind(this)),dlmReportsInstance.setTodayDownloads(),dlmReportsInstance.handleTopDownloads(),jQuery(document).on("click","body",function(e){e.stopPropagation(),0<jQuery(dlmReportsInstance.datePickerContainer).find("#dlm_date_range_picker").length&&dlmReportsInstance.hideDatepicker(jQuery(dlmReportsInstance.datePickerContainer),{target:"dlm-date-range-picker"})})}userReportsTab(){0!==Object.values(dlmReportsInstance.dlmUsersStats).length&&(dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.handleUserDownloads(),dlmReportsInstance.filterDownloads())}getDates(e,t){const a={};let n=e;for(;n<=t;)a[this.createDateElement(n)]=0,n=this.getNextDay(n);return a}getMonths(e){const t={};return Object.keys(e).map(e=>{e=e.substring(0,7);void 0===t[e]&&(t[e]=0)}),t}getDoubleMonths(e){const t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1];let s=0,o=a.substring(0,7),r=n.substring(0,7);return Object.keys(e).map(e=>{e=e.substring(0,7);o!==e&&r!==e&&(o=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getWeeks(e){let a={};return Object.keys(e).forEach(e=>{let t;t=15<moment(e).date()?e.substring(0,7)+"-15":e.substring(0,7)+"-01",void 0===a[t]&&(a[t]=0)}),a}getWeek(e){let t={},a=Object.keys(e)[Object.keys(e).length-1],n=0;return Object.keys(e).map(e=>{void 0===t[e]&&0==n%7&&(t[e]=0),n++}),void 0===t[a]&&(t[a]=0),t}getDoubleDays(e){let t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1],s=0;return Object.keys(e).map(e=>{a!==e&&n!==e&&(a=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getNextDay(e){const t=new Date(e);return t.setDate(e.getDate()+1),t}createDateElement(e){var t=(e.getMonth()+1<10?"0":"")+(e.getMonth()+1);return e.getFullYear()+"-"+t+"-"+("0"+e.getDate()).slice(-2)}getSetDates(e,t){let a,n;if(void 0!==e&&e)a=dlmReportsInstance.createDateElement(new Date(e));else{const s=new Date;s.setDate(s.getDate()-30),a=dlmReportsInstance.createDateElement(s)}if(void 0!==t&&t){e=new Date(t);n=dlmReportsInstance.createDateElement(e)}else{const o=new Date;o.setDate(o.getDate()+1),n=dlmReportsInstance.createDateElement(o)}return{startDate:a,endDate:n}}createDataOnDate(e,t){let{startDate:a,endDate:n}={...dlmReportsInstance.getSetDates(e,t)},s,o,r,d,l,c=(dlmReportsInstance.reportsData=void 0!==dlmReportsInstance.dlmReportsStats?JSON.parse(JSON.stringify(dlmReportsInstance.dlmReportsStats)):{},o=moment(n,"YYYY-MM-DD").month()-moment(a,"YYYY-MM-DD").month(),r=moment(n,"YYYY-MM-DD").year()-moment(a,"YYYY-MM-DD").year(),s=moment(n).date()-moment(a).date(),dlmReportsInstance.chartType="day",0==r&&-6<o&&o<6?1<o||o<-1?dlmReportsInstance.chartType=2==o?"week":"weeks":1==o&&(8<s||-14<s||0==s)&&(dlmReportsInstance.chartType="days"):o<=0?dlmReportsInstance.chartType="month":dlmReportsInstance.chartType="months",dlmReportsInstance.getDates(new Date(a),new Date(n))),m,i,p,g;switch(dlmReportsInstance.chartType){case"months":i=dlmReportsInstance.getDoubleMonths(c),l=i;break;case"month":var u=dlmReportsInstance.getMonths(c);l=u;break;case"weeks":p=dlmReportsInstance.getWeeks(c),l=p;break;case"week":g=dlmReportsInstance.getWeek(c),l=g;break;case"days":m=dlmReportsInstance.getDoubleDays(c),l=m;break;case"day":l=c}Object.values(dlmReportsInstance.reportsData).forEach((s,e)=>{var o=JSON.parse(s.download_ids);if(void 0!==c[s.date])switch(dlmReportsInstance.chartType){case"months":d=s.date.substring(0,7);let e=parseInt(s.date.substring(5,7)),t=s.date.substring(0,5),a=6<(e-1).length?t+(e-1):t+"0"+(e-1);Object.values(o).forEach((e,t)=>{void 0===i[d]?void 0!==i[a]&&(i[a]=i[a]+e.downloads):i[d]=i[d]+e.downloads}),l=i;break;case"month":d=s.date.substring(0,7),Object.values(o).forEach((e,t)=>{monthDownloads[d]=void 0!==monthDownloads[d]?monthDownloads[d]+e.downloads:e.downloads}),l=monthDownloads;break;case"weeks":d=15<moment(s.date).date()?s.date.substring(0,7)+"-15":s.date.substring(0,7)+"-01",Object.values(o).forEach((e,t)=>{p[d]=void 0!==p[d]?p[d]+e.downloads:e.downloads}),l=p;break;case"week":d=s.date,Object.values(o).forEach((t,e)=>{if(void 0===g[d])for(let e=1;e<8;e++){var a=moment(s.date).date(moment(s.date).date()-e).format("YYYY-MM-DD");void 0!==g[a]&&(g[a]=g[a]+t.downloads)}else g[d]=g[d]+t.downloads}),l=g;break;case"days":d=s.date;let n=moment(s.date).date(moment(s.date).date()-1).format("YYYY-MM-DD");Object.values(o).forEach((e,t)=>{void 0===m[d]?void 0!==m[n]&&(m[n]=m[n]+e.downloads):m[d]=m[d]+e.downloads}),l=m;break;case"day":Object.values(o).forEach((e,t)=>{c[s.date]=c[s.date]+e.downloads}),l=c}else delete dlmReportsInstance.reportsData[e]});const h=Object.keys(c);e=h.length,t=h.findIndex(e=>a===e);let R=h.findIndex(e=>n===e);-1===t&&-1===R?dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:!1,daysLength:e}:(-1===R&&(R=e),dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:dlmReportsInstance.reportsData,daysLength:e})}dlmCreateChart(t,a,n=!1){if(t&&a){let e=Chart.getChart("total_downloads_chart");dlmReportsInstance.chartDataObject={dataSetLabel:"Downloads",dataSetColor:"#27ae60",dataSetbg:dlmReportsInstance.chartGradient,dataSetPointbg:dlmReportsInstance.chartColors.darkCyan.default,dataSetBorder:dlmReportsInstance.chartColors.darkCyan.default,dataSetElementColor:"#2ecc71",lineType:"original",xAxis:"x",chartData:t},void 0!==e&&e.destroy(),jQuery(document).trigger("dlm_reports_before_data_sets",[dlmReportsInstance.chartDataObject,t,n]),0<dlmReportsInstance.dataSets.length&&(dlmReportsInstance.dataSets=dlmReportsInstance.dataSets.filter(e=>dlmReportsInstance.chartDataObject.lineType!==e.origin)),dlmReportsInstance.dataSets.push({origin:dlmReportsInstance.chartDataObject.lineType,label:dlmReportsInstance.chartDataObject.dataSetLabel,color:dlmReportsInstance.chartDataObject.dataSetColor,data:dlmReportsInstance.chartDataObject.chartData,type:"line",fill:!0,backgroundColor:dlmReportsInstance.chartDataObject.dataSetbg,pointBackgroundColor:dlmReportsInstance.chartDataObject.dataSetPointbg,pointHoverBackgroundColor:"#fff",borderColor:dlmReportsInstance.chartDataObject.dataSetBorder,pointBorderWidth:1,lineTension:.3,borderWidth:1,pointRadius:3,elements:{line:{borderColor:dlmReportsInstance.chartDataObject.dataSetElementColor,borderWidth:1},point:{radius:4,hoverRadius:4,pointStyle:"circle"}}});t=Object.values(dlmReportsInstance.dataSets).filter(e=>"original"===e.origin);let o=Object.keys(t[0].data);dlmReportsInstance.dataSets.sort(function(e,t){return"original"===e.origin?-1:1}),dlmReportsInstance.chart=new Chart(a,{title:"",data:{datasets:dlmReportsInstance.dataSets},height:450,is_series:1,options:{aspectRatio:5,animation:!1,interaction:{mode:"index",intersect:!1},stacked:!1,scales:{x:{grid:{display:!1},ticks:{callback:e=>{let t="";var a=o[e],n=o[o.length-1],s=moment(n).month(moment(n).month()-1).format("YYYY-MM");return t="undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?(e=moment(o[e]).month())<11?a===s?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+" - "+moment(a).month(e+1).format("MMM")+moment(a).format(", YYYY"):a===s||a===n?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+moment(a).format(" YYYY")+" - "+moment(a).month(e+1).format("MMM")+moment(a).month(e+1).format(", YYYY"):"undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?moment(a).format("MMMM, YYYY"):moment(a).format("D MMM")}}},y:{grid:{drawBorder:!1},min:0,max:0!==dlmReportsInstance.getMaxDownload()?1===Math.ceil(dlmReportsInstance.getMaxDownload()/10)?dlmReportsInstance.getMaxDownload()+1:10*Math.ceil(dlmReportsInstance.getMaxDownload()/10):100,ticks:{stepSize:0!==dlmReportsInstance.getMaxDownload()?Math.ceil(dlmReportsInstance.getMaxDownload()/4):25,callback:e=>dlmReportsInstance.shortNumber(e)}}},normalized:!0,parsing:{xAxisKey:"x",yAxisKey:"y"},plugins:{tooltip:{enabled:!1,external:dlmReportsInstance.externalTooltipHandler.bind(dlmReportsInstance,this)},legend:{display:!0}}}})}}dlmDownloadsSummary(){let a={};if(!1===dlmReportsInstance.stats||!1===dlmReportsInstance.stats.summaryStats||Object.keys(dlmReportsInstance.stats.summaryStats).length<=0)return this.setTotalDownloads(0),this.setDailyAverage(0),void this.setMostDownloaded("--");dlmReportsInstance.totalDownloads=0,dlmReportsInstance.stats.summaryStats.forEach(e=>{e=JSON.parse(e.download_ids),Object.entries(e).forEach(([e,t])=>{dlmReportsInstance.totalDownloads+=t.downloads,a[e]=void 0===a[e]?{downloads:t.downloads,title:t.title,id:e}:{downloads:a[e].downloads+t.downloads,title:t.title,id:e}})}),dlmReportsInstance.mostDownloaded=Object.values(a).sort((e,t)=>e.downloads-t.downloads).reverse(),dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads),dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads/parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0)),dlmReportsInstance.setMostDownloaded(dlmReportsInstance.mostDownloaded[0].title)}createDatepicker(e,t,a){const n=new Date;let s=n.getDate()-1,o=n.getMonth()+1,r=o-1;var d=n.getFullYear(),l=(s<10&&(s="0"+s),o<10&&(o="0"+o),r<10&&(r="0"+r),d+"-"+o+"-"+s),d=d+"-"+r+"-"+s,c=jQuery("<div>").addClass("dlm_rdrs_overlay"),a=jQuery("<div>").attr("id",a.replace("#",""));return"dlm-date-range-picker"===t.target?(dlmReportsInstance.startDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_start_date").attr("value",d),dlmReportsInstance.endDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_end_date").attr("value",l),c.append(a).append(dlmReportsInstance.startDateInput).append(dlmReportsInstance.endDateInput)):jQuery(document).trigger("dlm_create_date_picker_"+t.target,[dlmReportsInstance,c,a,d,l]),c}displayDatepicker(e,o){var t;if(jQuery(e)){if(t="#"+jQuery(e).attr("id").replace(/-/gi,"_"),"dlm-date-range-picker"===o.target){if(dlmReportsInstance.datePicker.opened)return;dlmReportsInstance.datePicker.opened=!0}else jQuery(document).trigger("dlm_display_datepicker_"+o.target,[dlmReportsInstance,o,e]);let s=dlmReportsInstance.createDatepicker(e,o,t);e.append(s);var a=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,n=(new Date,[]),e=(jQuery(document).trigger("dlm_datepicker_shortcuts_"+o.target,[dlmReportsInstance,o,e,n]),{separator:" to ",autoClose:!0,getValue:function(){},setValue:function(e,t,a){s.find('input[type="hidden"]').first().val(t),s.find('input[type="hidden"]').last().val(a)},inline:!0,alwaysOpen:!0,container:t,endDate:new Date,startDate:a,showShortcuts:!0,shortcuts:null,customShortcuts:n});s.dateRangePicker(e).on("datepicker-change",(e,t)=>{var a,n;t.date1&&t.date2&&(a=t.date1.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),n=t.date2.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),s.parent().find("span.date-range-info").text(a+" - "+n)),"dlm-date-range-picker"===o.target?(dlmReportsInstance.dates.downloads={start_date:t.date1,end_date:t.date2},dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer,!1),dlmReportsInstance.dlmDownloadsSummary(),0<Object.values(dlmReportsInstance.dlmUsersStats.logs).length&&dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date)):jQuery(document).trigger("dlm_daterangepicker_init_"+o.target,[dlmReportsInstance,t.date1,t.date2]),dlmReportsInstance.setTopDownloads(),s.data("dateRangePicker").close()}),"dlm-date-range-picker"===o.target?s.data("dateRangePicker").setDateRange(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date):jQuery(document).trigger("dlm_daterangepicker_after_init_"+o.target,[s,dlmReportsInstance])}}hideDatepicker(e,t){"dlm-date-range-picker"===t.target?dlmReportsInstance.datePicker.opened=!1:jQuery(document).trigger("dlm_hide_datepicker_"+t.target,[dlmReportsInstance,e,t]),e.find(".dlm_rdrs_overlay").remove()}toggleDatepicker(e){e.stopPropagation();const t=jQuery(e.target).parents(".dlm-reports-header-date-selector");e={target:t.attr("id"),object:dlmReportsInstance.datePicker};dlmReportsInstance.closeDatePickers(t),"dlm-date-range-picker"===e.target?dlmReportsInstance.datePicker.opened?dlmReportsInstance.hideDatepicker(t,e):dlmReportsInstance.displayDatepicker(t,e):jQuery(document).trigger("dlm_toggle_datepicker_"+e.target,[dlmReportsInstance,t,e])}setTotalDownloads(e){jQuery(".dlm-reports-block-summary li#total span").html(e.toLocaleString())}setDailyAverage(e){jQuery(".dlm-reports-block-summary li#average span").html(e.toLocaleString())}setMostDownloaded(e){jQuery(".dlm-reports-block-summary li#popular span").html(e)}setTodayDownloads(){let e=0;Object.keys(dlmReportsInstance.dlmReportsStats).length<=0?jQuery(".dlm-reports-block-summary li#today span").html(e.toLocaleString()):(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].date===dlmReportsInstance.createDateElement(new Date)&&(e=Object.values(JSON.parse(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].download_ids)).reduce((e,t)=>e+t.downloads,0)),jQuery(".dlm-reports-block-summary li#today span").html(e))}setTopDownloads(e=0,t=!1){const a=jQuery("#total_downloads_table_wrapper2"),n=jQuery("#total_downloads_table_wrapper2 .total_downloads_table__list");if(n.empty(),n.parent().addClass("empty"),dlmReportsInstance.mostDownloaded&&!0!==t){var s=JSON.parse(JSON.stringify(dlmReportsInstance.mostDownloaded)).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<s.length;e++){const r=dlmReportsInstance.getDownloadByID(s[e].id);if(void 0===r)return;var o={id:s[e].id,title:s[e].title,edit_link:dlmAdminUrl+"post.php?post="+s[e].id+"&action=edit",total_downloads:r.total.toLocaleString()};jQuery(document).trigger("dlm_reports_top_downloads_item_before_render",[o,dlmReportsInstance,s[e],r]),new dlmBackBone.modelTopDownloads(o)}n.parent().removeClass("empty"),10<dlmReportsInstance.mostDownloaded.length?a.find(".downloads-block-navigation button").removeClass("hidden"):a.find(".downloads-block-navigation button").addClass("hidden"),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))}}handleTopDownloads(){jQuery("html body").on("click","#total_downloads_table_wrapper2 .downloads-block-navigation button",function(){let e=jQuery(this).parents("#total_downloads_table_wrapper2"),t=e,a=e.attr("data-page"),n=jQuery(this),s=parseInt(a)+1,o=0!==a?parseInt(a)-1:0,r=e.find(".downloads-block-navigation").find("button").first(),d=e.find(".downloads-block-navigation").find("button").last();n.attr("disabled","disabled");var l={data:dlmReportsInstance.mostDownloaded,main_parent:e,offsetHolder:t,offset:a,link:n,nextPage:s,prevPage:o,prevButton:r,nextButton:d,doAction:dlmReportsInstance.setTopDownloads};dlmReportsInstance.handleSliderNavigation(l)})}handleSliderNavigation(e){const{data:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:c}={...e};"load-more"===s.data("action")?(a.attr("data-page",o),c(o),Math.ceil(t.length/10)>o+1&&l.removeAttr("disabled"),d.removeAttr("disabled")):0!==parseInt(n)&&(a.attr("data-page",r),c(r),1!==parseInt(n)&&d.removeAttr("disabled"),l.removeAttr("disabled"))}tabNagivation(){jQuery(document).on("click",".dlm-reports .dlm-insights-tab-navigation > li",function(){const e=jQuery(this),t=jQuery(".dlm-reports .dlm-insights-tab-navigation > li").not(e),a=jQuery('div.dlm-insights-tab-navigation__content[data-id="'+e.attr("id")+'"]'),n=jQuery("div.dlm-insights-tab-navigation__content").not(a);e.hasClass("active")||(e.addClass("active"),t.removeClass("active"),a.addClass("active"),n.removeClass("active"))})}getOrCreateTooltip(e){let t=e.canvas.parentNode.querySelector("div.dlm-canvas-tooltip"),a=e.canvas.parentNode.querySelector("div.dlm-reports-tooltip__line");if(t||((a=document.createElement("div")).className="dlm-reports-tooltip__line"),!t){(t=document.createElement("div")).className="dlm-canvas-tooltip";const n=document.createElement("div");n.className="dlm-reports-tooltip",t.appendChild(n),e.canvas.parentNode.appendChild(t),e.canvas.parentNode.appendChild(a)}return{tooltipEl:t,tooltipLine:a}}externalTooltipHandler(d,e){const{chart:t,tooltip:l}=e,{tooltipEl:a,tooltipLine:n}={...d.getOrCreateTooltip(t)};e=jQuery(a).parent().width();if(0===l.opacity)return a.style.opacity=0,void(n.style.opacity=0);if(l.body){const c=l.title||[],m=document.createElement("div"),i=(m.className="dlm-reports-tooltip__header",c.forEach(e=>{const t=document.createElement("div"),a=(t.className="dlm-reports-tooltip__row",document.createElement("p")),n=(a.className="dlm-reports-tooltip__info",a.appendChild(document.createTextNode("Downloads")),t.appendChild(a),jQuery(document).trigger("dlm_chart_tooltip_before",[dlmReportsInstance,l,t,d]),document.createElement("p"));n.className="dlm-reports-tooltip__date";var s=dlmReportsInstance.setChartTooltipDate(l.dataPoints[0].label,d,d.stats.chartStats);n.appendChild(document.createTextNode(s)),t.appendChild(n);const o=document.createElement("p"),r=(o.className="dlm-reports-tooltip__downloads",document.createElement("span"));r.className="dlm-reports-tooltip__downloads_pointer",r.style.backgroundColor=dlmReportsInstance.chartColors.darkCyan.default,o.appendChild(r),o.appendChild(document.createTextNode(dlmReportsInstance.shortNumber(l.dataPoints[0].formattedValue))),t.appendChild(o),jQuery(document).trigger("dlm_chart_tooltip_after",[dlmReportsInstance,l,t,d]),m.appendChild(t)}),a.querySelector("div.dlm-reports-tooltip"));for(;i.firstChild;)i.firstChild.remove();i.appendChild(m)}var{offsetLeft:s,offsetTop:o}=t.canvas;a.style.opacity=1;let r={isMargin:!(n.style.opacity=1),left:!1};l.caretX-l.width<0&&(r.isMargin=!0,r.left=!0),s+l.caretX+l.width>e&&(r.isMargin=!0,r.left=!1),r.isMargin?r.left?a.style.left=s+l.width+"px":a.style.left=e-l.width+"px":a.style.left=s+l.caretX+"px",n.style.left=s+l.caretX+"px",a.style.top=o+l.caretY-a.offsetHeight-10+"px"}createUserRelatedData(){dlmReportsInstance.userRelatedData=[],Object.values(dlmReportsInstance.userDownloads).forEach((e,t)=>{var a;"0"!==e.user_id&&(a=[e.user_id,e.download_id,e.download_date,e.download_status],e="user_"+e.user_id,void 0!==dlmReportsInstance.userRelatedData[e]?dlmReportsInstance.userRelatedData[e].push(a):dlmReportsInstance.userRelatedData[e]=[a])})}logsDataByDate(e,t){var{startDate:e,endDate:t}={...dlmReportsInstance.getSetDates(e,t)};dlmReportsInstance.userDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs));let a=new Date(e),n=(a.setDate(a.getDate()-1),a=a.getTime(),new Date(t));n.setDate(n.getDate()+1),n=n.getTime(),dlmReportsInstance.userDownloads=dlmReportsInstance.userDownloads.filter((e,t)=>{e=dlmReportsInstance.createDateElement(new Date(e.download_date));return(e=new Date(e).getTime())>a&&e<n}),dlmReportsInstance.createUserRelatedData(),dlmReportsInstance.setMostActiveUser(),dlmReportsInstance.setLoggedOutDownloads(),dlmReportsInstance.setLoggedInDownloads(),jQuery(document).trigger("dlm_set_logs_data_by_date",[dlmReportsInstance])}setMostActiveUser(){var e=dlmReportsInstance.getUserByID(dlmReportsInstance.getMostActiveID()[0]);jQuery(".dlm-reports-block-summary li#most_active_user span").html(dlmReportsInstance.userToolTipMarkup(e))}getMostActiveID(){return Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t,a)=>parseInt(e.length)>parseInt(t.length)&&0<e.length&&null!==dlmReportsInstance.getUserByID(e[0][0])?e:null!==dlmReportsInstance.getUserByID(t[0][0])?t:[],[]):0}getUserByID(t){if(!t||"0"===t)return null;var e=Object.values(dlmReportsInstance.dlmUsersStats.users).filter(e=>parseInt(t)===parseInt(e.ID));return 0<e.length?e[0]:null}getLoggedInDownloads(){return Object.values(dlmReportsInstance.userRelatedData).length?1<Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t)=>parseInt(e)+parseInt(t.length),0):Object.values(dlmReportsInstance.userRelatedData)[0].length:0}setLoggedInDownloads(){const e=dlmReportsInstance.getLoggedInDownloads();jQuery(".dlm-reports-block-summary li#logged_in span,#total_downloads_summary_wrapper .dlm-reports-logged-in").html(e.toLocaleString())}getLoggedOutDownloads(){return dlmReportsInstance.userDownloads.length-dlmReportsInstance.getLoggedInDownloads()}setLoggedOutDownloads(){const e=dlmReportsInstance.getLoggedOutDownloads();jQuery(".dlm-reports-block-summary li#logged_out span,#total_downloads_summary_wrapper .dlm-reports-logged-out").html(e.toLocaleString())}userToolTipMarkup(e){let t='<div class="dlm-user-reports">';return t=(t=t+'<div class="wpchill-tooltip"><i>[?]</i>'+'<div class="wpchill-tooltip-content">')+("<span>User ID: "+(null!==e?e.id:"--")+"</span>"),"object"!=typeof e&&e.url.length&&(t+="<span>User URL: "+(null!==e?e.url:"--")+"</span>"),t+="<span>User registration date: "+(null!==e?e.registered:"--")+"</span>",null!==e&&void 0!==e.role&&e.role.length&&(t+="<span>User role: "+e.role+"</span>"),t=(t+="</div></div>")+(null!==e?e.display_name:"--")+"</div>"}setUserDownloads(e=0,t=!1){const a=jQuery("#users_download_log"),n=jQuery("#users_download_log .user-logs__list");if(n.empty(),!0!==t){let t=[];t=(null!==dlmReportsInstance.tempDownloads?JSON.parse(JSON.stringify(dlmReportsInstance.tempDownloads)):JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads))).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<t.length;e++){var s=dlmReportsInstance.getUserByID(t[e].user_id.toString()),o=dlmReportsInstance.getDownloadCPT(t[e].download_id.toString()),r={key:e,user:"0"!==t[e].user_id&&null!=s?s.user_nicename:"--",ip:t[e].user_ip,role:null!==s&&null!==s.role?s.role:"--",download:void 0!==o?o.title:"--",valid_user:"0"!==t[e].user_id,edit_link:"user-edit.php?user_id="+t[e].user_id,edit_download_link:void 0!==o?dlmAdminUrl+"post.php?post="+o.id+"&action=edit":"#",status:t[e].download_status,download_date:t[e].download_date};jQuery(document).trigger("dlm_reports_user_logs_item_before_render",[r,dlmReportsInstance,t[e],s,o]),new dlmBackBone.modelUserLogs(r)}dlmReportsInstance.stopSpinner(jQuery("#users_download_log")),10!==t.length?a.find('.user-downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.user-downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),10<dlmReportsInstance.userDownloads.length?a.find(".user-downloads-block-navigation button").removeClass("hidden"):a.find(".user-downloads-block-navigation button").addClass("hidden")}}filterDownloads(){dlmReportsInstance.tempDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads)),dlmReportsInstance.currentFilters.length&&dlmReportsInstance.currentFilters.forEach(t=>{dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.filter(e=>t.on===e[t.type])}),dlmReportsInstance.setUserDownloads()}handleUserDownloads(){jQuery(".user-downloads-block-navigation").on("click","button",function(e){e.stopPropagation();let t=jQuery(this).parents("#users_downloads_table_wrapper"),a=t.find("#users_download_log"),n=a.attr("data-page"),s=jQuery(this),o=parseInt(n)+1,r=0!==n?parseInt(n)-1:0,d=t.find(".downloads-block-navigation button").first(),l=t.find(".downloads-block-navigation button").last();s.attr("disabled","disabled");e={data:dlmReportsInstance.tempDownloads,main_parent:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:dlmReportsInstance.setUserDownloads};dlmReportsInstance.handleSliderNavigation(e)})}togglePageSettings(){jQuery("#dlm-toggle-settings").on("click",function(e){e.stopPropagation(),jQuery(this).find(".dlm-toggle-settings__settings").toggleClass("display")}),jQuery(".dlm-toggle-settings__settings").on("click",function(e){e.stopPropagation()}),jQuery("html,body").on("click",function(){jQuery(this).find(".dlm-toggle-settings__settings").removeClass("display")}),jQuery(document).on("change",".wpchill-toggle__input",function(e){const t=jQuery(this),a=t.attr("name"),n={action:"dlm_update_report_setting",name:a,checked:t.is(":checked"),_ajax_nonce:dlmReportsNonce};jQuery.post(ajaxurl,n,function(e){a,jQuery(document).trigger("dlm_settings_ajax_response",[dlmReportsInstance,t,e])})})}getMaxDownload(){let t=0;return dlmReportsInstance.dataSets.forEach(e=>{e=Object.values(e.data).reduce((e,t)=>t<e?e:t,0);t<e&&(t=e)}),parseInt(t)}setChartTooltipDate(e,t,a){let n="";var s,o,r;return n="undefined"!==t.chartType&&"months"===t.chartType?(moment(e).year(),s=moment(e).month(),a=Object.keys(a)[Object.keys(a).length-1],o=moment(a).month(moment(a).month()-1).format("YYYY-MM"),r=moment(e).format("YYYY-MM"),s<11?r===o?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+" - "+moment(e).month(s+1).format("MMM")+moment(e).format(", YYYY"):r===o||r===a?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+moment(e).format(" YYYY")+" - "+moment(e).month(s+1).format("MMM")+moment(e).month(s+1).format(", YYYY")):"undefined"!==t.chartType&&"months"===t.chartType?moment(e).format("MMMM, YYYY"):moment(e).format("MMMM Do, YY")}closeDatePickers(e){jQuery(".dlm-reports-header-date-selector").not(e).each(function(){var e={target:jQuery(this).attr("id")};dlmReportsInstance.hideDatepicker(jQuery(this),e)})}shortNumber(e){return e=4<=(e="string"==typeof e?e.replace(/,/gi,""):parseInt(e).toString()).length?parseInt(e.substring(0,e.length-3)).toLocaleString()+"k":e}getDownloadByID(t){let a={total:0},n;return dlmReportsInstance.tempDownloads.forEach(function(e){t===e.download_id&&(n=e,a.total=a.total+1,jQuery(document).trigger("dlm_download_by_id",[dlmReportsInstance,a,n]))}),a}getDownloadCPT(t){var e=dlmReportsInstance.mostDownloaded.filter(e=>e.id===t,0)[0];return jQuery(document).trigger("dlm_download_cpt",[dlmReportsInstance,e]),e}setSpinner(e){e.append('<div class="dlm-reports-spinner"><span></span></div>')}stopSpinner(e){e.find(".dlm-reports-spinner").remove()}}
1
+ jQuery(function(e){const t=new DLM_Reports;dlmReportsInstance.fetchReportsData(),e(document).on("dlm_downloads_report_fetched",function(){t.init()})});class DLM_Reports{dlmReportsStats=[];dlmUsersStats={logs:[],users:[]};currentFilters=[];tempDownloads=null;templates={};totalDownloads=0;constructor(){(dlmReportsInstance=this).chartContainer=document.getElementById("total_downloads_chart");const e=dlmReportsInstance.chartContainer.getContext("2d");dlmReportsInstance.chartColors={purple:{default:"rgba(149, 76, 233, 1)",threesome:"rgba(149, 76, 233, 0.75)",half:"rgba(149, 76, 233, 0.5)",quarter:"rgba(149, 76, 233, 0.5)",zero:"rgba(149, 76, 233, 0.05)"},blue:{default:"rgba(67, 56, 202, 1)",threesome:"rgba(67, 56, 202, 0.75)",half:"rgba(67, 56, 202, 0.5)",quarter:"rgba(67, 56, 202, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},green:{default:"rgba(00, 255, 00, 1)",threesome:"rgba(00, 255, 00, 0.75)",half:"rgba(00, 255, 00, 0.5)",quarter:"rgba(00, 255, 00, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},royalBlue:{default:"rgba(65, 105, 225, 1)",threesome:"rgba(65, 105, 225, 0.75)",half:"rgba(65, 105, 225, 0.5)",quarter:"rgba(65, 105, 225, 0.25)",zero:"rgba(65, 105, 225, 0.05)"},persianBlue:{default:"rgba(28, 57, 187, 1)",threesome:"rgba(28, 57, 187, 0.75)",half:"rgba(28, 57, 187, 0.5)",quarter:"rgba(28, 57, 187, 0.25)",zero:"rgba(28, 57, 187, 0.05)"},darkCyan:{default:"rgba(0,129,167, 1)",threesome:"rgba(0,129,167, 0.75)",half:"rgba(0,129,167, 0.5)",quarter:"rgba(0,129,167, 0.25)",zero:"rgba(0,129,167, 0.05)"},strongCyan:{default:"rgba(0, 175, 185, 1)",threesome:"rgba(0, 175, 185, 0.75)",half:"rgba(0, 175, 185, 0.5)",quarter:"rgba(0, 175, 185, 0.25)",zero:"rgba(0, 175, 185, 0.05)"}},dlmReportsInstance.chartGradient=e.createLinearGradient(0,25,0,300),dlmReportsInstance.chartGradient.addColorStop(0,dlmReportsInstance.chartColors.darkCyan.half),dlmReportsInstance.chartGradient.addColorStop(.45,dlmReportsInstance.chartColors.darkCyan.quarter),dlmReportsInstance.chartGradient.addColorStop(1,dlmReportsInstance.chartColors.darkCyan.zero),dlmReportsInstance.datePickerContainer=document.getElementById("dlm-date-range-picker"),dlmReportsInstance.dataSets=[];let t=new Date;dlmReportsInstance.dates={downloads:{start_date:new Date(t.setMonth(t.getMonth()-1)),end_date:new Date}},dlmReportsInstance.chartDataObject={}}async fetchReportsData(){const e=jQuery('div[data-id="general_info"]'),t=await fetch(dlmDownloadReportsAPI);if(!t.ok){const a=document.createElement("div"),n=(a.className="dlm-loading-data",document.createTextNode("Seems like we bumped into an error! ")),s=document.createTextNode("Data fetching returned a status text of : "+fetchedData.statusText),o=document.createElement("h1"),r=document.createElement("h3");throw o.appendChild(n),r.appendChild(s),a.appendChild(o),a.appendChild(r),e.find(".dlm-loading-data").remove(),e.append(a),new Error("Something went wrong! Reports response did not come OK - "+fetchedData.statusText)}dlmReportsInstance.dlmReportsStats=await t.json(),dlmReportsInstance.mostDownloaded=!1,dlmReportsInstance.stats=!1,dlmReportsInstance.chartType="day",0<window.location.href.indexOf("dlm_time")&&(dlmReportsInstance.dates.downloads.start_date=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,dlmReportsInstance.dates.downloads.end_date=new Date,jQuery("#dlm-date-range-picker .date-range-info").html(dlmReportsInstance.dates.downloads.start_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"})+" - "+dlmReportsInstance.dates.downloads.end_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}))),dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.datePicker={opened:!1},jQuery(document).trigger("dlm_downloads_report_fetched",[dlmReportsInstance,dlmReportsInstance.dlmReportsStats])}async fetchUsersReportsData(e=0,t=dlmPHPinfo.retrieved_rows){const a=jQuery('div[data-id="user_reports"]');let n=dlmUserReportsAPI+"?offset="+e+"&limit="+t;0<dlmUserReportsAPI.indexOf("index.php?")&&(n=dlmUserReportsAPI+"&offset="+e+"&limit="+t);const s=await fetch(n);if(!s.ok)throw new Error("Something went wrong! Reports response did not come OK - "+s.statusText);e=await s.json();dlmReportsInstance.dlmUsersStats.logs=dlmReportsInstance.dlmUsersStats.logs.concat(e.logs),!0===e.done?(dlmReportsInstance.userDownloads=void 0!==dlmReportsInstance.dlmUsersStats.logs?JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs)):{},a.find(".dlm-loading-data").remove(),dlmReportsInstance.userReportsTab(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))):dlmReportsInstance.fetchUsersReportsData(e.offset)}async fetchUserData(){const e=await fetch(dlmUserDataAPI);if(!e.ok)throw new Error("Something went wrong! Reports response did not come OK - "+e.statusText);var t=await e.json();dlmReportsInstance.dlmUsersStats.users=dlmReportsInstance.dlmUsersStats.users.concat(t)}init(){dlmReportsInstance.tabNagivation(),dlmReportsInstance.overViewTab(),dlmReportsInstance.togglePageSettings(),dlmReportsInstance.fetchUserData(),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2")),dlmReportsInstance.fetchUsersReportsData(),jQuery(document).trigger("dlm_reports_init",[dlmReportsInstance]),dlmReportsInstance.eventsFunctions()}overViewTab(){dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer),dlmReportsInstance.dlmDownloadsSummary(),dlmReportsInstance.datePickerContainer.addEventListener("click",dlmReportsInstance.toggleDatepicker.bind(this)),dlmReportsInstance.setTodayDownloads(),dlmReportsInstance.handleTopDownloads(),jQuery(document).on("click","body",function(e){e.stopPropagation(),0<jQuery(dlmReportsInstance.datePickerContainer).find("#dlm_date_range_picker").length&&dlmReportsInstance.hideDatepicker(jQuery(dlmReportsInstance.datePickerContainer),{target:"dlm-date-range-picker"})})}userReportsTab(){0!==Object.values(dlmReportsInstance.dlmUsersStats).length&&(dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.handleUserDownloads(),dlmReportsInstance.filterDownloads())}getDates(e,t){const a={};let n=e;for(;n<=t;)a[this.createDateElement(n)]=0,n=this.getNextDay(n);return a}getMonths(e){const t={};return Object.keys(e).map(e=>{e=e.substring(0,7);void 0===t[e]&&(t[e]=0)}),t}getDoubleMonths(e){const t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1];let s=0,o=a.substring(0,7),r=n.substring(0,7);return Object.keys(e).map(e=>{e=e.substring(0,7);o!==e&&r!==e&&(o=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getWeeks(e){let a={};return Object.keys(e).forEach(e=>{let t;t=15<moment(e).date()?e.substring(0,7)+"-15":e.substring(0,7)+"-01",void 0===a[t]&&(a[t]=0)}),a}getWeek(e){let t={},a=Object.keys(e)[Object.keys(e).length-1],n=0;return Object.keys(e).map(e=>{void 0===t[e]&&0==n%7&&(t[e]=0),n++}),void 0===t[a]&&(t[a]=0),t}getDoubleDays(e){let t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1],s=0;return Object.keys(e).map(e=>{a!==e&&n!==e&&(a=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getNextDay(e){const t=new Date(e);return t.setDate(e.getDate()+1),t}createDateElement(e){var t=(e.getMonth()+1<10?"0":"")+(e.getMonth()+1);return e.getFullYear()+"-"+t+"-"+("0"+e.getDate()).slice(-2)}getSetDates(e,t){let a,n;if(void 0!==e&&e)a=dlmReportsInstance.createDateElement(new Date(e));else{const s=new Date;s.setDate(s.getDate()-30),a=dlmReportsInstance.createDateElement(s)}if(void 0!==t&&t){e=new Date(t);n=dlmReportsInstance.createDateElement(e)}else{const o=new Date;o.setDate(o.getDate()+1),n=dlmReportsInstance.createDateElement(o)}return{startDate:a,endDate:n}}createDataOnDate(e,t){let{startDate:a,endDate:n}={...dlmReportsInstance.getSetDates(e,t)},s,o,r,d,l,c=(dlmReportsInstance.reportsData=void 0!==dlmReportsInstance.dlmReportsStats?JSON.parse(JSON.stringify(dlmReportsInstance.dlmReportsStats)):{},o=moment(n,"YYYY-MM-DD").month()-moment(a,"YYYY-MM-DD").month(),r=moment(n,"YYYY-MM-DD").year()-moment(a,"YYYY-MM-DD").year(),s=moment(n).date()-moment(a).date(),dlmReportsInstance.chartType="day",0==r&&-6<o&&o<6?1<o||o<-1?dlmReportsInstance.chartType=2==o?"week":"weeks":1==o&&(8<s||-14<s||0==s)&&(dlmReportsInstance.chartType="days"):o<=0?dlmReportsInstance.chartType="month":dlmReportsInstance.chartType="months",dlmReportsInstance.getDates(new Date(a),new Date(n))),m,i,p,g;switch(dlmReportsInstance.chartType){case"months":i=dlmReportsInstance.getDoubleMonths(c),l=i;break;case"month":var u=dlmReportsInstance.getMonths(c);l=u;break;case"weeks":p=dlmReportsInstance.getWeeks(c),l=p;break;case"week":g=dlmReportsInstance.getWeek(c),l=g;break;case"days":m=dlmReportsInstance.getDoubleDays(c),l=m;break;case"day":l=c}Object.values(dlmReportsInstance.reportsData).forEach((s,e)=>{var o=JSON.parse(s.download_ids);if(void 0!==c[s.date])switch(dlmReportsInstance.chartType){case"months":d=s.date.substring(0,7);let e=parseInt(s.date.substring(5,7)),t=s.date.substring(0,5),a=6<(e-1).length?t+(e-1):t+"0"+(e-1);Object.values(o).forEach((e,t)=>{void 0===i[d]?void 0!==i[a]&&(i[a]=i[a]+e.downloads):i[d]=i[d]+e.downloads}),l=i;break;case"month":d=s.date.substring(0,7),Object.values(o).forEach((e,t)=>{monthDownloads[d]=void 0!==monthDownloads[d]?monthDownloads[d]+e.downloads:e.downloads}),l=monthDownloads;break;case"weeks":d=15<moment(s.date).date()?s.date.substring(0,7)+"-15":s.date.substring(0,7)+"-01",Object.values(o).forEach((e,t)=>{p[d]=void 0!==p[d]?p[d]+e.downloads:e.downloads}),l=p;break;case"week":d=s.date,Object.values(o).forEach((t,e)=>{if(void 0===g[d])for(let e=1;e<8;e++){var a=moment(s.date).date(moment(s.date).date()-e).format("YYYY-MM-DD");void 0!==g[a]&&(g[a]=g[a]+t.downloads)}else g[d]=g[d]+t.downloads}),l=g;break;case"days":d=s.date;let n=moment(s.date).date(moment(s.date).date()-1).format("YYYY-MM-DD");Object.values(o).forEach((e,t)=>{void 0===m[d]?void 0!==m[n]&&(m[n]=m[n]+e.downloads):m[d]=m[d]+e.downloads}),l=m;break;case"day":Object.values(o).forEach((e,t)=>{c[s.date]=c[s.date]+e.downloads}),l=c}else delete dlmReportsInstance.reportsData[e]});const h=Object.keys(c);e=h.length,t=h.findIndex(e=>a===e);let I=h.findIndex(e=>n===e);-1===t&&-1===I?dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:!1,daysLength:e}:(-1===I&&(I=e),dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:dlmReportsInstance.reportsData,daysLength:e})}dlmCreateChart(t,a,n=!1){if(t&&a){let e=Chart.getChart("total_downloads_chart");dlmReportsInstance.chartDataObject={dataSetLabel:"Downloads",dataSetColor:"#27ae60",dataSetbg:dlmReportsInstance.chartGradient,dataSetPointbg:dlmReportsInstance.chartColors.darkCyan.default,dataSetBorder:dlmReportsInstance.chartColors.darkCyan.default,dataSetElementColor:"#2ecc71",lineType:"original",xAxis:"x",chartData:t},void 0!==e&&e.destroy(),jQuery(document).trigger("dlm_reports_before_data_sets",[dlmReportsInstance.chartDataObject,t,n]),0<dlmReportsInstance.dataSets.length&&(dlmReportsInstance.dataSets=dlmReportsInstance.dataSets.filter(e=>dlmReportsInstance.chartDataObject.lineType!==e.origin)),dlmReportsInstance.dataSets.push({origin:dlmReportsInstance.chartDataObject.lineType,label:dlmReportsInstance.chartDataObject.dataSetLabel,color:dlmReportsInstance.chartDataObject.dataSetColor,data:dlmReportsInstance.chartDataObject.chartData,type:"line",fill:!0,backgroundColor:dlmReportsInstance.chartDataObject.dataSetbg,pointBackgroundColor:dlmReportsInstance.chartDataObject.dataSetPointbg,pointHoverBackgroundColor:"#fff",borderColor:dlmReportsInstance.chartDataObject.dataSetBorder,pointBorderWidth:1,lineTension:.3,borderWidth:1,pointRadius:3,elements:{line:{borderColor:dlmReportsInstance.chartDataObject.dataSetElementColor,borderWidth:1},point:{radius:4,hoverRadius:4,pointStyle:"circle"}}});t=Object.values(dlmReportsInstance.dataSets).filter(e=>"original"===e.origin);let o=Object.keys(t[0].data);dlmReportsInstance.dataSets.sort(function(e,t){return"original"===e.origin?-1:1}),dlmReportsInstance.chart=new Chart(a,{title:"",data:{datasets:dlmReportsInstance.dataSets},height:450,is_series:1,options:{aspectRatio:5,animation:!1,interaction:{mode:"index",intersect:!1},stacked:!1,scales:{x:{grid:{display:!1},ticks:{callback:e=>{let t="";var a=o[e],n=o[o.length-1],s=moment(n).month(moment(n).month()-1).format("YYYY-MM");return t="undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?(e=moment(o[e]).month())<11?a===s?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+" - "+moment(a).month(e+1).format("MMM")+moment(a).format(", YYYY"):a===s||a===n?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+moment(a).format(" YYYY")+" - "+moment(a).month(e+1).format("MMM")+moment(a).month(e+1).format(", YYYY"):"undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?moment(a).format("MMMM, YYYY"):moment(a).format("D MMM")}}},y:{grid:{drawBorder:!1},min:0,max:0!==dlmReportsInstance.getMaxDownload()?1===Math.ceil(dlmReportsInstance.getMaxDownload()/10)?dlmReportsInstance.getMaxDownload()+1:10*Math.ceil(dlmReportsInstance.getMaxDownload()/10):100,ticks:{stepSize:0!==dlmReportsInstance.getMaxDownload()?Math.ceil(dlmReportsInstance.getMaxDownload()/4):25,callback:e=>dlmReportsInstance.shortNumber(e)}}},normalized:!0,parsing:{xAxisKey:"x",yAxisKey:"y"},plugins:{tooltip:{enabled:!1,external:dlmReportsInstance.externalTooltipHandler.bind(dlmReportsInstance,this)},legend:{display:!0}}}})}}dlmDownloadsSummary(){let a={};if(!1===dlmReportsInstance.stats||!1===dlmReportsInstance.stats.summaryStats||Object.keys(dlmReportsInstance.stats.summaryStats).length<=0)return this.setTotalDownloads(0),this.setDailyAverage(0),void this.setMostDownloaded("--");dlmReportsInstance.totalDownloads=0,dlmReportsInstance.stats.summaryStats.forEach(e=>{e=JSON.parse(e.download_ids),Object.entries(e).forEach(([e,t])=>{dlmReportsInstance.totalDownloads+=t.downloads,a[e]=void 0===a[e]?{downloads:t.downloads,title:t.title,id:e}:{downloads:a[e].downloads+t.downloads,title:t.title,id:e}})}),dlmReportsInstance.mostDownloaded=dlmReportsInstance.orderItems(Object.values(a),"desc","downloads"),dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads),dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads/parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0)),dlmReportsInstance.setMostDownloaded(dlmReportsInstance.mostDownloaded[0].title)}createDatepicker(e,t,a){const n=new Date;let s=n.getDate()-1,o=n.getMonth()+1,r=o-1;var d=n.getFullYear(),l=(s<10&&(s="0"+s),o<10&&(o="0"+o),r<10&&(r="0"+r),d+"-"+o+"-"+s),d=d+"-"+r+"-"+s,c=jQuery("<div>").addClass("dlm_rdrs_overlay"),a=jQuery("<div>").attr("id",a.replace("#",""));return"dlm-date-range-picker"===t.target?(dlmReportsInstance.startDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_start_date").attr("value",d),dlmReportsInstance.endDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_end_date").attr("value",l),c.append(a).append(dlmReportsInstance.startDateInput).append(dlmReportsInstance.endDateInput)):jQuery(document).trigger("dlm_create_date_picker_"+t.target,[dlmReportsInstance,c,a,d,l]),c}displayDatepicker(e,o){var t;if(jQuery(e)){if(t="#"+jQuery(e).attr("id").replace(/-/gi,"_"),"dlm-date-range-picker"===o.target){if(dlmReportsInstance.datePicker.opened)return;dlmReportsInstance.datePicker.opened=!0}else jQuery(document).trigger("dlm_display_datepicker_"+o.target,[dlmReportsInstance,o,e]);let s=dlmReportsInstance.createDatepicker(e,o,t);e.append(s);var a=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,n=(new Date,[]),e=(jQuery(document).trigger("dlm_datepicker_shortcuts_"+o.target,[dlmReportsInstance,o,e,n]),{separator:" to ",autoClose:!0,getValue:function(){},setValue:function(e,t,a){s.find('input[type="hidden"]').first().val(t),s.find('input[type="hidden"]').last().val(a)},inline:!0,alwaysOpen:!0,container:t,endDate:new Date,startDate:a,showShortcuts:!0,shortcuts:null,customShortcuts:n});s.dateRangePicker(e).on("datepicker-change",(e,t)=>{var a,n;t.date1&&t.date2&&(a=t.date1.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),n=t.date2.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),s.parent().find("span.date-range-info").text(a+" - "+n)),"dlm-date-range-picker"===o.target?(dlmReportsInstance.dates.downloads={start_date:t.date1,end_date:t.date2},dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer,!1),dlmReportsInstance.dlmDownloadsSummary(),0<Object.values(dlmReportsInstance.dlmUsersStats.logs).length&&dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date)):jQuery(document).trigger("dlm_daterangepicker_init_"+o.target,[dlmReportsInstance,t.date1,t.date2]),dlmReportsInstance.setTopDownloads(),s.data("dateRangePicker").close()}),"dlm-date-range-picker"===o.target?s.data("dateRangePicker").setDateRange(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date):jQuery(document).trigger("dlm_daterangepicker_after_init_"+o.target,[s,dlmReportsInstance])}}hideDatepicker(e,t){"dlm-date-range-picker"===t.target?dlmReportsInstance.datePicker.opened=!1:jQuery(document).trigger("dlm_hide_datepicker_"+t.target,[dlmReportsInstance,e,t]),e.find(".dlm_rdrs_overlay").remove()}toggleDatepicker(e){e.stopPropagation();const t=jQuery(e.target).parents(".dlm-reports-header-date-selector");e={target:t.attr("id"),object:dlmReportsInstance.datePicker};dlmReportsInstance.closeDatePickers(t),"dlm-date-range-picker"===e.target?dlmReportsInstance.datePicker.opened?dlmReportsInstance.hideDatepicker(t,e):dlmReportsInstance.displayDatepicker(t,e):jQuery(document).trigger("dlm_toggle_datepicker_"+e.target,[dlmReportsInstance,t,e])}setTotalDownloads(e){jQuery(".dlm-reports-block-summary li#total span").html(e.toLocaleString())}setDailyAverage(e){jQuery(".dlm-reports-block-summary li#average span").html(e.toLocaleString())}setMostDownloaded(e){jQuery(".dlm-reports-block-summary li#popular span").html(e)}setTodayDownloads(){let e=0;Object.keys(dlmReportsInstance.dlmReportsStats).length<=0?jQuery(".dlm-reports-block-summary li#today span").html(e.toLocaleString()):(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].date===dlmReportsInstance.createDateElement(new Date)&&(e=Object.values(JSON.parse(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].download_ids)).reduce((e,t)=>e+t.downloads,0)),jQuery(".dlm-reports-block-summary li#today span").html(e))}setTopDownloads(e=0,t=!1){const a=jQuery("#total_downloads_table_wrapper2"),n=jQuery("#total_downloads_table_wrapper2 .total_downloads_table__list");if(n.empty(),n.parent().addClass("empty"),dlmReportsInstance.mostDownloaded&&!0!==t){var s=JSON.parse(JSON.stringify(dlmReportsInstance.mostDownloaded)).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<s.length;e++){const r=dlmReportsInstance.getDownloadByID(s[e].id);if(void 0===r)return;var o={id:s[e].id,title:s[e].title,edit_link:dlmAdminUrl+"post.php?post="+s[e].id+"&action=edit",total_downloads:r.total.toLocaleString()};jQuery(document).trigger("dlm_reports_top_downloads_item_before_render",[o,dlmReportsInstance,s[e],r]),new dlmBackBone.modelTopDownloads(o)}n.parent().removeClass("empty"),10<dlmReportsInstance.mostDownloaded.length?a.find(".downloads-block-navigation button").removeClass("hidden"):a.find(".downloads-block-navigation button").addClass("hidden"),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))}}handleTopDownloads(){jQuery("html body").on("click","#total_downloads_table_wrapper2 .downloads-block-navigation button",function(){let e=jQuery(this).parents("#total_downloads_table_wrapper2"),t=e,a=e.attr("data-page"),n=jQuery(this),s=parseInt(a)+1,o=0!==a?parseInt(a)-1:0,r=e.find(".downloads-block-navigation").find("button").first(),d=e.find(".downloads-block-navigation").find("button").last();n.attr("disabled","disabled");var l={data:dlmReportsInstance.mostDownloaded,main_parent:e,offsetHolder:t,offset:a,link:n,nextPage:s,prevPage:o,prevButton:r,nextButton:d,doAction:dlmReportsInstance.setTopDownloads};dlmReportsInstance.handleSliderNavigation(l)})}handleSliderNavigation(e){const{data:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:c}={...e};"load-more"===s.data("action")?(a.attr("data-page",o),c(o),Math.ceil(t.length/10)>o+1&&l.removeAttr("disabled"),d.removeAttr("disabled")):0!==parseInt(n)&&(a.attr("data-page",r),c(r),1!==parseInt(n)&&d.removeAttr("disabled"),l.removeAttr("disabled"))}tabNagivation(){jQuery(document).on("click",".dlm-reports .dlm-insights-tab-navigation > li",function(){const e=jQuery(this),t=jQuery(".dlm-reports .dlm-insights-tab-navigation > li").not(e),a=jQuery('div.dlm-insights-tab-navigation__content[data-id="'+e.attr("id")+'"]'),n=jQuery("div.dlm-insights-tab-navigation__content").not(a);e.hasClass("active")||(e.addClass("active"),t.removeClass("active"),a.addClass("active"),n.removeClass("active"))})}getOrCreateTooltip(e){let t=e.canvas.parentNode.querySelector("div.dlm-canvas-tooltip"),a=e.canvas.parentNode.querySelector("div.dlm-reports-tooltip__line");if(t||((a=document.createElement("div")).className="dlm-reports-tooltip__line"),!t){(t=document.createElement("div")).className="dlm-canvas-tooltip";const n=document.createElement("div");n.className="dlm-reports-tooltip",t.appendChild(n),e.canvas.parentNode.appendChild(t),e.canvas.parentNode.appendChild(a)}return{tooltipEl:t,tooltipLine:a}}externalTooltipHandler(d,e){const{chart:t,tooltip:l}=e,{tooltipEl:a,tooltipLine:n}={...d.getOrCreateTooltip(t)};e=jQuery(a).parent().width();if(0===l.opacity)return a.style.opacity=0,void(n.style.opacity=0);if(l.body){const c=l.title||[],m=document.createElement("div"),i=(m.className="dlm-reports-tooltip__header",c.forEach(e=>{const t=document.createElement("div"),a=(t.className="dlm-reports-tooltip__row",document.createElement("p")),n=(a.className="dlm-reports-tooltip__info",a.appendChild(document.createTextNode("Downloads")),t.appendChild(a),jQuery(document).trigger("dlm_chart_tooltip_before",[dlmReportsInstance,l,t,d]),document.createElement("p"));n.className="dlm-reports-tooltip__date";var s=dlmReportsInstance.setChartTooltipDate(l.dataPoints[0].label,d,d.stats.chartStats);n.appendChild(document.createTextNode(s)),t.appendChild(n);const o=document.createElement("p"),r=(o.className="dlm-reports-tooltip__downloads",document.createElement("span"));r.className="dlm-reports-tooltip__downloads_pointer",r.style.backgroundColor=dlmReportsInstance.chartColors.darkCyan.default,o.appendChild(r),o.appendChild(document.createTextNode(dlmReportsInstance.shortNumber(l.dataPoints[0].formattedValue))),t.appendChild(o),jQuery(document).trigger("dlm_chart_tooltip_after",[dlmReportsInstance,l,t,d]),m.appendChild(t)}),a.querySelector("div.dlm-reports-tooltip"));for(;i.firstChild;)i.firstChild.remove();i.appendChild(m)}var{offsetLeft:s,offsetTop:o}=t.canvas;a.style.opacity=1;let r={isMargin:!(n.style.opacity=1),left:!1};l.caretX-l.width<0&&(r.isMargin=!0,r.left=!0),s+l.caretX+l.width>e&&(r.isMargin=!0,r.left=!1),r.isMargin?r.left?a.style.left=s+l.width+"px":a.style.left=e-l.width+"px":a.style.left=s+l.caretX+"px",n.style.left=s+l.caretX+"px",a.style.top=o+l.caretY-a.offsetHeight-10+"px"}createUserRelatedData(){dlmReportsInstance.userRelatedData=[],Object.values(dlmReportsInstance.userDownloads).forEach((e,t)=>{var a;"0"!==e.user_id&&(a=[e.user_id,e.download_id,e.download_date,e.download_status],e="user_"+e.user_id,void 0!==dlmReportsInstance.userRelatedData[e]?dlmReportsInstance.userRelatedData[e].push(a):dlmReportsInstance.userRelatedData[e]=[a])})}logsDataByDate(e,t){var{startDate:e,endDate:t}={...dlmReportsInstance.getSetDates(e,t)};dlmReportsInstance.userDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs));let a=new Date(e),n=(a.setDate(a.getDate()-1),a=a.getTime(),new Date(t));n.setDate(n.getDate()+1),n=n.getTime(),dlmReportsInstance.userDownloads=dlmReportsInstance.userDownloads.filter((e,t)=>{e=dlmReportsInstance.createDateElement(new Date(e.download_date));return(e=new Date(e).getTime())>a&&e<n}),dlmReportsInstance.createUserRelatedData(),dlmReportsInstance.filterDownloads(),dlmReportsInstance.setMostActiveUser(),dlmReportsInstance.setLoggedOutDownloads(),dlmReportsInstance.setLoggedInDownloads(),jQuery(document).trigger("dlm_set_logs_data_by_date",[dlmReportsInstance])}setMostActiveUser(){var e=dlmReportsInstance.getUserByID(dlmReportsInstance.getMostActiveID()[0]);jQuery(".dlm-reports-block-summary li#most_active_user span").html(dlmReportsInstance.userToolTipMarkup(e))}getMostActiveID(){return Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t,a)=>parseInt(e.length)>parseInt(t.length)&&0<e.length&&null!==dlmReportsInstance.getUserByID(e[0][0])?e:null!==dlmReportsInstance.getUserByID(t[0][0])?t:[],[]):0}getUserByID(t){if(!t||"0"===t)return null;var e=Object.values(dlmReportsInstance.dlmUsersStats.users).filter(e=>parseInt(t)===parseInt(e.id));return Array.isArray(e)?0===e.length?null:e[0]:e}getLoggedInDownloads(){return Object.values(dlmReportsInstance.userRelatedData).length?1<Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t)=>parseInt(e)+parseInt(t.length),0):Object.values(dlmReportsInstance.userRelatedData)[0].length:0}setLoggedInDownloads(){const e=dlmReportsInstance.getLoggedInDownloads();jQuery(".dlm-reports-block-summary li#logged_in span,#total_downloads_summary_wrapper .dlm-reports-logged-in").html(e.toLocaleString())}getLoggedOutDownloads(){return dlmReportsInstance.userDownloads.length-dlmReportsInstance.getLoggedInDownloads()}setLoggedOutDownloads(){const e=dlmReportsInstance.getLoggedOutDownloads();jQuery(".dlm-reports-block-summary li#logged_out span,#total_downloads_summary_wrapper .dlm-reports-logged-out").html(e.toLocaleString())}userToolTipMarkup(e){let t='<div class="dlm-user-reports">';return t=(t=t+'<div class="wpchill-tooltip"><i>[?]</i>'+'<div class="wpchill-tooltip-content">')+("<span>User ID: "+(null!==e?e.id:"--")+"</span>"),"object"!=typeof e&&e.url.length&&(t+="<span>User URL: "+(null!==e?e.url:"--")+"</span>"),t+="<span>User registration date: "+(null!==e?e.registered:"--")+"</span>",null!==e&&void 0!==e.role&&e.role.length&&(t+="<span>User role: "+e.role+"</span>"),t=(t+="</div></div>")+(null!==e?e.display_name:"--")+"</div>"}setUserDownloads(e=0,t=!1){const a=jQuery("#users_download_log"),n=jQuery("#users_download_log .user-logs__list");if(n.empty(),!0!==t){let t=[];t=(null!==dlmReportsInstance.tempDownloads?JSON.parse(JSON.stringify(dlmReportsInstance.tempDownloads)):JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads))).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<t.length;e++){var s=dlmReportsInstance.getUserByID(t[e].user_id.toString()),o=dlmReportsInstance.getDownloadCPT(t[e].download_id.toString()),r={key:e,user:"0"!==t[e].user_id&&null!=s?s.display_name:"--",ip:t[e].user_ip,role:null!==s&&null!==s.role?s.role:"--",download:void 0!==o?o.title:"--",valid_user:"0"!==t[e].user_id,edit_link:"user-edit.php?user_id="+t[e].user_id,edit_download_link:void 0!==o?dlmAdminUrl+"post.php?post="+o.id+"&action=edit":"#",status:t[e].download_status,download_date:t[e].download_date};jQuery(document).trigger("dlm_reports_user_logs_item_before_render",[r,dlmReportsInstance,t[e],s,o]),new dlmBackBone.modelUserLogs(r)}dlmReportsInstance.stopSpinner(jQuery("#users_download_log")),10!==t.length?a.find('.user-downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.user-downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),10<dlmReportsInstance.userDownloads.length?a.find(".user-downloads-block-navigation button").removeClass("hidden"):a.find(".user-downloads-block-navigation button").addClass("hidden")}}filterDownloads(){dlmReportsInstance.tempDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads)),dlmReportsInstance.currentFilters.length&&dlmReportsInstance.currentFilters.forEach(t=>{dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.filter(e=>t.on===e[t.type])}),dlmReportsInstance.setUserDownloads()}handleUserDownloads(){jQuery(".user-downloads-block-navigation").on("click","button",function(e){e.stopPropagation();let t=jQuery(this).parents("#users_downloads_table_wrapper"),a=t.find("#users_download_log"),n=a.attr("data-page"),s=jQuery(this),o=parseInt(n)+1,r=0!==n?parseInt(n)-1:0,d=t.find(".downloads-block-navigation button").first(),l=t.find(".downloads-block-navigation button").last();s.attr("disabled","disabled");e={data:dlmReportsInstance.tempDownloads,main_parent:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:dlmReportsInstance.setUserDownloads};dlmReportsInstance.handleSliderNavigation(e)})}togglePageSettings(){jQuery("#dlm-toggle-settings").on("click",function(e){e.stopPropagation(),jQuery(this).find(".dlm-toggle-settings__settings").toggleClass("display")}),jQuery(".dlm-toggle-settings__settings").on("click",function(e){e.stopPropagation()}),jQuery("html,body").on("click",function(){jQuery(this).find(".dlm-toggle-settings__settings").removeClass("display")}),jQuery(document).on("change",".wpchill-toggle__input",function(e){const t=jQuery(this),a=t.attr("name"),n={action:"dlm_update_report_setting",name:a,checked:t.is(":checked"),_ajax_nonce:dlmReportsNonce};jQuery.post(ajaxurl,n,function(e){a,jQuery(document).trigger("dlm_settings_ajax_response",[dlmReportsInstance,t,e])})})}getMaxDownload(){let t=0;return dlmReportsInstance.dataSets.forEach(e=>{e=Object.values(e.data).reduce((e,t)=>t<e?e:t,0);t<e&&(t=e)}),parseInt(t)}setChartTooltipDate(e,t,a){let n="";var s,o,r;return n="undefined"!==t.chartType&&"months"===t.chartType?(moment(e).year(),s=moment(e).month(),a=Object.keys(a)[Object.keys(a).length-1],o=moment(a).month(moment(a).month()-1).format("YYYY-MM"),r=moment(e).format("YYYY-MM"),s<11?r===o?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+" - "+moment(e).month(s+1).format("MMM")+moment(e).format(", YYYY"):r===o||r===a?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+moment(e).format(" YYYY")+" - "+moment(e).month(s+1).format("MMM")+moment(e).month(s+1).format(", YYYY")):"undefined"!==t.chartType&&"months"===t.chartType?moment(e).format("MMMM, YYYY"):moment(e).format("MMMM Do, YY")}closeDatePickers(e){jQuery(".dlm-reports-header-date-selector").not(e).each(function(){var e={target:jQuery(this).attr("id")};dlmReportsInstance.hideDatepicker(jQuery(this),e)})}shortNumber(e){return e=4<=(e="string"==typeof e?e.replace(/,/gi,""):parseInt(e).toString()).length?parseInt(e.substring(0,e.length-3)).toLocaleString()+"k":e}getDownloadByID(t){let a={total:0},n;return dlmReportsInstance.tempDownloads.forEach(function(e){t===e.download_id&&(n=e,a.total=a.total+1,jQuery(document).trigger("dlm_download_by_id",[dlmReportsInstance,a,n]))}),a}getDownloadCPT(t){var e=dlmReportsInstance.mostDownloaded.filter(e=>e.id===t,0)[0];return jQuery(document).trigger("dlm_download_cpt",[dlmReportsInstance,e]),e}setSpinner(e){e.append('<div class="dlm-reports-spinner"><span></span></div>')}stopSpinner(e){e.find(".dlm-reports-spinner").remove()}eventsFunctions(){jQuery("body").on("click",".total_downloads_table_filters_total_downloads > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderOverviewItemsByTotal()}),jQuery("body").on("click",".total_downloads_table_filters_download_date > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderUserReportsItemsByDate()})}orderItems(e,a,n,t=0){return e.sort((e,t)=>"asc"!==a?t[n]-e[n]:e[n]-t[n]),e}orderOverviewItemsByTotal(){dlmReportsInstance.mostDownloaded=dlmReportsInstance.mostDownloaded.reverse(),dlmReportsInstance.setTopDownloads()}orderUserReportsItemsByDate(){dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.reverse(),dlmReportsInstance.setUserDownloads()}}
assets/js/upload-file.js DELETED
@@ -1,79 +0,0 @@
1
- jQuery(function ($) {
2
-
3
- /**
4
- * Set up the Media Uploader
5
- */
6
-
7
- let dlmUploadButtons = [];
8
- $('.dlm_upload_file').each((index, element) => {
9
-
10
- dlmUploadButtons.push($(element));
11
-
12
- const dlmUploaderOptions = {
13
- browser: $(element),
14
- plupload: {
15
- multi_selection: false,
16
- },
17
- params: {
18
- type: 'dlm_download'
19
- }
20
- },
21
- dlmUploader = new wp.Uploader(dlmUploaderOptions);
22
-
23
- dlmUploader.uploader.bind('FilesAdded', dlmFileAdded);
24
- dlmUploader.uploader.bind('FileUploaded', dlmAddFileToPath);
25
- });
26
-
27
-
28
- $(document).on('dlm_new_file_added', () => {
29
-
30
- $('.dlm_upload_file').each((index, element) => {
31
-
32
- if (dlmUploadButtons.includes($(element))) {
33
- return true;
34
- }
35
-
36
- dlmUploadButtons.push($(element));
37
-
38
- const dlmUploaderOptions = {
39
- browser: $(element),
40
- plupload: {
41
- multi_selection: false,
42
- },
43
- params: {
44
- type: 'dlm_download'
45
- }
46
- },
47
- dlmUploader = new wp.Uploader(dlmUploaderOptions);
48
- dlmUploader.uploader.bind('FilesAdded', dlmFileAdded);
49
- dlmUploader.uploader.bind('FileUploaded', dlmAddFileToPath);
50
- });
51
-
52
- });
53
-
54
- /**
55
- * Add the file url to File URLs meta
56
- * @param {*} up
57
- * @param {*} file
58
- */
59
- function dlmAddFileToPath(up, file) {
60
-
61
- const fileUrl = file.attachment.attributes.url;
62
- const fileURLs = jQuery(up.settings.browse_button).parents('td').find('textarea');
63
- fileURLs.parent().removeClass('dlm-blury');
64
- let filePaths = fileURLs.val();
65
- filePaths = filePaths ? filePaths + "\n" + fileUrl : fileUrl;
66
- fileURLs.val(filePaths);
67
- }
68
-
69
- /**
70
- * Blur the textarea so the user knows it is loading
71
- * @param {*} up
72
- * @param {*} file
73
- */
74
- function dlmFileAdded(up, file) {
75
-
76
- const fileURLs = jQuery(up.settings.browse_button).parents('td').find('textarea');
77
- fileURLs.parent().addClass('dlm-blury');
78
- }
79
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/upload-file.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(function(a){let n=[];function o(e,d){d=d.attachment.attributes.url;const l=jQuery(e.settings.browse_button).parents("td").find("textarea");l.parent().removeClass("dlm-blury");let t=l.val();t=t?t+"\n"+d:d,l.val(t)}function r(e,d){const l=jQuery(e.settings.browse_button).parents("td").find("textarea");l.parent().addClass("dlm-blury")}a(".dlm_upload_file").each((e,d)=>{n.push(a(d));const l={browser:a(d),plupload:{multi_selection:!1},params:{type:"dlm_download"}},t=new wp.Uploader(l);t.uploader.bind("FilesAdded",r),t.uploader.bind("FileUploaded",o)}),a(document).on("dlm_new_file_added",()=>{a(".dlm_upload_file").each((e,d)=>{if(n.includes(a(d)))return!0;n.push(a(d));const l={browser:a(d),plupload:{multi_selection:!1},params:{type:"dlm_download"}},t=new wp.Uploader(l);t.uploader.bind("FilesAdded",r),t.uploader.bind("FileUploaded",o)})})});
 
changelog.txt CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  = 4.6.0 - 20.09.2022 =
2
  Fixed: Flush permalinks on install/update to prevent 404s ( [#1036](https://github.com/WPChill/download-monitor/issues/1036) )
3
  Changed: Don't display DLM Uploads in Media Library ( [#1014](https://github.com/WPChill/download-monitor/issues/1014) )
1
+ = 4.6.1 - 26.09.2022 =
2
+ Fixed: User reports user fetching and displaying was broken ( [#1040](https://github.com/WPChill/download-monitor/issues/1040) ).
3
+ Fixed: Versions did not add the meta to the count ( [#1041](https://github.com/WPChill/download-monitor/issues/1041) ).
4
+ Fixed: Increase meta count if user wants ( [#1042](https://github.com/WPChill/download-monitor/issues/1042) )
5
+ Fixed: Add ordering to tables ( [#1044](https://github.com/WPChill/download-monitor/issues/1044) )
6
+ Fixed: XHR loader animation and visibility ( [#1045](https://github.com/WPChill/download-monitor/issues/1045) )
7
+
8
  = 4.6.0 - 20.09.2022 =
9
  Fixed: Flush permalinks on install/update to prevent 404s ( [#1036](https://github.com/WPChill/download-monitor/issues/1036) )
10
  Changed: Don't display DLM Uploads in Media Library ( [#1014](https://github.com/WPChill/download-monitor/issues/1014) )
download-monitor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Download Monitor
4
  Plugin URI: https://www.download-monitor.com
5
  Description: A full solution for managing and selling downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
- Version: 4.6.0
7
  Author: WPChill
8
  Author URI: https://wpchill.com
9
  Requires at least: 5.4
@@ -34,7 +34,7 @@ if ( ! defined( 'ABSPATH' ) ) {
34
 
35
  // Define DLM Version
36
 
37
- define( 'DLM_VERSION', '4.6.0' );
38
  define( 'DLM_UPGRADER_VERSION', '4.6.0' );
39
 
40
  // Define DLM FILE
3
  Plugin Name: Download Monitor
4
  Plugin URI: https://www.download-monitor.com
5
  Description: A full solution for managing and selling downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
+ Version: 4.6.1
7
  Author: WPChill
8
  Author URI: https://wpchill.com
9
  Requires at least: 5.4
34
 
35
  // Define DLM Version
36
 
37
+ define( 'DLM_VERSION', '4.6.1' );
38
  define( 'DLM_UPGRADER_VERSION', '4.6.0' );
39
 
40
  // Define DLM FILE
includes/backwards-compatibility/class-dlm-backwards-compatibility.php CHANGED
@@ -272,7 +272,10 @@ class DLM_Backwards_Compatibility {
272
  */
273
  public function meta_download_counts( $counts, $id ) {
274
 
275
- if ( isset( $this->upgrade_option['using_logs'] ) && '0' === $this->upgrade_option['using_logs'] ) {
 
 
 
276
 
277
  if ( 'dlm_download_version' === get_post_type( $id ) ) {
278
  $meta_counts = get_post_meta( get_post_parent( $id )->ID, '_download_count', true );
@@ -366,5 +369,4 @@ class DLM_Backwards_Compatibility {
366
 
367
  return $counts;
368
  }
369
-
370
  }
272
  */
273
  public function meta_download_counts( $counts, $id ) {
274
 
275
+ // Filter to enable adding meta counts to download counts.
276
+ $count_meta = apply_filters( 'dlm_count_meta_downloads', false );
277
+
278
+ if ( ( isset( $this->upgrade_option['using_logs'] ) && '0' === $this->upgrade_option['using_logs'] ) || $count_meta ) {
279
 
280
  if ( 'dlm_download_version' === get_post_type( $id ) ) {
281
  $meta_counts = get_post_meta( get_post_parent( $id )->ID, '_download_count', true );
369
 
370
  return $counts;
371
  }
 
372
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpchill, silkalns, barrykooij, mikejolley
3
  Tags: download manager, document management, file manager, digital store, ecommerce, document management plugin, download monitor, download counter, password protection, download protection, password, protect downloads, tracker, sell, shop, ecommerce, paypal
4
  Requires at least: 5.4
5
  Tested up to: 6.0
6
- Stable tag: 4.6.0
7
  License: GPLv3
8
  Text Domain: -
9
  Requires PHP: 5.6
@@ -121,6 +121,13 @@ More documentation can be found in our [Knowledge Base](https://www.download-mon
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
 
 
124
  = 4.6.0 - 20.09.2022 =
125
  Fixed: Flush permalinks on install/update to prevent 404s ( [#1036](https://github.com/WPChill/download-monitor/issues/1036) )
126
  Changed: Don't display DLM Uploads in Media Library ( [#1014](https://github.com/WPChill/download-monitor/issues/1014) )
3
  Tags: download manager, document management, file manager, digital store, ecommerce, document management plugin, download monitor, download counter, password protection, download protection, password, protect downloads, tracker, sell, shop, ecommerce, paypal
4
  Requires at least: 5.4
5
  Tested up to: 6.0
6
+ Stable tag: 4.5.99
7
  License: GPLv3
8
  Text Domain: -
9
  Requires PHP: 5.6
121
 
122
  == Changelog ==
123
 
124
+ = 4.6.1 - 26.09.2022 =
125
+ Fixed: User reports user fetching and displaying was broken ( [#1040](https://github.com/WPChill/download-monitor/issues/1040) ).
126
+ Fixed: Versions did not add the meta to the count ( [#1041](https://github.com/WPChill/download-monitor/issues/1041) ).
127
+ Fixed: Increase meta count if user wants ( [#1042](https://github.com/WPChill/download-monitor/issues/1042) )
128
+ Fixed: Add ordering to tables ( [#1044](https://github.com/WPChill/download-monitor/issues/1044) )
129
+ Fixed: XHR loader animation and visibility ( [#1045](https://github.com/WPChill/download-monitor/issues/1045) )
130
+
131
  = 4.6.0 - 20.09.2022 =
132
  Fixed: Flush permalinks on install/update to prevent 404s ( [#1036](https://github.com/WPChill/download-monitor/issues/1036) )
133
  Changed: Don't display DLM Uploads in Media Library ( [#1014](https://github.com/WPChill/download-monitor/issues/1014) )
src/Admin/Reports/class-dlm-reports.php CHANGED
@@ -320,14 +320,14 @@ if ( ! class_exists( 'DLM_Reports' ) ) {
320
  }
321
 
322
  $cache_key = 'dlm_insights_users';
323
- $user_data = array();
324
-
325
  $stats = wp_cache_get( $cache_key, 'dlm_user_data' );
 
326
  if ( ! $stats ) {
327
  $users = get_users();
328
  foreach ( $users as $user ) {
329
  $user_data = $user->data;
330
- $users_data[ $user_data->ID ] = array(
331
  'id' => $user_data->ID,
332
  'nicename' => $user_data->user_nicename,
333
  'url' => $user_data->user_url,
@@ -338,8 +338,7 @@ if ( ! class_exists( 'DLM_Reports' ) ) {
338
  }
339
  wp_cache_set( $cache_key, $user_data, 'dlm_user_data', 12 * HOUR_IN_SECONDS );
340
  }
341
-
342
- return $user_data;
343
  }
344
 
345
  /**
320
  }
321
 
322
  $cache_key = 'dlm_insights_users';
323
+ $users_data = array();
 
324
  $stats = wp_cache_get( $cache_key, 'dlm_user_data' );
325
+
326
  if ( ! $stats ) {
327
  $users = get_users();
328
  foreach ( $users as $user ) {
329
  $user_data = $user->data;
330
+ $users_data[] = array(
331
  'id' => $user_data->ID,
332
  'nicename' => $user_data->user_nicename,
333
  'url' => $user_data->user_url,
338
  }
339
  wp_cache_set( $cache_key, $user_data, 'dlm_user_data', 12 * HOUR_IN_SECONDS );
340
  }
341
+ return $users_data;
 
342
  }
343
 
344
  /**
src/Admin/Reports/components/php-components/top-downloads-header.php CHANGED
@@ -7,7 +7,7 @@ if ( ! empty( $dlm_top_downloads['top_downloads']['table_headers'] ) ) {
7
  echo '<table class="dlm-reports-table__table"><thead><tr class="dlm-reports-table__filters">';
8
 
9
  foreach ( $dlm_top_downloads['top_downloads']['table_headers'] as $key => $table_header ) {
10
- echo '<th scope="col" class="total_downloads_table_filters_' . esc_attr( $key ) . '">' . esc_html( $table_header ) . '</td>';
11
  }
12
 
13
  echo '</tr></thead><!--/.dlm-reports-dlm-reports-table__filters--><!--/.dlm-reports-dlm-reports-table__table-->';
7
  echo '<table class="dlm-reports-table__table"><thead><tr class="dlm-reports-table__filters">';
8
 
9
  foreach ( $dlm_top_downloads['top_downloads']['table_headers'] as $key => $table_header ) {
10
+ echo '<th scope="col" class="total_downloads_table_filters_' . esc_attr( $key ) . '">' . ( 'total_downloads' === $key ? '<a href="#">' . esc_html( $table_header ) . '</a><span class="dashicons dashicons-arrow-down"></span>' : esc_html( $table_header ) ) . '</td>';
11
  }
12
 
13
  echo '</tr></thead><!--/.dlm-reports-dlm-reports-table__filters--><!--/.dlm-reports-dlm-reports-table__table-->';
src/Admin/Reports/components/php-components/user-logs-header.php CHANGED
@@ -7,7 +7,7 @@ if ( ! empty( $dlm_top_downloads['user_logs']['table_headers'] ) ) {
7
  echo '<table class="dlm-reports-table__table"><thead><tr class="dlm-reports-table__filters">';
8
 
9
  foreach ( $dlm_top_downloads['user_logs']['table_headers'] as $key => $table_header ) {
10
- echo '<th scope="col" class="total_downloads_table_filters_' . esc_attr( $key ) . '">' . esc_html( $table_header ) . '</th>';
11
  }
12
 
13
  echo '</tr></thead><!--/.dlm-reports-dlm-reports-table__filters--><!--/.dlm-reports-dlm-reports-table__table-->';
7
  echo '<table class="dlm-reports-table__table"><thead><tr class="dlm-reports-table__filters">';
8
 
9
  foreach ( $dlm_top_downloads['user_logs']['table_headers'] as $key => $table_header ) {
10
+ echo '<th scope="col" class="total_downloads_table_filters_' . esc_attr( $key ) . '">' . ( 'download_date' === $key ? '<a href="#">' . esc_html( $table_header ) . '</a><span class="dashicons dashicons-arrow-down"></span>' : esc_html( $table_header ) ) . '</th>';
11
  }
12
 
13
  echo '</tr></thead><!--/.dlm-reports-dlm-reports-table__filters--><!--/.dlm-reports-dlm-reports-table__table-->';
src/DLM.php CHANGED
@@ -132,9 +132,10 @@ class WP_DLM {
132
  deactivate_plugins( 'dlm-download-duplicator/dlm-download-duplicator.php' );
133
  }
134
 
135
- if ( defined( 'DLM_BETA' ) && DLM_BETA && class_exists( 'DLM_Beta_Testers') ) {
 
136
  new DLM_Beta_Testers();
137
- }
138
 
139
  new DLM_Review();
140
 
132
  deactivate_plugins( 'dlm-download-duplicator/dlm-download-duplicator.php' );
133
  }
134
 
135
+ // The beta testers class
136
+ /*if ( defined( 'DLM_BETA' ) && DLM_BETA && class_exists( 'DLM_Beta_Testers') ) {
137
  new DLM_Beta_Testers();
138
+ }*/
139
 
140
  new DLM_Review();
141
 
src/Logs/LogExportCSV.php DELETED
@@ -1,150 +0,0 @@
1
- <?php
2
- // @todo razvan : Probably will export from table download_logs, but only the remaining data
3
- class DLM_Log_Export_CSV {
4
-
5
- /**
6
- * Check if is allowed
7
- *
8
- * @return bool
9
- */
10
- private function is_allowed() {
11
-
12
- if ( empty( $_GET['dlm_download_logs'] ) ) {
13
- return false;
14
- }
15
-
16
- if ( ! current_user_can( 'manage_downloads' ) ) {
17
- return false;
18
- }
19
-
20
- return true;
21
- }
22
-
23
- /**
24
- * Run
25
- */
26
- public function run() {
27
- global $wpdb;
28
-
29
- // check if allowed
30
- if ( ! $this->is_allowed() ) {
31
- wp_die( "You're not allowed to export logs." );
32
- }
33
-
34
- // catch and sanitize filter values
35
- $filter_status = isset( $_REQUEST['filter_status'] ) ? sanitize_text_field( wp_unslash($_REQUEST['filter_status']) ) : '';
36
- $filter_month = ! empty( $_REQUEST['filter_month'] ) ? sanitize_text_field( wp_unslash($_REQUEST['filter_month']) ) : '';
37
-
38
- // setup filters
39
- $filters = array();
40
-
41
- // setup month filter
42
- if ( ! empty( $filter_month ) ) {
43
- $filters[] = array(
44
- 'key' => 'download_date',
45
- 'value' => date( 'Y-m-01', strtotime( $filter_month ) ),
46
- 'operator' => '>='
47
- );
48
-
49
- $filters[] = array(
50
- 'key' => 'download_date',
51
- 'value' => date( 'Y-m-t', strtotime( $filter_month ) ),
52
- 'operator' => '<='
53
- );
54
- }
55
-
56
- // get downloads
57
- $items = download_monitor()->service( 'log_item_repository' )->retrieve( $filters );
58
-
59
- // rows
60
- $rows = array();
61
- $row = array();
62
- $row[] = __( 'Download ID', 'download-monitor' );
63
- $row[] = __( 'Download Title', 'download-monitor' );
64
- $row[] = __( 'Version ID', 'download-monitor' );
65
- $row[] = __( 'Filename', 'download-monitor' );
66
- $row[] = __( 'User ID', 'download-monitor' );
67
- $row[] = __( 'User Login', 'download-monitor' );
68
- $row[] = __( 'User Email', 'download-monitor' );
69
- $row[] = __( 'Date', 'download-monitor' );
70
- $row[] = __( 'Meta Data', 'download-monitor' );
71
- $rows[] = '"' . implode( '","', $row ) . '"';
72
-
73
- if ( ! empty( $items ) ) {
74
-
75
- /** @var DLM_Log_Item $item */
76
- foreach ( $items as $item ) {
77
-
78
- try {
79
- /** @var DLM_Download $download */
80
- $download = download_monitor()->service( 'download_repository' )->retrieve_single( $item->get_download_id() );
81
- } catch ( Exception $e ) {
82
- $download = new DLM_Download();
83
- }
84
-
85
- try {
86
- $version = download_monitor()->service( 'version_repository' )->retrieve_single( $item->get_version_id() );
87
- $download->set_version( $version );
88
- } catch ( Exception $e ) {
89
-
90
- }
91
-
92
- $row = array();
93
- $row[] = $item->get_download_id();
94
-
95
- if ( $download->exists() ) {
96
- $row[] = $download->get_title();
97
- } else {
98
- $row[] = '-';
99
- }
100
-
101
- $row[] = $item->get_version_id();
102
-
103
- if ( $download->exists() && $download->get_version()->get_filename() ) {
104
- $row[] = $download->get_version()->get_filename();
105
- } else {
106
- $row[] = '-';
107
- }
108
-
109
- $row[] = $item->get_user_id();
110
-
111
- if ( $item->get_user_id() ) {
112
- $user = get_user_by( 'id', $item->get_user_id() );
113
- }
114
-
115
- if ( ! isset( $user ) || ! $user ) {
116
- $row[] = '-';
117
- $row[] = '-';
118
- } else {
119
- $row[] = $user->user_login;
120
- $row[] = $user->user_email;
121
- }
122
-
123
- unset( $user );
124
-
125
- $row[] = $item->get_download_date()->format( 'Y-m-d H:i:s' );
126
-
127
- // setup meta data string
128
- $meta = $item->get_meta_data();
129
- $meta_str = "";
130
- if ( ! empty( $meta ) ) {
131
- foreach ( $meta as $mk => $mv ) {
132
- $meta_str .= $mk . ": " . $mv . "\n";
133
- }
134
- }
135
- $row[] = $meta_str;
136
-
137
- $rows[] = '"' . implode( '","', $row ) . '"';
138
- }
139
- }
140
-
141
- $log = implode( "\n", $rows );
142
-
143
- header( "Content-type: text/csv" );
144
- header( "Content-Disposition: attachment; filename=download_log.csv" );
145
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
146
- header( "Content-Length: " . strlen( $log ) );
147
- echo wp_kses_post( $log );
148
- exit;
149
- }
150
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Logs/LogItem.php CHANGED
@@ -343,6 +343,7 @@ class DLM_Log_Item {
343
  '%s'
344
  )
345
  );
346
- }
347
 
348
- }
 
 
343
  '%s'
344
  )
345
  );
 
346
 
347
+ do_action( 'dlm_increase_download_count', $this );
348
+ }
349
+ }