jQuery(function($) { var photo_array = false, comment_id = false, colspan = (WPDATA.current_page == 'product') ? 2 : 5, tr = false, tr_edit = false, busy = false; if (WPDATA.current_page == 'product' && $('#add-new-comment').length > 0 && $('#no-comments').length === 0){ $('#add-new-comment').after('
'); $('#remove-comments').click(function(){ var r_btn = $(this).find('a'); r_btn.html(WPDATA.i18n_please_wait); var data = {'action': 'a2wl_arvi_remove_product_reviews', 'id':WPDATA.product_id}; jQuery.post(ajaxurl, data, function (response) { var json = jQuery.parseJSON(response); if (json.state == 'ok') { r_btn.html(WPDATA.i18n_done); location.reload(); } else { r_btn.html(WPDATA.i18n_error_occur); console.log('[' + json.state + ']message: ', json.message); } }); return false; }); } function reset_vars(){ tr_edit.remove(); tr.show(); photo_array = false, comment_id = false, tr = false, tr_edit = false, busy = false; } function reset_dialog(){ if (tr_edit && tr){ var lostChanges = confirm("Are you sure you want to do this? The review changes you made will be lost."); if ( lostChanges ){ reset_vars(); return true; } else return false; } return true; } function get_photos(id, f){ var data = {'action': 'a2wl_arvi_get_comment_photos', 'id':id}; jQuery.post(ajaxurl, data, function (response) { var json = jQuery.parseJSON(response); if (json.state == 'ok') { f(json.photos); } else { console.log('[' + json.state + ']message: ', json.message); f(false); } }); } function generate_photos_html(photos){ var html = '