Sha256: 78a49c150b7936504009936d13bfbf44bb6460eaea37440cdc4cc5b38ea457e9
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
//{{{ URL PARAMETER CONTROL function add_parameters(url, parameters){ var string; if ( typeof(parameters) == 'string' || typeof(parameters) == 'String'){ string = parameters; }else{ var pairs = []; for (parameter in parameters){ pairs.push(parameter + "=" + parameters[parameter]); } string = pairs.join("&"); } if (string.length == 0){return(url)} if (url.indexOf('?') == -1){ return url + '?' + string; }else{ return url + '&' + string; } } function add_parameter(url, parameter, value){ var url = remove_parameter(url, parameter) url = add_parameters(url, parameter + "=" + value) return url; } function remove_parameter(url, parameter){ if (url.match("&" + parameter + "=")){ return url.replace("&" + parameter + "=", '&REMOVE=').replace(/REMOVE=[^&]+/, '').replace(/\?&/, '?').replace(/&&/, '&').replace(/[?&]$/, ''); }else{ return url.replace("?" + parameter + "=", '?REMOVE=').replace(/REMOVE=[^&]+/, '').replace(/\?&/, '?').replace(/&&/, '&').replace(/[?&]$/, ''); } } function clean_element(elem){ return elem.replace(/\//g, '--') } function restore_element(elem){ return unescape(elem.replace(/--/g, '/')); } function parse_parameters(params){ var ret = {}, seg = params.replace(/^\?/,'').split('&'), len = seg.length, i = 0, s; for (;i<len;i++) { if (!seg[i]) { continue; } s = seg[i].split('='); ret[s[0]] = restore_element(s[1]); } return ret } function require_js(url, success){ var async = false; if (undefined === success){ async = false; }else{ async = true; } $.ajax({url: url, dataType:'script', async:async, success: success} ).fail(function(jqxhr, settings, exception){ console.log('Exception loading: ' + url) console.log(exception) console.log(jqxhr) }) }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rbbt-rest-1.1.2 | share/views/public/js/helpers.js |