Permalink
Browse files

random_order

  • Loading branch information...
1 parent 2f14127 commit 67606301b83f1c96754866468e8f6011c6db968f @dtudury committed Jul 1, 2011
View
@@ -7,12 +7,16 @@
<script language="javascript" src="js/utils/Closure.js"></script>
<script language="javascript" src="js/utils/PubSub.js"></script>
<script language="javascript" src="js/utils/configure.js"></script>
+ <script language="javascript" src="js/utils/deepPrint.js"></script>
<script language="javascript" src="js/cryptopotamus/Model.js"></script>
<script language="javascript" src="js/cryptopotamus/View.js"></script>
+ <script language="javascript" src="js/cryptopotamus/view/Div.js"></script>
+ <script language="javascript" src="js/cryptopotamus/view/FancyDiv.js"></script>
+ <script language="javascript" src="js/cryptopotamus/view/FancierDiv.js"></script>
<script language="javascript" src="js/cryptopotamus/Controller.js"></script>
<script language="javascript" src="js/cryptopotamus/handle_onload.js"></script>
</head>
- <body onload="IMPORT( 'cryptopotamus.handle_onload')()">
+ <body onload="IMPORT_FUNCTION( 'cryptopotamus.handle_onload')()">
<div id="content"></div>
</body>
</html>
View
@@ -16,23 +16,36 @@
global.PACKAGE_FUNCTION = function( qualified_name, in_function) {
_packaged_functions[ qualified_name] = in_function;
};
+
+ global.IMPORT_FUNCTION = function( qualified_name) {
+ if( !_name_space[ qualified_name]) {
+ var _class = function() {
+ return _packaged_functions[ qualified_name].apply( this, [].slice.call( arguments));
+ };
+ _name_space[ qualified_name] = _class;
+ }
+ return _name_space[ qualified_name];
+ };
+
/*****************************************************************************
*
*****************************************************************************/
global.IMPORT = function( qualified_name) {
if( !_name_space[ qualified_name]) {
var _class = function() {
- if( this.super_class) {
- var constructor = this.constructor;
- if( this.constructor == arguments.callee) constructor = this.super_class.constructor;
- if( constructor) constructor.apply( this, [].slice.call( arguments));
- } else if( _packaged_functions[ qualified_name]) {
- return _packaged_functions[ qualified_name].apply( this, [].slice.call( arguments));
+ if( !_class.prototype.super_class) {
+ var temp_prototype = new _class.super_class();
+ for( var name in temp_prototype) _class.prototype[ name] = temp_prototype[ name];
+ _class.prototype.constructor = _class;
+ _class.prototype.super_class = _class.super_class.prototype;
+ if( _class.instance_definition) _class.instance_definition( _class.prototype);
}
+ if( _class.prototype.constructor == _class) _class.prototype.constructor = _class.super_class.prototype.constructor;
+ if( _class.prototype.constructor) _class.prototype.constructor.apply( _class.prototype, [].slice.call( arguments));
};
- _class.define_instance = function( in_definition) { in_definition( this.prototype); return _class;};
- _class.define_static = function( in_definition) { in_definition( this); return _class;};
+ _class.define_instance = function( in_definition) { _class.instance_definition = in_definition; return _class;};
+ _class.define_static = function( in_definition) { if( in_definition) in_definition( _class); return _class;};
_name_space[ qualified_name] = _class;
}
return _name_space[ qualified_name];
@@ -41,15 +54,14 @@
/*****************************************************************************
*
*****************************************************************************/
- global.PACKAGE_CLASS = function( qualified_name, super_class, instance_definition, static_definition) {
- if( !super_class) super_class = Object;
+ global.PACKAGE = function( qualified_name, super_class, instance_definition, static_definition) {
+ if( !super_class) super_class = function() {};
var _class = IMPORT( qualified_name);
- _class.prototype = new super_class();
- _class.prototype.super_class = super_class.prototype;
- _class.prototype.constructor = _class;
- if( instance_definition) _class.define_instance( instance_definition);
- if( static_definition) _class.define_static( static_definition);
+ _class.qualified_name = qualified_name;
+ _class.super_class = super_class;
+ _class.define_instance( instance_definition);
+ _class.define_static( static_definition);
_name_space[ qualified_name] = _class;
return _class;
};
@@ -1,5 +1,5 @@
-PACKAGE_CLASS( "cryptopotamus.Controller").define_static( function( _) {
+PACKAGE( "cryptopotamus.Controller").define_static( function( _) {
var model = IMPORT( "cryptopotamus.Model");
@@ -1,5 +1,5 @@
-PACKAGE_CLASS( "cryptopotamus.Model").define_static( function( _) {
+PACKAGE( "cryptopotamus.Model").define_static( function( _) {
var PubSub = IMPORT( "utils.PubSub");
View
@@ -1,8 +1,8 @@
-PACKAGE_CLASS( "cryptopotamus.View").define_static( function( _) {
+PACKAGE( "cryptopotamus.View").define_static( function( _) {
var controller = IMPORT( "cryptopotamus.Controller");
- var configure = IMPORT( "utils.configure");
+ var configure = IMPORT_FUNCTION( "utils.configure");
_.new_top_nav = function() {
var div = _.new_div();
@@ -3,13 +3,30 @@
*****************************************************************************/
PACKAGE_FUNCTION( "cryptopotamus.handle_onload", function() {
-
+
var view = IMPORT( "cryptopotamus.View");
+ var Div = IMPORT( "cryptopotamus.view.Div");
+ var FancyDiv = IMPORT( "cryptopotamus.view.FancyDiv");
+ var FancierDiv = IMPORT( "cryptopotamus.view.FancierDiv");
+
+ var div;
+ /*
+ div = new Div( content);
+ console.log( "\n\n\n");
+ div = new FancyDiv( content);
+ console.log( "\n\n\n");
+ */
+ div = new FancierDiv( content);
+ console.log( "\n\n\n");
+ div = new FancierDiv( content);
+ console.log( "\n\n\n");
var content = document.getElementById( "content");
content.appendChild( view.new_top_nav());
- //content.appendChild( v.new_text_input());
content.appendChild( view.new_text_input( "name here"));
+
+
+
/*
var announce_new_salt = function() {
//window.alert( "new salt: " + m.get_salt());
@@ -0,0 +1,35 @@
+PACKAGE( "cryptopotamus.view.Div").define_instance( function( _) {
+
+ var deepPrint = IMPORT_FUNCTION( "utils.deepPrint");
+ var configure = IMPORT_FUNCTION( "utils.configure");
+
+ _.parent = null;
+ _.node = null;
+
+ _.constructor = function( in_parent) {
+ _.parent = in_parent;
+ _.node = _.get_node();
+// console.log( "config: Div");
+ console.log( "config: " + deepPrint( this.get_configuration()));
+ };
+
+ console.log( "setting foo to bar");
+
+ _.foo = "bar";
+
+ _.get_node = function() {
+ return document.createElement( "div");
+ };
+
+ _.get_configuration = function() {
+ return { a: "1", b: "2"};
+ };
+
+ _.extend_configuration = function( in_config) {
+ var config = {};
+ configure( config, this.super_class.get_configuration());
+ configure( config, in_config);
+ return config;
+ };
+
+});
@@ -0,0 +1,6 @@
+PACKAGE( "cryptopotamus.view.FancierDiv", IMPORT( "cryptopotamus.view.FancyDiv")).define_instance( function( _) {
+
+ _.get_configuration = function() {
+ return this.extend_configuration( { c: "14", d: "15"});
+ };
+});
@@ -0,0 +1,6 @@
+PACKAGE( "cryptopotamus.view.FancyDiv", IMPORT( "cryptopotamus.view.Div")).define_instance( function( _) {
+
+ _.get_configuration = function() {
+ return this.extend_configuration( { b: "7", c: "8"});
+ };
+});
View
@@ -3,7 +3,7 @@
*
*****************************************************************************/
-PACKAGE_CLASS( "utils.Closure").define_static( function( _) {
+PACKAGE( "utils.Closure").define_instance( function( _) {
_.constructor = function( target, executable) {
var args = [].slice.call( arguments, 2);
this.target = target;
View
@@ -3,7 +3,7 @@
*
*****************************************************************************/
-PACKAGE_CLASS( "utils.PubSub").define_instance( function( _) {
+PACKAGE( "utils.PubSub").define_instance( function( _) {
var Closure = IMPORT( "utils.Closure");
View
@@ -5,7 +5,7 @@
PACKAGE_FUNCTION( "utils.configure", function( target, source, defaults) {
- var configure = IMPORT( "utils.configure");
+ var configure = IMPORT_FUNCTION( "utils.configure");
//helper function for configure
function _copy_value( target, source, attribute) {
View
@@ -5,7 +5,7 @@
PACKAGE_FUNCTION( "utils.deepPrint", function( target, indent) {
- var deepPrint = IMPORT( "utils.deepPrint");
+ var deepPrint = IMPORT_FUNCTION( "utils.deepPrint");
indent = indent ? indent : "";
var new_indent = indent;

0 comments on commit 6760630

Please sign in to comment.