Last active
May 31, 2016 02:38
-
-
Save dominikwilkowski/374531aa638945c98de9 to your computer and use it in GitHub Desktop.
Javascript modulated setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************************************************************************************************************************** | |
* | |
* App framework and settings | |
* | |
* [Description of application] | |
* | |
* @license [url] [description] | |
* @author [author & @email] | |
* @repository [url] | |
* | |
**************************************************************************************************************************************************************/ | |
'use strict'; | |
var App = (function() { | |
//------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
// Settings | |
//------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
return { | |
DEBUG: true, //Enable/disable debugger | |
SETTING1: 'string', //Setting description | |
SETTING2: false, //Setting description | |
SETTING3: 1, //Setting description | |
SETTING4: {}, //Setting description | |
SETTING5: [], //Setting description | |
SETTING6: function() { //Setting description | |
return 'string'; | |
}, | |
//---------------------------------------------------------------------------------------------------------------------------------------------------------- | |
// Initiate app | |
//---------------------------------------------------------------------------------------------------------------------------------------------------------- | |
init: function() { | |
console.log('%cDEBUGGING INFORMATION', 'font-size: 25px;'); | |
App.module1.init(); | |
App.module2.init(); | |
}, | |
//---------------------------------------------------------------------------------------------------------------------------------------------------------- | |
// Debugging prettiness | |
// | |
// @param text [string] Text to be printed to console | |
// @param code [string] The type of message as a string: ['headline', 'report', 'error', 'interaction', 'send', 'receive'] | |
// | |
// @return [output] console.log output | |
//---------------------------------------------------------------------------------------------------------------------------------------------------------- | |
debugging: function( text, code ) { | |
if( Blender.DEBUG ) { | |
if( code === 'headline' ) { | |
let fonts = new CFonts({ | |
'text': text, | |
'colors': ['white', 'gray'], | |
'maxLength': 12, | |
}); | |
} | |
if( code === 'report' ) { | |
console.log(Chalk.bgWhite("\n" + Chalk.bold.green(' \u2611 ') + Chalk.black(text + ' '))); | |
} | |
else if( code === 'error' ) { | |
console.log(Chalk.bgWhite("\n" + Chalk.red(' \u2612 ') + Chalk.black(text + ' '))); | |
} | |
else if( code === 'interaction' ) { | |
console.log(Chalk.bgWhite("\n" + Chalk.blue(' \u261C ') + Chalk.black(text + ' '))); | |
} | |
else if( code === 'send' ) { | |
console.log(Chalk.bgWhite("\n" + Chalk.bold.cyan(' \u219D ') + Chalk.black(text + ' '))); | |
} | |
else if( code === 'receive' ) { | |
console.log(Chalk.bgWhite("\n" + Chalk.bold.cyan(' \u219C ') + Chalk.black(text + ' '))); | |
} | |
} | |
} | |
} | |
}()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************************************************************************************************************************** | |
* | |
* Module 1 | |
* | |
* Description of module | |
* | |
**************************************************************************************************************************************************************/ | |
(function(App) { | |
var module = {}; | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
// Private function | |
// [Description of method] | |
// | |
// @param [input1] {string} Description of input1 | |
// @param [input2] {string} Description of input2 | |
// | |
// @return {string} [text] | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
function dostuff( input1, input2 ) { | |
App.debugging( 'Running dostuff with ' + input1, 'report' ); | |
var variable = input1.toUpperCase(); | |
//some code | |
return variable; | |
} | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
// Public function | |
// [Description of method] | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
module.init = function() { | |
App.debugging( 'Initiate module1', 'report' ); | |
var output = dostuff( 'test', ['one', 'two'] ); //run private function | |
}; | |
App.module1 = module; | |
}(App)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************************************************************************************************************************** | |
* | |
* Module 2 | |
* | |
* Description of module | |
* | |
**************************************************************************************************************************************************************/ | |
(function(App) { | |
var module = {}; | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
// Public function | |
// [Description of method] | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
module.init = function() { | |
App.debugging( 'Initiate module2', 'report' ); | |
App.module2.get( true ); //fire off get method | |
}; | |
//------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
// module method | |
// | |
// open boolen Open something after get or not? | |
//------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
// Public function | |
// [Description of method] | |
// | |
// @param [input] {boolean} The sting you want to convert | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
module.get = function( open ) { | |
App.debugging( ( open ? 'Opening ' : 'Closing ' ) + 'get method', 'report' ); | |
var variable = ''; | |
if( open ) { | |
//open something | |
} | |
//some code | |
}; | |
App.module2 = module; | |
}(App)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************************************************************************************************************************** | |
* | |
* Initiate app | |
* | |
**************************************************************************************************************************************************************/ | |
App.init(); //start the app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment