Permalink
Browse files

package functionality shoehorned in

  • Loading branch information...
1 parent 2397027 commit 3b214693dce34560c7424de371611e6187be4f6e @dtudury committed Jun 30, 2011
Showing with 167 additions and 145 deletions.
  1. +10 −11 cryptopotamus.controller.js
  2. +6 −5 cryptopotamus.js
  3. +9 −12 cryptopotamus.model.js
  4. +25 −27 cryptopotamus.view.js
  5. +117 −90 utils.js
@@ -1,17 +1,16 @@
-if( !cryptopotamus) var cryptopotamus = { model:{}, view:{}, controller:{}};
+PACKAGE_CLASS( "cryptopotamus.controller").define_static( function( _) {
+
+ var model = IMPORT( "cryptopotamus.model");
-(function() {
- var m = cryptopotamus.model;
- var v = cryptopotamus.view;
- var c = this;
-
- c.update_salt = function( in_event) {
+ _.update_salt = function( in_event) {
var _event = window.event || in_event;
if (!_event.target) _event.target = _event.srcElement;
- m.set_salt( _event.target.value);
+ model.set_salt( _event.target.value);
};
- c.generate_all = function( in_event) {
- window.alert( "generate based on " + m.get_salt());
+
+ _.generate_all = function( in_event) {
+ window.alert( "generate based on " + model.get_salt());
};
-}).call( cryptopotamus.controller);
+
+});
View
@@ -2,18 +2,19 @@
if( !cryptopotamus) var cryptopotamus = { model:{}, view:{}, controller:{}};
(function() {
- var m = cryptopotamus.model;
- var v = cryptopotamus.view;
- var c = cryptopotamus.controller;
+
+ var view = IMPORT( "cryptopotamus.view");
this.handle_onload = function() {
var content = document.getElementById( "content");
- content.appendChild( v.new_top_nav());
+ content.appendChild( view.new_top_nav());
//content.appendChild( v.new_text_input());
- content.appendChild( v.new_text_input( "name here"));
+ content.appendChild( view.new_text_input( "name here"));
+ /*
var announce_new_salt = function() {
//window.alert( "new salt: " + m.get_salt());
};
m.publisher.subscribe( {}, announce_new_salt, m.NEW_SALT);
+ */
};
}).call( cryptopotamus);
View
@@ -1,21 +1,18 @@
-if( !cryptopotamus) var cryptopotamus = { model:{}, view:{}, controller:{}};
+PACKAGE_CLASS( "cryptopotamus.model").define_static( function( _) {
+
+ var PubSub = IMPORT( "utils.PubSub");
-(function() {
- var m = this;
- var v = cryptopotamus.view;
- var c = cryptopotamus.controller;
+ _.publisher = new PubSub();
- m.publisher = new utils.PubSub();
-
- m.NEW_SALT = "newsalt";
+ _.NEW_SALT = "newsalt";
var _salt;
- m.set_salt = function( salt) {
+ _.set_salt = function( salt) {
if( _salt == salt) return;
_salt = salt;
- m.publisher.sendMessage( m.NEW_SALT);
+ _.publisher.sendMessage( _.NEW_SALT);
};
- m.get_salt = function() { return _salt;};
+ _.get_salt = function() { return _salt;};
var _configs = [];
-}).call( cryptopotamus.model);
+});
View
@@ -1,38 +1,36 @@
-if( !cryptopotamus) var cryptopotamus = { model:{}, view:{}, controller:{}};
+PACKAGE_CLASS( "cryptopotamus.view").define_static( function( _) {
+
+ var controller = IMPORT( "cryptopotamus.controller");
+ var configure = IMPORT( "utils.configure");
-(function() {
- var m = cryptopotamus.model;
- var v = this;
- var c = cryptopotamus.controller;
-
- v.new_top_nav = function() {
- var div = v.new_div();
- div.appendChild( v.new_text( "salt: "));
- div.appendChild( v.new_password_input( c.update_salt));
- div.appendChild( v.new_button_input( c.generate_all, "generate all"));
+ _.new_top_nav = function() {
+ var div = _.new_div();
+ div.appendChild( _.new_text( "salt: "));
+ div.appendChild( _.new_password_input( controller.update_salt));
+ div.appendChild( _.new_button_input( controller.generate_all, "generate all"));
return div;
};
- v.new_text_input = function( value, size) {
+ _.new_text_input = function( value, size) {
var input = document.createElement( "input");
var _defaults = { value: "text here", size: 20};
var _no_prompt = { onfocus: null, onblur: null};
var _prompt = { value: value, style: {color:"grey"}};
var _clean_prompt = { value: "", style: {color:"black"}};
var configuration = { type: "text",
- onfocus : function() { utils.configure( input, _clean_prompt);},
+ onfocus : function() { configure( input, _clean_prompt);},
onblur : function() {
- if( input.value === "") utils.configure( input, _prompt);
- else utils.configure( input, _no_prompt);
+ if( input.value === "") configure( input, _prompt);
+ else configure( input, _no_prompt);
}
};
- utils.configure( configuration, _prompt);
- return utils.configure( input, configuration, _defaults);
+ configure( configuration, _prompt);
+ return configure( input, configuration, _defaults);
};
- v.new_button_input = function( onclick, value) {
+ _.new_button_input = function( onclick, value) {
var input = document.createElement( "input");
var configuration = { type: "button", value: value, onclick: onclick};
- return utils.configure( input, configuration);
+ return configure( input, configuration);
};
var _new_password_input_prompt = function() {
var input = document.createElement( "input");
@@ -44,7 +42,7 @@ if( !cryptopotamus) var cryptopotamus = { model:{}, view:{}, controller:{}};
setTimeout( function() { new_input.focus();}, 0);
}
};
- return utils.configure( input, configuration);
+ return configure( input, configuration);
};
var _new_password_input_used = function() {
var input = document.createElement( "input");
@@ -54,20 +52,20 @@ if( !cryptopotamus) var cryptopotamus = { model:{}, view:{}, controller:{}};
var new_input = _new_password_input_prompt();
input.parentNode.replaceChild( new_input, input);
} else {
- utils.configure( input, { onfocus: null, onblur: null});
+ configure( input, { onfocus: null, onblur: null});
}
},
- onkeyup: c.update_salt
+ onkeyup: controller.update_salt
};
- return utils.configure( input, configuration);
+ return configure( input, configuration);
};
- v.new_password_input = function( onchange, size) {
+ _.new_password_input = function( onchange, size) {
return _new_password_input_prompt();
};
- v.new_div = function() {
+ _.new_div = function() {
return document.createElement( "div");
};
- v.new_text = function( text) {
+ _.new_text = function( text) {
return document.createTextNode( text);
};
-}).call( cryptopotamus.view);
+});
Oops, something went wrong.

0 comments on commit 3b21469

Please sign in to comment.