diff --git a/grab-gets.jquery.json b/grab-gets.jquery.json index a760f92..00634e6 100644 --- a/grab-gets.jquery.json +++ b/grab-gets.jquery.json @@ -10,7 +10,7 @@ "checkbox", "radio" ], - "version": "1.0.3", + "version": "1.0.4", "author": { "name": "Sergey Astafev (saxa:p)", "url": "http://dontforget.pro", diff --git a/jquery.grab-gets.js b/jquery.grab-gets.js index 3167d7f..f3f09d0 100644 --- a/jquery.grab-gets.js +++ b/jquery.grab-gets.js @@ -1,10 +1,9 @@ /*! * jQuery grabget plugin * Description: Grab GET parameters from url and put, select and check elements of selected form - * version: 1.0.1-2013.11.10 + * version: 1.0.4-2013.22.12 * Requires jQuery v1.2 or later * Autor: saxa:p (http://dontforget.pro) - * Email: saxap@bk.ru * Examples and documentation at: http://malsup.com/jquery/form/ * Project repository: https://github.com/malsup/form * Dual licensed under the MIT and GPL licenses. @@ -18,16 +17,17 @@ $.extend({ getUrlVars: function(re){ var vars = [], hash; + var h0 = ''; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); + h0 = hash[0]; if (!re) { vars.push(hash[0]); vars[hash[0]] = hash[1]; - } else { - vars.push(hash[1]); - vars[hash[1]] = hash[0]; + } else { + vars[decodeURIComponent(hash[1])] = decodeURIComponent(h0); } } return vars; @@ -70,14 +70,16 @@ form.find('select').each( function() { var iname = $(this).attr('name'); $(this).find('option').each( function() { - if ( $.inArray($(this).val(), arr) !== -1 ) { + var ival = $(this).val(); + if ( arr[ival] == iname ) { $(this).attr('selected', 'selected'); } }); }); form.find('input[type="checkbox"], input[type="radio"]').each( function() { var iname = $(this).attr('name'); - if ( $.inArray($(this).val(), arr) !== -1 ) { + var ival = $(this).val(); + if ( arr[ival] == iname ) { $(this).attr('checked', 'checked'); } }); diff --git a/jquery.grab-gets.min.js b/jquery.grab-gets.min.js index 8f7484b..3b65a0a 100644 --- a/jquery.grab-gets.min.js +++ b/jquery.grab-gets.min.js @@ -1,7 +1,7 @@ /*! * jQuery grabget plugin * Description: Grab GET parameters from url and put, select and check elements of selected form - * version: 1.0.1-2013.11.10 + * version: 1.0.4-2013.22.12 * Requires jQuery v1.2 or later * Autor: saxa:p (http://dontforget.pro) * Examples and documentation at: http://malsup.com/jquery/form/ @@ -9,4 +9,4 @@ * Dual licensed under the MIT and GPL licenses. * https://github.com/malsup/form#copyright-and-license */ -(function($){jQuery.fn.grabgets=function(options){options=$.extend({hidden:true},options);$.extend({getUrlVars:function(re){var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');for(var i=0;i