X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=6b1e0f6fcc4b2a30956d916d2afab510264efd73;hb=7ef365454c1ca797f41f77d80187f6014b64b4ac;hp=de050e02ef5711ea9ab5abc723a9498af31827c3;hpb=4e3ce33fda02425e9bb6218da13c25eac2555112;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index de050e0..6b1e0f6 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -96,16 +96,6 @@ mkws.log = function(string) { }; -mkws.objectWithParent = function(parent) { - function thing() {} // Must be function so `prototype' works - - thing.prototype = parent; - var res = new thing(); - thing.prototype = null; - return res; -}; - - // This function is taken from a StackOverflow answer // http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144 mkws.getParameterByName = function(name) { @@ -154,13 +144,25 @@ mkws.setMkwsConfig = function(overrides) { dummy: "dummy" }; - mkws.config = Object.create(config_default); + mkws.config = mkws.objectInheritingFrom(config_default); for (var k in overrides) { mkws.config[k] = overrides[k]; } }; +// This code is from Douglas Crockford's article "Prototypal Inheritance in JavaScript" +// http://javascript.crockford.com/prototypal.html +// mkws.objectInheritingFrom behaves the same as Object.create, +// but since the latter is not available in IE8 we can't use it. +// +mkws.objectInheritingFrom = function(o) { + function F() {} + F.prototype = o; + return new F(); +} + + // The following functions are dispatchers for team methods that // are called from the UI using a team-name rather than implicit // context. @@ -312,21 +314,15 @@ mkws.pagerNext = function(tname) { } } - - // I don't understand why I need this copy, but I do: mkws_config - // is not visible inside the document.ready function, but the - // saved copy is. - var saved_config; - if (typeof mkws_config === 'undefined') { - log("setting empty config"); - saved_config = {}; - } else { - log("using config: " + $.toJSON(mkws_config)); - saved_config = mkws_config; - } - - $(document).ready(function() { + var saved_config; + if (typeof mkws_config === 'undefined') { + log("setting empty config"); + saved_config = {}; + } else { + log("using config: " + $.toJSON(mkws_config)); + saved_config = mkws_config; + } mkws.setMkwsConfig(saved_config); for (var key in mkws.config) {