Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | 1x 8x 8x 7x 7x 15x 15x 15x 1x 15x 7x 8x 7x 7x 5x 5x 5x 3x 5x 1x 7x 6x 1x 1x 5x 7x 1x 7x | /**
* Classe utilitaire
*
* @module Helper
* @alias Gp.Helper
*/
var Helper = {
/**
* concatenation des parametres key/value dans les urls
*
* @method normalyzeParameters
* @static
* @param {Object} params - tableau de clef/valeur
*
* @example
* Gp.Utils.Helper.normalyzeParameters ({
* key1:value1,
* key2:value2,
* key3:value3
* });
* // out : "key1=value1&key2=value2&key3=value3"
*
* @returns {String} retourne les paramètres concaténés
*/
normalyzeParameters : function (params) {
var myParams = null;
if (params) {
var tabParams = [];
for (var key in params) {
Eif (params.hasOwnProperty(key)) {
var value = params[key];
if (!value) {
value = "";
}
tabParams.push(key + "=" + value);
}
}
myParams = tabParams.join("&");
}
return myParams;
},
/**
* Concaténation et encodage des urls.
*
* @method normalyzeUrl
* @static
* @param {String} url - url
* @param {Object|String} params - tableau de clef/valeur ou string
* @param {Boolean} encode - true|false, false par defaut
*
* @example
* Gp.Utils.Helper.normalyzeUrl (url, {
* key1:value1,
* key2=:value2,
* key3:value3
* });
* // out : "url?key1=value1&key2=value2&key3=value3"
*
* @returns {String} retourne une url normalisée
*/
normalyzeUrl : function (url, params, encode) {
var myUrl = url;
if (url) {
Iif (url.split("?").length - 1 >= 2) {
// S'il y a plusieurs "?" dans l'URL, on garde le premier et on remplace les autres par des &
var firstOccuranceIndex = url.search(/\?/) + 1;
myUrl = url.substring(0, firstOccuranceIndex) + url.slice(firstOccuranceIndex).replace(/\?/g, "&");
}
var k = url.indexOf("?");
if (k === -1) { // pas de ? et KVP
myUrl += "?";
}
if (k !== -1 && k !== url.length - 1) { // KVP
myUrl += "&";
}
}
if (params) {
if (typeof params === "string") {
params = params.replace("?", "");
myUrl += params;
} else {
myUrl += this.normalyzeParameters(params);
}
}
if (encode) {
// FIXME bonne idée ?
myUrl = encodeURIComponent(myUrl);
}
return myUrl;
},
/**
* Indentation d'une chaine
*
* @method indent
* @static
* @param {Number} n - nombre de tabulation
* @param {String} msg - chaine
*
* @example
* Gp.Utils.Helper.indent (2, "message à indenter")
* // out
* // ........message à indenter
*
* @returns {String} retourne une chaine indentée
*/
indent : function (n, msg) {
var num = n || 0;
return new Array(num + 1).join("\t") + msg;
}
};
export default Helper;
|