JS: tried namespaces
This commit is contained in:
parent
b01a28d580
commit
e84cfc58a1
|
@ -25,11 +25,21 @@
|
||||||
// Immediately start random number generator collector.
|
// Immediately start random number generator collector.
|
||||||
sjcl.random.startCollectors();
|
sjcl.random.startCollectors();
|
||||||
|
|
||||||
// jQuery(document).ready(function() {
|
// startup
|
||||||
// // startup
|
jQuery(document).ready(function() {
|
||||||
// }
|
/**
|
||||||
|
* main application start, called when DOM is fully loaded and
|
||||||
|
* runs controller initalization after translations are loaded
|
||||||
|
*/
|
||||||
|
PrivateBin.i18n.loadTranslations();
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name PrivateBin
|
||||||
|
* @namespace
|
||||||
|
*/
|
||||||
|
var PrivateBin = window.PrivateBin || {};
|
||||||
|
|
||||||
jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
||||||
/**
|
/**
|
||||||
* static helper methods
|
* static helper methods
|
||||||
*
|
*
|
||||||
|
@ -38,7 +48,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
* @name helper
|
* @name helper
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
var helper = (function (window, document) {
|
PrivateBin.helper = (function (window, document, jQuery, sjcl, Base64, RawDeflate) {
|
||||||
var me = {};
|
var me = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -360,7 +370,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
})(window, document);
|
})(window, document, jQuery, sjcl, Base64, RawDeflate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* internationalization methods
|
* internationalization methods
|
||||||
|
@ -370,7 +380,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
* @name i18n
|
* @name i18n
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
var i18n = (function (window, document) {
|
PrivateBin.i18n = (function (window, document, jQuery, sjcl, Base64, RawDeflate) {
|
||||||
var me = {};
|
var me = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -507,7 +517,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
me.loadTranslations = function()
|
me.loadTranslations = function()
|
||||||
{
|
{
|
||||||
var newLanguage = helper.getCookie('lang');
|
var newLanguage = PrivateBin.helper.getCookie('lang');
|
||||||
|
|
||||||
// auto-select language based on browser settings
|
// auto-select language based on browser settings
|
||||||
if (newLanguage.length === 0)
|
if (newLanguage.length === 0)
|
||||||
|
@ -541,7 +551,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
})(window, document);
|
})(window, document, jQuery, sjcl, Base64, RawDeflate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* filter methods
|
* filter methods
|
||||||
|
@ -551,7 +561,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
* @name filter
|
* @name filter
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
var filter = (function (window, document) {
|
PrivateBin.filter = (function (window, document, jQuery, sjcl, Base64, RawDeflate) {
|
||||||
var me = {};
|
var me = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -565,7 +575,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
me.compress = function(message)
|
me.compress = function(message)
|
||||||
{
|
{
|
||||||
return Base64.toBase64( RawDeflate.deflate( Base64.utob(message) ) );
|
return Base64.toBase64( RawDeflate.deflate( Base64.utob(message) ) );
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* decompress a message compressed with filter.compress()
|
* decompress a message compressed with filter.compress()
|
||||||
|
@ -578,7 +588,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
me.decompress = function(data)
|
me.decompress = function(data)
|
||||||
{
|
{
|
||||||
return Base64.btou( RawDeflate.inflate( Base64.fromBase64(data) ) );
|
return Base64.btou( RawDeflate.inflate( Base64.fromBase64(data) ) );
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* compress, then encrypt message with given key and password
|
* compress, then encrypt message with given key and password
|
||||||
|
@ -599,7 +609,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
return sjcl.encrypt(key, me.compress(message), options);
|
return sjcl.encrypt(key, me.compress(message), options);
|
||||||
}
|
}
|
||||||
return sjcl.encrypt(key + sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(password)), me.compress(message), options);
|
return sjcl.encrypt(key + sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(password)), me.compress(message), options);
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* decrypt message with key, then decompress
|
* decrypt message with key, then decompress
|
||||||
|
@ -632,10 +642,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
};
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
})(window, document);
|
})(window, document, jQuery, sjcl, Base64, RawDeflate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PrivateBin logic
|
* PrivateBin logic
|
||||||
|
@ -645,7 +655,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
* @name controller
|
* @name controller
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
var controller = (function (window, document) {
|
PrivateBin.controller = (function (window, document, jQuery, sjcl, Base64, RawDeflate) {
|
||||||
var me = {};
|
var me = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1862,7 +1872,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
$passwordForm.submit(me.submitPasswordModal);
|
$passwordForm.submit(me.submitPasswordModal);
|
||||||
|
|
||||||
$(window).on('popstate', me.historyChange);
|
$(window).on('popstate', me.historyChange);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* main application
|
* main application
|
||||||
|
@ -1955,18 +1965,4 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
})(window, document);
|
})(window, document, jQuery, sjcl, Base64, RawDeflate);
|
||||||
|
|
||||||
/**
|
|
||||||
* main application start, called when DOM is fully loaded and
|
|
||||||
* runs controller initalization after translations are loaded
|
|
||||||
*/
|
|
||||||
$(i18n.loadTranslations);
|
|
||||||
|
|
||||||
return {
|
|
||||||
helper: helper,
|
|
||||||
i18n: i18n,
|
|
||||||
filter: filter,
|
|
||||||
controller: controller
|
|
||||||
};
|
|
||||||
}(jQuery, sjcl, Base64, RawDeflate);
|
|
||||||
|
|
Loading…
Reference in New Issue