Permalink
Browse files

Put javascript code into closures (module pattern)

  • Loading branch information...
1 parent 9c72c90 commit fbe9e779d706f04790d09994ebffae228580f012 @squiddy squiddy committed Dec 18, 2011
@@ -1,3 +1,8 @@
+var Changes = (function(window){
+
+// Localize globals
+var TIMELINE_URL = window.TIMELINE_URL, getLoadText = window.getLoadText;
+
var currentproject, changethres, trendthres, projectmatrix, revisionboxes = {};
function getConfiguration() {
@@ -126,4 +131,13 @@ function init(defaults) {
$("#permalink").click(function() {
window.location = "?" + $.param(getConfiguration());
});
+
+ refreshContent();
}
+
+return {
+ init: init,
+ config: config
+};
+
+})(window);
@@ -1,3 +1,8 @@
+var Comparison = (function(window){
+
+// Localize globals
+var readCheckbox = window.readCheckbox, getLoadText = window.getLoadText;
+
var compdata, bench_units;
function getConfiguration() {
@@ -419,3 +424,9 @@ function init(defaults) {
window.location = "?" + $.param(getConfiguration());
});
}
+
+return {
+ init: init
+};
+
+})(window);
@@ -1,3 +1,9 @@
+var Timeline = (function(window){
+
+// Localize globals
+var CHANGES_URL = window.CHANGES_URL, readCheckbox = window.readCheckbox,
+ getLoadText = window.getLoadText;
+
var seriesindex = [],
baselineColor = "#d8b83f",
seriesColors = ["#4bb2c5", "#EAA228", "#579575", "#953579", "#839557", "#ff5800", "#958c12", "#4b5de4", "#0085cc"],
@@ -323,3 +329,9 @@ function init(def) {
window.location = "?" + $.param(getConfiguration());
});
}
+
+return {
+ init: init
+};
+
+})(window);
@@ -69,8 +69,12 @@
var TIMELINE_URL = "{% url timeline %}";
$(function() {
- // Configure defaults
- init({
+ Changes.config({
+ changethres: {{ defaultchangethres }},
+ trendthres: {{ defaulttrendthres }}
+ });
+
+ Changes.init({
project: "{{ defaultexecutable.project }}",
executable: "{{ defaultexecutable.id }}",
environment: "{{ defaultenvironment.id }}",
@@ -79,13 +83,6 @@
projectmatrix: eval({{ projectmatrix|safe }}),
revisionlists: eval({{ revisionlists|safe }})
});
-
- config({
- changethres: {{ defaultchangethres }},
- trendthres: {{ defaulttrendthres }}
- });
-
- refreshContent();
});
</script>
{% endblock %}
@@ -90,7 +90,7 @@
<script type="text/javascript">
$(function() {
- init({
+ Comparison.init({
chart_type: "{{ selectedchart }}",
baseline: "{{ selectedbaseline }}",
direction: "{{ selecteddirection }}",
@@ -107,7 +107,7 @@
var CHANGES_URL = "{% url changes %}";
$(function() {
- init({
+ Timeline.init({
revisions: {{ defaultlast }},
baseline: "{{ defaultbaseline }}",
executables: [{% for exe in checkedexecutables %}{{ exe.id }}, {% endfor %}],

0 comments on commit fbe9e77

Please sign in to comment.