1if(!(window.console && console.log)) { 2 console = { 3 log: function(){}, 4 debug: function(){}, 5 info: function(){}, 6 warn: function(){}, 7 error: function(){} 8 }; 9} 10 11 12 13jQuery( document ).ready(function($) { 14 15 console.log(jQuery.cookie("pid")); 16 if(sp_vars.sp_cu_user_projects_required == 1 && (jQuery.cookie("pid") == 0 || jQuery.cookie("pid") == null)){ 17 $('.sp_cdm_add_file').hide(); 18 } 19 20 21 22 23 24 25 26 $( document ).on( "click", ".sp-cdm-search-button", function() { 27 cdm_ajax_search(); 28 return false; 29 }); 30 31 32 $('#search_files').keypress(function (e) { 33 if (e.which == 13) { 34 cdm_ajax_search(); 35 return false; //<---- Add this line 36 } 37 }); 38 39 40 // edit a folder 41 $( document ).on( "click", ".sp-cdm-save-category", function() { 42 43 var id = jQuery(this).attr('data-id'); 44 45 if(jQuery("#edit_project_name_" + id).val() == ""){ 46 alert("Please enter a project name"); 47 48 }else{ 49 50 51 jQuery.post(sp_vars.ajax_url, {action: "cdm_save_category", name: jQuery("#edit_project_name_" + id).val(), id: id}, function(response){ 52 cdm_ajax_search(); 53 54 jQuery("#edit_category").dialog("close"); 55 alert(response); 56 }) 57 58 } 59 60 return false; 61 62 }); 63 64 65 // Delete a folder 66 $( document ).on( "click", ".sp-cdm-delete-category", function() { 67 var id = jQuery(this).attr('data-id'); 68 69 jQuery( "#delete_category_" + id ).dialog({ 70 71 resizable: false, 72 73 height:240, 74 75 width:440, 76 77 modal: true, 78 79 buttons: { 80 81 "Delete all items": function() { 82 83 jQuery.post(sp_vars.ajax_url, {action: "cdm_remove_category", id: id}, function(response){ 84 jQuery.cookie("pid", 0, { expires: 7 , path:"/" }); 85 cdm_ajax_search(); 86 }) 87 88 89 90 jQuery( this ).dialog( "close" ); 91 92 93 94 }, 95 96 Cancel: function() { 97 98 jQuery( this ).dialog( "close" ); 99 100 } 101 102 } 103 104 }); 105 106 107 return false; 108 109 }); 110 111 112}); 113 114 115 116 117 function cdm_download_file(id){ 118 jQuery.get(sp_vars.ajax_url, {action: "cdm_download_file", fid:id}, function(response){ 119 120 }); 121 return false; 122 } 123 function cdm_download_project(id,nonce){ 124 125 window.location.href = sp_vars.ajax_url +"?action=cdm_download_project&nonce=" + nonce + "&id="+ id; 126 127 128 return false; 129 } 130 131 function cdmOpenModal(name){ 132 jQuery(".cdm-modal").remodal({ hashTracking: false}); 133 var inst = jQuery.remodal.lookup[jQuery("[data-remodal-id=" + name + "]").data("remodal")]; 134 inst.open(); 135 136 } 137 function cdmCloseModal(name){ 138 jQuery(".cdm-modal").remodal({ hashTracking: false}); 139 var inst = jQuery.remodal.lookup[jQuery("[data-remodal-id=" + name + "]").data("remodal")]; 140 141 inst.close(); 142 143 } 144 145 function cdmRefreshFile(file){ 146 147 jQuery(".view-file-content").empty(); 148 149 jQuery.get(sp_vars.ajax_url, {action: "cdm_view_file", id: file}, function(response){ 150 jQuery(".view-file-content").html(response); 151 }) 152 153 } 154 function cdmViewFile(file){ 155 156 jQuery(".view-file-content").empty(); 157 158 jQuery.get(sp_vars.ajax_url, {action: "cdm_view_file", id: file}, function(response){ 159 jQuery(".view-file-content").html(response); 160 jQuery(".cdm-modal").remodal({ hashTracking: false}); 161 var inst = jQuery.remodal.lookup[jQuery("[data-remodal-id=file]").data("remodal")]; 162 inst.open(); 163 }) 164 165 166 167 } 168 169 170jQuery(document).on('closed', ".cdm-modal", function (e) { 171 172jQuery.cookie("viewfile_tab", 0, { expires: 7 , path:"/" }); 173 174}); 175 176 function sp_cu_add_project(){ 177 178 179 jQuery.post(sp_vars.ajax_url, {action: "cdm_save_category", name: jQuery("#sub_category_name").val(), uid: jQuery("#sub_category_uid").val(),parent: jQuery(".cdm_premium_pid_field").val()}, function(response){ 180 cdmCloseModal("folder"); 181 cdm_ajax_search(); 182 jQuery(".pid_select").append(jQuery("<option>", { 183 184 value: response, 185 text : jQuery("#sub_category_name").val(), 186 selected : "selected" 187 } 188 189 )); 190 191 }) 192 193 194 195 } 196 197 198 199 200function cdm_refresh_file_view(fid){ 201 jQuery(".view-file-content").empty(); 202 203 jQuery.get(sp_vars.ajax_url, {action: "cdm_view_file", id: fid}, function(response){ 204 jQuery(".view-file-content").html(response); 205 }) 206 207 208} 209 210function cdm_check_file_perms(pid){ 211 212 213 jQuery.post(sp_vars.ajax_url, {action: "cdm_file_permissions", pid:pid}, function(msg){ 214 215 if(msg == 1){ 216 jQuery('.hide_add_file_permission').show(); 217 }else{ 218 jQuery('.hide_add_file_permission').hide(); 219 } 220 }); 221 222 223} 224 225function cdm_check_folder_perms(pid){ 226 227 228 jQuery.post(sp_vars.ajax_url, {action: "cdm_folder_permissions", pid:pid}, function(msg){ 229 230 if(msg == 1){ 231 jQuery('.hide_add_folder_permission').show(); 232 }else{ 233 jQuery('.hide_add_folder_permission').hide(); 234 } 235 }); 236 237 238 239 240jQuery.event.trigger({ 241 type: "cdm_check_folder_perms", 242 pid: pid 243}); 244 245} 246 247 248function sp_cu_reload_all_projects(context_folder_pid){ 249 250 251 252 jQuery.post(sp_vars.ajax_url, {action: "cdm_project_dropdown", pid:ontext_folder_pid}, function(msg){ 253 254 jQuery('.pid_select').html(msg); 255 }); 256 257 258 259 260 261} 262
263function sp_cu_confirm_delete(div,h,file_id){ 264 265 266if(jQuery(window).width()*0.9< 768){ 267 var width = jQuery(window).width()*0.9; 268 }else{ 269 var width = 320; 270 } 271 272 var NewDialog = jQuery('<div id="sp_cu_confirm_delete"> ' + div + '</div>'); 273 274 275 276 jQuery( NewDialog ).dialog({ 277 278 width:width, 279 280 height:'auto', 281 282 modal: true, 283 284 buttons: { 285 286 "Yes": function() { 287 288 289 jQuery.post(sp_vars.ajax_url, {action: "cdm_delete_file", file_id:file_id}, function(response){ 290 291 cdmCloseModal('file'); 292 jQuery( NewDialog ).remove(); 293 cdm_ajax_search(); 294 }); 295 296 297 298 299 }, 300 301 Cancel: function() { 302 303 jQuery( NewDialog ).remove(); 304 305 } 306 307 } 308 309 }); 310 311 312 313} 314 315 316 317 318 319 320 321function sp_cu_confirm(div,h,url){ 322 323 324if(jQuery(window).width()*0.9< 768){ 325 var width = jQuery(window).width()*0.9; 326 }else{ 327 var width = 320; 328 } 329 jQuery( div ).dialog({ 330 331 width:width, 332 333 height:'auto', 334 335 modal: true, 336 337 buttons: { 338 339 "Yes": function() { 340 341 window.location = url; 342 343 }, 344 345 Cancel: function() { 346 347 jQuery( this ).dialog( "close" ); 348 349 } 350 351 } 352 353 }); 354 355 356 357} 358 359 360 361function sp_cu_dialog(div,w,h){ 362 363 364 365 366 if(jQuery(window).width()*0.9< 768){ 367 var width = jQuery(window).width()*0.9; 368 }else{ 369 var width = w; 370 } 371 var dialogBox = jQuery(div); 372 var usableDialog = dialogBox[0]; 373 //jQuery("div.ui-dialog").remove(); 374 375 376 377 jQuery(usableDialog).dialog({ 378 379 height:'auto', 380 381 width:width 382 383 }); 384 385} 386 387/* 388jQuery(document).ready(function() { 389// jQuery("#cdm_upload_table tr:first").css("display", "none"); 390jQuery("#cdm_og").attr("checked","checked"); 391 392setInterval(function(){cdmPremiumReValidate();},1000); 393 394}); 395*/ 396 397function cdm_disable_uploads(){ 398 399 jQuery(".sp_cdm_add_file").hide(); 400 jQuery(".sp_cdm_add_folder").hide(); 401 402} 403 404function cdm_enable_uploads(){ 405 406 jQuery(".sp_cdm_add_file").hide(); 407 jQuery(".sp_cdm_add_folder").hide(); 408 409} 410jQuery(document).ready(function() { 411 412 413 414 415 jQuery( document ).on( "click", ".cdm_refresh_file_view", function() { 416 cdm_refresh_file_view(jQuery(this).attr('data-id')); 417 418 return false; 419 }); 420 421 422 423jQuery( ".cdm_button" ).button(); 424 425 426jQuery.ajaxSetup({ cache: false }); 427 428 429 430//add another file input when one is selected 431 432var max = 20; 433 434var replaceMe = function(){ 435 436 var obj = jQuery(this); 437 438 if(jQuery("#cdm_upload_fields input[type='file']").length > max) 439 440 { 441 442 alert('fail'); 443 444 obj.val(""); 445 446 return false; 447 448 } 449 450 jQuery(obj).css({'position':'absolute','left':'-9999px','display':'none'}).parent().prepend('<input type="file" name="'+obj.attr('name')+'"/>') 451 452 jQuery('#upload_list').append('<div class="sp_upload_div"><span class="sp_upload_name">'+obj.val()+'</span><input type="button" value="cancel"/><div>'); 453 454 jQuery("#cdm_upload_fields input[type='file']").change(replaceMe); 455 456 jQuery("#cdm_upload_fields input[type='button']").click(function(){ 457 458 jQuery(this).parent().remove(); 459 460 jQuery(obj).remove(); 461 462 return false; 463 464 465 466 467 468 }); 469 470} 471 472jQuery("#cdm_upload_fields input[type='file']").change(replaceMe); 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 jQuery('a.su_ajax').click(function() { 489 490 var url = this.href; 491 492 // show a spinner or something via css 493 494 var dialog = jQuery('<div style="display:none" class="loading"></div>').appendTo('body'); 495 496 // open the dialog 497 498 dialog.dialog({ 499 500 // add a close listener to prevent adding multiple divs to the document 501 502 close: function(event, ui) { 503 504 // remove div with all data and events 505 506 dialog.remove(); 507 508 }, 509 510 modal: true, 511 512 title: jQuery(this).attr('title'), 513 514 height:'auto', 515 516 width:700 517 518 }); 519 520 // load remote content 521 522 dialog.load( 523 524 url, 525 526 {}, // omit this param object to issue a GET request instead a POST request, otherwise you may provide post parameters within the object 527 528 function (responseText, textStatus, XMLHttpRequest) { 529 530 // remove the loading class 531 532 dialog.removeClass('loading'); 533 534 } 535 536 ); 537 538 //prevent the browser to follow the link 539 540 return false; 541 542 }); 543 544 545 546}); 547 548 549 550 551 552 553 554 555 556
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.