Merge branch 'upstream/pizzazz2' into 'master'

Re-format all of the html, javascript and CSS to make it easier to move around subsequently.

See merge request cara/cara!64
This commit is contained in:
Philip James Elson 2020-11-07 10:37:36 +00:00
commit 150b098e43
15 changed files with 13595 additions and 151 deletions

View file

@ -7,5 +7,5 @@
}
.red {
box-shadow: 0px 0px 2px 1px red;
}
box-shadow: 0px 0px 2px 1px red;
}

View file

@ -1,9 +1,9 @@
#body {
top: 10px;
left: 20px;
bottom: 20px;
right: 20px;
padding: 20px;
top: 10px;
left: 20px;
bottom: 20px;
right: 20px;
padding: 20px;
}
h1 {
@ -26,12 +26,12 @@ p.data_title {
p.data_text {
padding-left: 30px;
padding-left:1em;
padding-left: 1em;
}
p.data_subtext {
padding-left: 60px;
margin-left:-3em;
margin-left: -3em;
}
p.result_title {

View file

@ -1,18 +1,18 @@
function on_ventilation_type_change(){
ventilation_types = $('input[type=radio][name=ventilation_type]');
ventilation_types.each(function( index ) {
if (this.checked) {
getChildElement($(this)).show();
require_fields(this);
} else {
getChildElement($(this)).hide();
unrequire_fields(this);
// Clear the inputs for this newly hidden child element.
getChildElement($(this)).find('input').not('input[type=radio]').val('');
getChildElement($(this)).find('input[type=radio]').prop("checked", false);
getChildElement($(this)).find('input').prop("required", false);
}
});
function on_ventilation_type_change() {
ventilation_types = $('input[type=radio][name=ventilation_type]');
ventilation_types.each(function (index) {
if (this.checked) {
getChildElement($(this)).show();
require_fields(this);
} else {
getChildElement($(this)).hide();
unrequire_fields(this);
// Clear the inputs for this newly hidden child element.
getChildElement($(this)).find('input').not('input[type=radio]').val('');
getChildElement($(this)).find('input[type=radio]').prop("checked", false);
getChildElement($(this)).find('input').prop("required", false);
}
});
}
@ -23,8 +23,8 @@ function getChildElement(elem) {
/* -------Required fields------- */
function require_fields(obj){
switch(obj.id) {
function require_fields(obj) {
switch (obj.id) {
case "room_type_volume":
require_room_volume(true);
require_room_dimensions(false);
@ -65,10 +65,11 @@ function require_fields(obj){
break;
default:
break;
} }
}
}
function unrequire_fields(obj){
switch(obj.id) {
function unrequire_fields(obj) {
switch (obj.id) {
case "mechanical":
require_mechanical_ventilation(false);
break;
@ -77,67 +78,66 @@ function unrequire_fields(obj){
break;
default:
break;
} }
}
}
function require_room_volume(option) {
$("#room_volume").prop('required',option);
$("#room_volume").prop('required', option);
}
function require_room_dimensions(option) {
$("#floor_area").prop('required',option);
$("#ceiling_height").prop('required',option);
$("#floor_area").prop('required', option);
$("#ceiling_height").prop('required', option);
}
function require_mechanical_ventilation(option) {
$("#air_type_changes").prop('required',option);
$("#air_type_supply").prop('required',option);
}
$("#air_type_changes").prop('required', option);
$("#air_type_supply").prop('required', option);
}
function require_natural_ventilation(option) {
$("#windows_number").prop('required',option);
$("#window_height").prop('required',option);
$("#window_width").prop('required',option);
$("#opening_distance").prop('required',option);
$("#always").prop('required',option);
$("#interval").prop('required',option);
$("#event_type_single").prop('required',option);
$("#event_type_recurrent").prop('required',option);
$("#windows_number").prop('required', option);
$("#window_height").prop('required', option);
$("#window_width").prop('required', option);
$("#opening_distance").prop('required', option);
$("#always").prop('required', option);
$("#interval").prop('required', option);
$("#event_type_single").prop('required', option);
$("#event_type_recurrent").prop('required', option);
}
function require_air_changes(option) {
$("#air_changes").prop('required',option);
$("#air_changes").prop('required', option);
}
function require_air_supply(option) {
$("#air_supply").prop('required',option);
$("#air_supply").prop('required', option);
}
function require_single_event(option) {
$("#single_event_date").prop('required',option);
$("#single_event_date").prop('required', option);
}
function require_recurrent_event(option) {
$("#recurrent_event_month").prop('required',option);
$("#recurrent_event_month").prop('required', option);
}
function require_lunch(option) {
$("#lunch_start").prop('required',option);
$("#lunch_finish").prop('required',option);
$("#lunch_start").prop('required', option);
$("#lunch_finish").prop('required', option);
}
function setMaxInfectedPeople(){
function setMaxInfectedPeople() {
$("#infected_people").attr("max", $("#total_people").val());
}
/* -------UI------- */
$(function() {
$(function () {
$(".datepicker").datepicker({
dateFormat: 'mm/dd/yy'});
dateFormat: 'mm/dd/yy'
});
});
$( function() {
$(".dialog").dialog({modal:true});
});
function show_disclaimer() {
var dots = document.getElementById("dots");
@ -154,7 +154,8 @@ function show_disclaimer() {
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
$("#DIALOG_welcome").dialog("option", "height", 600);
} }
}
}
/* -------Form validation------- */
function validate_form(form) {
@ -162,14 +163,15 @@ function validate_form(form) {
var submit = true;
//Validate all dates
$("input[required].datepicker").each(function() {
$("input[required].datepicker").each(function () {
$(this).removeClass("red");
var fromDate = $(this).val();
if (!isValidDate(fromDate)) {
$(this).addClass("red");
submit = false;
} });
}
});
return submit;
}
@ -180,13 +182,13 @@ function isValidDate(date) {
var d = matches[2];
var m = matches[1];
var y = matches[3];
if (y > 2100 || y < 1900) return false;
var composedDate = new Date(y+'/'+m+'/'+d);
return composedDate.getDate() == d && composedDate.getMonth()+1 == m && composedDate.getFullYear() == y;
if (y > 2100 || y < 1900) return false;
var composedDate = new Date(y + '/' + m + '/' + d);
return composedDate.getDate() == d && composedDate.getMonth() + 1 == m && composedDate.getFullYear() == y;
}
/* -------Debugging------- */
function debug_submit(form){
function debug_submit(form) {
//Prevent default posting of form - put here to work in case of errors
event.preventDefault();
@ -194,20 +196,20 @@ function debug_submit(form){
//Serialize the data in the form
var serializedData = objectifyForm($(form).serializeArray());
console.log( serializedData );
console.log(serializedData);
return false; //don't submit
}
function objectifyForm(formArray) {
var returnArray = {};
for (var i = 0; i < formArray.length; i++)
returnArray[formArray[i]['name']] = formArray[i]['value'];
return returnArray;
var returnArray = {};
for (var i = 0; i < formArray.length; i++)
returnArray[formArray[i]['name']] = formArray[i]['value'];
return returnArray;
}
/* ------ On Load ---------- */
$( document ).ready(function() {
$(document).ready(function () {
// When the document is ready, deal with the fact that we may be here
// as a result of a forward/back browser action. If that is the case, update
// the visibility of some of our inputs.
@ -219,7 +221,7 @@ $( document ).ready(function() {
// Call the function now to handle forward/back button presses in the browser.
on_ventilation_type_change();
$("input[name=mechanical_ventilation_type]").change(function(){
$("input[name=mechanical_ventilation_type]").change(function () {
console.log('Changed!');
})
@ -229,7 +231,8 @@ $( document ).ready(function() {
$("#total_people").change(setMaxInfectedPeople);
var radioValue = $("input[name='event_type']:checked");
if(radioValue.val()){
if (radioValue.val()) {
require_fields(radioValue.get(0));
}
});
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -217,4 +217,4 @@
.cboxSlideshow_off #cboxSlideshow:hover {
background-position: -75px -25px;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,26 +1,37 @@
if (document.location.hostname == "test-cara.web.cern.ch") {
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwikui.web.cern.ch/piwikui/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
(function () {
var u = "//piwikui.web.cern.ch/piwikui/";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', '7615']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = u + 'piwik.js';
s.parentNode.insertBefore(g, s);
})();
} else if (document.location.hostname == 'cara.web.cern.ch') {
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwikui.web.cern.ch/piwikui/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
(function () {
var u = "//piwikui.web.cern.ch/piwikui/";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', '7616']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = u + 'piwik.js';
s.parentNode.insertBefore(g, s);
})();
} else {
console.log("Usage tracking disabled for hostname: " + document.location.hostname);
console.log("Usage tracking disabled for hostname: " + document.location.hostname);
}

View file

@ -11,12 +11,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome | CARA</title>
<link rel="stylesheet" media="all" href="/static/cern-theme.css">
<link rel="stylesheet" media="all" href="/static/cern-theme2.css">
<!-- <link rel="stylesheet" media="all" href="/static/prism.css"> -->
<link rel="stylesheet" media="all" href="/static/cern-theme3.css">
<link rel="stylesheet" media="all" href="/static/colorbox.css">
<link rel="stylesheet" media="all" href="/static/cern-theme4.css">
<link rel="stylesheet" media="all" href="/static/css/cern-theme.css">
<link rel="stylesheet" media="all" href="/static/css/cern-theme2.css">
<link rel="stylesheet" media="all" href="/static/css/cern-theme3.css">
<link rel="stylesheet" media="all" href="/static/css/colorbox.css">
<link rel="stylesheet" media="all" href="/static/css/cern-theme4.css">
</head>