Skip to content

Instantly share code, notes, and snippets.

@tuvokki
Created October 21, 2013 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuvokki/7080299 to your computer and use it in GitHub Desktop.
Save tuvokki/7080299 to your computer and use it in GitHub Desktop.
Script by Stijn
(function() {
var test, something;
function privateFunc() {
};
var myObject = {
myMethod: function() {privateFunc.apply(this, []);}
};
window.myObject = myObject;
window.Planon = window.Planon || {};
Planon.myFunction = function myFunction() {alert("my function!");};
// Expose
/// -------------------------------------------------
window.Planon = window.Planon || {};
var test = function() {return "Hello!"};
Planon.PnFrame = {
test: "MyField",
testSomething: function testSomething() {
return test();
}
};
Planon.PnFrame.testSomething = function testSomething() {
alert(this.test);
}
})();
// alert(Planon.PnFrame.testSomething());
function myConstructor(text) {
this.test += text;
}
myConstructor.prototype.test = "Wow!";
var myObj = new myConstructor("Great!");
// alert(myObj.test);
function Base ( ) {
// ...
this.color = "blue";
// ...
}
function Sub ( ) {
this.color = "red";
alert("Other? " + this.other); // ??
}
Sub.prototype = new Base( );
var sub0 = new Sub();
sub0.other;
Base.prototype.other = "Bye!";
Sub.prototype.showColor = function ( ) {
alert("Sub color:" + this.color); //red or blue???
}
alert("Sub proto color:" + Sub.prototype.color);
var sub = new Sub();
sub.showColor();
// console.log("Sub color: ", Sub.showColor());
var myBrowser = "IE";
function doSpiffyThings() {
alert("Spiffy stuff!");
}
if (myBrowser != "Chrome") {
doSpiffyThings = function doSpiffyThings() {
alert("Can only do spiffy stuff in Chrome");
}
}
doSpiffyThings();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment