wp/wp-content/plugins/portfolio/js/script.js
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 function update_postmeta() {
       
     2 	(function($){
       
     3 		setMessage("<p>"+update_message+"</p>");
       
     4 		var curr = 0;
       
     5 		$.ajax({
       
     6 			url: '../wp-admin/admin-ajax.php?action=prtfl_update_info',//update_url,
       
     7 			type: "POST",
       
     8 			data: "action1=get_portfolio_id",
       
     9 			success: function(result) {
       
    10 				var list = eval('('+result+')');
       
    11 				
       
    12 				if (!list) {
       
    13 					setError( "<p>"+not_found_info+"</p>" );
       
    14 					$("#ajax_update_postmeta").removeAttr("disabled");
       
    15 					return;
       
    16 				}		
       
    17 				$('#prtfl_loader').show();
       
    18 
       
    19 				function updatenItem() {
       
    20 					if (curr >= list.length) {
       
    21 						$.ajax({
       
    22 							url: '../wp-admin/admin-ajax.php?action=prtfl_update_info',
       
    23 							type: "POST",
       
    24 							data: "action1=update_options",
       
    25 							success: function(result) {
       
    26 							}
       
    27 						});
       
    28 						$("#ajax_update_postmeta").removeAttr("disabled");
       
    29 						setMessage("<p>"+success+"</p>");
       
    30 						$('#prtfl_loader').hide();
       
    31 						return;
       
    32 					}
       
    33 
       
    34 					$.ajax({
       
    35 						url: '../wp-admin/admin-ajax.php?action=prtfl_update_info',
       
    36 						type: "POST",
       
    37 						data: "action1=update_info&id="+list[curr].ID,
       
    38 						success: function(result) {
       
    39 							curr = curr + 1;
       
    40 							updatenItem();
       
    41 						}
       
    42 					});
       
    43 				}
       
    44 
       
    45 				updatenItem();
       
    46 			},
       
    47 			error: function( request, status, error ) {
       
    48 				setError( "<p>"+error + request.status+"</p>" );
       
    49 			}
       
    50 		});
       
    51 	})(jQuery);
       
    52 }
       
    53 
       
    54 function update_images() {
       
    55 	(function($){
       
    56 		setMessage("<p>"+update_img_message+"</p>");
       
    57 		var curr = 0;
       
    58 		$.ajax({
       
    59 			url: '../wp-admin/admin-ajax.php?action=prtfl_update_image',//update_img_url,
       
    60 			type: "POST",
       
    61 			data: "action1=get_all_attachment",
       
    62 			success: function(result) {
       
    63 				var list = eval('('+result+')');
       
    64 				
       
    65 				if (!list) {
       
    66 					setError( "<p>"+not_found_img_info+"</p>" );
       
    67 					$("#ajax_update_images").removeAttr("disabled");
       
    68 					return;
       
    69 				}		
       
    70 				$('#prtfl_img_loader').show();
       
    71 
       
    72 				function updatenImageItem() {
       
    73 					if (curr >= list.length) {
       
    74 						$.ajax({
       
    75 							url: '../wp-admin/admin-ajax.php?action=prtfl_update_image',
       
    76 							type: "POST",
       
    77 							data: "action1=update_options",
       
    78 							success: function(result) {
       
    79 							}
       
    80 						});
       
    81 						$("#ajax_update_images").removeAttr("disabled");
       
    82 						setMessage("<p>"+img_success+"</p>");
       
    83 						$('#prtfl_img_loader').hide();
       
    84 						return;
       
    85 					}
       
    86 
       
    87 					$.ajax({
       
    88 						url: '../wp-admin/admin-ajax.php?action=prtfl_update_image',
       
    89 						type: "POST",
       
    90 						data: "action1=update_image&id="+list[curr].ID,
       
    91 						success: function(result) {
       
    92 							curr = curr + 1;
       
    93 							updatenImageItem();
       
    94 						}
       
    95 					});
       
    96 				}
       
    97 
       
    98 				updatenImageItem();
       
    99 			},
       
   100 			error: function( request, status, error ) {
       
   101 				setError( "<p>"+img_error + request.status+"</p>" );
       
   102 			}
       
   103 		});
       
   104 	})(jQuery);
       
   105 }
       
   106 
       
   107 function setMessage(msg) {
       
   108 	(function($){
       
   109 		$(".error").hide();
       
   110 		$(".updated").html(msg);
       
   111 		$(".updated").show();
       
   112 	})(jQuery);
       
   113 }
       
   114 
       
   115 function setError(msg) {
       
   116 	(function($){
       
   117 		$(".updated").hide();
       
   118 		$(".error").html(msg);
       
   119 		$(".error").show();
       
   120 	})(jQuery);
       
   121 }