mkws.log now assigned from existing function rather than vice versa.
[mkws-moved-to-github.git] / src / mkws-core.js
index c308554..7f5b0f5 100644 (file)
@@ -13,7 +13,6 @@ var mkws = {
     authenticated: false,
     log_level: 1, // Will be overridden from mkws_config, but
                   // initial value allows jQuery popup to use logging.
-    paz: undefined, // will be set up during initialisation
     teams: {},
     locale_lang: {
        "de": {
@@ -85,7 +84,7 @@ if (mkws_config == null || typeof mkws_config != 'object') {
 
 // wrapper to call team() after page load
 (function (j) {
-    mkws.log = function (string) {
+    function log(string) {
        if (!mkws.log_level)
            return;
 
@@ -101,10 +100,10 @@ if (mkws_config == null || typeof mkws_config != 'object') {
        }
        console.log(string);
     }
-    var log = mkws.log;
+    mkws.log = log;
 
 
-    mkws.handleNodeWithTeam = function(node, callback) {
+    function handleNodeWithTeam(node, callback) {
        // First branch for DOM objects; second branch for jQuery objects
        var classes = node.className || node.attr('class');
        if (!classes) {
@@ -130,7 +129,7 @@ if (mkws_config == null || typeof mkws_config != 'object') {
     }
 
 
-    mkws.resizePage = function () {
+    function resizePage() {
        var list = ["mkwsSwitch", "mkwsLang"];
 
        var width = mkws_config.responsive_design_width;
@@ -316,9 +315,9 @@ if (mkws_config == null || typeof mkws_config != 'object') {
        if (mkws_config.responsive_design_width) {
            // Responsive web design - change layout on the fly based on
            // current screen width. Required for mobile devices.
-           $(window).resize(function(e) { mkws.resizePage() });
+           $(window).resize(resizePage);
            // initial check after page load
-           $(document).ready(function() { mkws.resizePage() });
+           $(document).ready(resizePage);
        }
 
        // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp"
@@ -354,7 +353,7 @@ if (mkws_config == null || typeof mkws_config != 'object') {
        // the mkwsTeam_* class. Make all team objects.
        var then = $.now();
        $('[class^="mkws"],[class*=" mkws"]').each(function () {
-           mkws.handleNodeWithTeam(this, function(tname, type) {
+           handleNodeWithTeam(this, function(tname, type) {
                if (!mkws.teams[tname]) {
                    mkws.teams[tname] = team(j, tname);
                    log("Made MKWS team '" + tname + "'");
@@ -366,7 +365,7 @@ if (mkws_config == null || typeof mkws_config != 'object') {
        // that sometimes makes new widget nodes (e.g. creating
        // mkwsTermlists inside mkwsResults.
        $('[class^="mkws"],[class*=" mkws"]').each(function () {
-           mkws.handleNodeWithTeam(this, function(tname, type) {
+           handleNodeWithTeam(this, function(tname, type) {
                var myTeam = mkws.teams[tname];
                var myWidget = widget(j, myTeam, type, this);
            });