mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Some template cleanup
This commit is contained in:
@@ -11,14 +11,6 @@
|
|||||||
<script src="{% static 'js/moment.js' %}"></script>
|
<script src="{% static 'js/moment.js' %}"></script>
|
||||||
<script src="{% static 'js/main.min.js' %}"></script>
|
<script src="{% static 'js/main.min.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
function getUrlVars() {
|
|
||||||
var vars = {};
|
|
||||||
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
|
|
||||||
vars[key] = value;
|
|
||||||
});
|
|
||||||
return vars;
|
|
||||||
}
|
|
||||||
|
|
||||||
viewToUrl = {
|
viewToUrl = {
|
||||||
'timeGridWeek':'week',
|
'timeGridWeek':'week',
|
||||||
'timeGridDay':'day',
|
'timeGridDay':'day',
|
||||||
@@ -78,7 +70,7 @@
|
|||||||
'url': $(this).attr('url')
|
'url': $(this).attr('url')
|
||||||
}
|
}
|
||||||
|
|
||||||
if($(this).attr('is_rig')==true || $(this).attr('status') == "Cancelled"){
|
if($(this).attr('is_rig')===true || $(this).attr('status') === "Cancelled"){
|
||||||
thisEvent['color'] = colours[$(this).attr('status')];
|
thisEvent['color'] = colours[$(this).attr('status')];
|
||||||
}else{
|
}else{
|
||||||
thisEvent['color'] = colours['non-rig'];
|
thisEvent['color'] = colours['non-rig'];
|
||||||
@@ -95,31 +87,35 @@
|
|||||||
$('#calendar-header').text(view.title);
|
$('#calendar-header').text(view.title);
|
||||||
|
|
||||||
// Enable/Disable "Today" button as required
|
// Enable/Disable "Today" button as required
|
||||||
|
let $today = $('#today-button');
|
||||||
if(moment().isBetween(view.currentStart, view.currentEnd)){
|
if(moment().isBetween(view.currentStart, view.currentEnd)){
|
||||||
//Today is within the current view
|
//Today is within the current view
|
||||||
$('#today-button').prop('disabled', true);
|
$today.prop('disabled', true);
|
||||||
}else{
|
}else{
|
||||||
$('#today-button').prop('disabled', false);
|
$today.prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set active view select button
|
// Set active view select button
|
||||||
|
let $month = $('#month-button');
|
||||||
|
let $week = $('#week-button');
|
||||||
|
let $day = $('#day-button');
|
||||||
switch(view.type){
|
switch(view.type){
|
||||||
case 'dayGridMonth':
|
case 'dayGridMonth':
|
||||||
$('#month-button').addClass('active');
|
$month.addClass('active');
|
||||||
$('#week-button').removeClass('active');
|
$week.removeClass('active');
|
||||||
$('#day-button').removeClass('active');
|
$day.removeClass('active');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'timeGridWeek':
|
case 'timeGridWeek':
|
||||||
$('#month-button').removeClass('active');
|
$month.removeClass('active');
|
||||||
$('#week-button').addClass('active');
|
$week.addClass('active');
|
||||||
$('#day-button').removeClass('active');
|
$day.removeClass('active');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'timeGridDay':
|
case 'timeGridDay':
|
||||||
$('#month-button').removeClass('active');
|
$month.removeClass('active');
|
||||||
$('#week-button').removeClass('active');
|
$week.removeClass('active');
|
||||||
$('#day-button').addClass('active');
|
$day.addClass('active');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
history.replaceState(null,null,"{% url 'web_calendar' %}"+viewToUrl[view.type]+'/'+moment(view.currentStart).format('YYYY-MM-DD')+'/');
|
history.replaceState(null,null,"{% url 'web_calendar' %}"+viewToUrl[view.type]+'/'+moment(view.currentStart).format('YYYY-MM-DD')+'/');
|
||||||
|
|||||||
@@ -30,21 +30,6 @@
|
|||||||
{% include 'partials/datetime-fix.html' %}
|
{% include 'partials/datetime-fix.html' %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function setTime23Hours() {
|
|
||||||
$('#{{ form.end_time.id_for_label }}').val('23:00');
|
|
||||||
}
|
|
||||||
|
|
||||||
function setTime02Hours() {
|
|
||||||
var id_start = "{{ form.start_date.id_for_label }}";
|
|
||||||
var id_end_date = "{{ form.end_date.id_for_label }}";
|
|
||||||
var id_end_time = "{{ form.end_time.id_for_label }}";
|
|
||||||
if ($('#'+id_start).val() == $('#'+id_end_date).val()) {
|
|
||||||
var end_date = new Date($('#'+id_end_date).val());
|
|
||||||
end_date.setDate(end_date.getDate() + 1);
|
|
||||||
$('#'+id_end_date).val(end_date.getISOString());
|
|
||||||
}
|
|
||||||
$('#'+id_end_time).val('02:00');
|
|
||||||
}
|
|
||||||
const matches = window.matchMedia("(prefers-reduced-motion: reduce)").matches || window.matchMedia("(update: slow)").matches;
|
const matches = window.matchMedia("(prefers-reduced-motion: reduce)").matches || window.matchMedia("(update: slow)").matches;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
dur = matches ? 0 : 500;
|
dur = matches ? 0 : 500;
|
||||||
@@ -53,14 +38,14 @@
|
|||||||
$('.form-is_rig').slideUp(dur);
|
$('.form-is_rig').slideUp(dur);
|
||||||
});
|
});
|
||||||
{% elif not object.pk and form.errors %}
|
{% elif not object.pk and form.errors %}
|
||||||
if ($('#{{form.is_rig.auto_id}}').attr('checked') != 'checked') {
|
if ($('#{{form.is_rig.auto_id}}').attr('checked') !== 'checked') {
|
||||||
$('.form-is_rig').hide();
|
$('.form-is_rig').hide();
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not object.pk %}
|
{% if not object.pk %}
|
||||||
$('#is_rig-selector button').on('click', function () {
|
$('#is_rig-selector button').on('click', function () {
|
||||||
$('.form-non_rig').slideDown(dur);
|
$('.form-non_rig').slideDown(dur);
|
||||||
if ($(this).data('is_rig') == 1) {
|
if ($(this).data('is_rig') === 1) {
|
||||||
$('#{{form.is_rig.auto_id}}').prop('checked', true);
|
$('#{{form.is_rig.auto_id}}').prop('checked', true);
|
||||||
if ($('.form-non_rig').is(':hidden')) {
|
if ($('.form-non_rig').is(':hidden')) {
|
||||||
$('.form-is_rig').show();
|
$('.form-is_rig').show();
|
||||||
|
|||||||
@@ -27,12 +27,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
function parseBool(str) {
|
function parseBool(str) {
|
||||||
if (str.toLowerCase() == 'true') {
|
return str.toLowerCase() == 'true';
|
||||||
return true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$('input[type=radio][name=big_power]').change(function() {
|
$('input[type=radio][name=big_power]').change(function() {
|
||||||
$('#{{ form.power_mic.id_for_label }}').prop('required', parseBool(this.value));
|
$('#{{ form.power_mic.id_for_label }}').prop('required', parseBool(this.value));
|
||||||
|
|||||||
@@ -14,11 +14,7 @@
|
|||||||
$('#' + String(ID)).val(CSA);
|
$('#' + String(ID)).val(CSA);
|
||||||
}
|
}
|
||||||
function checkIfCableHidden() {
|
function checkIfCableHidden() {
|
||||||
if (document.getElementById("id_is_cable").checked) {
|
document.getElementById("cable-table").hidden = !document.getElementById("id_is_cable").checked;
|
||||||
document.getElementById("cable-table").hidden = false;
|
|
||||||
} else {
|
|
||||||
document.getElementById("cable-table").hidden = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
checkIfCableHidden();
|
checkIfCableHidden();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
|
<script src="{% static 'js/jquery-ui.js' %}"></script>
|
||||||
<script src="{% static "js/interaction.js" %}"></script>
|
<script src="{% static "js/interaction.js" %}"></script>
|
||||||
<script src="{% static "js/modal.js" %}"></script>
|
<script src="{% static "js/modal.js" %}"></script>
|
||||||
<script>
|
<script>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
success: function(){
|
success: function(){
|
||||||
$link = $(this);
|
$link = $(this);
|
||||||
// Anti modal inception
|
// Anti modal inception
|
||||||
if ($link.parents('#modal').length == 0) {
|
if ($link.parents('#modal').length === 0) {
|
||||||
modaltarget = $link.data('target');
|
modaltarget = $link.data('target');
|
||||||
modalobject = "";
|
modalobject = "";
|
||||||
$('#modal').load(url, function (e) {
|
$('#modal').load(url, function (e) {
|
||||||
|
|||||||
@@ -30,19 +30,19 @@
|
|||||||
//Get query string value
|
//Get query string value
|
||||||
var searchUrl=location.search;
|
var searchUrl=location.search;
|
||||||
|
|
||||||
if(key!="") {
|
if(key!=="") {
|
||||||
oldValue = getParameterByName(key);
|
oldValue = getParameterByName(key);
|
||||||
removeVal=key+"="+oldValue;
|
removeVal=key+"="+oldValue;
|
||||||
if(searchUrl.indexOf('?'+removeVal+'&')!= "-1") {
|
if(searchUrl.indexOf('?'+removeVal+'&')!== "-1") {
|
||||||
urlValue=urlValue.replace('?'+removeVal+'&','?');
|
urlValue=urlValue.replace('?'+removeVal+'&','?');
|
||||||
}
|
}
|
||||||
else if(searchUrl.indexOf('&'+removeVal+'&')!= "-1") {
|
else if(searchUrl.indexOf('&'+removeVal+'&')!== "-1") {
|
||||||
urlValue=urlValue.replace('&'+removeVal+'&','&');
|
urlValue=urlValue.replace('&'+removeVal+'&','&');
|
||||||
}
|
}
|
||||||
else if(searchUrl.indexOf('?'+removeVal)!= "-1") {
|
else if(searchUrl.indexOf('?'+removeVal)!== "-1") {
|
||||||
urlValue=urlValue.replace('?'+removeVal,'');
|
urlValue=urlValue.replace('?'+removeVal,'');
|
||||||
}
|
}
|
||||||
else if(searchUrl.indexOf('&'+removeVal)!= "-1") {
|
else if(searchUrl.indexOf('&'+removeVal)!== "-1") {
|
||||||
urlValue=urlValue.replace('&'+removeVal,'');
|
urlValue=urlValue.replace('&'+removeVal,'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
param = $(value).val();
|
param = $(value).val();
|
||||||
val = $(value).prop('checked');
|
val = $(value).prop('checked');
|
||||||
|
|
||||||
if(val != defaultVal){
|
if(val !== defaultVal){
|
||||||
url = url+param+"="+val+"&";
|
url = url+param+"="+val+"&";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user