Skip to content

Instantly share code, notes, and snippets.

View k33g's full-sized avatar
💭
Read my code at https://gitlab.com/k33g

Philippe Charrière k33g

💭
Read my code at https://gitlab.com/k33g
View GitHub Profile
@k33g
k33g / gist:709982
Created November 22, 2010 13:38
oo javascript again
$class({
//Class definition
$def:function Animal(){
this.name = "";
this.getName=function(){return this.name;}
this.setName=function(value){this.name=value;}
this.Animal=function(p_name){
this.name = p_name;
@k33g
k33g / gist:709987
Created November 22, 2010 13:41
js for oo javascript again
(function (){
/*mummy*/
var mum = {
types:new Array(),
interface:function(interface_def){
var interface_name = (new interface_def).constructor.name;
mum.types[interface_name]= new interface_def;
},
/*class def*/
class:function(p_class){
@k33g
k33g / gist:710104
Created November 22, 2010 15:20
inheritance of private members in javascript without prototype
function animal(p){
var note = "a note from animal";
var name = p
this.getNote=function(){return note}
this.setNote=function(value){note = value}
this.getName=function(){return name;}
this.setName=function(value){name=value;}
@k33g
k33g / gist:710319
Created November 22, 2010 17:41
inheritance of private members in javascript "the return"
Object.prototype.extends = function(p_class){
var instance = new p_class
instance.constructor = this.constructor;
instance.getTypeName = function(){return instance.constructor.name;}
instance.parent = new p_class;
return instance;
}
//Object.prototype.getSelf = function(){return self;}
@k33g
k33g / gist:711237
Created November 23, 2010 04:18
Pattern ;-) private members inheritance or prototype is evil
(function (){
/*mummy*/
var mum = {
extends:function(child){
var thatChild = child;
return new function(){
this.with = function(parent){
var instance = new parent;
@k33g
k33g / gist:711246
Created November 23, 2010 04:25
Function() F capital
var pouet = new Function("param1","param2","alert(param1+' '+param2)");
pouet("Hello","World!")
@k33g
k33g / gist:711316
Created November 23, 2010 05:31
Pattern 2 ;-) private members inheritance or prototype is evil
(function (){
/*mummy*/
var mum = {
select:function(child){
var thatChild = child;
return {
extends : function(parent){
var instance = new parent;
@k33g
k33g / gist:713280
Created November 24, 2010 07:41
Private members inheritance + interfaces + properties
/*--- interfaces definition ---*/
function IBase(){
this.Id = "";
}
function IHuman(){
this.getName=function(){}
this.setName=function(){}
this.talking=function(){}
this.walking=function(){}
@k33g
k33g / gist:713285
Created November 24, 2010 07:45
mummy.js / Library for https://gist.github.com/713280
(function (){
/*mummy*/
var mum = {
select:function(child){
var thatChild = child;
return {
extends : function(parent){
var instance = new parent;
instance.constructor = thatChild.constructor;
@k33g
k33g / gist:718801
Created November 28, 2010 10:36
two columns iPad layout template for JoApp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<meta name="format-detection" content="false">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>joApp</title>
<link rel="stylesheet" href="css/jo.css" type="text/css">
<link rel="apple-touch-icon" href="apple-touch-icon.png">