Revert "JS: tried namespaces"

This reverts commit e84cfc58a1.
This commit is contained in:
rugk 2017-02-08 20:12:22 +01:00
parent e84cfc58a1
commit 52f1fb143e
No known key found for this signature in database
GPG Key ID: 05D40A636AFAB34D
1 changed files with 1901 additions and 1897 deletions

View File

@ -25,21 +25,11 @@
// Immediately start random number generator collector. // Immediately start random number generator collector.
sjcl.random.startCollectors(); sjcl.random.startCollectors();
// startup // jQuery(document).ready(function() {
jQuery(document).ready(function() { // // startup
/** // }
* 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
* *
@ -48,7 +38,7 @@ var PrivateBin = window.PrivateBin || {};
* @name helper * @name helper
* @class * @class
*/ */
PrivateBin.helper = (function (window, document, jQuery, sjcl, Base64, RawDeflate) { var helper = (function (window, document) {
var me = {}; var me = {};
/** /**
@ -370,7 +360,7 @@ PrivateBin.helper = (function (window, document, jQuery, sjcl, Base64, RawDeflat
}; };
return me; return me;
})(window, document, jQuery, sjcl, Base64, RawDeflate); })(window, document);
/** /**
* internationalization methods * internationalization methods
@ -380,7 +370,7 @@ PrivateBin.helper = (function (window, document, jQuery, sjcl, Base64, RawDeflat
* @name i18n * @name i18n
* @class * @class
*/ */
PrivateBin.i18n = (function (window, document, jQuery, sjcl, Base64, RawDeflate) { var i18n = (function (window, document) {
var me = {}; var me = {};
/** /**
@ -517,7 +507,7 @@ PrivateBin.i18n = (function (window, document, jQuery, sjcl, Base64, RawDeflate)
*/ */
me.loadTranslations = function() me.loadTranslations = function()
{ {
var newLanguage = PrivateBin.helper.getCookie('lang'); var newLanguage = 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)
@ -551,7 +541,7 @@ PrivateBin.i18n = (function (window, document, jQuery, sjcl, Base64, RawDeflate)
}; };
return me; return me;
})(window, document, jQuery, sjcl, Base64, RawDeflate); })(window, document);
/** /**
* filter methods * filter methods
@ -561,7 +551,7 @@ PrivateBin.i18n = (function (window, document, jQuery, sjcl, Base64, RawDeflate)
* @name filter * @name filter
* @class * @class
*/ */
PrivateBin.filter = (function (window, document, jQuery, sjcl, Base64, RawDeflate) { var filter = (function (window, document) {
var me = {}; var me = {};
/** /**
@ -575,7 +565,7 @@ PrivateBin.filter = (function (window, document, jQuery, sjcl, Base64, RawDeflat
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()
@ -588,7 +578,7 @@ PrivateBin.filter = (function (window, document, jQuery, sjcl, Base64, RawDeflat
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
@ -609,7 +599,7 @@ PrivateBin.filter = (function (window, document, jQuery, sjcl, Base64, RawDeflat
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
@ -642,10 +632,10 @@ PrivateBin.filter = (function (window, document, jQuery, sjcl, Base64, RawDeflat
} }
} }
return ''; return '';
}; }
return me; return me;
})(window, document, jQuery, sjcl, Base64, RawDeflate); })(window, document);
/** /**
* PrivateBin logic * PrivateBin logic
@ -655,7 +645,7 @@ PrivateBin.filter = (function (window, document, jQuery, sjcl, Base64, RawDeflat
* @name controller * @name controller
* @class * @class
*/ */
PrivateBin.controller = (function (window, document, jQuery, sjcl, Base64, RawDeflate) { var controller = (function (window, document) {
var me = {}; var me = {};
/** /**
@ -1872,7 +1862,7 @@ PrivateBin.controller = (function (window, document, jQuery, sjcl, Base64, RawDe
$passwordForm.submit(me.submitPasswordModal); $passwordForm.submit(me.submitPasswordModal);
$(window).on('popstate', me.historyChange); $(window).on('popstate', me.historyChange);
} };
/** /**
* main application * main application
@ -1965,4 +1955,18 @@ PrivateBin.controller = (function (window, document, jQuery, sjcl, Base64, RawDe
}; };
return me; return me;
})(window, document, jQuery, sjcl, Base64, RawDeflate); })(window, document);
/**
* 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);