Skip to content

Commit 4d52038

Browse files
committed
Clean up some Javascript issues
Fixes #338
1 parent a2243ca commit 4d52038

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

src/Resources/public/js/datatables.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
switch (config.state) {
2929
case 'fragment':
3030
state = window.location.hash;
31-
state = (state.length > 1 ? deparam(state.substr(1)) : {});
31+
state = (state.length > 1 ? deparam(state.substring(1)) : {});
3232
break;
3333
case 'query':
3434
state = window.location.search;
35-
state = (state.length > 1 ? deparam(state.substr(1)) : {});
35+
state = (state.length > 1 ? deparam(state.substring(1)) : {});
3636
break;
3737
case 'local':
3838
stateDuration = 0
@@ -102,7 +102,7 @@
102102
}
103103

104104
root.html(data.template);
105-
dt = $('table', root).DataTable(dtOpts);
105+
var dt = $('table', root).DataTable(dtOpts);
106106
if (config.state !== 'none') {
107107
dt.on('draw.dt', function(e) {
108108
var data = $.param(dt.state()).split('&');
@@ -119,7 +119,7 @@
119119
case 'query':
120120
var windowLocationSearch = deparam(decodeURIComponent(diff.join('&')))
121121
if(window.location.search !== null) {
122-
windowLocationSearch = deparam(window.location.search.substr(1))
122+
windowLocationSearch = deparam(window.location.search.substring(1))
123123
Object.assign(windowLocationSearch, deparam(decodeURIComponent(diff.join('&'))))
124124
}
125125
history.replaceState(null, null, window.location.origin + window.location.pathname
@@ -185,34 +185,28 @@
185185
blob = new Blob([this.response], { type: type });
186186
}
187187

188-
if (typeof window.navigator.msSaveBlob !== 'undefined') {
189-
// IE workaround for "HTML7007: One or more blob URLs were revoked by closing the blob for which they were created. These URLs will no longer resolve as the data backing the URL has been freed."
190-
window.navigator.msSaveBlob(blob, filename);
191-
}
192-
else {
193-
const URL = window.URL || window.webkitURL;
194-
const downloadUrl = URL.createObjectURL(blob);
188+
const URL = window.URL || window.webkitURL;
189+
const downloadUrl = URL.createObjectURL(blob);
195190

196-
if (filename) {
197-
// use HTML5 a[download] attribute to specify filename
198-
const a = document.createElement("a");
199-
// safari doesn't support this yet
200-
if (typeof a.download === 'undefined') {
201-
window.location = downloadUrl;
202-
}
203-
else {
204-
a.href = downloadUrl;
205-
a.download = filename;
206-
document.body.appendChild(a);
207-
a.click();
208-
}
191+
if (filename) {
192+
// use HTML5 a[download] attribute to specify filename
193+
const a = document.createElement("a");
194+
// safari doesn't support this yet
195+
if (typeof a.download === 'undefined') {
196+
window.location = downloadUrl;
209197
}
210198
else {
211-
window.location = downloadUrl;
199+
a.href = downloadUrl;
200+
a.download = filename;
201+
document.body.appendChild(a);
202+
a.click();
212203
}
213-
214-
setTimeout(function() { URL.revokeObjectURL(downloadUrl); }, 100); // cleanup
215204
}
205+
else {
206+
window.location = downloadUrl;
207+
}
208+
209+
setTimeout(function() { URL.revokeObjectURL(downloadUrl); }, 100); // cleanup
216210
}
217211
};
218212

@@ -236,8 +230,8 @@
236230
keys = key.split(']['),
237231
keys_last = keys.length - 1;
238232

239-
if (/\[/.test(keys[0]) && /\]$/.test(keys[keys_last])) {
240-
keys[keys_last] = keys[keys_last].replace(/\]$/, '');
233+
if (/\[/.test(keys[0]) && /]$/.test(keys[keys_last])) {
234+
keys[keys_last] = keys[keys_last].replace(/]$/, '');
241235
keys = keys.shift().split('[').concat(keys);
242236
keys_last = keys.length - 1;
243237
} else {

0 commit comments

Comments
 (0)