projects
/
project
/
luci2
/
ui.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cc66f61
)
luci2: Switch LuCI2.ui.renderView() from new Function() to eval() and use "//@ source...
author
Jo-Philipp Wich
<jow@openwrt.org>
Mon, 30 Sep 2013 12:28:02 +0000
(12:28 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Mon, 30 Sep 2013 12:29:26 +0000
(12:29 +0000)
luci2/htdocs/luci2/luci2.js
patch
|
blob
|
history
diff --git
a/luci2/htdocs/luci2/luci2.js
b/luci2/htdocs/luci2/luci2.js
index
e401c7c
..
0d253ce
100644
(file)
--- a/
luci2/htdocs/luci2/luci2.js
+++ b/
luci2/htdocs/luci2/luci2.js
@@
-1979,13
+1979,22
@@
function LuCI2()
if (_luci2._views[name] instanceof _luci2.ui.view)
return _luci2._views[name].render();
if (_luci2._views[name] instanceof _luci2.ui.view)
return _luci2._views[name].render();
- return $.ajax(_luci2.globals.resource + '/view/' + name + '.js', {
+ var url = _luci2.globals.resource + '/view/' + name + '.js';
+
+ return $.ajax(url, {
method: 'GET',
cache: true,
dataType: 'text'
}).then(function(data) {
try {
method: 'GET',
cache: true,
dataType: 'text'
}).then(function(data) {
try {
- var viewConstructor = (new Function(['L', '$'], 'return ' + data))(_luci2, $);
+ var viewConstructorSource = (
+ '(function(L, $) {\n' +
+ 'return %s' +
+ '})(_luci2, $);\n\n' +
+ '//@ sourceURL=%s'
+ ).format(data, url);
+
+ var viewConstructor = eval(viewConstructorSource);
_luci2._views[name] = new viewConstructor({
name: name,
_luci2._views[name] = new viewConstructor({
name: name,
@@
-1994,7
+2003,9
@@
function LuCI2()
return _luci2._views[name].render();
}
return _luci2._views[name].render();
}
- catch(e) { };
+ catch(e) {
+ alert('Unable to instantiate view "%s": %s'.format(url, e));
+ };
return $.Deferred().resolve();
});
return $.Deferred().resolve();
});