From ae59c6072a13ba41dc5fc6e290d4207ef252f9c9 Mon Sep 17 00:00:00 2001 From: kksidd Date: Sun, 28 Aug 2016 15:51:12 +0530 Subject: [PATCH] Fix multiple output of JS on failed form submission --- couch/functions.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/couch/functions.php b/couch/functions.php index 47587a4..cb83a97 100644 --- a/couch/functions.php +++ b/couch/functions.php @@ -1529,7 +1529,7 @@ function date_dropdowns( $date='', $simple_mode=0 ){ $s = substr( $date, 17, 2 ); $year = ''; - if( $simple_field ){ + if( $simple_mode ){ $month = ''; - if( !$simple_field ){ + if( !$simple_mode ){ $month .= ''.$FUNCS->get_icon('caret-bottom').''; } $day = ''; @@ -3936,15 +3936,33 @@ function load_css( $src='' ){ } function add_js( $code ){ - $this->admin_js .= $code . "\r\n"; + static $sig = array(); + + $hash = MD5( $code ); + if( !isset($sig[$hash]) ){ + $this->admin_js .= $code . "\r\n"; + $sig[$hash] = 1; + } } function add_css( $css ){ - $this->admin_css .= $css . "\r\n"; + static $sig = array(); + + $hash = MD5( $css ); + if( !isset($sig[$hash]) ){ + $this->admin_css .= $css . "\r\n"; + $sig[$hash] = 1; + } } function add_html( $html ){ - $this->admin_html .= $html . "\r\n"; + static $sig = array(); + + $hash = MD5( $html ); + if( !isset($sig[$hash]) ){ + $this->admin_html .= $html . "\r\n"; + $sig[$hash] = 1; + } } function get_js(){