Flatten and load configurations.
This commit is contained in:
parent
93f4b4e7d5
commit
f57ef16bb7
@ -650,7 +650,25 @@
|
||||
|
||||
Main = {
|
||||
init: function() {
|
||||
var pathname;
|
||||
var flatten, key, pathname, val;
|
||||
flatten = function(parent, obj) {
|
||||
var key, val;
|
||||
if (obj instanceof Array) {
|
||||
Conf[parent] = obj[0];
|
||||
} else if (typeof obj === 'object') {
|
||||
for (key in obj) {
|
||||
val = obj[key];
|
||||
flatten(key, val);
|
||||
}
|
||||
} else {
|
||||
Conf[parent] = obj;
|
||||
}
|
||||
};
|
||||
flatten(null, Config);
|
||||
for (key in Conf) {
|
||||
val = Conf[key];
|
||||
Conf[key] = $.get(key, val);
|
||||
}
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
if (g.REPLY = pathname[2] === 'res') {
|
||||
|
||||
@ -498,6 +498,21 @@ class Post
|
||||
|
||||
Main =
|
||||
init: ->
|
||||
# flatten Config into Conf
|
||||
# and get saved or default values
|
||||
flatten = (parent, obj) ->
|
||||
if obj instanceof Array
|
||||
Conf[parent] = obj[0]
|
||||
else if typeof obj is 'object'
|
||||
for key, val of obj
|
||||
flatten key, val
|
||||
else # string or number
|
||||
Conf[parent] = obj
|
||||
return
|
||||
flatten null, Config
|
||||
for key, val of Conf
|
||||
Conf[key] = $.get key, val
|
||||
|
||||
pathname = location.pathname.split '/'
|
||||
g.BOARD = new Board pathname[1]
|
||||
if g.REPLY = pathname[2] is 'res'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user