Skip to content

Commit

Permalink
merge tse calendar from master
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavis-xyz committed Feb 19, 2024
2 parents dbc303c + bd08ba7 commit 87643d0
Show file tree
Hide file tree
Showing 27 changed files with 1,275 additions and 2 deletions.
16 changes: 16 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@ <h3 class="cardTitle">Inverter Inertia Emulation</h3>
</div>
</a>
</article>
<article>
<a href="./tse-calendar">
<div class="card">
<img
src="tse-calendar/web-screenshot.png"
alt="Screenshot of timetable web page"
class="cardImage"
width="1124"
height="559" >
<div class="cardBottom">
<h3 class="cardTitle">TSE Calendar Sync and Filter</h3>
<p class="cardDesc">A tool to synchronise personalised Toulouse School of Economics timetables to your calendar app</p>
</div>
</div>
</a>
</article>
</div>

<nav>
Expand Down
9 changes: 8 additions & 1 deletion docs/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Matthew Davis</title>
<link>https://www.mdavis.xyz</link>
<description>A collection of projects, stories and thoughts about technology and politics</description>
<lastBuildDate>Wed, 19 Oct 2022 22:14:11 GMT</lastBuildDate>
<lastBuildDate>Mon, 19 Feb 2024 14:46:42 GMT</lastBuildDate>
<generator>PyRSS2Gen-1.1.0</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<item>
Expand Down Expand Up @@ -98,5 +98,12 @@
<guid isPermaLink="true">https://www.mdavis.xyz/thesis</guid>
<pubDate>Thu, 27 Oct 2016 00:00:00 GMT</pubDate>
</item>
<item>
<title>TSE Calendar Sync and Filter</title>
<link>https://www.mdavis.xyz/tse-calendar</link>
<description>A tool to synchronise personalised Toulouse School of Economics timetables to your calendar app</description>
<guid isPermaLink="true">https://www.mdavis.xyz/tse-calendar</guid>
<pubDate>Mon, 19 Feb 2024 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>
Binary file added docs/tse-calendar/combined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/tse-calendar/combined.xcf
Binary file not shown.
421 changes: 421 additions & 0 deletions docs/tse-calendar/index.html

Large diffs are not rendered by default.

Binary file added docs/tse-calendar/phone-screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 186 additions & 0 deletions docs/tse-calendar/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
ute_url_base = "https://ade-production.ut-capitole.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?data="
lambda_domain = "vvq4ws26xtuivxfdmznouhi7ge0dpqcq.lambda-url.eu-west-3.on.aws"
const alphanumericRegex = /^[a-zA-Z0-9]+$/;

function courseChanged() {
var courseDropdown = document.getElementById("courseDropdown");
var originalUrlField = document.getElementById("original-url");
var otherParent = document.getElementById("other-url-stuff");

if (courseDropdown.value === "other") {
otherParent.style.display = "block";
originalUrlField.value = "";
} else {
var selectedOption = courseDropdown.options[courseDropdown.selectedIndex];

otherParent.style.display = "none";
originalUrlField.value = selectedOption.getAttribute("data-url");
}

updateOutputUrl();
}
document.addEventListener('DOMContentLoaded', function() {
// after page refresh, hide/unhide the custom url field
courseChanged();
});
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("original-url").placeholder = ute_url_base + 'something';
});
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("previous-url").placeholder = 'https://' + lambda_domain + '/...';
});

function updateOutputUrl() {
var courseDropdown = document.getElementById("courseDropdown");
var originalUrlField = document.getElementById("original-url");
var filterDirection = document.getElementById("filter-direction").value
var keywordsText = document.getElementById("keywords").value;
var outputUrlField = document.getElementById("output-url");
var textToShow = "";
var urlId;

console.log("Updating output URL");

if (courseDropdown.value === "other") {
const originalUrl = originalUrlField.value;
if (! originalUrl.startsWith(ute_url_base)){
originalUrlField.classList.add("badInput");
outputUrlField.value = "Invalid URL";
}else{
urlId = originalUrl.replace(ute_url_base, '').trim();

// Test the input against the regular expression
if (!alphanumericRegex.test(urlId)){
originalUrlField.classList.add("badInput");
outputUrlField.value = "Invalid URL";
return;
}

originalUrlField.classList.remove("badInput");
console.log(`Found ${urlId} from original URL`);
}
}else{
// grab URL id from data tag
var selectedOption = courseDropdown.options[courseDropdown.selectedIndex];
urlId = selectedOption.getAttribute("data-url")
}

// Constructing the URL
const protocol = "https://";
const basepath = `/ics/${urlId}`;
const filterDirectionParam = `filter_direction=${filterDirection}`;

// add keywords to parameters
const feParams = keywordsText
.split('\n')
.map(line => line.trim())
.filter(keyword => keyword !== '')
.map(keyword => `fe=${encodeURIComponent(keyword)}`)
.join('&');

// Constructing the final URL
const finalUrl = `${protocol}${lambda_domain}${basepath}?${filterDirectionParam}${feParams ? `&${feParams}` : ''}`;

outputUrlField.value = finalUrl;

updateWarning();
}

function updateWarning(){
const filterDirection = document.getElementById("filter-direction").value;
w = document.getElementById("exclusion-warning");
if (filterDirection == 'blacklist'){
w.style.display = 'block';
}else{
w.style.display = 'none';
}
}

document.addEventListener('DOMContentLoaded', function() {
updateWarning()
});

function copyToClipboard() {
// Get the textarea element
var textarea = document.getElementById("output-url");

// Select the text in the textarea
textarea.select();
textarea.setSelectionRange(0, 99999); // For mobile devices

// Copy the selected text to the clipboard
document.execCommand("copy");

// Deselect the textarea
textarea.setSelectionRange(0, 0);

console.log("Copied");
}

function showExplanations() {
// Hide all paragraphs inside the explanations container
var paragraphs = document.querySelectorAll('#explanations div');
paragraphs.forEach(function(paragraph) {
paragraph.style.display = 'none';
});

// Show the selected paragraph
var selectedOption = document.getElementById('installation-target').value;
var selectedParagraph = document.getElementById(selectedOption + "-explanation");
selectedParagraph.style.display = 'block';
}
document.addEventListener('DOMContentLoaded', function() {
// after page refresh, hide/unhide the custom url field
showExplanations();
});

function reverseUrl(){
var oldUrlField = document.getElementById("previous-url");
const oldUrl = new URL(oldUrlField.value.trim());

if (oldUrl.host != lambda_domain){
oldUrlField.classList.add("badInput");
console.log(`Received old URL, bad domain: ${oldUrl.host}`)
return ;
}else{
var urlId = oldUrl.pathname.split('/').pop();

if (!alphanumericRegex.test(urlId)){
oldUrlField.classList.add("badInput");
console.log("Received old URL, bad ID")
return;
}
console.log(`urlId is ${urlId}`);
// figure out if that's one of the known courseDropdowns
// if yes, select it
// if no, select other, and paste the URL into the custom URL field
var selectElement = document.getElementById("courseDropdown");
var correspondingCourse = selectElement.querySelector('option[data-url="' + urlId + '"]');
var otherUrlField = document.getElementById("original-url");
if (correspondingCourse) {
// Option found, select it
console.log(`course from URL is ${correspondingCourse.id}`);
correspondingCourse.selected = true;
otherUrlField.value = '';
} else {
console.log(`course from URL is unknown`);
document.getElementById('other-course').selected = true;
otherUrlField.value = oldUrlField.value;
}

var queryParams = new URLSearchParams(oldUrl.search);

var filter_direction = queryParams.get("filter_direction"); // Returns "value1"
if (! filter_direction){
filter_direction = "blacklist";
}
document.getElementById("filter-direction").value = filter_direction;

document.getElementById("keywords").value = queryParams.getAll("fe").join('\n');


oldUrlField.classList.remove("badInput");
updateOutputUrl();
}

}
29 changes: 29 additions & 0 deletions docs/tse-calendar/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
body {
font-family: Arial, sans-serif;
margin: 20px;
}

label {
display: block;
margin-top: 10px;
}

.badInput {
border-color: red;
}

.inline-image {
height: 2em; /* Adjust the height as needed */
vertical-align: middle;
margin-right: 0.2em; /* Optional: Adjust the spacing between image and text */
background-color: black;
border-radius: 0.3em;
}

textarea {
width: 90%;
}

.warning {
color: red;
}
Binary file added docs/tse-calendar/sync-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/tse-calendar/web-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions extraWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,56 @@ etc)
place.)
(why
emoji?)
TSE
synchronise
Toulouse
UT
Capitole
TP
TD
M1
Groupe
d'étudiant
ecole
économie
-TSE
UT1
M2
EA
PPD
subfolder
générer
QR
organises
TDs/TPs
TD/TP
EMAAA1MTA
CalDav
synchronised
Thunderbird
+
ICS
ICSx
username
synchronisation
minimising
synchronising
GitLab
unfiltered
timeout
24x7
lifecycle
TTL
SAM
WAF
IAM
CSS
JavaScript
université
personalised
I:EA
economie
I:E
I:DSSS
SE
I:MED
37 changes: 37 additions & 0 deletions pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,40 @@
template: "markdown"
markdown: "content.md"
date: 27/10/2016


- title: "TSE Calendar Sync and Filter"
description: "A tool to synchronise personalised Toulouse School of Economics timetables to your calendar app"
path: "tse-calendar"
images:
card:
path: "web-screenshot.png"
description: "Screenshot of timetable web page"
width: 1124
height: 559
top:
path: "combined.png"
description: "Web page syncing to phone calendar app"
width: 1841
height: 5500
template: "html"
html: "content.html"
date: 19/2/2024

# - title: "Test template"
# description: "Subtitle here"
# path: "blank-js"
# images:
# card:
# path: "thumb.jpg"
# description: "Card caption"
# width: 1000
# height: 667
# top:
# path: "big-bike.jpg"
# description: "Thumbnail caption"
# width: 1500
# height: 725
# template: "html"
# html: "content.html"
# date: 19/2/2024
1 change: 1 addition & 0 deletions pages/blank-js/common.css
9 changes: 9 additions & 0 deletions pages/blank-js/content.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<p>
Test file
</p>
<p id = "js-test">
javascript not loaded
</p>
<p class="myclass">
This should be red text.
</p>
Binary file added pages/blank-js/docs/images/calendar-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions pages/blank-js/docs/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const popupId = "popup";
var popupEl = null;
const iframeID = "popup-iframe";
var iframeEl = null;

window.addEventListener("load",function(){
document.getElementById('js-test').innerHTML = "javascript loaded";
},false);
3 changes: 3 additions & 0 deletions pages/blank-js/docs/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.myclass {
color: red;
}
1 change: 1 addition & 0 deletions pages/tse-calendar/common.css
Loading

0 comments on commit 87643d0

Please sign in to comment.