ads
8 months ago
control
8 months ago
img
10 years ago
blocker.js
2 weeks ago
blocker.min.js
2 weeks ago
embed.js
5 years ago
embed.min.js
7 months ago
front.js
2 days ago
front.min.js
2 days ago
jquery-ui-timepicker-addon.js
10 years ago
jquery-ui-timepicker-addon.min.js
7 months ago
jquery.dataTables.min.js
1 year ago
jquery.validate.js
7 months ago
jquery.validate.min.js
2 weeks ago
jqueryFileTree.js
5 years ago
jqueryFileTree.min.js
7 months ago
overwatch.js
7 months ago
overwatch.min.js
7 months ago
password-strength.js
2 years ago
password-strength.min.js
7 months ago
simple-scrollbar.js
7 months ago
simple-scrollbar.min.js
7 months ago
simplebar.js
6 years ago
validator.min.js
9 years ago
vue.js
9 months ago
vue.min.js
9 months ago
wpdm-admin.js
2 weeks ago
wpdm-admin.min.js
2 weeks ago
wpdm.js
6 months ago
wpdm.min.js
6 months ago
wpdm-admin.js
860 lines
| 1 | //const { __, _x, _n, sprintf } = wp.i18n; |
| 2 | var allps; |
| 3 | var wpdm_pass_target = '#pps_z'; |
| 4 | var $modal_id = ''; |
| 5 | String.prototype.wpdm_shuffle = function () { |
| 6 | var a = this.split(""), |
| 7 | n = a.length; |
| 8 | |
| 9 | for (var i = n - 1; i > 0; i--) { |
| 10 | var j = Math.floor(Math.random() * (i + 1)); |
| 11 | var tmp = a[i]; |
| 12 | a[i] = a[j]; |
| 13 | a[j] = tmp; |
| 14 | } |
| 15 | return a.join(""); |
| 16 | } |
| 17 | |
| 18 | String.prototype.wpdm_hash = function(){ |
| 19 | if (Array.prototype.reduce){ |
| 20 | return this.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0); |
| 21 | } |
| 22 | var hash = 0; |
| 23 | if (this.length === 0) return hash; |
| 24 | for (var i = 0; i < this.length; i++) { |
| 25 | var character = this.charCodeAt(i); |
| 26 | hash = ((hash<<5)-hash)+character; |
| 27 | hash = hash & hash; // Convert to 32bit integer |
| 28 | } |
| 29 | return hash; |
| 30 | } |
| 31 | |
| 32 | var WPDM = { |
| 33 | actions: {}, |
| 34 | |
| 35 | init: function ($) { |
| 36 | |
| 37 | }, |
| 38 | |
| 39 | addAction: function (action, func) { |
| 40 | if(!WPDM.actions[action]) WPDM.actions[action] = []; |
| 41 | WPDM.actions[action].push(func); |
| 42 | }, |
| 43 | |
| 44 | doAction: function (action, ...params) { |
| 45 | if(typeof WPDM.actions[action] !== 'undefined') |
| 46 | WPDM.actions[action].forEach(fn => fn(...params)); |
| 47 | }, |
| 48 | |
| 49 | copy: function ($id) { |
| 50 | var copyText = document.getElementById($id); |
| 51 | copyText.select(); |
| 52 | copyText.setSelectionRange(0, 99999); |
| 53 | document.execCommand("copy"); |
| 54 | WPDM.notify('<i class="fa fa-check-double"></i> Copied', 'success', 'top-center', 1000); |
| 55 | }, |
| 56 | |
| 57 | copyTxt: function (textToCopy) { |
| 58 | WPDM.notify('<i class="fa fa-check-double"></i> Copied', 'success', 'top-center', 1000); |
| 59 | // navigator clipboard api needs a secure context (https) |
| 60 | if (navigator.clipboard && window.isSecureContext) { |
| 61 | // navigator clipboard api method' |
| 62 | return navigator.clipboard.writeText(textToCopy); |
| 63 | } else { |
| 64 | // text area method |
| 65 | let textArea = document.createElement("textarea"); |
| 66 | textArea.value = textToCopy; |
| 67 | // make the textarea out of viewport |
| 68 | textArea.style.position = "fixed"; |
| 69 | textArea.style.left = "-999999px"; |
| 70 | textArea.style.top = "-999999px"; |
| 71 | document.body.appendChild(textArea); |
| 72 | textArea.focus(); |
| 73 | textArea.select(); |
| 74 | return new Promise((res, rej) => { |
| 75 | // here the magic happens |
| 76 | document.execCommand('copy') ? res() : rej(); |
| 77 | textArea.remove(); |
| 78 | }); |
| 79 | } |
| 80 | }, |
| 81 | |
| 82 | hash: function (str) { |
| 83 | return str.wpdm_hash(); |
| 84 | }, |
| 85 | |
| 86 | beep: function () { |
| 87 | if (WPDM.audio == undefined) |
| 88 | var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAE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xZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU="); |
| 89 | else |
| 90 | var snd = new Audio(WPDM.audio); |
| 91 | snd.play(); |
| 92 | }, |
| 93 | |
| 94 | uniqueID: function (prefix) { |
| 95 | var uniq = Date.now() + "abcdefghijklmnopqrstuvwxyz_"; |
| 96 | uniq = uniq.wpdm_shuffle(); |
| 97 | uniq = uniq.substring(1, 10); |
| 98 | uniq = typeof prefix !== 'undefined' ? prefix+uniq : uniq; |
| 99 | return uniq; |
| 100 | }, |
| 101 | |
| 102 | popupWindow: function (url, title, w, h, onclose) { |
| 103 | /* Fixes dual-screen position Most browsers Firefox */ |
| 104 | var dualScreenLeft = typeof window.screenLeft !== 'undefined' ? window.screenLeft : screen.left; |
| 105 | var dualScreenTop = typeof window.screenTop !== 'undefined' ? window.screenTop : screen.top; |
| 106 | |
| 107 | var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; |
| 108 | var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; |
| 109 | |
| 110 | var left = ((width / 2) - (w / 2)) + dualScreenLeft; |
| 111 | var top = ((height / 2) - (h / 2)) + dualScreenTop; |
| 112 | var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); |
| 113 | |
| 114 | /* Puts focus on the newWindow */ |
| 115 | if (window.focus) { |
| 116 | newWindow.focus(); |
| 117 | } |
| 118 | if(onclose !== undefined) |
| 119 | newWindow.onbeforeunload = function(){ onclose.call(); } |
| 120 | return false; |
| 121 | }, |
| 122 | |
| 123 | bootAlert: function (heading, content, width) { |
| 124 | |
| 125 | // Map the legacy pixel width to a WPDM dialog size token |
| 126 | var size = !width ? 'sm' : (width >= 700 ? 'lg' : (width >= 480 ? 'md' : 'sm')); |
| 127 | |
| 128 | // Graceful fallback if the WPDM dialog system is not available |
| 129 | if (typeof WPDMDialog === 'undefined') { |
| 130 | window.alert(jQuery('<div>').html(heading).text()); |
| 131 | return jQuery(); |
| 132 | } |
| 133 | |
| 134 | // Remote content: load it through the WPDM dialog AJAX loader |
| 135 | if (content && typeof content === 'object' && content.url) { |
| 136 | return WPDMDialog.ajax(heading, content.url, { size: size, icon: false }); |
| 137 | } |
| 138 | |
| 139 | // Inline HTML / message content |
| 140 | return WPDMDialog.show({ |
| 141 | title: heading, |
| 142 | content: '<div class="modal-body">' + (content || '') + '</div>', |
| 143 | html: true, |
| 144 | icon: false, |
| 145 | size: size, |
| 146 | compactFooter: true, |
| 147 | buttons: [{ text: 'Close', type: 'secondary', action: 'close' }] |
| 148 | }); |
| 149 | }, |
| 150 | |
| 151 | |
| 152 | /** |
| 153 | * Local push notification |
| 154 | * @param title |
| 155 | * @param message |
| 156 | * @param icon |
| 157 | * @param image |
| 158 | * @param url |
| 159 | */ |
| 160 | pushNotify: function (title, message, icon, image, url) { |
| 161 | |
| 162 | var type = 'info'; |
| 163 | if(title.includes('rror') || message.includes('rror')) type = 'error'; |
| 164 | if(title.includes('uccess') || message.includes('uccess')) type = 'success'; |
| 165 | if(title.includes('arning') || message.includes('arning')) type = 'warning'; |
| 166 | |
| 167 | if (!('Notification' in window) || !('ServiceWorkerRegistration' in window)) { |
| 168 | WPDM.notify("<strong>"+title+"</strong><br/>"+message, type, 'top-right'); |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | Notification.requestPermission(function (result) { |
| 173 | if (result === 'granted') { |
| 174 | console.log('Notification: ' + result); |
| 175 | try { |
| 176 | var notification = new Notification(title, { |
| 177 | body: message, |
| 178 | icon: icon ? icon : 'https://cdn1.iconfinder.com/data/icons/hawcons/32/698558-icon-47-note-important-512.png', |
| 179 | image: image ? image : '' |
| 180 | }); |
| 181 | if (url) { |
| 182 | notification.onclick = function (e) { |
| 183 | e.preventDefault(); |
| 184 | window.open(url, '_blank'); |
| 185 | }; |
| 186 | } |
| 187 | } catch (err) { |
| 188 | WPDM.notify("<strong>"+title+"</strong><br/>"+message, type, 'top-right'); |
| 189 | console.log('Notification API error: ' + err); |
| 190 | } |
| 191 | } else { |
| 192 | WPDM.notify("<strong>"+title+"</strong><br/>"+message, type, 'top-right'); |
| 193 | console.log('Notification: ' + result); |
| 194 | } |
| 195 | }); |
| 196 | |
| 197 | }, |
| 198 | |
| 199 | |
| 200 | /** |
| 201 | * Shows notification |
| 202 | * @param message |
| 203 | * @param type |
| 204 | * @param position |
| 205 | */ |
| 206 | notify: function (message, type, position, autoclose) { |
| 207 | var $ = jQuery; |
| 208 | if (type === undefined || !type) type = 'info'; |
| 209 | if (position === undefined || !position) position = 'top-right'; |
| 210 | if (type === 'danger') type = 'error'; |
| 211 | var notifycont = position.indexOf('#') >= 0 ? position : '#wpdm-notify-' + position; |
| 212 | if ($(notifycont).length == 0) |
| 213 | $('body').prepend("<div id='wpdm-notify-" + position + "'></div>"); |
| 214 | var notif = $("<div class='wpdm-notify fetfont wpdm-notify-" + type + "' style='display: none'>" + message + "</div>"); |
| 215 | $(notifycont).append(notif); |
| 216 | $(notif).fadeIn(); |
| 217 | if (autoclose !== undefined) { |
| 218 | setTimeout(function () { |
| 219 | |
| 220 | $(notif).animate({ |
| 221 | opacity: 0 |
| 222 | }, 1000, function () { |
| 223 | $(this).slideUp(); |
| 224 | }); |
| 225 | |
| 226 | }, autoclose); |
| 227 | } |
| 228 | return $(notif); |
| 229 | }, |
| 230 | |
| 231 | /** |
| 232 | * Shows notification |
| 233 | * @param message |
| 234 | * @param type |
| 235 | * @param position |
| 236 | */ |
| 237 | floatify: function (html, position) { |
| 238 | var $ = jQuery; |
| 239 | if (position === undefined || !position) position = 'top-right'; |
| 240 | var floatifycont = '#wpdm-floatify-' + position; |
| 241 | if ($(floatifycont).length == 0) |
| 242 | $('body').prepend("<div class='w3eden' id='wpdm-floatify-" + position + "'></div>"); |
| 243 | var floatify = $("<div class='wpdm-floatify fetfont style='margin-right: -500px'>" + html + "</div>"); |
| 244 | $(floatifycont).append(floatify); |
| 245 | $(floatify).animate({marginRight: '0px'}); |
| 246 | return $(floatify); |
| 247 | }, |
| 248 | |
| 249 | blockUI: function (element, xhr) { |
| 250 | jQuery(element).addClass("blockui"); |
| 251 | if (xhr) |
| 252 | xhr.addEventListener("load", function () { |
| 253 | jQuery(element).removeClass("blockui"); |
| 254 | }); |
| 255 | }, |
| 256 | |
| 257 | unblockUI: function (element) { |
| 258 | jQuery(element).removeClass("blockui"); |
| 259 | }, |
| 260 | |
| 261 | overlay: function (element, html) { |
| 262 | var $ = jQuery; |
| 263 | var overlaycontent = $("<div class='wpdm-overlay-content' style='display: none'>" + html + "<div class='wpdm-overlay-close' style='cursor: pointer'><i class='far fa-times-circle'></i> close</div></div>"); |
| 264 | $(element).addClass('wpdm-overlay').append(overlaycontent); |
| 265 | $(overlaycontent).fadeIn(); |
| 266 | $('body').on('click', '.wpdm-overlay-close', function () { |
| 267 | $(overlaycontent).fadeOut(function () { |
| 268 | $(this).remove(); |
| 269 | }); |
| 270 | }); |
| 271 | return $(overlaycontent); |
| 272 | }, |
| 273 | |
| 274 | |
| 275 | // Map a legacy bootstrap button class (e.g. "btn btn-danger") to a WPDM dialog button type |
| 276 | _dialogBtnType: function (cls) { |
| 277 | cls = (cls || '').toLowerCase(); |
| 278 | if (cls.indexOf('danger') > -1) return 'danger'; |
| 279 | if (cls.indexOf('success') > -1) return 'success'; |
| 280 | if (cls.indexOf('primary') > -1 || cls.indexOf('info') > -1 || cls.indexOf('warning') > -1) return 'primary'; |
| 281 | return 'secondary'; |
| 282 | }, |
| 283 | |
| 284 | confirm: function (heading, content, buttons) { |
| 285 | var $ = jQuery; |
| 286 | var oldButtons = buttons || []; |
| 287 | |
| 288 | // Graceful fallback if the WPDM dialog system is not available |
| 289 | if (typeof WPDMDialog === 'undefined') { |
| 290 | if (window.confirm($('<div>').html(content).text()) && oldButtons.length && typeof oldButtons[0].callback === 'function') { |
| 291 | oldButtons[0].callback.call($()); |
| 292 | } |
| 293 | return $(); |
| 294 | } |
| 295 | |
| 296 | // Map the legacy buttons ({label, class, callback}) to WPDM dialog buttons |
| 297 | var dlgButtons = oldButtons.length ? oldButtons.map(function (button, i) { |
| 298 | return { |
| 299 | text: $('<div>').html(button.label).text(), // strip icons/markup from the label |
| 300 | type: WPDM._dialogBtnType(button.class), |
| 301 | action: 'btn_' + i |
| 302 | }; |
| 303 | }) : [{ text: 'OK', type: 'primary', action: 'btn_0' }]; |
| 304 | |
| 305 | WPDMDialog.show({ |
| 306 | title: heading, |
| 307 | message: content, |
| 308 | html: true, |
| 309 | type: 'question', |
| 310 | size: 'sm', |
| 311 | buttons: dlgButtons, |
| 312 | backdrop: 'static' |
| 313 | }).then(function (result) { |
| 314 | var m = /^btn_(\d+)$/.exec(result.action || ''); |
| 315 | if (m && oldButtons[m[1]] && typeof oldButtons[m[1]].callback === 'function') { |
| 316 | // The dialog is already closing; legacy callbacks expect `this` to be the |
| 317 | // modal, so pass an empty jQuery set where .modal()/.find() are safe no-ops. |
| 318 | oldButtons[m[1]].callback.call($()); |
| 319 | } |
| 320 | }); |
| 321 | |
| 322 | return $(); |
| 323 | }, |
| 324 | audioUI: function (audio) { |
| 325 | var $ = jQuery, song_length, song_length_m, song_length_s; |
| 326 | |
| 327 | if (parseInt(wpdm_asset.bsversion) !== 3) |
| 328 | var player_html = '<div class="w3eden"><div style="display: none" class="wdmapui" id="wdmapui"><div class="card m-2"><div class="card-body text-center"><div class="media"><div class="mr-3 wpdm-audio-control-buttons"><button class="btn btn-primary btn-play" id="wpdm-btn-play"><i class="fa fa-play"></i></button> <button class="btn btn-primary btn-backward" id="wpdm-btn-backward"><i class="fa fa-backward"></i></button> <button class="btn btn-primary btn-forward" id="wpdm-btn-forward"><i class="fa fa-forward"></i></button></div><div class="media-body"><div class="position-relative"><div id="played">00:00</div><div id="mins">00:00</div></div><div class="progress"><div id="wpdm-audio-progress" class="progress-bar bg-success" role="progressbar" style="width: 0%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div></div></div><div class="ml-3 wpdm-audio-control-buttons"> <button class="btn btn-info btn-volumctrl" id="wpdm-btn-volumctrl"><i class="fa fa-volume-up"></i></button> <div class="volumctrl"><input type="range" min="0" max="1" step="0.01" value="3" class="p-0" id="wpdm-audio-volume"></div></div></div></div></div></div></div>'; |
| 329 | else |
| 330 | var player_html = '<div class="w3eden"><div style="display: none" class="wdmapui" id="wdmapui"><div class="panel panel-default" style="margin: 0;border: 0;border-radius: 0;border-top: 1px solid #dddddd;background: #fcfcfc"><div class="panel-body text-center"><div class="media"><div class="pull-right wpdm-audio-control-buttons"><button class="btn btn-info btn-volumctrl" id="wpdm-btn-volumctrl"><i class="fa fa-volume-up"></i></button> <div class="volumctrl"> <input type="range" min="0" max="1" step="0.01" value="3" class="p-0" id="wpdm-audio-volume"> </div></div><div class="wpdm-audio-control-buttons pull-left"><nobr><button class="btn btn-primary btn-play" id="wpdm-btn-play"><i class="fa fa-play"></i></button> <button class="btn btn-primary btn-backward" id="wpdm-btn-backward"><i class="fa fa-backward"></i></button> <button class="btn btn-primary btn-forward" id="wpdm-btn-forward"><i class="fa fa-forward"></i></button></nobr></div><div class="media-body"><div class="position-relative"><div id="played">00:00</div><div id="mins">00:00</div></div><div class="progress"><div id="wpdm-audio-progress" class="progress-bar bg-success" role="progressbar" style="width: 0%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div></div></div></div></div></div></div></div>'; |
| 331 | |
| 332 | if (audio.duration !== Infinity) { |
| 333 | song_length = parseInt(audio.duration); |
| 334 | song_length_m = parseInt(song_length / 60); |
| 335 | song_length_s = song_length - (song_length_m * 60); |
| 336 | song_length_m = song_length_m > 9 ? song_length_m : "0" + song_length_m; |
| 337 | song_length_s = song_length_s > 9 ? song_length_s : "0" + song_length_s; |
| 338 | } else { |
| 339 | song_length_m = "--"; |
| 340 | song_length_s = "--"; |
| 341 | audio.addEventListener("durationchange", function (e) { |
| 342 | console.log(this.duration); |
| 343 | if (this.duration !== Infinity) { |
| 344 | song_length = parseInt(this.duration); |
| 345 | song_length_m = parseInt(song_length / 60); |
| 346 | song_length_s = song_length - (song_length_m * 60); |
| 347 | song_length_m = song_length_m > 9 ? song_length_m : "0" + song_length_m; |
| 348 | song_length_s = song_length_s > 9 ? song_length_s : "0" + song_length_s; |
| 349 | $('#mins').html(song_length_m + ":" + song_length_s); |
| 350 | next(song_length); |
| 351 | } |
| 352 | }, false); |
| 353 | } |
| 354 | |
| 355 | if ($('#wdmapui').length === 0) { |
| 356 | $('body').append(player_html); |
| 357 | $("#wdmapui").slideDown(); |
| 358 | $('#mins').html(song_length_m + ":" + song_length_s); |
| 359 | $('body').on('click', '#wdmapui .progress', function (e) { |
| 360 | let value = e.offsetX * 100 / this.clientWidth; |
| 361 | var played = parseInt(song_length * value / 100); |
| 362 | var played_m = parseInt(played / 60); |
| 363 | var played_s = played - (played_m * 60); |
| 364 | played_m = played_m > 9 ? played_m : "0" + played_m; |
| 365 | played_s = played_s > 9 ? played_s : "0" + played_s; |
| 366 | $('#played').html(played_m + ":" + played_s); |
| 367 | audio.currentTime = (song_length * value) / 100; |
| 368 | $(this).find('.progress-bar').css('width', value + "%"); |
| 369 | //video.currentTime = duration * (value / 100); |
| 370 | }); |
| 371 | $('body').on('click', '#wpdm-btn-backward', function () { |
| 372 | let value = (parseInt($('#wdmapui .progress-bar').css('width')) / parseInt($('#wdmapui .progress').css('width'))) * 100 - 10; |
| 373 | if (value < 0) value = 0; |
| 374 | var played = parseInt(song_length * value / 100); |
| 375 | var played_m = parseInt(played / 60); |
| 376 | var played_s = played - (played_m * 60); |
| 377 | played_m = played_m > 9 ? played_m : "0" + played_m; |
| 378 | played_s = played_s > 9 ? played_s : "0" + played_s; |
| 379 | $('#played').html(played_m + ":" + played_s); |
| 380 | audio.currentTime = (song_length * value) / 100; |
| 381 | $('#wdmapui .progress-bar').css('width', value + "%"); |
| 382 | }); |
| 383 | $('body').on('click', '#wpdm-btn-forward', function () { |
| 384 | let value = (parseInt($('#wdmapui .progress-bar').css('width')) / parseInt($('#wdmapui .progress').css('width'))) * 100 + 10; |
| 385 | if (value > 100) value = 100; |
| 386 | var played = parseInt(song_length * value / 100); |
| 387 | var played_m = parseInt(played / 60); |
| 388 | var played_s = played - (played_m * 60); |
| 389 | played_m = played_m > 9 ? played_m : "0" + played_m; |
| 390 | played_s = played_s > 9 ? played_s : "0" + played_s; |
| 391 | $('#played').html(played_m + ":" + played_s); |
| 392 | audio.currentTime = (song_length * value) / 100; |
| 393 | $('#wdmapui .progress-bar').css('width', value + "%"); |
| 394 | }); |
| 395 | $('#wpdm-btn-volumctrl').on('click', function () { |
| 396 | $(this).next('.volumctrl').toggle(); |
| 397 | }); |
| 398 | $('body').on('click', '.btn-play', function () { |
| 399 | if ($(this).find('.fa').hasClass('fa-play')) { |
| 400 | $(this).find('.fa').addClass('fa-pause').removeClass('fa-play'); |
| 401 | $(this).data('state', 'playing'); |
| 402 | audio.play(); |
| 403 | } else { |
| 404 | $(this).find('.fa').addClass('fa-play').removeClass('fa-pause'); |
| 405 | $(this).data('state', 'paused'); |
| 406 | audio.pause(); |
| 407 | } |
| 408 | }); |
| 409 | $('body').on('change', '#wpdm-audio-volume', function () { |
| 410 | audio.volume = this.value; |
| 411 | }); |
| 412 | |
| 413 | } |
| 414 | $('#mins').html(song_length_m + ":" + song_length_s); |
| 415 | audio.addEventListener("play", function () { |
| 416 | $('#wpdm-btn-play').find('.fa').addClass('fa-pause').removeClass('fa-play'); |
| 417 | }); |
| 418 | audio.addEventListener("pause", function () { |
| 419 | $('#wpdm-btn-play').find('.fa').addClass('fa-play').removeClass('fa-pause'); |
| 420 | }); |
| 421 | audio.addEventListener("timeupdate", function (e) { |
| 422 | var song_length = parseInt(audio.duration); |
| 423 | var time_now = audio.currentTime; |
| 424 | var percent = (time_now / song_length) * 100; |
| 425 | if (percent > 100) percent = 100; |
| 426 | $('#wpdm-audio-progress').css('width', percent + "%"); |
| 427 | var played = parseInt(time_now); |
| 428 | var played_m = parseInt(played / 60); |
| 429 | var played_s = played - (played_m * 60); |
| 430 | played_m = played_m > 9 ? played_m : "0" + played_m; |
| 431 | played_s = played_s > 9 ? played_s : "0" + played_s; |
| 432 | $('#played').html(played_m + ":" + played_s); |
| 433 | }); |
| 434 | |
| 435 | |
| 436 | } |
| 437 | |
| 438 | }; |
| 439 | |
| 440 | |
| 441 | (function ($, window) { |
| 442 | |
| 443 | $.fn.contextMenu = function (settings) { |
| 444 | |
| 445 | return this.each(function () { |
| 446 | |
| 447 | // Open context menu |
| 448 | $(this).on("contextmenu", function (e) { |
| 449 | // return native menu if pressing control |
| 450 | if (e.ctrlKey) return; |
| 451 | if($(this).parent().hasClass('panel-folder')) $('.hide-on-dir').css('display', 'none'); |
| 452 | else $('.hide-on-dir').css('display', 'block'); |
| 453 | //open menu |
| 454 | var $menu = $(settings.menuSelector) |
| 455 | .data("invokedOn", $(this)) |
| 456 | .show() |
| 457 | .css({ |
| 458 | position: "fixed", |
| 459 | left: e.clientX, // getMenuPosition(e.clientX, 'width', 'scrollLeft'), |
| 460 | top: e.clientY // getMenuPosition(e.clientY, 'height', 'scrollTop') |
| 461 | }) |
| 462 | .off('click') |
| 463 | .on('click', 'a', function (e) { |
| 464 | $menu.hide(); |
| 465 | e.preventDefault(); |
| 466 | var $invokedOn = $menu.data("invokedOn"); |
| 467 | var $selectedMenu = $(e.target); |
| 468 | |
| 469 | settings.menuSelected.call(this, $invokedOn, $selectedMenu); |
| 470 | }); |
| 471 | |
| 472 | return false; |
| 473 | }); |
| 474 | |
| 475 | //make sure menu closes on any click |
| 476 | $('body').click(function () { |
| 477 | $(settings.menuSelector).hide(); |
| 478 | }); |
| 479 | }); |
| 480 | |
| 481 | function getMenuPosition(mouse, direction, scrollDir) { |
| 482 | var win = $(window)[direction](), |
| 483 | scroll = $(window)[scrollDir](), |
| 484 | menu = $(settings.menuSelector)[direction](), |
| 485 | position = mouse + scroll; |
| 486 | |
| 487 | // opening menu would pass the side of the page |
| 488 | if (mouse + menu > win && menu < mouse) |
| 489 | position -= menu; |
| 490 | |
| 491 | return position; |
| 492 | } |
| 493 | |
| 494 | }; |
| 495 | })(jQuery, window); |
| 496 | |
| 497 | jQuery(function ($) { |
| 498 | |
| 499 | // Uploading files |
| 500 | var file_frame, dfield, $body = $('body'); |
| 501 | |
| 502 | $body.on('click', '.wpdm-notify', function () { |
| 503 | $(this).animate({ |
| 504 | opacity: 0 |
| 505 | }, 1000, function () { |
| 506 | $(this).slideUp(); |
| 507 | }); |
| 508 | }); |
| 509 | |
| 510 | $body.on('click', '.wpdm-modal-pop', function (e) { |
| 511 | e.preventDefault(); |
| 512 | var url = $(this).attr('href'); |
| 513 | var width = 600; |
| 514 | var title = $(this).text(); |
| 515 | if ($(this).data('width') !== undefined) width = $(this).data('width'); |
| 516 | if ($(this).attr('title') !== undefined) title = $(this).attr('title'); |
| 517 | if ($(this).data('url') !== undefined) url = $(this).data('url'); |
| 518 | var size = width >= 700 ? 'lg' : (width >= 480 ? 'md' : 'sm'); |
| 519 | WPDM.dialog.ajax(title, url, { size: size, icon: false }); |
| 520 | return false; |
| 521 | }); |
| 522 | |
| 523 | $body.on('click', '.__wpdm_approvedr', function (event) { |
| 524 | event.preventDefault(); |
| 525 | $btn = $(this); |
| 526 | $btn.attr('disabled', 'disabled').html('<i class="fa fa-refresh fa-spin"></i>'); |
| 527 | $('.__wpdm_declinedr_' + $btn.data('rid')).remove(); |
| 528 | $.post(ajaxurl, { |
| 529 | __approvedr: $(this).data('nonce'), |
| 530 | __rid: $(this).data('rid'), |
| 531 | action: 'approveDownloadRequest' |
| 532 | }, function (res) { |
| 533 | if (res.match(/ok/)) { |
| 534 | $btn.removeClass('btn-info').addClass('btn-success').html('Approved'); |
| 535 | } |
| 536 | }); |
| 537 | }); |
| 538 | |
| 539 | $body.on('click', '.txtsc', function (event) { |
| 540 | $(this).select(); |
| 541 | }); |
| 542 | |
| 543 | $body.on('click', '.__wpdm_declinedr', function (event) { |
| 544 | event.preventDefault(); |
| 545 | if (!confirm('Are you sure?')) return false; |
| 546 | $btn = $(this); |
| 547 | $btn.attr('disabled', 'disabled').html('<i class="fa fa-refresh fa-spin"></i>'); |
| 548 | $.post(ajaxurl, { |
| 549 | __declinedr: $(this).data('nonce'), |
| 550 | __rid: $(this).data('rid'), |
| 551 | action: 'declineDownloadRequest' |
| 552 | }, function (res) { |
| 553 | if (res.match(/ok/)) { |
| 554 | $('#__emlrow_' + $btn.data('rid')).remove(); |
| 555 | } |
| 556 | }); |
| 557 | }); |
| 558 | |
| 559 | |
| 560 | $body.on('click', '.btn-onclick', function () { |
| 561 | $(this).css('width', $(this).css('width')).attr('disabled', 'disabled'); |
| 562 | $(this).html($(this).data('onclick')); |
| 563 | }); |
| 564 | |
| 565 | $body.on('click', '.btn-media-upload', function (event) { |
| 566 | event.preventDefault(); |
| 567 | dfield = $($(this).attr('rel')); |
| 568 | |
| 569 | // If the media frame already exists, reopen it. |
| 570 | if (file_frame) { |
| 571 | file_frame.open(); |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | // Create the media frame. |
| 576 | file_frame = wp.media.frames.file_frame = wp.media({ |
| 577 | title: $(this).data('uploader_title'), |
| 578 | button: { |
| 579 | text: $(this).data('uploader_button_text') |
| 580 | }, |
| 581 | multiple: false // Set to true to allow multiple files to be selected |
| 582 | }); |
| 583 | |
| 584 | // When an image is selected, run a callback. |
| 585 | file_frame.on('select', function () { |
| 586 | // We set multiple to false so only get one image from the uploader |
| 587 | attachment = file_frame.state().get('selection').first().toJSON(); |
| 588 | dfield.val(attachment.url); |
| 589 | |
| 590 | }); |
| 591 | |
| 592 | // Finally, open the modal |
| 593 | file_frame.open(); |
| 594 | }); |
| 595 | |
| 596 | $body.on('click', '.btn-image-selector', function (event) { |
| 597 | event.preventDefault(); |
| 598 | dfield = $($(this).attr('rel')); |
| 599 | var dfield_h = $($(this).attr('rel') + '_hidden'); |
| 600 | |
| 601 | // If the media frame already exists, reopen it. |
| 602 | if (file_frame) { |
| 603 | file_frame.open(); |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | // Create the media frame. |
| 608 | file_frame = wp.media.frames.file_frame = wp.media({ |
| 609 | title: $(this).data('uploader_title'), |
| 610 | button: { |
| 611 | text: $(this).data('uploader_button_text') |
| 612 | }, |
| 613 | multiple: false // Set to true to allow multiple files to be selected |
| 614 | }); |
| 615 | |
| 616 | // When an image is selected, run a callback. |
| 617 | file_frame.on('select', function () { |
| 618 | // We set multiple to false so only get one image from the uploader |
| 619 | attachment = file_frame.state().get('selection').first().toJSON(); |
| 620 | console.log(attachment); |
| 621 | dfield.attr('src', attachment.url); |
| 622 | dfield_h.val(attachment.url); |
| 623 | |
| 624 | }); |
| 625 | |
| 626 | // Finally, open the modal |
| 627 | file_frame.open(); |
| 628 | }); |
| 629 | |
| 630 | allps = $('#pps_z').val(); |
| 631 | if (allps == undefined) allps = ''; |
| 632 | $('#ps').val(allps.replace(/\]\[/g, "\n").replace(/[\]|\[]+/g, '')); |
| 633 | shuffle = function () { |
| 634 | var sl = 'abcdefghijklmnopqrstuvwxyz'; |
| 635 | var cl = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 636 | var nm = '0123456789'; |
| 637 | var sc = '~!@#$%^&*()_'; |
| 638 | ps = ""; |
| 639 | pss = ""; |
| 640 | ps = sl; |
| 641 | if ($('#passtrn').val() > 1) ps += cl; |
| 642 | if ($('#passtrn').val() > 2) ps += nm; |
| 643 | if ($('#passtrn').val() > 3) ps += sc; |
| 644 | var i = 0; |
| 645 | while (i <= ps.length) { |
| 646 | $max = ps.length - 1; |
| 647 | $num = Math.floor(Math.random() * $max); |
| 648 | $temp = ps.substr($num, 1); |
| 649 | pss += $temp; |
| 650 | i++; |
| 651 | } |
| 652 | |
| 653 | $('#ps').val(pss); |
| 654 | |
| 655 | |
| 656 | }; |
| 657 | $('#gps').click(shuffle); |
| 658 | |
| 659 | $body.on('click', '#gpsc', function () { |
| 660 | var allps = ""; |
| 661 | shuffle(); |
| 662 | for (k = 0; k < $('#pcnt').val(); k++) { |
| 663 | allps += "[" + randomPassword(pss, $('#ncp').val()) + "]"; |
| 664 | |
| 665 | } |
| 666 | vallps = allps.replace(/\]\[/g, "\n").replace(/[\]|\[]+/g, ''); |
| 667 | $('#ps').val(vallps); |
| 668 | |
| 669 | }); |
| 670 | |
| 671 | $body.on('click', '#pins', function () { |
| 672 | var aps; |
| 673 | aps = $('#ps').val(); |
| 674 | aps = aps.replace(/\n/g, "]["); |
| 675 | allps = "[" + aps + "]"; |
| 676 | $(wpdm_pass_target).val(allps); |
| 677 | var $dlg = $(this).closest('.wpdm-dialog-wrapper'); |
| 678 | if ($dlg.length) { $dlg.find('.wpdm-dialog__close').trigger('click'); } |
| 679 | else { $('#generatepass').modal('hide'); } |
| 680 | }); |
| 681 | |
| 682 | $body.on('click', '*:data[toggle="iframe-modal"]', function (e) { |
| 683 | e.preventDefault(); |
| 684 | var url; |
| 685 | if ($(this).attr('href') !== undefined) url = $(this).attr('href'); |
| 686 | else url = $(this).data('url'); |
| 687 | wpdm_iframe_modal(utl); |
| 688 | }); |
| 689 | |
| 690 | $body.on('click', '#testemail', function () { |
| 691 | $.post(ajaxurl, {action: 'wpdm_test_email', template: $('#etmpl').val()}) |
| 692 | }); |
| 693 | |
| 694 | try { |
| 695 | $('.ttip').tooltip(); |
| 696 | } catch (e) { |
| 697 | |
| 698 | } |
| 699 | |
| 700 | }); |
| 701 | |
| 702 | function randomPassword(chars, size) { |
| 703 | |
| 704 | //var size = 10; |
| 705 | if (parseInt(size) == Number.NaN || size == "") size = 8; |
| 706 | var i = 1; |
| 707 | var ret = ""; |
| 708 | while (i <= size) { |
| 709 | $max = chars.length - 1; |
| 710 | $num = Math.floor(Math.random() * $max); |
| 711 | $temp = chars.substr($num, 1); |
| 712 | ret += $temp; |
| 713 | i++; |
| 714 | } |
| 715 | return ret; |
| 716 | } |
| 717 | |
| 718 | function __showDownloadLink(pid, fid) { |
| 719 | var url; |
| 720 | url = wpdmConfig.siteURL + "?wpdmdl=" + pid + "&ind=" + fid; |
| 721 | __bootModal("File Download Link", '<textarea readonly="readonly" class="form-control" style="font-family: monospace">' + url + '</textarea>'); |
| 722 | } |
| 723 | |
| 724 | function __bootModal(heading, content, width) { |
| 725 | var size = !width ? 'sm' : (width >= 700 ? 'lg' : (width >= 480 ? 'md' : 'sm')); |
| 726 | |
| 727 | if (typeof WPDMDialog === 'undefined') { |
| 728 | window.alert(jQuery('<div>').html(content).text()); |
| 729 | return; |
| 730 | } |
| 731 | |
| 732 | WPDMDialog.show({ |
| 733 | title: heading, |
| 734 | content: '<div class="modal-body"><p>' + (content || '') + '</p></div>', |
| 735 | html: true, |
| 736 | icon: false, |
| 737 | size: size, |
| 738 | compactFooter: true, |
| 739 | buttons: [{ text: 'Close', type: 'secondary', action: 'close' }] |
| 740 | }); |
| 741 | } |
| 742 | |
| 743 | function wpdm_boot_popup(heading, content, buttons) { |
| 744 | var $ = jQuery; |
| 745 | var oldButtons = buttons || []; |
| 746 | |
| 747 | if (typeof WPDMDialog === 'undefined') { |
| 748 | if (window.confirm($('<div>').html(content).text()) && oldButtons.length && typeof oldButtons[0].callback === 'function') { |
| 749 | oldButtons[0].callback.call($()); |
| 750 | } |
| 751 | return $(); |
| 752 | } |
| 753 | |
| 754 | var dlgButtons = oldButtons.length ? oldButtons.map(function (button, i) { |
| 755 | return { |
| 756 | text: $('<div>').html(button.label).text(), |
| 757 | type: WPDM._dialogBtnType(button.class), |
| 758 | action: 'btn_' + i |
| 759 | }; |
| 760 | }) : [{ text: 'OK', type: 'primary', action: 'btn_0' }]; |
| 761 | |
| 762 | WPDMDialog.show({ |
| 763 | title: heading, |
| 764 | message: content, |
| 765 | html: true, |
| 766 | type: 'question', |
| 767 | size: 'sm', |
| 768 | buttons: dlgButtons, |
| 769 | backdrop: 'static' |
| 770 | }).then(function (result) { |
| 771 | var m = /^btn_(\d+)$/.exec(result.action || ''); |
| 772 | if (m && oldButtons[m[1]] && typeof oldButtons[m[1]].callback === 'function') { |
| 773 | oldButtons[m[1]].callback.call($()); |
| 774 | } |
| 775 | }); |
| 776 | |
| 777 | return $(); |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * Open an url in iframe modal |
| 782 | * @param url |
| 783 | * @param closebutton |
| 784 | * @returns {boolean} |
| 785 | */ |
| 786 | function wpdm_iframe_modal(url, closebutton) { |
| 787 | var iframe, $ = jQuery; |
| 788 | if (url === 'close') { |
| 789 | $('#wpdm_iframe_modal').hide(); |
| 790 | $('#ifcb').hide(); |
| 791 | $('body').removeClass('wpdm-iframe-modal-open'); |
| 792 | return false; |
| 793 | } |
| 794 | console.log($('#wpdm_iframe_modal').attr('src')); |
| 795 | if ($('#wpdm_iframe_modal').length === 1 && url === $('#wpdm_iframe_modal').attr('src')) { |
| 796 | $('#wpdm_iframe_modal').fadeIn(); |
| 797 | $('#ifcb').fadeIn(); |
| 798 | try { |
| 799 | document.getElementById('wpdm_iframe_modal').contentWindow.showModal(); |
| 800 | } catch (e) { |
| 801 | |
| 802 | } |
| 803 | return false; |
| 804 | } else { |
| 805 | $('#wpdm_iframe_modal').remove(); |
| 806 | $('#ifcb').remove(); |
| 807 | } |
| 808 | var closebutton_html = ""; |
| 809 | if (closebutton !== undefined && closebutton === true) |
| 810 | closebutton_html = "<span id='ifcb' class='w3eden'><a href='#' onclick='return wpdm_iframe_modal(\"close\");' style='border-radius: 0;position: fixed;top: 0;right: 0;z-index: 9999999999 !important;width: 40px;line-height: 40px;padding: 0' class='btn btn-danger'><i class='fas fa-times'></i></a></span>"; |
| 811 | |
| 812 | iframe = '<iframe src="' + url + '" style="width: 100%;height: 100%;position: fixed;z-index: 999999999 !important;border: 0;left: 0;top: 0;right: 0;bottom: 0;background: rgba(0,0,0,0.2);display: none;" id="wpdm_iframe_modal"></iframe>' + closebutton_html; |
| 813 | $('body').append(iframe).addClass('wpdm-iframe-modal-open'); |
| 814 | $('#wpdm_iframe_modal').fadeIn(); |
| 815 | |
| 816 | } |
| 817 | |
| 818 | |
| 819 | /* ----------------------------------------------------------------------- * |
| 820 | * Backward-compat bridge for the WPDM dialog system. |
| 821 | * |
| 822 | * WPDM.bootAlert()/WPDM.confirm() now render WPDM dialogs instead of the old |
| 823 | * bootstrap-style modal markup. Legacy code (and AJAX-loaded partials) still |
| 824 | * call `.modal('hide')` — often on a stale `#__mdid` element — to dismiss the |
| 825 | * popup. This wraps the existing `$.fn.modal` plugin so that a `'hide'` call |
| 826 | * which targets (or sits inside) a WPDM dialog, or matches nothing at all, |
| 827 | * closes the active WPDM dialog instead. |
| 828 | * ----------------------------------------------------------------------- */ |
| 829 | (function ($) { |
| 830 | if (!$ || !$.fn || !$.fn.modal || $.fn.__wpdmDialogBridge) return; |
| 831 | |
| 832 | var _origModal = $.fn.modal; |
| 833 | |
| 834 | function closeWpdmDialog($wrap) { |
| 835 | var $btn = $wrap.find('.wpdm-dialog__close').first(); |
| 836 | if ($btn.length) { $btn.trigger('click'); } |
| 837 | else { $wrap.find('.wpdm-dialog-backdrop').first().trigger('click'); } |
| 838 | } |
| 839 | |
| 840 | $.fn.modal = function (option) { |
| 841 | if (option === 'hide') { |
| 842 | // Target is, or lives inside, a WPDM dialog |
| 843 | var $wrap = this.closest('.wpdm-dialog-wrapper'); |
| 844 | if ($wrap.length) { closeWpdmDialog($wrap); return this; } |
| 845 | // Legacy selector matched nothing (e.g. a stale #__mdid): close the top dialog |
| 846 | if (this.length === 0) { |
| 847 | var $top = $('.wpdm-dialog-wrapper.wpdm-dialog-visible').last(); |
| 848 | if ($top.length) { closeWpdmDialog($top); return this; } |
| 849 | } |
| 850 | } |
| 851 | return _origModal.apply(this, arguments); |
| 852 | }; |
| 853 | |
| 854 | $.fn.__wpdmDialogBridge = true; |
| 855 | })(jQuery); |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 |