1/** 2 * WP File Download 3 * 4 * @package WP File Download 5 * @author Joomunited 6 * @version 1.0 7 */ 8 9jQuery(document).ready(function ($) { 10 // var sourcefiles = $("#wpfd-template-files").html(); 11 // var sourcecategories = $("#wpfd-template-categories").html(); 12 var default_hash = window.location.hash; 13 var tree = $('.wpfd-foldertree-default'); 14 var tree_source_cat = $('.wpfd-content-default').data('category'); 15 var allCategoriesBreadcrumbs = '<li><a class="catlink" data-idcat="all_0" href="javascript:void(0);">' + wpfdparams.translates.wpfd_all_categories + '</a></li>'; 16 var allCategoriesDividerBreadcrumbs = '<li><a class="catlink" data-idcat="all_0" href="javascript:void(0);">' + wpfdparams.translates.wpfd_all_categories + '</a><span class="divider"> > </span></li>'; 17 var cParents = {}; 18 if (window.wpfdAjax === undefined) { 19 window.wpfdAjax = {}; 20 } 21 window.wpfdAjax[tree_source_cat] = {category: null, file: null}; 22 23 $(".wpfd-content-default").each(function () { 24 var topCat = $(this).data('category'); 25 if (topCat == 'all_0') { 26 cParents[topCat] = {parent: 0, term_id: 0, name: $(this).find("h2").text().trim()}; 27 } else { 28 cParents[topCat] = {parent: 0, term_id: topCat, name: $(this).find("h2").text().trim()}; 29 } 30 31 $(this).find(".wpfdcategory.catlink").each(function () { 32 var tempidCat = $(this).data('idcat'); 33 cParents[tempidCat] = {parent: topCat, term_id: tempidCat, name: $(this).text().trim()}; 34 }); 35 36 initInputSelected(topCat); 37 initDownloadSelected(topCat); 38 wpfdMailNotifyFileChanges(topCat); 39 wpfdFrontFilesOrdering(topCat); 40 }); 41 42 Handlebars.registerHelper('bytesToSize', function (bytes) { 43 if (typeof bytes === "undefined") { 44 return 'n/a'; 45 } 46 47 return bytes.toString().toLowerCase() === 'n/a' ? bytes : bytesToSize(parseInt(bytes)); 48 }); 49 50 Handlebars.registerHelper("xif", function(param, second, options) { 51 if (param === second) { 52 return options.fn(this); 53 } else { 54 return options.inverse(this); 55 } 56 }); 57 58 Handlebars.registerHelper('UrlCustomFields', function (url) { 59 if (typeof url === "undefined") { 60 return ''; 61 } 62 63 return bytes.toString().toLowerCase() === 'n/a' ? bytes : bytesToSize(parseInt(bytes)); 64 }); 65 66 Handlebars.registerHelper('ifEquals', function(arg1, arg2, options) { 67 return (arg1 === arg2) ? options.fn(this) : options.inverse(this); 68 }); 69 70 function wpfdDefaultDisplayDownloadedFiles() { 71 var fileDownload = $('.wpfd-content.wpfd-content-default .file'); 72 var linkDownload = $('.wpfd-content.wpfd-content-default .wpfd_downloadlink'); 73 var user_login_id = wpfdparams.wpfd_user_login_id; 74 if (linkDownload.length) { 75 linkDownload.on('click', function () { 76 var fileId = $(this).parents('.file').data('id'); 77 var isDownloadedFile = localStorage.getItem('wpfd_downloaded_file_' + user_login_id + '_' + fileId); 78 const download_timestamp = Math.floor(Date.now() / 1000); 79 if (isDownloadedFile === null) { 80 localStorage.setItem('wpfd_downloaded_file_' + user_login_id + '_' + fileId, 'yes'); 81 localStorage.setItem('wpfd_downloaded_file_' + user_login_id + '_' + fileId + '_timer', download_timestamp.toString()); 82 $(this).parents('.file').addClass('is_downloaded'); 83 } else { 84 localStorage.setItem('wpfd_downloaded_file_' + user_login_id + '_' + fileId + '_timer', download_timestamp.toString()); 85 } 86 }); 87 } 88 89 if (fileDownload.length) { 90 fileDownload.each(function () { 91 var id = $(this).data('id'); 92 var edit = $(this).data('edit'); 93 var isFileDownload = localStorage.getItem('wpfd_downloaded_file_' + user_login_id + '_' + id); 94 if (isFileDownload) { 95 $(this).addClass('is_downloaded'); 96 var download_timer = localStorage.getItem('wpfd_downloaded_file_' + user_login_id + '_' + id + '_timer'); 97 if (!download_timer) { 98 download_timer = 0; 99 } 100 101 if (parseInt(edit) - parseInt(download_timer) > 0) { 102 $(this).addClass('new_edit'); 103 } 104 } 105 106 $(this).show(); 107 }); 108 } 109 110 $('.wpfd-content.wpfd-content-default').show(); 111 } 112 wpfdDefaultDisplayDownloadedFiles(); 113 114 function default_initClick() { 115 $(document).off('click', '.wpfd-content-default .catlink').on('click', '.wpfd-content-default .catlink', function(e) { 116 var ctheme = $(this).parents('.wpfd-content').find('.wpfd_root_category_theme').val(); 117 var c_root_cat = $(this).parents('.wpfd-content').find('.wpfd_root_category_id').val(); 118 var rootCat = ".wpfd-content-default.wpfd-content-multi[data-category=" + c_root_cat + "]"; 119 var current_category = $(rootCat).find('#current_category_' + c_root_cat).val(); 120 $(".wpfd-content[data-category=" + $(this).parents('.wpfd-content-'+ctheme).data('category') + "] .wpfd-container-"+ctheme).find('.wpfd-categories .wpfdcategory.catlink').each(function () { 121 var tempidCat = $(this).data('idcat'); 122 var catName = ''; 123 if ($(this).attr('title') !== undefined) { 124 catName = $(this).attr('title').trim(); 125 } else if ($(this).data('title') !== undefined) { 126 catName = $(this).data('title').trim(); 127 } 128 cParents[tempidCat] = {parent: current_category, term_id: tempidCat, name: catName}; 129 }); 130 default_load(c_root_cat, $(this).data('idcat')); 131 return false;
132 }) 133 } 134 135 function initInputSelected(sc) { 136 $(document).on('change', ".wpfd-content-default.wpfd-content-multi[data-category=" + sc + "] input.cbox_file_download", function () { 137 var rootCat = ".wpfd-content-default.wpfd-content-multi[data-category=" + sc + "]"; 138 var selectedFiles = $(rootCat + " input.cbox_file_download:checked"); 139 var mailNotify = parseInt($(rootCat + " .wpfd_category_notify_file_changes").val()) === 1 ? true : false; 140 var globalNotify = parseInt($(rootCat + " .wpfd_global_notify_file_changes").val()) === 1 ? true : false; 141 var loginUser = parseInt($(rootCat + " .wpfd_user_login").val()) === 0 ? false : true; 142 var filesId = []; 143 144 if (selectedFiles.length) { 145 selectedFiles.each(function (index, file) { 146 filesId.push($(file).data('id')); 147 }); 148 } 149 150 if (!globalNotify || !loginUser) { 151 mailNotify = false; 152 } 153 154 if (filesId.length > 0) { 155 $(rootCat + " .wpfdSelectedFiles").remove(); 156 $('<input type="hidden" class="wpfdSelectedFiles" value="' + filesId.join(',') + '" />') 157 .insertAfter($(rootCat).find(" #current_category_slug_" + sc)); 158 hideDownloadAllBtn(sc, true); 159 $(rootCat + " .default-download-selected").remove(); 160 161 if (mailNotify) { 162 $(rootCat).find(".wpfd-category-mail-subscribe-selected").remove(); 163 $(rootCat).find(".wpfd-category-mail-subscribe-all").hide(); 164 var mailSelectedBtn = $('<a href="javascript:void(0);" class="wpfd-category-mail-subscribe-selected" style="display: block;">' + wpfdparams.translates.mail_notify_selected + '</a>'); 165 $(rootCat).find("div.wpfd-header-btn-group").append(mailSelectedBtn); 166 } 167 168 var downloadSelectedBtn = $('<a href="javascript:void(0);" class="default-download-selected" style="display: block;">' + wpfdparams.translates.download_selected + '<i class="zmdi zmdi-check-all wpfd-download-category"></i></a>'); 169 $(rootCat).find("div.wpfd-header-btn-group").append(downloadSelectedBtn); 170 } else { 171 $(rootCat + " .wpfdSelectedFiles").remove(); 172 $(rootCat + " .default-download-selected").remove(); 173 hideDownloadAllBtn(sc, false); 174 175 if (mailNotify) { 176 $(rootCat).find(".wpfd-category-mail-subscribe-selected").remove(); 177 $(rootCat).find(".wpfd-category-mail-subscribe-all").show(); 178 } 179 } 180 }); 181 } 182 183 function hideDownloadAllBtn(sc, hide) { 184 var rootCat = ".wpfd-content-default.wpfd-content-multi[data-category=" + sc + "]"; 185 var downloadCatButton = $(rootCat + " .default-download-category"); 186 if (downloadCatButton.length === 0 || downloadCatButton.hasClass('display-download-category')) { 187 return; 188 } 189 if (hide) { 190 $(rootCat + " .default-download-category").hide(); 191 } else { 192 $(rootCat + " .default-download-category").show(); 193 } 194 } 195 196 function showMailSubscriptions(sc, show) { 197 var rootCat = ".wpfd-content.wpfd-content-multi[data-category=" + sc + "]"; 198 var globalNotify = parseInt($(rootCat + " .wpfd_global_notify_file_changes").val()) === 1 ? true : false; 199 var loginUser = parseInt($(rootCat + " .wpfd_user_login").val()) === 0 ? false : true; 200 var subscribeAll = $(rootCat + " .wpfd-category-mail-subscribe-all"); 201 var subscribeSelected = $(rootCat + " .wpfd-category-mail-subscribe-selected"); 202 203 if (show) { 204 subscribeAll.show(); 205 subscribeSelected.show(); 206 } else { 207 subscribeAll.hide(); 208 subscribeSelected.hide(); 209 } 210 211 if (!globalNotify || !loginUser) { 212 subscribeAll.hide(); 213 subscribeSelected.hide(); 214 } 215 } 216 217 function initDownloadSelected(sc) { 218 var rootCat = ".wpfd-content-default.wpfd-content-multi[data-category=" + sc + "]"; 219 $(document).on('click', rootCat + ' .default-download-selected', function () { 220 if ($(rootCat).find('.wpfdSelectedFiles').length > 0) { 221 var current_category = $(rootCat).find('#current_category_' + sc).val(); 222 var category_name = $(rootCat).find('#current_category_slug_' + sc).val(); 223 var selectedFilesId = $(rootCat).find('.wpfdSelectedFiles').val(); 224 $.ajax({ 225 url: wpfdparams.wpfdajaxurl + "?action=wpfd&task=files.zipSeletedFiles&filesId=" + selectedFilesId + "&wpfd_category_id=" + current_category, 226 dataType: "json", 227 }).done(function (results) { 228 if (results.success) { 229 var hash = results.data.hash; 230 window.location.href = wpfdparams.wpfdajaxurl + "?action=wpfd&task=files.downloadZipedFile&hash=" + hash + "&wpfd_category_id=" + current_category + "&wpfd_category_name=" + category_name; 231 } else { 232 alert(results.data.message); 233 } 234 }) 235 } 236 }); 237 } 238 239 function wpfdMailNotifyFileChanges(sc) { 240 var rootCat = ".wpfd-content-default.wpfd-content-multi[data-category=" + sc + "]"; 241 242 // Mail notify all files 243 $(document).on('click', rootCat + ' .wpfd-category-mail-subscribe-all', function (e) { 244 e.preventDefault(); 245 var current_category = $(rootCat).find('#current_category_' + sc).val(); 246 var category_name = $(rootCat).find('#current_category_slug_' + sc).val(); 247 var selectedFilesId = $(rootCat).find('.wpfdSelectedFiles').val(); 248 var title = $(rootCat).find('.wpfd-category-mail-subscribe-all').text(); 249 $.ajax({ 250 url: wpfdparams.wpfdajaxurl + "?action=wpfd&task=files.mailNotifyEntireCategoryFiles&wpfd_category_id=" + current_category, 251 dataType: "json", 252 beforeSend: function () { 253 $(rootCat).find('.wpfd-category-mail-subscribe-all').text('Subscribing...'); 254 }, 255 }).done(function (results) { 256 if (results.success) { 257 var hash = results.data.hash; 258 $(rootCat).find('.wpfd-category-mail-subscribe-all').text('Done!'); 259 setTimeout(function () { 260 $(rootCat).find('.wpfd-category-mail-subscribe-all').text(title); 261 }, 1500); 262 } else { 263 alert(results.data.message); 264 } 265 }) 266 }); 267 268 // Mail notify selected files 269 $(document).on('click', rootCat + ' .wpfd-category-mail-subscribe-selected', function (e) { 270 e.preventDefault(); 271 if ($(rootCat).find('.wpfdSelectedFiles').length > 0) { 272 var current_category = $(rootCat).find('#current_category_' + sc).val(); 273 var category_name = $(rootCat).find('#current_category_slug_' + sc).val(); 274 var selectedFilesId = $(rootCat).find('.wpfdSelectedFiles').val(); 275 $.ajax({ 276 url: wpfdparams.wpfdajaxurl + "?action=wpfd&task=files.mailNotifySelectedFiles&filesId=" + selectedFilesId + "&wpfd_category_id=" + current_category, 277 dataType: "json", 278 beforeSend: function () { 279 $(rootCat).find('.wpfd-category-mail-subscribe-selected').text('Subscribing...'); 280 }, 281 }).done(function (results) { 282 if (results.success) { 283 var hash = results.data.hash; 284 $(rootCat).find('.wpfd-category-mail-subscribe-selected').text('Done!'); 285 setTimeout(function () { 286 $(rootCat).find('.wpfd-category-mail-subscribe-selected').text(wpfdparams.translates.mail_notify_selected); 287 }, 1500); 288 } else { 289 alert(results.data.message); 290 } 291 }) 292 } 293 }); 294 } 295 296 function wpfdFrontFilesOrdering(sc) { 297 var sourcecat = ".wpfd-content-default.wpfd-content-multi[data-category=" + sc + "]"; 298 299 // Front files ordering 300 $(document).on('change', sourcecat + ' .ju-front-ordering', function (e) { 301 e.preventDefault(); 302 303 // Just specific category shortcode generator, not ALL 304 if (parseInt(sc) === 0) { 305 return false;
306 } 307 308 var current_category_id = $(sourcecat).find('#current_category_' + sc).val(); 309 var front_files_ordering = $(sourcecat + ' .front-selected-files-ordering').val(); 310 var front_files_ordering_direction = $(sourcecat + ' .front-selected-files-ordering-direction').val(); 311 var page = 1; 312 var page_limit = $(sourcecat).find('#page_limit_' + sc).val(); 313 var show_files = 1; 314 var ordering_hash = window.location.hash; 315 ordering_hash = ordering_hash.replace('#', ''); 316 317 if (ordering_hash !== '' && ordering_hash.indexOf('-wpfd-') !== -1) { 318 var hasha = ordering_hash.split('-'); 319 var re = new RegExp("^(p[0-9]+)$"); 320 var stringpage = hasha.pop(); 321 322 if (re.test(stringpage)) { 323 page = stringpage.replace('p', ''); 324 } 325 } 326 327 $(sourcecat).find('#current_ordering_' + sc).val(front_files_ordering); 328 $(sourcecat).find('#current_ordering_direction_' + sc).val(front_files_ordering_direction); 329 330 default_front_ordering_load(sc, current_category_id, page); 331 }); 332 } 333 334 default_initClick(); 335 336 if (typeof wpfdColorboxInit !== 'undefined') { 337 wpfdColorboxInit(); 338 } 339 340 function wpfd_default_menu_category_link_handlers() { 341 if ($('.wpfd_menu_category_links .elementor-icon-list-item').length) { 342 $('.wpfd_menu_category_links .elementor-icon-list-item').unbind('click').on('click', function (e) { 343 var hashSubUrl = $(this).find('a').attr('href'); 344 var hashGoId = ''; 345 346 if (hashSubUrl.indexOf('/') !== -1) { 347 var hashParams = hashSubUrl.split('/'); 348 hashGoId = hashParams[hashParams.length - 1]; 349 hashGoId = hashGoId.replace('#', ''); 350 351 if (hashGoId !== '') { 352 var hashGoIda = hashGoId.split('-'); 353 var hashGoIda_sourcecat = hashGoIda[0]; 354 var hashGoIda_category_id = hashGoIda[1]; 355 356 setTimeout(function () { 357 default_load(hashGoIda_sourcecat, hashGoIda_category_id, null); 358 if ($('#e-n-menu-content-1872').length) { 359 $('#e-n-menu-content-1872').hide(); 360 } 361 }, 100); 362 } 363 } 364 }); 365 } 366 } 367 368 wpfd_default_menu_category_link_handlers(); 369 370 default_hash = default_hash.replace('#', ''); 371 if (default_hash !== '' && default_hash.indexOf('-wpfd-') !== -1) { 372 var hasha = default_hash.split('-'); 373 var re = new RegExp("^(p[0-9]+)$"); 374 var page = null; 375 var stringpage = hasha.pop(); 376 377 if (re.test(stringpage)) { 378 page = stringpage.replace('p', ''); 379 } 380 381 var hash_category_id = hasha[1]; 382 var hash_sourcecat = hasha[0]; 383 384 if (hash_sourcecat.toString() === 'all_0' && parseInt(hash_category_id) === 0) { 385 hash_category_id = 'all_0'; 386 } 387 388 if (parseInt(hash_category_id) > 0 || hash_category_id === 'all_0') { 389 if (hash_sourcecat.toString() !== 'all_0' && hash_category_id == 'all_0') { 390 hash_category_id = 0; 391 } 392 setTimeout(function () { 393 default_load(hash_sourcecat, hash_category_id, page); 394 current_folder_showing(hash_category_id); 395 }, 100); 396 } 397 } 398 399 _wpfd_text = function (text) { 400 if (typeof (l10n) !== 'undefined') { 401 return l10n[text]; 402 } 403 return text; 404 }; 405 406 function toMB(mb) { 407 return mb * 1024 * 1024; 408 } 409 var allowedExt = wpfdparams.allowed; 410 allowedExt = allowedExt.split(','); 411 allowedExt.sort(); 412 413 function initUploader(currentContainer) { 414 var upload_type = 'file'; 415 // Init the uploader 416 var uploader = new Resumable({ 417 target: wpfdparams.wpfduploadajax + '?action=wpfd&task=files.upload&upload_from=front', 418 query: { 419 id_category: $(currentContainer).find('input[name=id_category]').val(), 420 }, 421 fileParameterName: 'file_upload', 422 simultaneousUploads: 2, 423 maxFileSize: toMB(wpfdparams.maxFileSize), 424 maxFileSizeErrorCallback: function (file) { 425 alert(file.name + ' ' + _wpfd_text('is too large, please upload file(s) less than ') + wpfdparams.maxFileSize + 'Mb!'); 426 }, 427 chunkSize: wpfdparams.serverUploadLimit - 50 * 1024, // Reduce 50KB to avoid error 428 forceChunkSize: true, 429 fileType: allowedExt, 430 fileTypeErrorCallback: function (file) { 431 alert(file.name + ' cannot upload!<br/><br/>' + _wpfd_text('This type of file is not allowed to be uploaded. You can add new file types in the plugin configuration')); 432 }, 433 generateUniqueIdentifier: function (file, event) { 434 var relativePath = file.webkitRelativePath || file.fileName || file.name; 435 var size = file.size; 436 var prefix = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); 437 return (prefix + size + '-' + relativePath.replace(/[^0-9a-zA-Z_-]/img, '')); 438 } 439 }); 440 441 if (!uploader.support) { 442 alert(_wpfd_text('Your browser does not support HTML5 file uploads!')); 443 } 444 445 if (typeof (willUpload) === 'undefined') { 446 var willUpload = true; 447 } 448 449 uploader.on('createFolders', function (files) { 450 upload_type = 'folder'; 451 var currentRootCat = currentContainer.find('input[name=id_category]').val() 452 // Prepare category tree 453 var paths = files.map(function(file) { 454 if (file.hasOwnProperty('catId')) { 455 currentRootCat = file.catId; 456 } 457 var filePath = (file.hasOwnProperty('relativePath')) ? file.relativePath : file.webkitRelativePath; 458 var namePos = filePath.lastIndexOf(file.name); 459 return filePath.substr(0,namePos); 460 }); 461 // get unique value (not empty value) 462 paths = paths.filter( function(item, i, ar) { return item && ar.indexOf(item) === i } ); 463 if (paths.length > 0) { 464 var categoryType = currentContainer.find('input[name=category_type]').val(); 465 // Send ajax to initial categories 466 $.ajax({ 467 url: wpfdparams.wpfduploadajax + '?action=wpfd&task=categories.createCategoriesDeep', 468 data: { 469 paths: paths.join('|'), 470 category_id: currentRootCat, 471 type: categoryType 472 }, 473 method: 'POST', 474 success: function (data) { 475 } 476 }); 477 } 478 }) 479 480 uploader.on('filesAdded', function (files) {
481 files.forEach(function (file) { 482 var progressBlock = '<div class="wpfd_process_block" id="' + file.uniqueIdentifier + '">' 483 + '<div class="wpfd_process_fileinfo">' 484 + '<span class="wpfd_process_filename">' + file.fileName + '</span>' 485 + '<span class="wpfd_process_cancel">Cancel</span>' 486 + '</div>' 487 + '<div class="wpfd_process_full" style="display: block;">' 488 + '<div class="wpfd_process_run" data-w="0" style="width: 0%;"></div>' 489 + '</div></div>'; 490 491 //$('#preview', '.wpreview').before(progressBlock); 492 currentContainer.find('#preview', '.wpreview').before(progressBlock); 493 $(currentContainer).find('.wpfd_process_cancel').unbind('click').click(function () { 494 fileID = $(this).parents('.wpfd_process_block').attr('id'); 495 fileObj = uploader.getFromUniqueIdentifier(fileID); 496 uploader.removeFile(fileObj); 497 $(this).parents('.wpfd_process_block').fadeOut('normal', function () { 498 $(this).remove(); 499 }); 500 501 if (uploader.files.length === 0) { 502 $(currentContainer).find('.wpfd_process_pause').fadeOut('normal', function () { 503 $(this).remove(); 504 }); 505 } 506 507 $.ajax({ 508 url: wpfdparams.wpfduploadajax + '?action=wpfd&task=files.upload', 509 method: 'POST', 510 dataType: 'json', 511 data: { 512 id_category: currentContainer.find('input[name=id_category]').val(), 513 deleteChunks: fileID 514 }, 515 success: function (res, stt) { 516 if (res.response === true) { 517 } 518 } 519 }) 520 }); 521 }); 522 523 // Do not run uploader if no files added or upload same files again 524 if (files.length > 0) { 525 uploadPauseBtn = $(currentContainer).find('.wpreview').find('.wpfd_process_pause').length; 526 restableBlock = $(currentContainer).find('.wpfd_process_block'); 527 528 if (!uploadPauseBtn) { 529 restableBlock.before('<div class="wpfd_process_pause">Pause</div>'); 530 $(currentContainer).find('.wpfd_process_pause').unbind('click').click(function () { 531 if (uploader.isUploading()) { 532 uploader.pause(); 533 $(this).text('Start'); 534 $(this).addClass('paused'); 535 willUpload = false; 536 } else { 537 uploader.upload(); 538 $(this).text('Pause'); 539 $(this).removeClass('paused'); 540 willUpload = true; 541 } 542 }); 543 } 544 545 uploader.opts.query = { 546 id_category: currentContainer.find('input[name=id_category]').val() 547 }; 548 549 if (willUpload) { 550 setTimeout( function() {uploader.upload();}, 1000); 551 } 552 } 553 }); 554 555 uploader.on('fileProgress', function (file) { 556 $(currentContainer).find('.wpfd_process_block#' + file.uniqueIdentifier) 557 .find('.wpfd_process_run').width(Math.floor(file.progress() * 100) + '%'); 558 }); 559 560 uploader.on('fileSuccess', function (file, res) { 561 var thisUploadBlock = currentContainer.find('.wpfd_process_block#' + file.uniqueIdentifier); 562 thisUploadBlock.find('.wpfd_process_cancel').addClass('uploadDone').text('OK').unbind('click'); 563 thisUploadBlock.find('.wpfd_process_full').remove(); 564 565 var response = JSON.parse(res); 566 if (response.response === false && typeof(response.datas) !== 'undefined') { 567 if (typeof(response.datas.code) !== 'undefined' && response.datas.code > 20) { 568 alert('<div>' + response.datas.message + '</div>'); 569 return false;
570 } 571 } 572 if (typeof(response) === 'string') { 573 alert('<div>' + response + '</div>'); 574 return false; 575 } 576 577 if (response.response !== true) { 578 alert(response.response); 579 return false; 580 } 581 }); 582 583 uploader.on('fileError', function (file, msg) { 584 thisUploadBlock = currentContainer.find('.wpfd_process_block#' + file.uniqueIdentifier); 585 thisUploadBlock.find('.wpfd_process_cancel').addClass('uploadError').text('Error').unbind('click'); 586 thisUploadBlock.find('.wpfd_process_full').remove(); 587 }); 588 589 uploader.on('complete', function () { 590 //load sub categories 591 var currentRootCat = currentContainer.find('input[name=id_category]').val(); 592 var sourcecat = currentContainer.parents('.wpfd-content.wpfd-content-multi').data('category'); 593 var theme = currentContainer.parents('.wpfd-content.wpfd-content-multi[data-category=' + sourcecat + ']').find('.wpfd_root_category_theme').val(); 594 var wpfd_tree = $('.wpfd-content[data-category="'+sourcecat+'"] .wpfd-foldertree'); 595 wpfd_tree.jaofiletree({ 596 script: wpfdparams.wpfduploadajax + '?juwpfisadmin=false&action=wpfd&task=categories.getCats', 597 usecheckboxes: false, 598 root: sourcecat, 599 expanded: parseInt(wpfdparams.allow_category_tree_expanded) === 1 ? true : false 600 }); 601 602 var categoryAjaxUrl = wpfdparams.wpfdajaxurl + "task=categories.display&view=categories&id=" + currentRootCat + "&top=" + sourcecat; 603 if (wpfdDefaultCategoriesLocalCache.exist(categoryAjaxUrl)) { 604 wpfdDefaultCategoriesLocalCache.remove(categoryAjaxUrl); 605 } 606 607 var fileCount = $(currentContainer).find('.wpfd_process_cancel').length; 608 var categoryId = $(currentContainer).find('input[name=id_category]').val(); 609 var ajax_url = typeof (wpfdparams.wpfduploadajax) !== 'undefined' ? wpfdparams.wpfduploadajax : wpfd_var.wpfduploadajax; 610 $.ajax({ 611 url: ajax_url + '?action=wpfd&task=files.wpfdPendingUploadFiles', 612 method: 'POST', 613 dataType: 'json', 614 data: { 615 uploadedFiles: fileCount, 616 id_category: categoryId, 617 }, 618 success: function (res) { 619 currentContainer.find('.progress').delay(300).fadeIn(300).hide(300, function () { 620 $(this).remove(); 621 }); 622 currentContainer.find('.uploaded').delay(300).fadeIn(300).hide(300, function () { 623 $(this).remove(); 624 }); 625 $('#wpreview .file').delay(1200).show(1200, function () { 626 $(this).removeClass('done placeholder'); 627 }); 628 629 $('.gritter-item-wrapper ').remove(); 630 $(currentContainer).find('#wpfd-upload-messages').append(wpfdparams.translates.msg_upload_file); 631 $(currentContainer).find('#wpfd-upload-messages').delay(1200).fadeIn(1200, function () { 632 $(currentContainer).find('#wpfd-upload-messages').empty(); 633 $(currentContainer).find('.wpfd_process_pause').remove(); 634 $(currentContainer).find('.wpfd_process_block').remove(); 635 }); 636 637 // Call list files 638 if (currentContainer.parent('.wpfd-upload-form').length) { 639 var sourcecat = currentContainer.parents('.wpfd-content.wpfd-content-multi').data('category'); 640 var current_category = currentContainer.parents('.wpfd-content.wpfd-content-multi').find('#current_category_' + sourcecat).val(); 641 642 // Refresh uploaded files on caching 643 var ordering = currentContainer.parents('.wpfd-content.wpfd-content-multi').find('#current_ordering_' + sourcecat).val(); 644 var orderingDirection = currentContainer.parents('.wpfd-content.wpfd-content-multi').find('#current_ordering_direction_' + sourcecat).val(); 645 var page_limit = currentContainer.parents('.wpfd-content.wpfd-content-multi').find('#page_limit_' + sourcecat).val(); 646 var params = $.param({ 647 task: 'files.display', 648 view: 'files', 649 id: current_category, 650 rootcat: sourcecat, 651 page: page, 652 orderCol: ordering, 653 orderDir: orderingDirection, 654 page_limit: page_limit 655 }); 656 var fileAjaxUrl = wpfdparams.wpfdajaxurl + params; 657 if (wpfdDefaultFilesLocalCache.exist(fileAjaxUrl)) { 658 wpfdDefaultFilesLocalCache.remove(fileAjaxUrl); 659 } 660 661 upload_type = 'file'; 662 default_load(sourcecat, current_category, null,upload_type); 663 return false;
664 } 665 } 666 }); 667 }); 668 669 uploader.assignBrowse($(currentContainer).find('#upload_button')); 670 uploader.assignBrowse($(currentContainer).find('#upload_folder_button'), true); 671 uploader.assignDrop($(currentContainer).find('.jsWpfdFrontUpload')); 672 } 673 674 function default_load(sourcecat, catid, page, upload_type) { 675 $(document).trigger('wpfd:category-loading'); 676 var pathname = window.location.href.replace(window.location.hash, ''); 677 var container = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]"); 678 var containerDefault = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default"); 679 var empty_subcategories = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_is_empty_subcategories"); 680 var empty_files = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_is_empty_files"); 681 container.find('#current_category_' + sourcecat).val(catid); 682 container.next('.wpfd-pagination').remove(); 683 containerDefault.empty(); 684 containerDefault.html($('#wpfd-loading-wrap').html()); 685 686 if (empty_subcategories.length) { 687 empty_subcategories.val('1'); 688 } 689 690 if (empty_files.length) { 691 empty_files.val('1'); 692 } 693 694 // Get categories 695 var oldCategoryAjax = window.wpfdAjax[tree_source_cat].category; 696 if (oldCategoryAjax !== null) { 697 oldCategoryAjax.abort(); 698 } 699 var categoryAjaxUrl = wpfdparams.wpfdajaxurl + "task=categories.display&view=categories&id=" + catid + "&top=" + sourcecat; 700 window.wpfdAjax[tree_source_cat].category = $.ajax({ 701 url: categoryAjaxUrl, 702 dataType: "json", 703 cache: true, 704 beforeSend: function () { 705 if (container.find('.wpfd-form-search-file-category').length) { 706 container.find('.wpfd-form-search-file-category').remove(); 707 } 708 709 if (wpfdDefaultCategoriesLocalCache.exist(categoryAjaxUrl) && upload_type != 'folder') { 710 var triggerCategories = wpfdDefaultCategoriesLocalCache.get(categoryAjaxUrl); 711 wpfdDefaultCategoriesLocalCacheTrigger(triggerCategories, sourcecat, page, pathname, catid, container, empty_subcategories); 712 return false; 713 } 714 return true; 715 } 716 }).done(function (categories) { 717 wpfdDefaultCategoriesLocalCache.set(categoryAjaxUrl, categories); 718 719 // Search file in category section 720 var $displayFileSearch = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_root_category_display_file_search'); 721 if ($displayFileSearch.length) { 722 var $themeName = container.find('.wpfd_root_category_theme').val(); 723 724 if (typeof (categories.category.correctConvertCategoryId) === 'undefined') { 725 categories.category.correctConvertCategoryId = 0; 726 } 727 728 var $searchContent = '<form action="" id="adminForm-'+ categories.category.term_id +'" class="wpfd-adminForm wpfd-form-search-file-category" name="adminForm" method="post">' + 729 wpfdparams.wp_nonce_field_localize + 730 '<div id="loader" style="display:none; text-align: center">' + 731 '<img src="'+ wpfdparams.wpfd_plugin_url +'/app/site/assets/images/searchloader.svg" style="margin: 0 auto"/>' + 732 '</div>' + 733 '<div class="box-search-filter wpfd-category-search-section">' + 734 '<div class="searchSection">' + 735 '<div class="only-file input-group clearfix wpfd_search_input" id="Search_container">' + 736 '<img src="'+ wpfdparams.wpfd_plugin_url +'/app/site/assets/images/search-24.svg" class="material-icons wpfd-icon-search wpfd-search-file-category-icon" />' + 737 '<input type="text" class="pull-left required txtfilename" name="q" id="txtfilename" autocomplete="off" placeholder="'+ wpfdparams.translates.msg_search_file_category_placeholder +'" value="" />' + 738 '</div>' + 739 '<button id="btnsearchbelow" class="btnsearchbelow wpfd-btnsearchbelow" type="button">'+ wpfdparams.translates.msg_search_file_category_search +'</button>' + 740 '</div>' + 741 '<input type="hidden" id="filter_catid" class="chzn-select filter_catid" name="catid" value="'+ categories.category.correctConvertCategoryId +'" data-cattype="" data-slug="" />' + 742 '<input type="hidden" name="theme" value="'+ $themeName +'">' + 743 '<input type="hidden" name="limit" value="15">' + 744 '<div id="wpfd-results" class="wpfd-results list-results"></div>' + 745 '</div>' + 746 '</form>'; 747 748 container.prepend($searchContent); 749 wpfdDefaultSearchFileCategoryHandle(); 750 } 751 752 // Notify file changes 753 if (typeof (categories.notify_file_changes) !== 'undefined' && parseInt(categories.notify_file_changes) === 1) { 754 $(".wpfd-content.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_category_notify_file_changes').val('1'); 755 showMailSubscriptions(sourcecat, true); 756 } else { 757 $(".wpfd-content.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_category_notify_file_changes').val('0'); 758 showMailSubscriptions(sourcecat, false); 759 } 760 761 if (page !== null && page !== undefined) { 762 window.history.pushState('', document.title, pathname + '#' + sourcecat + '-' + catid + '-wpfd-' + categories.category.slug + '-p' + page); 763 } else { 764 window.history.pushState('', document.title, pathname + '#' + sourcecat + '-' + catid + '-wpfd-' + categories.category.slug); 765 } 766 767 container.find('#current_category_slug_' + sourcecat).val(categories.category.slug); 768 var sourcecategories = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-template-categories").html(); 769 if (sourcecategories) { 770 var template = Handlebars.compile(sourcecategories); 771 var html = template(categories); 772 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").prepend(html); 773 } 774 775 if (categories.category.breadcrumbs !== undefined) { 776 if (sourcecat.toString() === 'all_0' && catid.toString() !== 'all_0' && parseInt(catid) !== 0) { 777 categories.category.breadcrumbs = allCategoriesBreadcrumbs + categories.category.breadcrumbs; 778 } 779 $(".wpfd-content-multi[data-category=" + sourcecat + "] .breadcrumbs").html(categories.category.breadcrumbs); 780 } 781 782 for (var i = 0; i < categories.categories.length; i++) { 783 cParents[categories.categories[i].term_id] = categories.categories[i]; 784 } 785 786 default_breadcrum(sourcecat, catid, categories.category); 787 default_initClick(); 788 789 if (tree.length) { 790 var currentTree = container.find('.wpfd-foldertree-default'); 791 currentTree.find('li').removeClass('selected'); 792 currentTree.find('i.md').removeClass('md-folder-open').addClass("md-folder"); 793 currentTree.jaofiletree('open', sourcecat, currentTree); 794 currentTree.jaofiletree('open', catid, currentTree); 795 796 var el = currentTree.find('a[data-file="' + catid + '"]').parent(); 797 el.find(' > i.md').removeClass("md-folder").addClass("md-folder-open"); 798 799 if (!el.hasClass('selected')) { 800 el.addClass('selected'); 801 } 802 var ps = currentTree.find('.icon-open-close'); 803 804 $.each(ps.get().reverse(), function (i, p) { 805 if (typeof $(p).data() !== 'undefined' && $(p).data('id') == Number(hash_category_id)) { 806 hash_category_id = $(p).data('parent_id'); 807 if(parseInt(wpfdparams.allow_category_tree_expanded) !== 1) { 808 $(p).click(); 809 } 810 } 811 }); 812 } 813 814 if ($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default >
814 .wpfd-password-form").length) { 815 hideDownloadAllBtn(sourcecat, true); 816 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").attr('href', '#'); 817 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdcategory").hide(); 818 } 819 820 // Clean mail checkbox 821 if (parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_category_notify_file_changes").val()) === 0 || 822 parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_global_notify_file_changes").val()) === 0) { 823 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd_cloud_checkbox_mail").remove(); 824 } 825 826 if (empty_subcategories.length) { 827 empty_subcategories.val(categories.categories.length); 828 fire_empty_category_message(sourcecat); 829 } 830 }); 831 832 var ordering = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('#current_ordering_' + sourcecat).val(); 833 var orderingDirection = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('#current_ordering_direction_' + sourcecat).val(); 834 var page_limit = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('#page_limit_' + sourcecat).val(); 835 var themeName = $(".wpfd-content-default[data-category=" + sourcecat + "]").find('.wpfd_root_category_theme').val(); 836 var show_files = 1; 837 var atts_shortcode = window["wpfdfrontend_" + themeName]; 838 if (atts_shortcode !== undefined && atts_shortcode.shortcode_param.show_files !== undefined && sourcecat === 'all_0' && (parseInt(catid) === 0 || catid === 'all_0')) { 839 show_files = atts_shortcode.shortcode_param.show_files; 840 } 841 842 var params = $.param({ 843 task: 'files.display', 844 view: 'files', 845 id: catid, 846 rootcat: sourcecat, 847 page: page, 848 orderCol: ordering, 849 orderDir: orderingDirection, 850 page_limit: page_limit, 851 show_files: show_files 852 }); 853 854 //Get files 855 var oldFileAjax = window.wpfdAjax[tree_source_cat].file; 856 var fileAjaxUrl = wpfdparams.wpfdajaxurl + params; 857 if (oldFileAjax !== null) { 858 oldFileAjax.abort(); 859 } 860 window.wpfdAjax[tree_source_cat].file = $.ajax({ 861 url: fileAjaxUrl, 862 dataType: "json", 863 cache: true, 864 beforeSend: function () { 865 if (wpfdDefaultFilesLocalCache.exist(fileAjaxUrl) && (upload_type === null || upload_type === undefined)) { 866 var triggerFiles = wpfdDefaultFilesLocalCache.get(fileAjaxUrl); 867 wpfdDefaultFilesLocalCacheTrigger(triggerFiles, sourcecat, empty_files, fileAjaxUrl); 868 return false; 869 } 870 return true; 871 } 872 }).done(function (content) { 873 // Set files local cache 874 if (typeof (content.pagination) !== 'undefined' && content.pagination.length) { 875 content.cache_pagination = content.pagination; 876 } 877 wpfdDefaultFilesLocalCache.set(fileAjaxUrl, content); 878 879 if (typeof (content.categoryPassword) !== 'undefined' && content.categoryPassword.length) { 880 hideDownloadAllBtn(sourcecat, true); 881 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").attr('href', '#'); 882 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdcategory").hide(); 883 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").empty(); 884 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").append(content.categoryPassword); 885 } else { 886 if (content.files.length || content.downloadable_files.length) { 887 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").removeClass("display-download-category"); 888 } else { 889 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").addClass("display-download-category"); 890 } 891 892 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").after(content.pagination); 893 delete content.pagination; 894 var sourcefiles = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-template-files").html(); 895 if (sourcefiles) { 896 var template = Handlebars.compile(sourcefiles); 897 var html = template(content); 898 html = $('<textarea/>').html(html).val(); 899 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").append(html); 900 901 if ($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default .file .file-custom-field.file-url").length) { 902 var link = typeof (wpfdparams.translates.wpfd_url_custom_field) !== 'undefined' ? wpfdparams.translates.wpfd_url_custom_field : 'Link'; 903 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default .file .file-custom-field.file-url").each(function () { 904 var label = $(this).attr('data-field-label'); 905 var url = $(this).attr('data-field-val'); 906 var urlContents = '<div><span>
906' + label + ': </span><a href="' + url + '" target="_blank">' + link + '</a></div>'; 907 $(this).empty().append(urlContents); 908 }); 909 } 910 } 911 912 if (typeof (content.filepasswords) !== 'undefined') { 913 $.each(content.filepasswords, function( file_id, pw_form ) { 914 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').empty(); 915 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').addClass('wpfd-password-protection-form'); 916 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').append(pw_form); 917 }); 918 } 919 920 if (content.uploadform !== undefined && content.uploadform.length) { 921 var upload_form_html = '<div class="wpfd-upload-form" style="margin: 20px 10px">'; 922 upload_form_html += content.uploadform; 923 upload_form_html += '</div>'; 924 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").append(upload_form_html); 925 926 if (typeof (Wpfd) === 'undefined') { 927 Wpfd = {}; 928 } 929 930 var containers = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] div[class*=wpfdUploadForm]"); 931 if (containers.length > 0) { 932 containers.each(function(i, el) { 933 initUploader($(el)); 934 }); 935 } 936 } 937 938 if (typeof wpfdColorboxInit !== 'undefined') { 939 wpfdColorboxInit(); 940 } 941 942 wpfdTrackDownload(); 943 944 default_init_pagination($('.wpfd-content-default[data-category=' + sourcecat + '] + .wpfd-pagination')); 945 wpfd_remove_loading($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default")); 946 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdSelectedFiles").remove(); 947 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-selected").remove(); 948 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-category-mail-subscribe-selected").remove(); 949 hideDownloadAllBtn(sourcecat, false); 950 } 951 if (empty_files.length) { 952 empty_files.val(content.files.length); 953 fire_empty_category_message(sourcecat); 954 } 955 956 // Clean mail checkbox 957 if (parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_category_notify_file_changes").val()) === 0 || 958 parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_global_notify_file_changes").val()) === 0) { 959 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd_cloud_checkbox_mail").remove(); 960 } 961 962 if (typeof (content.notify_file_changes) !== 'undefined' && parseInt(content.notify_file_changes) === 1) { 963 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_mail_checkbox').show(); 964 } 965 966 wpfdDefaultDisplayDownloadedFiles(); 967 wpfdDefaultDownloadFiles(); 968 wpfdPreviewFileNewName(); 969 wpfdWooCommerceAddToCart(); 970 }); 971 $(document).trigger('wpfd:category-loaded'); 972 } 973 974 function default_front_ordering_load(sourcecat, catid, page) { 975 var pathname = window.location.href.replace(window.location.hash, ''); 976 var container = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]"); 977 var containerDefault = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default"); 978 var empty_subcategories = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_is_empty_subcategories"); 979 var empty_files = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_is_empty_f
979iles"); 980 container.find('#current_category_' + sourcecat).val(catid); 981 container.next('.wpfd-pagination').remove(); 982 containerDefault.empty(); 983 containerDefault.html($('#wpfd-loading-wrap').html()); 984 985 if (empty_subcategories.length) { 986 empty_subcategories.val('1'); 987 } 988 989 if (empty_files.length) { 990 empty_files.val('1'); 991 } 992 993 // Ordering get categories 994 var categoryAjaxUrl = wpfdparams.wpfdajaxurl + "task=categories.display&view=categories&id=" + catid + "&top=" + sourcecat; 995 window.wpfdAjax[tree_source_cat].category = $.ajax({ 996 url: categoryAjaxUrl, 997 dataType: "json", 998 cache: true, 999 beforeSend: function () { 1000 if (container.find('.wpfd-form-search-file-category').length) { 1001 container.find('.wpfd-form-search-file-category').remove(); 1002 } 1003 return true; 1004 } 1005 }).done(function (categories) { 1006 // Search file in category section 1007 var $displayFileSearch = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_root_category_display_file_search'); 1008 if ($displayFileSearch.length) { 1009 var $themeName = container.find('.wpfd_root_category_theme').val(); 1010 1011 if (typeof (categories.category.correctConvertCategoryId) === 'undefined') { 1012 categories.category.correctConvertCategoryId = 0; 1013 } 1014 1015 var $searchContent = '<form action="" id="adminForm-'+ categories.category.term_id +'" class="wpfd-adminForm wpfd-form-search-file-category" name="adminForm" method="post">' + 1016 wpfdparams.wp_nonce_field_localize + 1017 '<div id="loader" style="display:none; text-align: center">' + 1018 '<img src="'+ wpfdparams.wpfd_plugin_url +'/app/site/assets/images/searchloader.svg" style="margin: 0 auto"/>' + 1019 '</div>' + 1020 '<div class="box-search-filter wpfd-category-search-section">' + 1021 '<div class="searchSection">' + 1022 '<div class="only-file input-group clearfix wpfd_search_input" id="Search_container">' + 1023 '<img src="'+ wpfdparams.wpfd_plugin_url +'/app/site/assets/images/search-24.svg" class="material-icons wpfd-icon-search wpfd-search-file-category-icon" />' + 1024 '<input type="text" class="pull-left required txtfilename" name="q" id="txtfilename" autocomplete="off" placeholder="'+ wpfdparams.translates.msg_search_file_category_placeholder +'" value="" />' + 1025 '</div>' + 1026 '<button id="btnsearchbelow" class="btnsearchbelow wpfd-btnsearchbelow" type="button">'+ wpfdparams.translates.msg_search_file_category_search +'</button>' + 1027 '</div>' + 1028 '<input type="hidden" id="filter_catid" class="chzn-select filter_catid" name="catid" value="'+ categories.category.correctConvertCategoryId +'" data-cattype="" data-slug="" />' + 1029 '<input type="hidden" name="theme" value="'+ $themeName +'">' + 1030 '<input type="hidden" name="limit" value="15">' + 1031 '<div id="wpfd-results" class="wpfd-results list-results"></div>' + 1032 '</div>' + 1033 '</form>'; 1034 1035 container.prepend($searchContent); 1036 wpfdDefaultSearchFileCategoryHandle(); 1037 } 1038 1039 // Notify file changes 1040 if (typeof (categories.notify_file_changes) !== 'undefined' && parseInt(categories.notify_file_changes) === 1) { 1041 $(".wpfd-content.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_category_notify_file_changes').val('1'); 1042 showMailSubscriptions(sourcecat, true); 1043 } else { 1044 $(".wpfd-content.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_category_notify_file_changes').val('0'); 1045 showMailSubscriptions(sourcecat, false); 1046 } 1047 1048 container.find('#current_category_slug_' + sourcecat).val(categories.category.slug); 1049 var sourcecategories = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-template-categories").html(); 1050 1051 if (sourcecategories) { 1052 var template = Handlebars.compile(sourcecategories); 1053 var html = template(categories); 1054 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").prepend(html); 1055 } 1056 1057 if (categories.category.breadcrumbs !== undefined) { 1058 if (sourcecat.toString() === 'all_0' && catid.toString() !== 'all_0' && parseInt(catid) !== 0) { 1059 categories.category.breadcrumbs = allCategoriesBreadcrumbs + categories.category.breadcrumbs; 1060 } 1061 $(".wpfd-content-multi[data-category=" + sourcecat + "] .breadcrumbs").html(categories.category.breadcrumbs); 1062 } 1063 1064 for (var i = 0; i < categories.categories.length; i++) { 1065 cParents[categories.categories[i].term_id] = categories.categories[i]; 1066 } 1067 1068 default_breadcrum(sourcecat, catid, categories.category); 1069 default_initClick(); 1070 1071 if (tree.length) { 1072 var currentTree = container.find('.wpfd-foldertree-default'); 1073 currentTree.find('li').removeClass('selected'); 1074 currentTree.find('i.md').removeClass('md-folder-open').addClass("md-folder"); 1075 currentTree.jaofiletree('open', catid, currentTree); 1076 var el = currentTree.find('a[data-file="' + catid + '"]').parent(); 1077 el.find(' > i.md').removeClass("md-folder").addClass("md-folder-open"); 1078 1079 if (!el.hasClass('selected')) { 1080 el.addClass('selected'); 1081 } 1082 1083 var ps = currentTree.find('.icon-open-close'); 1084 1085 $.each(ps.get().reverse(), function (i, p) { 1086 if (typeof $(p).data() !== 'undefined' && $(p).data('id') == Number(hash_category_id)) { 1087 hash_category_id = $(p).data('parent_id'); 1088 if(parseInt(wpfdparams.allow_category_tree_expanded) !== 1) { 1089 $(p).click(); 1090 } 1091 } 1092 }); 1093 } 1094 1095 if ($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default >
1095 .wpfd-password-form").length) { 1096 hideDownloadAllBtn(sourcecat, true); 1097 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").attr('href', '#'); 1098 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdcategory").hide(); 1099 } 1100 1101 // Clean mail checkbox 1102 if (parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_category_notify_file_changes").val()) === 0 || 1103 parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_global_notify_file_changes").val()) === 0) { 1104 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd_cloud_checkbox_mail").remove(); 1105 } 1106 1107 if (empty_subcategories.length) { 1108 empty_subcategories.val(categories.categories.length); 1109 fire_empty_category_message(sourcecat); 1110 } 1111 }); 1112 1113 var ordering = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('#current_ordering_' + sourcecat).val(); 1114 var orderingDirection = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('#current_ordering_direction_' + sourcecat).val(); 1115 var page_limit = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('#page_limit_' + sourcecat).val(); 1116 var themeName = $(".wpfd-content-default[data-category=" + sourcecat + "]").find('.wpfd_root_category_theme').val(); 1117 var show_files = 1; 1118 var atts_shortcode = window["wpfdfrontend_" + themeName]; 1119 1120 if (atts_shortcode !== undefined && atts_shortcode.shortcode_param.show_files !== undefined && sourcecat === 'all_0' && (parseInt(catid) === 0 || catid === 'all_0')) { 1121 show_files = atts_shortcode.shortcode_param.show_files; 1122 } 1123 1124 var params = $.param({ 1125 task: 'files.display', 1126 view: 'files', 1127 id: catid, 1128 rootcat: sourcecat, 1129 page: page, 1130 orderCol: ordering, 1131 orderDir: orderingDirection, 1132 page_limit: page_limit, 1133 show_files: show_files 1134 }); 1135 1136 // Ordering get files 1137 var fileAjaxUrl = wpfdparams.wpfdajaxurl + params; 1138 window.wpfdAjax[tree_source_cat].file = $.ajax({ 1139 url: fileAjaxUrl, 1140 dataType: "json", 1141 cache: true, 1142 beforeSend: function () { 1143 return true; 1144 } 1145 }).done(function (content) { 1146 // Set files local cache 1147 if (typeof (content.pagination) !== 'undefined' && content.pagination.length) { 1148 content.cache_pagination = content.pagination; 1149 } 1150 1151 if (typeof (content.categoryPassword) !== 'undefined' && content.categoryPassword.length) { 1152 hideDownloadAllBtn(sourcecat, true); 1153 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").attr('href', '#'); 1154 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdcategory").hide(); 1155 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").empty(); 1156 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").append(content.categoryPassword); 1157 } else { 1158 if (content.files.length || content.downloadable_files.length) { 1159 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").removeClass("display-download-category"); 1160 } else { 1161 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").addClass("display-download-category"); 1162 } 1163 1164 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").after(content.pagination); 1165 delete content.pagination; 1166 var sourcefiles = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-template-files").html(); 1167 if (sourcefiles) { 1168 var template = Handlebars.compile(sourcefiles); 1169 var html = template(content); 1170 html = $('<textarea/>').html(html).val(); 1171 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").append(html); 1172 1173 if ($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default .file .file-custom-field.file-url").length) { 1174 var link = typeof (wpfdparams.translates.wpfd_url_custom_field) !== 'undefined' ? wpfdparams.translates.wpfd_url_custom_field : 'Link'; 1175 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default .file .file-custom-field.file-url").each(function () { 1176 var label = $(this).attr('data-field-label'); 1177 var url = $(this).attr('data-field-val'); 1178 var urlContents = '<div><span>
1178' + label + ': </span><a href="' + url + '" target="_blank">' + link + '</a></div>'; 1179 $(this).empty().append(urlContents); 1180 }); 1181 } 1182 } 1183 1184 if (typeof (content.filepasswords) !== 'undefined') { 1185 $.each(content.filepasswords, function( file_id, pw_form ) { 1186 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').empty(); 1187 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').addClass('wpfd-password-protection-form'); 1188 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').append(pw_form); 1189 }); 1190 } 1191 1192 if (content.uploadform !== undefined && content.uploadform.length) { 1193 var upload_form_html = '<div class="wpfd-upload-form" style="margin: 20px 10px">'; 1194 upload_form_html += content.uploadform; 1195 upload_form_html += '</div>'; 1196 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").append(upload_form_html); 1197 1198 if (typeof (Wpfd) === 'undefined') { 1199 Wpfd = {}; 1200 } 1201 1202 var containers = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] div[class*=wpfdUploadForm]"); 1203 if (containers.length > 0) { 1204 containers.each(function(i, el) { 1205 initUploader($(el)); 1206 }); 1207 } 1208 } 1209 1210 if (typeof wpfdColorboxInit !== 'undefined') { 1211 wpfdColorboxInit(); 1212 } 1213 1214 wpfdTrackDownload(); 1215 default_init_pagination($('.wpfd-content-default[data-category=' + sourcecat + '] + .wpfd-pagination')); 1216 wpfd_remove_loading($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default")); 1217 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdSelectedFiles").remove(); 1218 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-selected").remove(); 1219 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-category-mail-subscribe-selected").remove(); 1220 hideDownloadAllBtn(sourcecat, false); 1221 } 1222 if (empty_files.length) { 1223 empty_files.val(content.files.length); 1224 fire_empty_category_message(sourcecat); 1225 } 1226 1227 // Clean mail checkbox 1228 if (parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_category_notify_file_changes").val()) === 0 || 1229 parseInt($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] #wpfd_global_notify_file_changes").val()) === 0) { 1230 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd_cloud_checkbox_mail").remove(); 1231 } 1232 1233 if (typeof (content.notify_file_changes) !== 'undefined' && parseInt(content.notify_file_changes) === 1) { 1234 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_mail_checkbox').show(); 1235 } 1236 1237 wpfdDefaultDisplayDownloadedFiles(); 1238 wpfdDefaultDownloadFiles(); 1239 wpfdPreviewFileNewName(); 1240 }); 1241 } 1242 1243 function default_breadcrum(sourcecat, catid, category) { 1244 var links = []; 1245 var current_Cat = cParents[catid]; 1246 var defaultdownloadcategory = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category"); 1247 if (!current_Cat) { 1248 defaultdownloadcategory.attr('href', category.linkdownload_cat); 1249 return false;
1250 } 1251 links.unshift(current_Cat); 1252 if (current_Cat.parent !== 0) { 1253 while (cParents[current_Cat.parent]) { 1254 current_Cat = cParents[current_Cat.parent]; 1255 if (links.includes(current_Cat)) { 1256 break; 1257 } 1258 links.unshift(current_Cat); 1259 } 1260 } 1261 1262 var html = ''; 1263 if (sourcecat.toString() === 'all_0' && catid.toString() !== 'all_0' && parseInt(catid) !== 0) { 1264 html = allCategoriesDividerBreadcrumbs; 1265 } 1266 for (var i = 0; i < links.length; i++) { 1267 if (links[i].parent.toString() === 'undefined') { 1268 continue; 1269 } 1270 if (i < links.length - 1) { 1271 if (links[i].term_id != "all_0" && parseInt(links[i].term_id) != 0) { 1272 html += '<li><a class="catlink" data-idcat="' + links[i].term_id + '" href="javascript:void(0)">'; 1273 html += links[i].name + '</a><span class="divider"> > </span></li>'; 1274 } 1275 } else { 1276 if (links[i].term_id != "all_0" && parseInt(links[i].term_id) != 0) { 1277 html += '<li><span>' + links[i].name + '</span></li>'; 1278 } else { 1279 html += '<li><span>' + wpfdparams.translates.wpfd_all_categories + '</span></li>'; 1280 } 1281 } 1282 } 1283 1284 if (html == '' && (catid.toString() == 'all_0' || parseInt(catid) == 0)) { 1285 html += '<li><span>' + wpfdparams.translates.wpfd_all_categories + '</span></li>'; 1286 } 1287 1288 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-breadcrumbs-default").html(html); 1289 defaultdownloadcategory.attr('href', category.linkdownload_cat); 1290 } 1291 1292 if (tree.length) { 1293 tree.each(function () { 1294 var topCat = $(this).parents('.wpfd-content-default.wpfd-content-multi').data('category'); 1295 var is_private_category = $(this).parents('.wpfd-content-default.wpfd-content-multi').hasClass('wpfd-private-category-content'); 1296 var private_category = is_private_category ? 1 : 0; 1297 $(this).jaofiletree({ 1298 script: wpfdparams.wpfdajaxurl + 'task=categories.getCats&private_category=' + private_category, 1299 usecheckboxes: false, 1300 root: topCat, 1301 showroot: cParents[topCat].name, 1302 expanded: parseInt(wpfdparams.allow_category_tree_expanded) === 1 ? true : false, 1303 onclick: function (elem, file) { 1304 if (is_private_category) { 1305 return false; 1306 } 1307 1308 var topCat = $(elem).parents('.wpfd-content-default.wpfd-content-multi').data('category'); 1309 if (topCat !== file) { 1310 $('.directory', $(elem).parents('.wpfd-content-default.wpfd-content-multi')).each(function () { 1311 if (!$(this).hasClass('selected') && $(this).find('> ul > li').length === 0) { 1312 $(this).removeClass('expanded'); 1313 } 1314 }); 1315 1316 if (parseInt(wpfdparams.allow_category_tree_expanded) !== 1) { 1317 $(elem).parents('.directory').each(function () { 1318 var $this = $(this); 1319 var category = $this.find(' > a'); 1320 var parent = $this.find('.icon-open-close'); 1321 if (parent.length > 0) { 1322 if (typeof cParents[category.data('file')] === 'undefined') { 1323 cParents[category.data('file')] = { 1324 parent: parent.data('parent_id'), 1325 term_id: category.data('file'), 1326 name: category.text() 1327 }; 1328 } 1329 } 1330 }); 1331 } 1332 } 1333 1334 default_load(topCat, file); 1335 } 1336 }); 1337 1338 if(parseInt(wpfdparams.allow_category_tree_expanded) === 1) { 1339 var ele = $(this); 1340 setTimeout(function() { 1341 ele.find("li.directory a").each(function () { 1342 var tempCatID = $(this).data('catid'); 1343 var patentCatID = $(this).data('parent_id'); 1344 if (tempCatID == 'all_0') { 1345 cParents[tempCatID] = {parent: 0, term_id: 0, name: $(this).text().trim()}; 1346 } else { 1347 cParents[tempCatID] = {parent: patentCatID, term_id: tempCatID, name: $(this).text().trim()}; 1348 } 1349 }); 1350 }, 1000); 1351 } 1352 }) 1353 } 1354 1355 $('.wpfd-content-default + .wpfd-pagination').each(function (index, elm) { 1356 var $this = $(elm); 1357 default_init_pagination($this); 1358 }); 1359 1360 function default_init_pagination($this) { 1361 var number = $this.find('a:not(.current)'); 1362 var wrap = $this.prev('.wpfd-content-default'); 1363 var sourcecat = wrap.data('category'); 1364 var current_category = wrap.find('#current_category_' + sourcecat).val(); 1365 1366 number.unbind('click').bind('click', function () { 1367 var page_number = $(this).attr('data-page'); 1368 var current_sourcecat = $(this).attr('data-sourcecat'); 1369 var wrap = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "]"); 1370 var current_category = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "]").find('#current_category_' + current_sourcecat).val(); 1371 if (typeof page_number !== 'undefined') { 1372 var pathname = window.location.href.replace(window.location.hash, ''); 1373 var category = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "]").find('#current_category_' + current_sourcecat).val(); 1374 var category_slug = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "]").find('#current_category_slug_' + current_sourcecat).val(); 1375 var ordering = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "]").find('#current_ordering_' + current_sourcecat).val(); 1376 var orderingDirection = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "]").find('#current_ordering_direction_' + current_sourcecat).val(); 1377 var page_limit = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "]").find('#page_limit_' + current_sourcecat).val(); 1378 1379 window.history.pushState('', document.title, pathname + '#' + current_sourcecat + '-' + category + '-wpfd-' + category_slug + '-p' + page_number); 1380 1381 $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default:not(.wpfd-results .wpfd-container-default) .wpfd_list").remove(); 1382 $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default:not(.wpfd-results .wpfd-container-default)").append($('#wpfd-loading-wrap').html()); 1383 var show_files = 1; 1384 var themeName = $(".wpfd-content-default[data-category=" + sourcecat + "]").find('.wpfd_root_category_theme').val(); 1385 var atts_shortcode = window["wpfdfrontend_" + themeName]; 1386 if (atts_shortcode !== undefined && atts_shortcode.shortcode_param.show_files !== undefined && sourcecat === 'all_0' && (parseInt(catid) === 0 || catid === 'all_0')) { 1387 show_files = atts_shortcode.shortcode_param.show_files; 1388 } 1389 1390 var params = $.param({ 1391 task: 'files.display', 1392 view: 'files', 1393 id: current_category, 1394 rootcat: current_sourcecat, 1395 page: page_number, 1396 orderCol: ordering, 1397 orderDir: orderingDirection, 1398 page_limit: page_limit, 1399 show_files: show_files 1400 }); 1401 1402 //Get files 1403 $.ajax({ 1404 url: wpfdparams.wpfdajaxurl + params, 1405 dataType: "json", 1406 beforeSend: function () { 1407 $('html, body').animate({scrollTop: $(".wpfd-content[data-category=" + current_sourcecat + "]").offset().top}, 'fast'); 1408 } 1409 }).done(function (content) { 1410 delete content.category; 1411 wrap.next('.wpfd-pagination').remove(); 1412 wrap.after(content.pagination); 1413 delete content.pagination; 1414 var sourcefiles = $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-template-files:not(.wpfd-results .wpfd-template-files)").html(); 1415 var template = Handlebars.compile(sourcefiles); 1416 var html = template(content); 1417 1418 if ($(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default:not(.wpfd-results .wpfd-container-default) .wpfd-upload-form").length) { 1419 $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default:not(.wpfd-results .wpfd-container-default) .wpfd-upload-form").before(html); 1420 } else { 1421 $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default:not(.wpfd-results .wpfd-container-default)").append(html); 1422 } 1423 1424 if ($(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default .file .file-custom-field.file-url").length) { 1425 var link = typeof (wpfdparams.translates.wpfd_url_custom_field) !== 'undefined' ? wpfdparams.translates.wpfd_url_custom_field : 'Link'; 1426 $(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default .file .file-custom-field.file-url").each(function () { 1427 var label = $(this).attr('data-field-label'); 1428 var url = $(this).attr('data-field-val'); 1429 var urlContents = '<div><span>
1429' + label + ': </span><a href="' + url + '" target="_blank">' + link + '</a></div>'; 1430 $(this).empty().append(urlContents); 1431 }); 1432 } 1433 1434 // File password security 1435 if (typeof (content.filepasswords) !== 'undefined') { 1436 $.each(content.filepasswords, function( file_id, pw_form ) { 1437 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').empty(); 1438 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').addClass('wpfd-password-protection-form'); 1439 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").find('.file[data-id="' + file_id + '"]').append(pw_form); 1440 }); 1441 } 1442 1443 if (typeof wpfdColorboxInit !== 'undefined') { 1444 wpfdColorboxInit(); 1445 } 1446 default_init_pagination(wrap.next('.wpfd-pagination')); 1447 wpfd_remove_loading($(".wpfd-content-default.wpfd-content-multi[data-category=" + current_sourcecat + "] .wpfd-container-default:not(.wpfd-results .wpfd-container-default)")); 1448 wpfdDefaultDisplayDownloadedFiles(); 1449 wpfdDefaultDownloadFiles(); 1450 wpfdPreviewFileNewName(); 1451 }); 1452 } 1453 }); 1454 } 1455 1456 function wpfd_container_with_foldertree() { 1457 $('.wpfd-content-default .wpfd-container').each(function () { 1458 if($(this).children('.with_foldertree').length > 0) { 1459 $(this).addClass('wpfd_dfcontainer_foldertree'); 1460 } else { 1461 if($(this).hasClass('wpfd_dfcontainer_foldertree')) { 1462 $(this).removeClass('wpfd_dfcontainer_foldertree'); 1463 } 1464 } 1465 }); 1466 1467 //parent-content 1468 $('.wpfd-content-default').each(function () { 1469 if($(this).children().has('.wpfd-foldertree').length > 0) { 1470 $(this).addClass('wpfd_contentdefault_foldertree'); 1471 } else { 1472 if($(this).hasClass('wpfd_contentdefault_foldertree')) { 1473 $(this).removeClass('wpfd_contentdefault_foldertree'); 1474 } 1475 } 1476 }); 1477 } 1478 1479 wpfd_container_with_foldertree(); 1480 1481 function fire_empty_category_message(category_id) { 1482 if (!category_id) { 1483 return; 1484 } 1485 var root_category = '.wpfd-content-default.wpfd-content-multi[data-category=' + category_id + ']'; 1486 var display_empty_category_message = $(root_category).find('#wpfd_display_empty_category_message').val(); 1487 var empty_category_message_val = $(root_category).find('#wpfd_empty_category_message_val').val(); 1488 var is_empty_subcategories = $(root_category).find('#wpfd_is_empty_subcategories').val(); 1489 var is_empty_files = $(root_category).find('#wpfd_is_empty_files').val(); 1490 1491 if (parseInt(display_empty_category_message) !== 1 1492 || parseInt(is_empty_subcategories) !== 0 || parseInt(is_empty_files) !== 0 ) { 1493 return; 1494 } 1495 1496 var code = '<div class="wpfd-empty-category-message-section">'; 1497 code += '<p class="wpfd-empty-category-message">'; 1498 code += empty_category_message_val; 1499 code += '</p>'; 1500 code += '</div>'; 1501 1502 $(root_category).find('.wpfd-empty-category-message-section').remove(); 1503 $(root_category).find('.wpfd-container-default').append(code); 1504 } 1505 1506 var destroy_upload = $('.wpfd-upload-form.destroy'); 1507 if (destroy_upload.length) { 1508 destroy_upload.remove(); 1509 } 1510 1511 // Local categories cache trigger 1512 function wpfdDefaultCategoriesLocalCacheTrigger(triggerCategories, sourcecat, page, pathname, catid, container, empty_subcategories) { 1513 // Check if file search display is enabled 1514 var $displayFileSearch = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_root_category_display_file_search'); 1515 if ($displayFileSearch.length) { 1516 var $themeName = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_root_category_theme').val(); 1517 1518 if (typeof (triggerCategories.category.correctConvertCategoryId) === 'undefined') { 1519 triggerCategories.category.correctConvertCategoryId = 0; 1520 } 1521 1522 var $searchContent = '<form action="" id="adminForm-'+ triggerCategories.category.term_id +'" class="wpfd-adminForm wpfd-form-search-file-category" name="adminForm" method="post">' + 1523 wpfdparams.wp_nonce_field_localize + 1524 '<div id="loader" style="display:none; text-align: center">' + 1525 '<img src="'+ wpfdparams.wpfd_plugin_url +'/app/site/assets/images/searchloader.svg" style="margin: 0 auto"/>' + 1526 '</div>' + 1527 '<div class="box-search-filter wpfd-category-search-section">' + 1528 '<div class="searchSection">' + 1529 '<div class="only-file input-group clearfix wpfd_search_input" id="Search_container">' + 1530 '<img src="'+ wpfdparams.wpfd_plugin_url +'/app/site/assets/images/search-24.svg" class="material-icons wpfd-icon-search wpfd-search-file-category-icon" />' + 1531 '<input type="text" class="pull-left required txtfilename" name="q" id="txtfilename" autocomplete="off" placeholder="'+ wpfdparams.translates.msg_search_file_category_placeholder +'" value="" />' + 1532 '</div>' + 1533 '<button id="btnsearchbelow" class="btnsearchbelow wpfd-btnsearchbelow" type="button">'+ wpfdparams.translates.msg_search_file_category_search +'</button>' + 1534 '</div>' + 1535 '<input type="hidden" id="filter_catid" class="chzn-select filter_catid" name="catid" value="'+ triggerCategories.category.correctConvertCategoryId +'" data-cattype="" data-slug="" />' + 1536 '<input type="hidden" name="theme" value="'+ $themeName +'">' + 1537 '<input type="hidden" name="limit" value="15">' + 1538 '<div id="wpfd-results" class="wpfd-results list-results"></div>' + 1539 '</div>' + 1540 '</form>'; 1541 1542 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").prepend($searchContent); 1543 wpfdDefaultSearchFileCategoryHandle(); 1544 } 1545 1546 // Notify file changes 1547 if (typeof (triggerCategories.notify_file_changes) !== 'undefined' && parseInt(triggerCategories.notify_file_changes) === 1) { 1548 $(".wpfd-content.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_category_notify_file_changes').val('1'); 1549 showMailSubscriptions(sourcecat, true); 1550 } else { 1551 $(".wpfd-content.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_category_notify_file_changes').val('0'); 1552 showMailSubscriptions(sourcecat, false); 1553 } 1554 1555 // Update browser history 1556 var historyState = ''; 1557 if (page !== null && page !== undefined) { 1558 historyState = `#${sourcecat}-${catid}-wpfd-${triggerCategories.category.slug}-p${page}`; 1559 } else { 1560 historyState = `#${sourcecat}-${catid}-wpfd-${triggerCategories.category.slug}`; 1561 } 1562 window.history.pushState('', document.title, pathname + historyState); 1563 1564 // Update container and categories 1565 container.find('#current_category_slug_' + sourcecat).val(triggerCategories.category.slug); 1566 var sourcecategories = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-template-categories").html(); 1567 if (sourcecategories) { 1568 var template = Handlebars.compile(sourcecategories); 1569 var html = template(triggerCategories); 1570 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default").prepend(html); 1571 } 1572 1573 // Update breadcrumbs and initialize click events 1574 if (triggerCategories.category.breadcrumbs !== undefined) { 1575 $(".wpfd-content-multi[data-category=" + sourcecat + "] .breadcrumbs").html(triggerCategories.category.breadcrumbs); 1576 } 1577 for (var i = 0; i < triggerCategories.categories.length; i++) { 1578 cParents[triggerCategories.categories[i].term_id] = triggerCategories.categories[i]; 1579 } 1580 1581 default_breadcrum(sourcecat, catid, triggerCategories.category); 1582 default_initClick(); 1583 1584 // Expand tree if present 1585 if (tree.length) { 1586 var currentTree = container.find('.wpfd-foldertree-default'); 1587 currentTree.find('li').removeClass('selected'); 1588 currentTree.find('i.md').removeClass('md-folder-open').addClass("md-folder"); 1589 1590 currentTree.jaofiletree('open', catid, currentTree); 1591 1592 var el = currentTree.find('a[data-file="' + catid + '"]').parent(); 1593 el.find(' > i.md').removeClass("md-folder").addClass("md-folder-open"); 1594 1595 if (!el.hasClass('selected')) { 1596 el.addClass('selected'); 1597 } 1598 var ps = currentTree.find('.icon-open-close'); 1599 1600 $.each(ps.get().reverse(), function (i, p) { 1601 if (typeof $(p).data() !== 'undefined' && $(p).data('id') == Number(hash_category_id)) { 1602 hash_category_id = $(p).data('parent_id'); 1603 $(p).click(); 1604 } 1605 }); 1606 1607 } 1608 1609 // Hide download button and empty subcategories message if needed 1610 if ($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default >
1610 .wpfd-password-form").length) { 1611 hideDownloadAllBtn(sourcecat, true); 1612 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-category").attr('href', '#'); 1613 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdcategory").hide(); 1614 } 1615 1616 if (empty_subcategories.length) { 1617 empty_subcategories.val(triggerCategories.categories.length); 1618 fire_empty_category_message(sourcecat); 1619 } 1620 } 1621 1622 // Local files cache trigger 1623 function wpfdDefaultFilesLocalCacheTrigger(triggerFiles, sourcecat, empty_files, fileAjaxUrl) { 1624 var sourceCatSelector = ".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]"; 1625 1626 if (typeof (triggerFiles.categoryPassword) !== 'undefined' && triggerFiles.categoryPassword.length) { 1627 hideDownloadAllBtn(sourcecat, true); 1628 $(sourceCatSelector + " .default-download-category").attr('href', '#'); 1629 $(sourceCatSelector + " .wpfdcategory").hide(); 1630 $(sourceCatSelector + " .wpfd-container-default").empty().append(triggerFiles.categoryPassword); 1631 } else { 1632 if (triggerFiles.files.length || triggerFiles.downloadable_files.length) { 1633 $(sourceCatSelector + " .default-download-category").removeClass("display-download-category"); 1634 } else { 1635 $(sourceCatSelector + " .default-download-category").addClass("display-download-category"); 1636 } 1637 1638 $(sourceCatSelector).after(triggerFiles.cache_pagination); 1639 1640 var sourcefiles = $(sourceCatSelector + " .wpfd-template-files").html(); 1641 var template = Handlebars.compile(sourcefiles); 1642 var html = template(triggerFiles); 1643 html = $('<textarea/>').html(html).val(); 1644 $(sourceCatSelector + " .wpfd-container-default").append(html); 1645 1646 if ($(sourceCatSelector + " .wpfd-container-default .file .file-custom-field.file-url").length) { 1647 var link = typeof (wpfdparams.translates.wpfd_url_custom_field) !== 'undefined' ? wpfdparams.translates.wpfd_url_custom_field : 'Link'; 1648 $(sourceCatSelector + " .wpfd-container-default .file .file-custom-field.file-url").each(function () { 1649 var label = $(this).attr('data-field-label'); 1650 var url = $(this).attr('data-field-val'); 1651 var urlContents = '<div><span>
1651' + label + ': </span><a href="' + url + '" target="_blank">' + link + '</a></div>'; 1652 $(this).empty().append(urlContents); 1653 }); 1654 } 1655 1656 if (typeof (triggerFiles.filepasswords) !== 'undefined') { 1657 $.each(triggerFiles.filepasswords, function( file_id, pw_form ) { 1658 var fileSelector = $(sourceCatSelector + " .wpfd-container-default").find('.file[data-id="' + file_id + '"]') 1659 $(fileSelector).empty().addClass('wpfd-password-protection-form').append(pw_form); 1660 }); 1661 } 1662 1663 if (triggerFiles.uploadform !== undefined && triggerFiles.uploadform.length) { 1664 var upload_form_html = '<div class="wpfd-upload-form" style="margin: 20px 10px">'; 1665 upload_form_html += triggerFiles.uploadform; 1666 upload_form_html += '</div>'; 1667 $(sourceCatSelector + " .wpfd-container-default").append(upload_form_html); 1668 1669 if (typeof (Wpfd) === 'undefined') { 1670 Wpfd = {}; 1671 } 1672 1673 var containers = $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] div[class*=wpfdUploadForm]"); 1674 if (containers.length > 0) { 1675 containers.each(function(i, el) { 1676 initUploader($(el)); 1677 }); 1678 } 1679 } 1680 1681 if (typeof wpfdColorboxInit !== 'undefined') { 1682 wpfdColorboxInit(); 1683 } 1684 1685 wpfdTrackDownload(); 1686 1687 default_init_pagination($('.wpfd-content-default[data-category=' + sourcecat + '] + .wpfd-pagination')); 1688 wpfd_remove_loading($(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfd-container-default")); 1689 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .wpfdSelectedFiles").remove(); 1690 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "] .default-download-selected").remove(); 1691 hideDownloadAllBtn(sourcecat, false); 1692 } 1693 if (empty_files.length) { 1694 empty_files.val(triggerFiles.files.length); 1695 fire_empty_category_message(sourcecat); 1696 } 1697 1698 if (typeof (triggerFiles.notify_file_changes) !== 'undefined' && parseInt(triggerFiles.notify_file_changes) === 1) { 1699 $(".wpfd-content-default.wpfd-content-multi[data-category=" + sourcecat + "]").find('.wpfd_mail_checkbox').show(); 1700 } 1701 1702 wpfdDefaultDisplayDownloadedFiles(); 1703 wpfdDefaultDownloadFiles(); 1704 wpfdPreviewFileNewName(); 1705 } 1706 1707 // Search file category 1708 function wpfdDefaultCategoryAjaxSearch(element, ordering, direction, pushState = true) { 1709 var $ = jQuery; 1710 var sform = element; 1711 var $key = $(sform).find('input[name=q]').val(); 1712 var $placeholder = $(sform).find('input[name=q]').attr('placeholder'); 1713 1714 // Avoid conflict key search 1715 if ($key.toString() === $placeholder.toString()) { 1716 $key = ''; 1717 } 1718 1719 // Get the form data 1720 var formData = { 1721 'q': $key, 1722 'catid': $(sform).find('[name=catid]').val(), 1723 'theme': $(sform).find('[name=theme]').val(), 1724 'wpfd_search_nonce': $(sform).find('input[name=wpfd_search_nonce]').val(), 1725 'limit': $(sform).find('[name=limit]').val() 1726 }; 1727 1728 formData = cleanObj(formData); 1729 1730 if (jQuery.isEmptyObject(formData) || 1731 (typeof (formData.q) === 'undefined' && 1732 typeof (formData.catid) !== 'undefined' && 1733 parseInt(formData.catid) === 0) || typeof (formData.q) === 'undefined') { 1734 $(element).find(".txtfilename").focus(); 1735 return false; 1736 } 1737 1738 if ((typeof ordering !== 'undefined') && ordering) formData.ordering = ordering; 1739 if ((typeof direction !== 'undefined') && direction) formData.dir = direction; 1740 1741 // Pagination 1742 if (pushState) { 1743 var filter_url = jQuery.param(formData); 1744 var currentUrl = window.location.search; 1745 var pushUrl; 1746 if (typeof URLSearchParams !== 'undefined') { 1747 var currentFilters = new URLSearchParams(currentUrl.substring(1));
1748 Object.keys(formData).forEach(function (key) { 1749 if (currentFilters.has(key)) { 1750 currentFilters.delete(key); 1751 } 1752 }); 1753 if (currentUrl.substring(1) === '?' && currentFilters.toString() !== '') { 1754 pushUrl = currentFilters.toString() + '&' + filter_url; 1755 1756 } else { 1757 pushUrl = '?' + filter_url; 1758 } 1759 1760 window.history.pushState(formData, "", pushUrl); 1761 } 1762 } 1763 1764 $.ajax({ 1765 method: "POST", 1766 url: wpfdparams.wpfdajaxurl + "task=search.display", 1767 data: formData, 1768 beforeSend: function () { 1769 $(element).find(".wpfd-results").html(''); 1770 $(element).find(".wpfd-results").prepend($(element).find("#loader").clone().show()); 1771 }, 1772 success: function (result) { 1773 $(element).find(".wpfd_search_file_suggestion").html(''); 1774 $(element).find(".wpfd_search_file_suggestion").fadeOut(300); 1775 1776 $(element).find(".wpfd-results").html(result); 1777 $(element).find(".wpfd-results .wpfd-container-default").addClass('wpfd-container-default-search'); 1778 if ($(element).find(".wpfd-results .wpfd-form-search-file-category").length) { 1779 $(element).find(".wpfd-results .wpfd-form-search-file-category").remove(); 1780 } 1781 wpfdDefaultInitSorting(); 1782 if (typeof wpfdColorboxInit !== 'undefined') { 1783 wpfdColorboxInit(); 1784 } 1785 wpfdWooCommerceAddToCart(); 1786 } 1787 }); 1788 } 1789 1790 // Sort initial 1791 function wpfdDefaultInitSorting() { 1792 jQuery('.orderingCol').click(function (e) { 1793 e.preventDefault(); 1794 var ordering = jQuery(this).data('ordering'); 1795 var direction = jQuery(this).data('direction'); 1796 wpfdDefaultCategoryAjaxSearch(ordering, direction); 1797 }); 1798 1799 jQuery(".list-results #limit").change(function (e) { 1800 e.preventDefault(); 1801 jQuery('input[name="limit"]').val(jQuery(this).val()); 1802 var formID = '#' + jQuery(this).closest('form').attr('id'); 1803 wpfdDefaultCategoryAjaxSearch(formID); 1804 return false; 1805 }); 1806 } 1807 1808 function wpfdDefaultSearchFileCategoryHandle() { 1809 $(".wpfd-content .wpfd-adminForm").submit(function (e) { 1810 e.preventDefault(); 1811 return false; 1812 }); 1813 1814 $('.wpfd-content .txtfilename').on('keyup', function(e) { 1815 var $this = $(this); 1816 if (e.keyCode === 13 || e.which === 13 || e.key === 'Enter') 1817 { 1818 e.preventDefault(); 1819 1820 if ($this.val() === '') { 1821 return; 1822 } 1823 1824 var formID = '#' + $this.closest('form').attr('id'); 1825 wpfdDefaultCategoryAjaxSearch(formID); 1826 1827 return; 1828 } 1829 }); 1830 1831 // Ajax filters 1832 $(".wpfd-content .btnsearchbelow").on('click', function (e) { 1833 e.preventDefault(); 1834 var formID = '#' + $(this).closest('form').attr('id'); 1835 wpfdDefaultCategoryAjaxSearch(formID); 1836 return false; 1837 }); 1838 } 1839 wpfdDefaultSearchFileCategoryHandle(); 1840 1841 function wpfdDefaultDownloadFiles() { 1842 if (!wpfdparams.offRedirectLinkDownloadImageFile) { 1843 $('.file.png .wpfd_downloadlink, .file.jpg .wpfd_downloadlink, .file.jpeg .wpfd_downloadlink, .file.gif .wpfd_downloadlink').on('click', function (event) { 1844 event.preventDefault(); 1845 var fileId = $(this).parents('.file').data('id'); 1846 var categoryId = $(this).parents('.file').data('catid'); 1847 var cloudType = $(this).parents('.wpfd-content-default').find('.wpfd_root_category_type').val(); 1848 1849 if (!fileId || !categoryId) { 1850 return false; 1851 } 1852 1853 if ($(this).find('.wpfd-add-to-cart').length) { 1854 return false;
1855 } 1856 1857 window.location.href = wpfdparams.site_url + "?wpfd_action=wpfd_download_file&wpfd_file_id=" + fileId + "&wpfd_category_id=" + categoryId + "&cloudType=" + cloudType; 1858 }); 1859 } 1860 } 1861 wpfdDefaultDownloadFiles(); 1862 1863 function wpfdPreviewFileNewName() 1864 { 1865 $('.wpfd_previewlink').click(function (e) { 1866 var newWindow = $(this).attr('target'); 1867 var previewLink = $(this).attr('href'); 1868 var fileTitle = $(this).parents('.file').find('.wpfd_downloadlink').attr('title'); 1869 var fileName = fileTitle; 1870 fileName = fileName ? fileName : 'WPFD Preview File'; 1871 1872 if (newWindow === '_blank' && (previewLink.indexOf('previews') !== -1) && previewLink.indexOf('docs.google.com') === -1) { 1873 e.preventDefault(); 1874 var win = window.open(previewLink, '_blank'); 1875 win.onload = function () { 1876 setTimeout(function () { 1877 win.document.title = fileName; 1878 }, 100); 1879 1880 setTimeout(function () { 1881 $(win.document.head).append('<title>'+ fileName +'</title>'); 1882 }, 3000); 1883 }; 1884 1885 setTimeout(function () { 1886 if (win.document.title !== fileName) { 1887 win.document.title = fileName; 1888 } 1889 }, 1000); 1890 1891 setTimeout(function () { 1892 if (win.document.title !== fileName) { 1893 win.document.title = fileName; 1894 } 1895 }, 3000); 1896 } 1897 }); 1898 } 1899 wpfdPreviewFileNewName(); 1900 1901 function wpfdWooCommerceAddToCart() { 1902 if (typeof ('wc_add_to_cart_params') === "undefined") { 1903 return false; 1904 } 1905 1906 var $ = jQuery; 1907 $('.wpfd_downloadlink:has(.wpfd-add-to-cart)').unbind('click').click(function (e) { 1908 var $this = $(this); 1909 1910 if (!$this.attr('data-product_id')) { 1911 return true; 1912 } 1913 1914 e.preventDefault(); 1915 1916 var url = $this.attr('href'); 1917 var data = {}; 1918 $.each($this.data(), function (key, value) { 1919 data[key] = value; 1920 }); 1921 1922 jQuery.ajax({ 1923 url: wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'add_to_cart'), 1924 method: 'POST', 1925 data: data, 1926 success: function (response, status, xhr) { 1927 if (!response) { 1928 return; 1929 } 1930 1931 if (response.error && response.product_url) { 1932 window.location = response.product_url; 1933 return; 1934 } 1935 1936 // Redirect to cart option 1937 if (wc_add_to_cart_params.cart_redirect_after_add === 'yes') { 1938 window.location = wc_add_to_cart_params.cart_url; 1939 return; 1940 } 1941 1942 // Trigger event so themes can refresh other areas. 1943 $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $this]); 1944 1945 // Fallback, made sure added to cart button added. 1946 if (!wc_add_to_cart_params.is_cart && $this.parent().find('.added_to_cart').length === 0) { 1947 $this.removeClass('loading'); 1948 $this.addClass('added'); 1949 $this.after(' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart wc-forward" title="' + 1950 wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + '</a>'); 1951 } 1952 }, 1953 }); 1954 return false; 1955 }); 1956 } 1957 1958 function current_folder_showing(catid) { 1959 setTimeout(function () { 1960 var current_folder = $('.directory.selected').length ? $('.directory.selected') : $('[data-catid='+ catid +']'); 1961 1962 if (current_folder.length) { 1963 let parent_folders = current_folder.parents('.directory'); 1964 1965 if (parent_folders.length) { 1966 parent_folders.each(function () { 1967 $(this).removeClass('collapsed').addClass('expanded'); 1968 $(this).find('> .zmdi.zmdi-folder').removeClass('zmdi-folder').addClass('zmdi-folder-outline'); 1969 $(this).find('> ul.jaofiletree').show(); 1970 }); 1971 } 1972 } 1973 }, 3000); 1974 } 1975}); 1976 1977// Default categories local cache 1978var wpfdDefaultCategoriesLocalCache = { 1979 data: {}, 1980 remove: function (url) { 1981 delete wpfdDefaultCategoriesLocalCache.data[url]; 1982 }, 1983 exist: function (url) { 1984 return wpfdDefaultCategoriesLocalCache.data.hasOwnProperty(url) && wpfdDefaultCategoriesLocalCache.data[url] !== null; 1985 }, 1986 get: function (url) { 1987 return wpfdDefaultCategoriesLocalCache.data[url]; 1988 }, 1989 set: function (url, cachedData) { 1990 wpfdDefaultCategoriesLocalCache.remove(url);
1991 wpfdDefaultCategoriesLocalCache.data[url] = cachedData; 1992 } 1993}; 1994 1995// Default files local cache 1996var wpfdDefaultFilesLocalCache = { 1997 data: {}, 1998 remove: function (url) { 1999 delete wpfdDefaultFilesLocalCache.data[url]; 2000 }, 2001 exist: function (url) { 2002 return wpfdDefaultFilesLocalCache.data.hasOwnProperty(url) && wpfdDefaultFilesLocalCache.data[url] !== null; 2003 }, 2004 get: function (url) { 2005 return wpfdDefaultFilesLocalCache.data[url]; 2006 }, 2007 set: function(url, cachedData) { 2008 wpfdDefaultFilesLocalCache.remove(url); 2009 wpfdDefaultFilesLocalCache.data[url] = cachedData; 2010 } 2011};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.