This is a snippet of widget code that was provided as a sample that I'm trying to understand the syntax of. JSLint.com js parser doesn't like the use of 'public' and 'private' keyword in var declarations, though the script is working fine in my widget. If I rename 'public' and 'private' then JSLint throws a different error. Seems like it's JSON syntax, and interesting that 'public' is returned at the end. Can anyone help explain? I've cut out the AJAX functionality to keep it simple.
Code:
var Widgets = Widgets ? Widgets : function() {
var private = {
host: null,
container: null,
loadhtml: function(container) {
private.container = container;
}
};
var public = {
Init: function(container) {
private.container = document.getElementById(container);
private.loadhtml(private.container);
},
callbackMethod: function(data) {
if (!data) return;
var div = private.container;
div.innerHTML = data; // assign new HTML into #ROOT
div.style.display = 'block'; // make element visible
div.style.visibility = 'visible'; // make element visible
}
}
return public;
} ();