Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
3 changed files with 36 additions and 35 deletions
Showing only changes of commit d2a17ffdfb - Show all commits

View File

@ -12,13 +12,13 @@
const t_start = {{ t_start }};
const t_end = {{ t_end }};
const tick_time = 60 / {{ tick_time }}
const tick_delay = 1 / tick_time
const tick_time = 60 / {{ tick_time }};
const tick_delay = 1 / tick_time;
const period_default = {{ periode_defaut }};
function createTicks() {
let i = t_start
let i = t_start;
while (i <= t_end) {
const hourTick = document.createElement("div");
@ -33,7 +33,7 @@
timelineContainer.appendChild(tickLabel);
if (i < t_end) {
let j = Math.floor(i + 1)
let j = Math.floor(i + 1);
while (i < j) {
i += tick_delay;
@ -46,26 +46,28 @@
}
}
i = j
i = j;
} else {
i++;
}
}
}
function numberToTime(num) {
const integer = Math.floor(num)
const decimal = (num % 1) * 60
const integer = Math.floor(num);
const decimal = (num % 1) * 60;
let dec = `:${decimal}`
let dec = `:${decimal}`;
if (decimal < 10) {
dec = `:0${decimal}`
dec = `:0${decimal}`;
}
let int = `${integer}`
let int = `${integer}`;
if (integer < 10) {
int = `0${integer}`
int = `0${integer}`;
}
return int + dec
return int + dec;
}
@ -76,7 +78,7 @@
}
function setupTimeLine(callback) {
const func_call = callback ? callback : () => { }
const func_call = callback ? callback : () => { };
timelineContainer.addEventListener("mousedown", (event) => {
const startX = event.clientX;
@ -96,9 +98,9 @@
"mouseup",
() => {
generateAllEtudRow();
snapHandlesToQuarters()
snapHandlesToQuarters();
document.removeEventListener("mousemove", onMouseMove);
func_call()
func_call();
},
{ once: true }
);
@ -125,12 +127,12 @@
document.addEventListener(
"mouseup",
() => {
snapHandlesToQuarters()
snapHandlesToQuarters();
generateAllEtudRow();
document.removeEventListener("mousemove", onMouseMove);
func_call()
func_call();
},
{ once: true }
@ -162,40 +164,40 @@
const startValue = snapToQuarter(startHour);
const endValue = snapToQuarter(endHour);
const computedValues = [Math.max(startValue, t_start), Math.min(t_end, endValue)]
const computedValues = [Math.max(startValue, t_start), Math.min(t_end, endValue)];
if (computedValues[0] > t_end || computedValues[1] < t_start) {
return [t_start, min(t_end, t_start + period_default)]
return [t_start, min(t_end, t_start + period_default)];
}
if (computedValues[1] - computedValues[0] <= tick_delay && computedValues[1] < t_end - tick_delay) {
computedValues[1] += tick_delay;
}
return computedValues
return computedValues;
}
function setPeriodValues(deb, fin) {
deb = snapToQuarter(deb)
fin = snapToQuarter(fin)
let leftPercentage = (deb - t_start) / (t_end - t_start) * 100
let widthPercentage = (fin - deb) / (t_end - t_start) * 100
periodTimeLine.style.left = `${leftPercentage}%`
periodTimeLine.style.width = `${widthPercentage}%`
deb = snapToQuarter(deb);
fin = snapToQuarter(fin);
let leftPercentage = (deb - t_start) / (t_end - t_start) * 100;
let widthPercentage = (fin - deb) / (t_end - t_start) * 100;
periodTimeLine.style.left = `${leftPercentage}%`;
periodTimeLine.style.width = `${widthPercentage}%`;
snapHandlesToQuarters()
snapHandlesToQuarters();
generateAllEtudRow();
}
function snapHandlesToQuarters() {
const periodValues = getPeriodValues();
let lef = Math.min(computePercentage(periodValues[0], t_start), computePercentage(t_end, tick_delay))
let lef = Math.min(computePercentage(periodValues[0], t_start), computePercentage(t_end, tick_delay));
if (lef < 0) {
lef = 0;
}
const left = `${lef}%`
const left = `${lef}%`;
let wid = Math.max(computePercentage(periodValues[1], periodValues[0]), computePercentage(tick_delay, 0))
let wid = Math.max(computePercentage(periodValues[1], periodValues[0]), computePercentage(tick_delay, 0));
if (wid > 100) {
wid = 100;
}
@ -205,11 +207,11 @@
}
function computePercentage(a, b) {
return ((a - b) / (t_end - t_start)) * 100
return ((a - b) / (t_end - t_start)) * 100;
}
createTicks();
setPeriodValues(t_start, t_start + period_default)
setPeriodValues(t_start, t_start + period_default);
</script>
<style>

View File

@ -547,7 +547,6 @@ def signal_assiduites_diff():
grp + ' <span class="fontred">' + groups_infos.groups_titles + "</span>"
)
return HTMLBuilder(
header,
render_template(
@ -604,7 +603,7 @@ def _timeline(formsemestre_id=None) -> HTMLElement:
"assiduites/timeline.j2",
t_start=get_time("assi_morning_time", "08:00:00"),
t_end=get_time("assi_afternoon_time", "18:00:00"),
tick_time=ScoDocSiteConfig.get("assi_tick_time", 0.25),
tick_time=ScoDocSiteConfig.get("assi_tick_time", 15),
periode_defaut=sco_preferences.get_preference(
"periode_defaut", formsemestre_id
),

View File

@ -217,7 +217,7 @@ def config_assiduites():
form.afternoon_time.data = ScoDocSiteConfig.get(
"assi_afternoon_time", datetime.time(18, 0, 0)
)
form.tick_time.data = float(ScoDocSiteConfig.get("assi_tick_time", 0.25))
form.tick_time.data = float(ScoDocSiteConfig.get("assi_tick_time", 15))
return render_template(
"assiduites/config_assiduites.j2",
form=form,