Get new outreach engine working.

This commit is contained in:
Kevin Dungs
2014-08-11 21:45:17 +02:00
parent c452bc52cf
commit 88ddebc980
6 changed files with 62 additions and 25 deletions
+5 -6
View File
@@ -1,11 +1,10 @@
<p class="lead">You discovered CP violation!</p>
<h5><b>CP Symmetry</b></h5>
<p>C (Charge) and P (Parity, which can be thought of as “handedness”) are discrete transformations that can be applied to a physical system.</p>
<p>If a theory is symmetric under C, then it works the same if all particles are exchanged with their antiparticles.
If it has P-symmetry, then it is invariant under inversion (mirroring) of all spatial coordinates.</p>
<p>For a long time, physicists believed that all of physics is invariant under the combination CP of both symmetries.
<h4>CP Symmetry</h4>
<p data-min-level="1">C (Charge) and P (Parity) are discrete transformations that can be applied to a physical system.</p>
<p data-min-level="1">If a theory is symmetric under C, then it works the same if all particles are exchanged with their antiparticles.
If it has P-symmetry, then it is invariant under inversion ("mirroring") of all spatial coordinates</p>
<p data-min-level="5">For a long time, physicists believed that all of physics is invariant under the combination CP of both symmetries.
It turned out that this is wrong, as was discovered by Cronin, Fitch et al. in 1964 when they studied the decay of the neutral K meson.</p>
<div class="container">
+1 -1
View File
@@ -95,7 +95,7 @@
<p ng-show="r.level > 0" class="small">Research yields <strong>{{ r.reputation | niceNumber }}</strong> reputation.</p>
<div class="btn-group">
<button class="btn btn-primary" ng-disabled="!r.is_available()" ng-click="rc.doResearch(r)">Research <small>({{ r.cost | niceNumber }} data)</small></button>
<button class="btn btn-info" ng-show="r.level > 0" ng-click="r.showInfo()"><span class="glyphicon glyphicon-exclamation-sign"></span></button>
<button class="btn btn-info {{ r.interesting ? 'blink' : '' }}" ng-show="r.level > 0" ng-click="rc.showInfo(r)"><i class="fa fa-exclamation"></i></button>
</div>
</div>
</li>
+17 -4
View File
@@ -62,7 +62,7 @@
}, 1000);
}]);
app.controller('ResearchController', function() {
app.controller('ResearchController', ['$compile', function($compile) {
this.research = research;
this.doResearch = function(item) {
var cost = item.research();
@@ -72,9 +72,19 @@
achievements.update('research', item.name, 1);
UI.showUpdateValue("#update-data", -cost);
UI.showUpdateValue("#update-reputation", item.reputation);
analytics.sendEvent(
analytics.events.categoryResearch,
analytics.events.actionResearch,
item.name,
item.level
);
}
};
});
this.showInfo = function(r) {
UI.showModal(r.name, r.getInfo());
UI.showLevels(r.level);
};
}]);
app.controller('HRController', function() {
this.workers = workers;
@@ -107,7 +117,8 @@
this.achievementsAll = achievements.list;
});
app.controller('SaveController', ['$scope', '$interval', function($scope, $interval) {
app.controller('SaveController',
['$scope', '$interval', function($scope, $interval) {
$scope.lastSaved = new Date();
$scope.saveNow = function() {
GameObjects.saveAll();
@@ -115,7 +126,9 @@
achievements.lastSave = $scope.lastSaved.getTime();
};
$scope.restart = function() {
if (window.confirm('Do you really want to restart the game? All progress will be lost.')) {
if (window.confirm(
'Do you really want to restart the game? All progress will be lost.'
)) {
ObjectStorage.clear();
window.location.reload(true);
}
+6 -4
View File
@@ -61,6 +61,7 @@ var GameObjects = (function() {
*/
var researchPrototype = {
level: 0,
interesting: false,
is_visible: function() {
return this.level > 0 || lab.data >= this.cost * .7;
},
@@ -70,7 +71,10 @@ var GameObjects = (function() {
research: function() {
if (lab.research(this.cost, this.reputation)) {
this.level++;
analytics.sendEvent(analytics.events.categoryResearch, analytics.events.actionResearch, this.name, this.level);
if (this.info_levels.length > 0 && this.level === this.info_levels[0]) {
this.interesting = true;
this.info_levels.splice(0, 1);
}
var oldCost = this.cost;
this.cost = Math.round(this.cost * this.cost_increase);
return oldCost;
@@ -81,11 +85,9 @@ var GameObjects = (function() {
if (!this._info) {
this._info = Helpers.loadFile(this.info);
}
this.interesting = false;
return this._info;
},
showInfo: function() {
UI.showModal(this.name, this.getInfo());
}
};
var research = $.extend([], Helpers.loadFile('json/research.json'),
ObjectStorage.load('research'));
+15 -1
View File
@@ -21,13 +21,26 @@ var UI = (function () {
});
/** Show a bootstrap modal with dynamic content. */
var showModal = function(title, text) {
var showModal = function(title, text, level) {
var $modal = $('#infoBox');
$modal.find('#infoBoxLabel').html(title);
$modal.find('.modal-body').html(text);
$modal.modal({show: true});
};
/** Display only the elements with data-min-level above a certain
* threshold.
*/
var showLevels = function(level) {
$('#infoBox').find('[data-min-level]').each(function() {
if (level >= $(this).data('min-level')) {
$(this).show();
} else {
$(this).hide();
}
});
};
var showUpdateValue = function(ident, num) {
if (num != 0) {
var formatted = Helpers.formatNumberPostfix(num);
@@ -92,6 +105,7 @@ var UI = (function () {
return {
showModal: showModal,
showLevels: showLevels,
showUpdateValue: showUpdateValue,
validateVersion: validateVersion
}
+18 -9
View File
@@ -6,7 +6,8 @@
"cost": 10,
"cost_increase": 1.4,
"image": "assets/icons/png/CPV.png",
"info": "html/CPV.html"
"info": "html/CPV.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "J/ψ",
@@ -15,7 +16,8 @@
"cost": 100,
"cost_increase": 1.45,
"image": "assets/icons/png/Jpsi.png",
"info": "html/Jpsi.html"
"info": "html/Jpsi.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "τ lepton",
@@ -24,7 +26,8 @@
"cost": 2000,
"cost_increase": 1.5,
"image": "assets/icons/png/tau.png",
"info": "html/tau.html"
"info": "html/tau.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "Beauty quark",
@@ -33,7 +36,8 @@
"cost": 25000,
"cost_increase": 1.55,
"image": "assets/icons/png/b.png",
"info": "html/b.html"
"info": "html/b.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "W and Z boson",
@@ -42,7 +46,8 @@
"cost": 50000,
"cost_increase": 1.6,
"image": "assets/icons/png/weak.png",
"info": "html/weak.html"
"info": "html/weak.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "Top quark",
@@ -51,7 +56,8 @@
"cost": 2000000,
"cost_increase": 2,
"image": "assets/icons/png/t.png",
"info": "html/top.html"
"info": "html/top.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "Antihydrogen",
@@ -60,7 +66,8 @@
"cost": 10000000,
"cost_increase": 2.5,
"image": "assets/icons/png/antihydrogen.png",
"info": "html/antihydrogen.html"
"info": "html/antihydrogen.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "B oscillations",
@@ -69,7 +76,8 @@
"cost": 50000000,
"cost_increase": 2.5,
"image": "assets/icons/png/BBbar.png",
"info": "html/BBbar.html"
"info": "html/BBbar.html",
"info_levels": [1, 5, 10, 25]
},
{
"name": "Higgs boson",
@@ -78,6 +86,7 @@
"cost": 72500000,
"cost_increase": 3,
"image": "assets/icons/png/H.png",
"info": "html/H.html"
"info": "html/H.html",
"info_levels": [1, 5, 10, 25]
}
]