Skip to content

Commit 2a81067

Browse files
committed
Changing "histogram" to "hash_map" (Thanks Ratheous)
1 parent 74a0b2f commit 2a81067

File tree

9 files changed

+184
-175
lines changed

9 files changed

+184
-175
lines changed

functions/strings/get_html_translation_table.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ function get_html_translation_table(table, quote_style) {
1111
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
1212
// + input by: Frank Forte
1313
// + bugfixed by: T.Wild
14+
// + input by: Ratheous
1415
// % note: It has been decided that we're not going to add global
15-
// % note: dependencies to php.js. Meaning the constants are not
16-
// % note: real constants, but strings instead. integers are also supported if someone
16+
// % note: dependencies to php.js, meaning the constants are not
17+
// % note: real constants, but strings instead. Integers are also supported if someone
1718
// % note: chooses to create the constants themselves.
1819
// * example 1: get_html_translation_table('HTML_SPECIALCHARS');
1920
// * returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
2021

21-
var entities = {}, histogram = {}, decimal = 0, symbol = '';
22+
var entities = {}, hash_map = {}, decimal = 0, symbol = '';
2223
var constMappingTable = {}, constMappingQuoteStyle = {};
2324
var useTable = {}, useQuoteStyle = {};
2425

@@ -150,8 +151,8 @@ function get_html_translation_table(table, quote_style) {
150151
// ascii decimals to real symbols
151152
for (decimal in entities) {
152153
symbol = String.fromCharCode(decimal);
153-
histogram[symbol] = entities[decimal];
154+
hash_map[symbol] = entities[decimal];
154155
}
155156

156-
return histogram;
157+
return hash_map;
157158
}

functions/strings/html_entity_decode.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ function html_entity_decode( string, quote_style ) {
88
// + improved by: marc andreu
99
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
1010
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
11+
// + input by: Ratheous
1112
// - depends on: get_html_translation_table
1213
// * example 1: html_entity_decode('Kevin &amp; van Zonneveld');
1314
// * returns 1: 'Kevin & van Zonneveld'
1415
// * example 2: html_entity_decode('&amp;lt;');
1516
// * returns 2: '&lt;'
1617

17-
var histogram = {}, symbol = '', tmp_str = '', entity = '';
18+
var hash_map = {}, symbol = '', tmp_str = '', entity = '';
1819
tmp_str = string.toString();
1920

20-
if (false === (histogram = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
21+
if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
2122
return false;
2223
}
2324

24-
for (symbol in histogram) {
25-
entity = histogram[symbol];
25+
for (symbol in hash_map) {
26+
entity = hash_map[symbol];
2627
tmp_str = tmp_str.split(entity).join(symbol);
2728
}
2829
tmp_str = tmp_str.split('&#039;').join("'");

functions/strings/htmlentities.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ function htmlentities (string, quote_style) {
77
// + bugfixed by: Onno Marsman
88
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
99
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
10+
// + input by: Ratheous
1011
// - depends on: get_html_translation_table
1112
// * example 1: htmlentities('Kevin & van Zonneveld');
1213
// * returns 1: 'Kevin &amp; van Zonneveld'
1314
// * example 2: htmlentities("foo'bar","ENT_QUOTES");
1415
// * returns 2: 'foo&#039;bar'
1516

16-
var histogram = {}, symbol = '', tmp_str = '', entity = '';
17+
var hash_map = {}, symbol = '', tmp_str = '', entity = '';
1718
tmp_str = string.toString();
1819

19-
if (false === (histogram = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
20+
if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
2021
return false;
2122
}
22-
histogram["'"] = '&#039;';
23-
for (symbol in histogram) {
24-
entity = histogram[symbol];
23+
hash_map["'"] = '&#039;';
24+
for (symbol in hash_map) {
25+
entity = hash_map[symbol];
2526
tmp_str = tmp_str.split(symbol).join(entity);
2627
}
2728

functions/strings/htmlspecialchars.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ function htmlspecialchars (string, quote_style) {
66
// + bugfixed by: Arno
77
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
88
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
9+
// + input by: Ratheous
910
// - depends on: get_html_translation_table
1011
// * example 1: htmlspecialchars("<a href='test'>Test</a>", 'ENT_QUOTES');
1112
// * returns 1: '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;'
1213

13-
var histogram = {}, symbol = '', tmp_str = '', entity = '';
14+
var hash_map = {}, symbol = '', tmp_str = '', entity = '';
1415
tmp_str = string.toString();
1516

16-
if (false === (histogram = this.get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
17+
if (false === (hash_map = this.get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
1718
return false;
1819
}
1920

20-
histogram["'"] = '&#039;';
21-
for (symbol in histogram) {
22-
entity = histogram[symbol];
21+
hash_map["'"] = '&#039;';
22+
for (symbol in hash_map) {
23+
entity = hash_map[symbol];
2324
tmp_str = tmp_str.split(symbol).join(entity);
2425
}
2526

functions/strings/htmlspecialchars_decode.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ function htmlspecialchars_decode(string, quote_style) {
1010
// + bugfixed by: Onno Marsman
1111
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
1212
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
13+
// + input by: Ratheous
1314
// - depends on: get_html_translation_table
1415
// * example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
1516
// * returns 1: '<p>this -> &quot;</p>'
1617

17-
var histogram = {}, symbol = '', tmp_str = '', entity = '';
18+
var hash_map = {}, symbol = '', tmp_str = '', entity = '';
1819
tmp_str = string.toString();
1920

20-
if (false === (histogram = this.get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
21+
if (false === (hash_map = this.get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
2122
return false;
2223
}
2324

24-
for (symbol in histogram) {
25-
entity = histogram[symbol];
25+
for (symbol in hash_map) {
26+
entity = hash_map[symbol];
2627
tmp_str = tmp_str.split(entity).join(symbol);
2728
}
2829
tmp_str = tmp_str.split('&#039;').join("'");

functions/url/rawurldecode.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function rawurldecode( str ) {
44
// + input by: travc
55
// + input by: Brett Zamir (http://brett-zamir.me)
66
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
7+
// + input by: Ratheous
78
// * example 1: rawurldecode('Kevin+van+Zonneveld%21');
89
// * returns 1: 'Kevin+van+Zonneveld!'
910
// * example 2: rawurldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
@@ -13,25 +14,25 @@ function rawurldecode( str ) {
1314
// * example 4: rawurldecode('-22%97bc%2Fbc');
1415
// * returns 4: '-22—bc/bc'
1516

16-
var histogram = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
17+
var hash_map = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
1718

1819
var replacer = function(search, replace, str) {
1920
var tmp_arr = [];
2021
tmp_arr = str.split(search);
2122
return tmp_arr.join(replace);
2223
};
2324

24-
// The histogram is identical to the one in urlencode.
25-
histogram["'"] = '%27';
26-
histogram['('] = '%28';
27-
histogram[')'] = '%29';
28-
histogram['*'] = '%2A';
29-
histogram['~'] = '%7E';
30-
histogram['!'] = '%21';
25+
// The hash_map is identical to the one in urlencode.
26+
hash_map["'"] = '%27';
27+
hash_map['('] = '%28';
28+
hash_map[')'] = '%29';
29+
hash_map['*'] = '%2A';
30+
hash_map['~'] = '%7E';
31+
hash_map['!'] = '%21';
3132

3233

33-
for (unicodeStr in histogram) {
34-
hexEscStr = histogram[unicodeStr]; // Switch order when decoding
34+
for (unicodeStr in hash_map) {
35+
hexEscStr = hash_map[unicodeStr]; // Switch order when decoding
3536
ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
3637
}
3738

functions/url/rawurlencode.js

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ function rawurlencode( str ) {
66
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
77
// + input by: Michael Grier
88
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
9+
// + input by: Ratheous
910
// * example 1: rawurlencode('Kevin van Zonneveld!');
1011
// * returns 1: 'Kevin%20van%20Zonneveld%21'
1112
// * example 2: rawurlencode('http://kevin.vanzonneveld.net/');
1213
// * returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
1314
// * example 3: rawurlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
1415
// * returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
1516

16-
var histogram = {}, unicodeStr='', hexEscStr='';
17+
var hash_map = {}, unicodeStr='', hexEscStr='';
1718
var ret = str.toString();
1819

1920
var replacer = function(search, replace, str) {
@@ -22,52 +23,52 @@ function rawurlencode( str ) {
2223
return tmp_arr.join(replace);
2324
};
2425

25-
// The histogram is identical to the one in urldecode.
26-
histogram["'"] = '%27';
27-
histogram['('] = '%28';
28-
histogram[')'] = '%29';
29-
histogram['*'] = '%2A';
30-
histogram['~'] = '%7E';
31-
histogram['!'] = '%21';
32-
histogram['\u20AC'] = '%80';
33-
histogram['\u0081'] = '%81';
34-
histogram['\u201A'] = '%82';
35-
histogram['\u0192'] = '%83';
36-
histogram['\u201E'] = '%84';
37-
histogram['\u2026'] = '%85';
38-
histogram['\u2020'] = '%86';
39-
histogram['\u2021'] = '%87';
40-
histogram['\u02C6'] = '%88';
41-
histogram['\u2030'] = '%89';
42-
histogram['\u0160'] = '%8A';
43-
histogram['\u2039'] = '%8B';
44-
histogram['\u0152'] = '%8C';
45-
histogram['\u008D'] = '%8D';
46-
histogram['\u017D'] = '%8E';
47-
histogram['\u008F'] = '%8F';
48-
histogram['\u0090'] = '%90';
49-
histogram['\u2018'] = '%91';
50-
histogram['\u2019'] = '%92';
51-
histogram['\u201C'] = '%93';
52-
histogram['\u201D'] = '%94';
53-
histogram['\u2022'] = '%95';
54-
histogram['\u2013'] = '%96';
55-
histogram['\u2014'] = '%97';
56-
histogram['\u02DC'] = '%98';
57-
histogram['\u2122'] = '%99';
58-
histogram['\u0161'] = '%9A';
59-
histogram['\u203A'] = '%9B';
60-
histogram['\u0153'] = '%9C';
61-
histogram['\u009D'] = '%9D';
62-
histogram['\u017E'] = '%9E';
63-
histogram['\u0178'] = '%9F';
26+
// The hash_map is identical to the one in urldecode.
27+
hash_map["'"] = '%27';
28+
hash_map['('] = '%28';
29+
hash_map[')'] = '%29';
30+
hash_map['*'] = '%2A';
31+
hash_map['~'] = '%7E';
32+
hash_map['!'] = '%21';
33+
hash_map['\u20AC'] = '%80';
34+
hash_map['\u0081'] = '%81';
35+
hash_map['\u201A'] = '%82';
36+
hash_map['\u0192'] = '%83';
37+
hash_map['\u201E'] = '%84';
38+
hash_map['\u2026'] = '%85';
39+
hash_map['\u2020'] = '%86';
40+
hash_map['\u2021'] = '%87';
41+
hash_map['\u02C6'] = '%88';
42+
hash_map['\u2030'] = '%89';
43+
hash_map['\u0160'] = '%8A';
44+
hash_map['\u2039'] = '%8B';
45+
hash_map['\u0152'] = '%8C';
46+
hash_map['\u008D'] = '%8D';
47+
hash_map['\u017D'] = '%8E';
48+
hash_map['\u008F'] = '%8F';
49+
hash_map['\u0090'] = '%90';
50+
hash_map['\u2018'] = '%91';
51+
hash_map['\u2019'] = '%92';
52+
hash_map['\u201C'] = '%93';
53+
hash_map['\u201D'] = '%94';
54+
hash_map['\u2022'] = '%95';
55+
hash_map['\u2013'] = '%96';
56+
hash_map['\u2014'] = '%97';
57+
hash_map['\u02DC'] = '%98';
58+
hash_map['\u2122'] = '%99';
59+
hash_map['\u0161'] = '%9A';
60+
hash_map['\u203A'] = '%9B';
61+
hash_map['\u0153'] = '%9C';
62+
hash_map['\u009D'] = '%9D';
63+
hash_map['\u017E'] = '%9E';
64+
hash_map['\u0178'] = '%9F';
6465

6566

6667
// Begin with encodeURIComponent, which most resembles PHP's encoding functions
6768
ret = encodeURIComponent(ret);
6869

69-
for (unicodeStr in histogram) {
70-
hexEscStr = histogram[unicodeStr];
70+
for (unicodeStr in hash_map) {
71+
hexEscStr = hash_map[unicodeStr];
7172
ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
7273
}
7374

0 commit comments

Comments
 (0)