From 323b32734a70306ddd4b1a508f37066257e86fcd Mon Sep 17 00:00:00 2001 From: "BestNa.me Labs" Date: Thu, 10 Mar 2016 21:58:58 +0100 Subject: [PATCH] Added `decrease_total_clicks( id )` + call Added a function `decrease_total_clicks( id )` in js/insert.js which decreases the element containing the number of total clicks on the admin page by the value contained in the element `$('#clicks-' + id)` (i.e. by the value picked from the 'Clicks' column of the respective deleted row). Now called this method at the appropriate place in function `remove_link(id)`, thereby passing on `id` as parameter. --- js/insert.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/insert.js b/js/insert.js index cf5403e..4b5ae42 100644 --- a/js/insert.js +++ b/js/insert.js @@ -111,6 +111,7 @@ function remove_link(id) { zebra_table(); }); decrement_counter(); + decrease_total_clicks( id ); } else { alert('something wrong happened while deleting :/'); } @@ -194,6 +195,11 @@ function decrement_counter() { }); } +// Decrease number of total clicks +function decrease_total_clicks( id ) { + $('#total_clicks').html( parseInt( $('#total_clicks').html() ) - parseInt( $('#clicks-' + id).html() ) ); +} + // Toggle Share box function toggle_share(id) { if( $('#share-button-'+id).hasClass('disabled') ) { -- 2.42.0