Design Patterns : Singleton Pattern
This file contains 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
/** | |
* @fileoverview The base initialization method | |
* @author hwclass | |
*/ | |
/** | |
* base.js | |
* This file is used to make some creating initialization routines | |
*/ | |
'use strict'; | |
//----------------------------------------------------------- | |
// Public | |
//----------------------------------------------------------- | |
/** @type {Object} */ | |
var Config = require(‘models/Config’); | |
/** @type {Object} */ | |
var configInstance = new Config(); | |
/** @type {Object} */ | |
var config = configInstance.getConfig(); | |
/** @type {null} */ | |
configInstance = null; | |
$(‘.error).html(config.messages.errors.default); |
This file contains 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
/** | |
* @fileoverview The base object to get configuration | |
* @author hwclass | |
*/ | |
/** | |
* models/Config.js | |
* This object is used to fetch needed configuration parameters | |
*/ | |
'use strict'; | |
//----------------------------------------------------------- | |
// Public | |
//----------------------------------------------------------- | |
/** | |
* Config object | |
* @noparam | |
*/ | |
module.exports = (function () { | |
return function () { | |
var config = { | |
urls : { | |
tabs : { | |
address : '/#address', | |
payment : '/#payment' | |
} | |
}, | |
messages : { | |
errors : { | |
no_address_selected : 'Please, select an address to go next', | |
no_cards_used : 'You need to choose a credit card to pay', | |
default : 'An error occured. Please try again later' | |
} | |
} | |
/** | |
* getConfig method | |
* @noparam | |
*/ | |
var getConfig = function () { | |
return config; | |
} | |
return { | |
getConfig : getConfig | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment