From 460c37984ffe6b53ecb6cd9f7d34b5e146dda9d1 Mon Sep 17 00:00:00 2001 From: ozhozh Date: Wed, 25 May 2011 17:06:38 +0000 Subject: [PATCH] Simpler JS to please that retard IE8. Fixes issue 801. git-svn-id: http://yourls.googlecode.com/svn/trunk@627 12232710-3e20-11de-b438-597f59cd7555 --- js/common.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/js/common.js b/js/common.js index 5f0b34e..4c8cade 100644 --- a/js/common.js +++ b/js/common.js @@ -29,13 +29,13 @@ function html_pulse( el, newtext ){ // Update feedback message function feedback(msg, type, delay) { - close = ( type == 'fail' || type == 'error' ) ? true : false; - delay = delay || ( close == true ? 10000 : 3500 ); + closeme = ( type == 'fail' || type == 'error' ) ? true : false; + delay = delay || ( closeme == true ? 10000 : 3500 ); $.notifyBar({ html: ''+msg+'', delay: delay, animationSpeed: "normal", - close: close, + close: closeme, cls: type }); return true; @@ -87,20 +87,22 @@ function get_var_from_query( url, varname, default_val ) { default_val = ''; } - try{ - url = url.split('?')[1].split('&').reverse().filter(function(e){ - var pair = e.split('='); - return( pair[0] == varname ); - })[0].split('=')[1]; - // weeeeeeee - // split the query string on '&', reverse to check last pairs first so that ?ozh=1&ozh=2 matches ozh=2 first - // then filter on each pair to find the matching 'varname=something', - // which is then returned in a one element array that we split on '=' and take second part. woot! - } catch(err) { - return default_val; + // Split the url on '?' and get only the params (which is element 1) + url = url.split('?')[1]; + // Now split those params on '&' so we can get each one individually (Ex. param_var=param_value) + url = url.split('&'); + // Now we have to find the varname in that array using methods that IE likes (Curse you IE!!!) + var i=0; + for( i=0; i