implementing JS module pattern to expose functions for unit testing

This commit is contained in:
El RIDO 2017-01-22 10:42:11 +01:00
parent 5f09264625
commit 8029c2819f
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
3 changed files with 17 additions and 9 deletions

View File

@ -25,7 +25,7 @@
// Immediately start random number generator collector. // Immediately start random number generator collector.
sjcl.random.startCollectors(); sjcl.random.startCollectors();
$(function() { jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
/** /**
* static helper methods * static helper methods
* *
@ -1782,9 +1782,17 @@ $(function() {
} }
} }
/** return {
* main application start, called when DOM is fully loaded helper: helper,
* runs privatebin when translations were loaded i18n: i18n,
*/ filter: filter,
i18n.loadTranslations($.proxy(privatebin.init, privatebin)); privatebin: privatebin
}); };
}(jQuery, sjcl, Base64, RawDeflate);
/**
* main application start, called when DOM is fully loaded
* runs privatebin when translations were loaded
*/
jQuery(jQuery.PrivateBin.i18n.loadTranslations(jQuery.proxy(jQuery.PrivateBin.privatebin.init, jQuery.PrivateBin.privatebin)));

View File

@ -69,7 +69,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-n74tkij+nVUsfoO68TgNUptNTTGxVeeuMPD59XjP2yKnAnpWKQJ2GM5qZVGbtiOCc02F1IH49tJRgAyZGHETlA==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-BQtm9WwSHdMAGNuJYDpAICZGADZxANQ2DkJ6cXnWHlemnTq3xtdL+7cYoB/0no9Aa+PnA7JLvNTQWa+g2hIawA==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->

View File

@ -47,7 +47,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-n74tkij+nVUsfoO68TgNUptNTTGxVeeuMPD59XjP2yKnAnpWKQJ2GM5qZVGbtiOCc02F1IH49tJRgAyZGHETlA==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-BQtm9WwSHdMAGNuJYDpAICZGADZxANQ2DkJ6cXnWHlemnTq3xtdL+7cYoB/0no9Aa+PnA7JLvNTQWa+g2hIawA==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->