/
uploader.js
593 lines (534 loc) · 25.2 KB
/
uploader.js
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
$(document).on('ready pjax:scriptcomplete', function () {
doFileUpload();
fixParentHeigth();
});
function fixParentHeigth(fieldname, elementHeight)
{
fieldname = fieldname || '';
elementHeight = elementHeight || 0;
if (window != top)
{
//~ frameheight=Math.max($(document).height(),$('html').outerHeight()+30,150);
if (fieldname != '')
{
frameheight = Math.max($(document).height() + elementHeight, $('#field' + fieldname + '_listfiles').parent().height());
} else
{
frameheight = Math.max($(document).height() + elementHeight, 150);
}
if (jQuery.isFunction(parent.updateUploadFrame))
{
parent.updateUploadFrame(window.name, frameheight);
}
}
}
function doFileUpload()
{
var fieldname = $('#ia').val();
/* Load the previously uploaded files */
var filecount = window.parent.window.$('#java' + fieldname + '_filecount').val();
$('#' + fieldname + '_filecount').val(filecount);
var image_extensions = new Array("gif", "jpeg", "jpg", "png", "swf", "psd", "bmp", "tiff", "jp2", "iff", "bmp", "xbm", "ico");
if (filecount > 0)
{
var jsontext = window.parent.window.$('#java' + fieldname).val();
var json = '';
try{
json = JSON.parse(jsontext);
} catch(e) {}
if ($('#field' + fieldname + '_listfiles').length == 0)
{
$("<ul id='field" + fieldname + "_listfiles' class='files-list' />").insertAfter("#uploadstatus");
}
var i;
$('#' + fieldname + '_licount').val(filecount);
for (i = 1; i <= filecount; i++)
{
var previewblock = "<li id='" + fieldname + "_li_" + i + "' class='previewblock file-element'>";
previewblock += "<div class='file-preview'>";
if (isValueInArray(image_extensions, json[i - 1].ext.toLowerCase()))
previewblock += "<img src='" + uploadurl + "/filegetcontents/" + json[i - 1].filename + "/fieldname/" + fieldname + "' class='uploaded' onload='fixParentHeigth(fieldname)' />";
else
previewblock += "<div class='upload-placeholder' />";
previewblock += "<span class='file-name'>" + htmlentities(decodeURIComponent(json[i - 1].name),null,null,false) + "</span>";
previewblock += "</div>";
previewblock += "<div class='file-info'><fieldset>";
if ($('#' + fieldname + '_show_title').val() == 1 || $('#' + fieldname + '_show_comment').val() == 1)
{
if ($('#' + fieldname + '_show_title').val() == 1)
{
previewblock += "<div class='form-group'><label class='control-label col-xs-4' for='" + fieldname + "_title_" + i + "'>" + uploadLang.titleFld + "</label>" + "<div class='input-container'><input class='form-control' type='text' value='" + htmlentities(json[i - 1].title,null,null,false) + "' id='" + fieldname + "_title_" + i + "' /></div></div>";
}
if ($('#' + fieldname + '_show_comment').val() == 1)
{
previewblock += "<div class='form-group'><label class='control-label col-xs-4' for='" + fieldname + "_comment_" + i + "'>" + uploadLang.commentFld + "</label>" + "<div class='input-container'><input class='form-control' type='text' value='" + htmlentities(json[i - 1].comment,null,null,false) + "' id='" + fieldname + "_comment_" + i + "' /></div></div>";
}
}
previewblock += "<div class='form-group'><div class='col-xs-4'></div><div class='input-container'><a class='btn btn-danger' onclick='deletefile(\"" + fieldname + "\", " + i + ")'><span class='fa fa-trash'></span> " + uploadLang.deleteFile + "</a></div></div>";
previewblock += "</fieldset></div>";
previewblock += "<input type='hidden' id='" + fieldname + "_size_" + i + "' value=" + json[i - 1].size + " />" +
"<input type='hidden' id='" + fieldname + "_name_" + i + "' value=" + htmlentities(json[i - 1].name,null,null,false) + " />" +
"<input type='hidden' id='" + fieldname + "_file_index_" + i + "' value=" + i + " />" +
"<input type='hidden' id='" + fieldname + "_filename_" + i + "' value=" + htmlentities(json[i - 1].filename,null,null,false) + " />" +
"<input type='hidden' id='" + fieldname + "_ext_" + i + "' value=" + htmlentities(json[i - 1].ext) + " />";
previewblock += "</li>";
// add file to the list
$('#field' + fieldname + '_listfiles').append(previewblock);
fixParentHeigth(fieldname);
}
}
// The upload button
var button = $('#button1'), interval;
new AjaxUpload(button, {
action: uploadurl + '/sid/' + surveyid + '/preview/' + questgrppreview + '/fieldname/' + fieldname + '/',
name: 'uploadfile',
data: $.extend({
valid_extensions: $('#' + fieldname + '_allowed_filetypes').val(),
max_filesize: $('#' + fieldname + '_maxfilesize').val(),
preview: $('#preview').val(),
surveyid: surveyid,
fieldname: fieldname,
}, csrfData
),
onSubmit: function (file, ext) {
var maxfiles = parseInt($('#' + fieldname + '_maxfiles').val());
var filecount = parseInt($('#' + fieldname + '_filecount').val());
var allowed_filetypes = $('#' + fieldname + '_allowed_filetypes').val().split(",");
/* If maximum number of allowed filetypes have already been uploaded,
* do not upload the file and display an error message ! */
if (filecount >= maxfiles)
{
$('#notice').html('<p class="alert alert-danger"><span class="fa fa-exclamation-circle"></span> ' + uploadLang.errorNoMoreFiles + '</p>');
fixParentHeigth(fieldname);
return false;
}
/* If the file being uploaded is not allowed,
* do not upload the file and display an error message ! */
var allowSubmit = false;
for (var i = 0; i < allowed_filetypes.length; i++)
{
//check to see if it's the proper extension
if (jQuery.trim(allowed_filetypes[i].toLowerCase()) == jQuery.trim(ext.toLowerCase()))
{
//it's the proper extension
allowSubmit = true;
break;
}
}
if (allowSubmit == false)
{
$('#notice').html('<p class="alert alert-danger"><span class="fa fa-exclamation-circle"></span> ' + uploadLang.errorOnlyAllowed.replace('%s', $('#' + fieldname + '_allowed_filetypes').val()) + '</p>');
fixParentHeigth(fieldname);
return false;
}
// change button text, when user selects file
button.text(uploadLang.uploading);
// If you want to allow uploading only 1 file at time,
// you can disable upload button
this.disable();
// Uploding -> Uploading. -> Uploading...
interval = window.setInterval(function () {
var text = button.text();
if (text.length < 13)
{
button.text(text + '.');
} else
{
button.text(uploadLang.uploading);
}
}, 400);
},
onComplete: function (file, response) {
button.text(uploadLang.selectfile);
window.clearInterval(interval);
// enable upload button
this.enable();
// Once the file has been uploaded via AJAX,
// the preview is appended to the list of files
try{
var metadata = jQuery.parseJSON(response);
} catch(e) {
/* Suppose we get an HTML error ? Replace whole HTML (without head) */
$('body').html(response);
return;
}
var count = parseInt($('#' + fieldname + '_licount').val());
count++;
$('#' + fieldname + '_licount').val(count);
var image_extensions = new Array("gif", "jpeg", "jpg", "png", "swf", "psd", "bmp", "tiff", "jp2", "iff", "bmp", "xbm", "ico");
if (metadata.success)
{
$('#notice').html('<p class="alert alert-success"><span class="fa fa-success"></span> ' + metadata.msg + '</p>');
if ($('#field' + fieldname + '_listfiles').length == 0)
{
$("<ul id='field" + fieldname + "_listfiles' class='files-list' />").insertAfter("#uploadstatus");
}
var previewblock = "<li id='" + fieldname + "_li_" + count + "' class='previewblock file-element'>";
previewblock += "<div class='file-preview'>";
if (isValueInArray(image_extensions, metadata.ext.toLowerCase()))
previewblock += "<img src='" + uploadurl + "/filegetcontents/" + decodeURIComponent(metadata.filename) + "/fieldname/" + fieldname + "' class='uploaded' onload='fixParentHeigth(fieldname)' />";
else
previewblock += "<div class='upload-placeholder' />";
previewblock += "<span class='file-name'>" + escapeHtml(decodeURIComponent(metadata.name)) + "<span>";
previewblock += "</div>";
previewblock += "<div class='file-info'><fieldset>";
if ($('#' + fieldname + '_show_title').val() == 1 || $('#' + fieldname + '_show_comment').val() == 1)
{
if ($('#' + fieldname + '_show_title').val() == 1)
{
previewblock += "<div class='form-group'><label class='control-label col-xs-4' for='" + fieldname + "_title_" + count + "'>" + uploadLang.titleFld + "</label>" + "<div class='input-container'><input class='form-control' type='text' value='' id='" + fieldname + "_title_" + count + "' /></div></div>";
}
if ($('#' + fieldname + '_show_comment').val() == 1)
{
previewblock += "<div class='form-group'><label class='control-label col-xs-4' for='" + fieldname + "_comment_" + count + "'>" + uploadLang.commentFld + "</label>" + "<div class='input-container'><input class='form-control' type='text' value='' id='" + fieldname + "_comment_" + count + "' /></div></div>";
}
}
previewblock += "<div class='form-group'><div class='col-xs-4'></div><div class='input-container'><a class='btn btn-danger' onclick='deletefile(\"" + fieldname + "\", " + count + ")'><span class='fa fa-trash'></span> " + uploadLang.deleteFile + "</a></div></div>";
previewblock += "</fieldset></div>";
previewblock += "<input type='hidden' id='" + fieldname + "_size_" + count + "' value=" + metadata.size + " />" +
"<input type='hidden' id='" + fieldname + "_file_index_" + count + "' value=" + metadata.file_index + " />" +
"<input type='hidden' id='" + fieldname + "_name_" + count + "' value=" + metadata.name + " />" +
"<input type='hidden' id='" + fieldname + "_filename_" + count + "' value=" + metadata.filename + " />" +
"<input type='hidden' id='" + fieldname + "_ext_" + count + "' value=" + metadata.ext + " />";
previewblock += "</li>";
// add file to the list
$('#field' + fieldname + '_listfiles').prepend(previewblock);
var filecount = parseInt($('#' + fieldname + '_filecount').val());
var minfiles = parseInt($('#' + fieldname + '_minfiles').val());
filecount++;
var maxfiles = parseInt($('#' + fieldname + '_maxfiles').val());
$('#' + fieldname + '_filecount').val(filecount);
if (filecount < minfiles) {
$('#uploadstatus').html(uploadLang.errorNeedMore.replace('%s', (minfiles - filecount))).removeClass('hidden');
} else if (filecount < maxfiles) {
$('#uploadstatus').html(uploadLang.errorMoreAllowed.replace('%s', (maxfiles - filecount))).removeClass('hidden');
} else {
$('#uploadstatus').html(uploadLang.errorMaxReached).removeClass('hidden');
}
fixParentHeigth(fieldname);
if (filecount >= maxfiles) {
//$('#notice').html('<p class="alert alert-success"><span class="fa fa-check"></span> ' + uploadLang.errorTooMuch + '</p>');
}
fixParentHeigth(fieldname);
} else {
$('#notice').html('<p class="alert alert-danger"><span class="fa fa-exclamation-circle"></span> ' + metadata.msg + '</p>');
fixParentHeigth(fieldname);
}
}
});
// if it has been jst opened, the upload button should be automatically clicked !
// TODO: auto open using click() not working at all ! :(
}
function isValueInArray(arr, val)
{
inArray = false;
for (i = 0; i < arr.length; i++)
if (val.toLowerCase() == arr[i].toLowerCase())
inArray = true;
return inArray;
}
// pass the JSON data from the iframe to the main survey page
function passJSON(fieldname, show_title, show_comment, pos)
{
var json = "[";
var filecount = 0;
var licount = parseInt($('#' + fieldname + '_licount').val());
var i = 1;
while (i <= licount)
{
if ($("#" + fieldname + "_li_" + i).is(':visible'))
{
if (filecount > 0)
json += ",";
json += '{ ';
if ($("#" + fieldname + "_show_title").val() == 1)
json += '"title":"' + htmlentities($("#" + fieldname + "_title_" + i).val(),null,null,false) + '",';
if ($("#" + fieldname + "_show_comment").val() == 1)
json += '"comment":"' + htmlentities($("#" + fieldname + "_comment_" + i).val(),null,null,false) + '",';
json += '"size":"' + $("#" + fieldname + "_size_" + i).val() + '",' +
'"name":"' + htmlentities($("#" + fieldname + "_name_" + i).val(),null,null,false) + '",' +
'"filename":"' + htmlentities($("#" + fieldname + "_filename_" + i).val(),null,null,false) + '",' +
'"ext":"' + htmlentities($("#" + fieldname + "_ext_" + i).val(),null,null,false) + '"}';
filecount += 1;
}
i += 1;
}
json += "]";
window.parent.window.copyJSON(json, filecount, fieldname, show_title, show_comment, pos);
}
function saveAndExit(fieldname, show_title, show_comment, pos)
{
var filecount = parseInt($('#' + fieldname + '_filecount').val());
var minfiles = parseInt($('#' + fieldname + '_minfiles').val());
if (minfiles != 0 && filecount < minfiles && showpopups)
{
var confirmans = confirm(uploadLang.errorNeedMoreConfirm.replace('%s', (minfiles - filecount)));
if (confirmans)
{
passJSON(fieldname, show_title, show_comment, pos);
return true;
} else
return false;
} else
{
passJSON(fieldname, show_title, show_comment, pos);
return true;
}
}
function deletefile(fieldname, count)
{
var file_index;
var filename = $("#" + fieldname + "_filename_" + count).val();
var name = $("#" + fieldname + "_name_" + count).val();
var filecount = parseInt($('#' + fieldname + '_filecount').val());
var licount = parseInt($('#' + fieldname + '_licount').val());
fileheight = $("#" + fieldname + "_li_" + count).height();
$("#" + fieldname + "_li_" + count).remove();
$.ajax(
{
method: "POST",
url: uploadurl,
data: $.extend({
'delete': 1,
'fieldname': fieldname,
'filename': filename,
'name': name,
}, csrfData)
})
.done(function (msg) {
$('#notice').html('<p class="alert alert-success"><span class="fa fa-check"></span> ' + msg + '</p>');
setTimeout(function () {
$(".success").remove();
}, 5000);
$("#" + fieldname + "_li_" + count).hide();
filecount--;
$('#' + fieldname + '_filecount').val(filecount);
file_index = $("#" + fieldname + "_file_index_" + count).val();
for (j = count; j <= licount; j++)
{
if ($('#' + fieldname + '_li_' + j).is(":visible"))
{
$('#' + fieldname + '_file_index_' + j).val(file_index);
file_index++;
}
}
var minfiles = parseInt($('#' + fieldname + '_minfiles').val());
var maxfiles = parseInt($('#' + fieldname + '_maxfiles').val());
if (filecount < minfiles)
{
$('#uploadstatus').html(uploadLang.errorNeedMore.replace('%s', (minfiles - filecount)));
fixParentHeigth(fieldname, -fileheight);
} else
{
$('#uploadstatus').html(uploadLang.errorMoreAllowed.replace('%s', (maxfiles - filecount)));
fixParentHeigth(fieldname, -fileheight);
}
});
}
function escapeHtml(unsafe)
{
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
function htmlentities (string, quote_style, charset, double_encode) {
// Convert all applicable characters to HTML entities
//
// version: 1107.2516
// discuss at: http://phpjs.org/functions/htmlentities
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: nobbler
// + tweaked by: Jack
// + bugfixed by: Onno Marsman
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: Ratheous
// + improved by: Rafał Kukawski (http://blog.kukawski.pl)
// - depends on: get_html_translation_table
// * example 1: htmlentities('Kevin & van Zonneveld');
// * returns 1: 'Kevin & van Zonneveld'
// * example 2: htmlentities("foo'bar","ENT_QUOTES");
// * returns 2: 'foo'bar'
var hash_map = {},
symbol = '',
entity = '',
self = this;
string += '';
double_encode = !!double_encode || double_encode == null;
if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
return false;
}
hash_map["'"] = ''';
if (double_encode) {
for (symbol in hash_map) {
entity = hash_map[symbol];
string = string.split(symbol).join(entity);
}
} else {
string = string.replace(/([\s\S]*?)(&(?:#\d+|#x[\da-f]+|[a-z][\da-z]*);|$)/g, function (ignore, text, entity) {
return self.htmlentities(text, quote_style, charset) + entity;
});
}
return string;
}
function get_html_translation_table (table, quote_style) {
// Returns the internal translation table used by htmlspecialchars and htmlentities
//
// version: 1107.2516
// discuss at: http://phpjs.org/functions/get_html_translation_table
// + original by: Philip Peterson
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: noname
// + bugfixed by: Alex
// + bugfixed by: Marco
// + bugfixed by: madipta
// + improved by: KELAN
// + improved by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: Frank Forte
// + bugfixed by: T.Wild
// + input by: Ratheous
// % note: It has been decided that we're not going to add global
// % note: dependencies to php.js, meaning the constants are not
// % note: real constants, but strings instead. Integers are also supported if someone
// % note: chooses to create the constants themselves.
// * example 1: get_html_translation_table('HTML_SPECIALCHARS');
// * returns 1: {'"': '"', '&': '&', '<': '<', '>': '>'}
var entities = {},
hash_map = {},
decimal = 0,
symbol = '';
var constMappingTable = {},
constMappingQuoteStyle = {};
var useTable = {},
useQuoteStyle = {};
// Translate arguments
constMappingTable[0] = 'HTML_SPECIALCHARS';
constMappingTable[1] = 'HTML_ENTITIES';
constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
constMappingQuoteStyle[2] = 'ENT_COMPAT';
constMappingQuoteStyle[3] = 'ENT_QUOTES';
useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
throw new Error("Table: " + useTable + ' not supported');
// return false;
}
entities['38'] = '&';
if (useTable === 'HTML_ENTITIES') {
entities['160'] = ' ';
entities['161'] = '¡';
entities['162'] = '¢';
entities['163'] = '£';
entities['164'] = '¤';
entities['165'] = '¥';
entities['166'] = '¦';
entities['167'] = '§';
entities['168'] = '¨';
entities['169'] = '©';
entities['170'] = 'ª';
entities['171'] = '«';
entities['172'] = '¬';
entities['173'] = '­';
entities['174'] = '®';
entities['175'] = '¯';
entities['176'] = '°';
entities['177'] = '±';
entities['178'] = '²';
entities['179'] = '³';
entities['180'] = '´';
entities['181'] = 'µ';
entities['182'] = '¶';
entities['183'] = '·';
entities['184'] = '¸';
entities['185'] = '¹';
entities['186'] = 'º';
entities['187'] = '»';
entities['188'] = '¼';
entities['189'] = '½';
entities['190'] = '¾';
entities['191'] = '¿';
entities['192'] = 'À';
entities['193'] = 'Á';
entities['194'] = 'Â';
entities['195'] = 'Ã';
entities['196'] = 'Ä';
entities['197'] = 'Å';
entities['198'] = 'Æ';
entities['199'] = 'Ç';
entities['200'] = 'È';
entities['201'] = 'É';
entities['202'] = 'Ê';
entities['203'] = 'Ë';
entities['204'] = 'Ì';
entities['205'] = 'Í';
entities['206'] = 'Î';
entities['207'] = 'Ï';
entities['208'] = 'Ð';
entities['209'] = 'Ñ';
entities['210'] = 'Ò';
entities['211'] = 'Ó';
entities['212'] = 'Ô';
entities['213'] = 'Õ';
entities['214'] = 'Ö';
entities['215'] = '×';
entities['216'] = 'Ø';
entities['217'] = 'Ù';
entities['218'] = 'Ú';
entities['219'] = 'Û';
entities['220'] = 'Ü';
entities['221'] = 'Ý';
entities['222'] = 'Þ';
entities['223'] = 'ß';
entities['224'] = 'à';
entities['225'] = 'á';
entities['226'] = 'â';
entities['227'] = 'ã';
entities['228'] = 'ä';
entities['229'] = 'å';
entities['230'] = 'æ';
entities['231'] = 'ç';
entities['232'] = 'è';
entities['233'] = 'é';
entities['234'] = 'ê';
entities['235'] = 'ë';
entities['236'] = 'ì';
entities['237'] = 'í';
entities['238'] = 'î';
entities['239'] = 'ï';
entities['240'] = 'ð';
entities['241'] = 'ñ';
entities['242'] = 'ò';
entities['243'] = 'ó';
entities['244'] = 'ô';
entities['245'] = 'õ';
entities['246'] = 'ö';
entities['247'] = '÷';
entities['248'] = 'ø';
entities['249'] = 'ù';
entities['250'] = 'ú';
entities['251'] = 'û';
entities['252'] = 'ü';
entities['253'] = 'ý';
entities['254'] = 'þ';
entities['255'] = 'ÿ';
}
if (useQuoteStyle !== 'ENT_NOQUOTES') {
entities['34'] = '"';
}
if (useQuoteStyle === 'ENT_QUOTES') {
entities['39'] = ''';
}
entities['60'] = '<';
entities['62'] = '>';
// ascii decimals to real symbols
for (decimal in entities) {
symbol = String.fromCharCode(decimal);
hash_map[symbol] = entities[decimal];
}
return hash_map;
}