Skip to content

Commit

Permalink
3.11.5 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
QkeleQ10 authored Jun 19, 2024
1 parent aa113d2 commit 0abc361
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 33 deletions.
2 changes: 1 addition & 1 deletion manifest-firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"manifest_version": 3,
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"version": "3.11.4",
"version": "3.11.5",
"default_locale": "nl",
"icons": {
"16": "icons/[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"manifest_version": 3,
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"version": "3.11.4",
"version": "3.11.5",
"default_locale": "nl",
"icons": {
"16": "icons/[email protected]",
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion popup/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="./favicon.ico">
<title>Study Tools-configuratiepaneel</title>
<script type="module" crossorigin src="./assets/index-CFAfwAOA.js"></script>
<script type="module" crossorigin src="./assets/index-DmvJ8t9n.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-BmeHimE9.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion popup/src/components/IconInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const iconCats = {
"Kalenders": '',
"Bestanden": '',
"Personen": '',
"Divers": '☀⏾',
"Divers": '☀⏾',
"Cirkels": '',
"Vierkanten": '⬛',
"Handen": '',
Expand Down
26 changes: 15 additions & 11 deletions src/magister/scripts/gamification.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ async function constructWrapped(lastYearOnly) {
for (let i = 0; i < years.length; i++) {
const year = years[i]

const newElement = await constructWrappedForYear(year, i)
const newElement = await constructWrappedForYear(i)
yearsWrapper.append(newElement)
}

if (!lastYearOnly) {
const newElement = await constructWrappedForYear({}, years.length)
const newElement = await constructWrappedForYear(years.length)
yearsWrapper.append(newElement)

const previousButton = element('button', 'st-wrapped-prev', dialog, { class: 'st-button icon', 'data-icon': '', disabled: true })
Expand Down Expand Up @@ -143,8 +143,10 @@ async function constructWrapped(lastYearOnly) {

resolve(dialog)

async function constructWrappedForYear(year, i) {
async function constructWrappedForYear(i) {
return new Promise(async (resolveYear) => {
let year = JSON.parse(JSON.stringify((i === years.length ? {} : years[i]) || {}))

let seed = cyrb128((year.groep?.code + year.lesperiode?.code) || (user.name?.firstname + i))
let rand = sfc32(seed[0], seed[1], seed[2], seed[3])

Expand All @@ -167,9 +169,9 @@ async function constructWrapped(lastYearOnly) {
year.grades = years.flatMap(obj => obj.grades)
.filter((grade, index, self) =>
index === self.findIndex((g) =>
g.CijferKolom.KolomKop === grade.CijferKolom.KolomKop &&
g.CijferKolom.KolomNaam === grade.CijferKolom.KolomNaam &&
g.CijferStr === grade.CijferStr
g?.CijferKolom?.KolomKop === grade.CijferKolom.KolomKop &&
g?.CijferKolom?.KolomNaam === grade.CijferKolom.KolomNaam &&
g?.CijferStr === grade.CijferStr
)
)
year.events = years.flatMap(obj => obj.events)
Expand All @@ -182,9 +184,9 @@ async function constructWrapped(lastYearOnly) {
.filter(grade => grade.CijferKolom.KolomSoort == 1 && !isNaN(Number(grade.CijferStr.replace(',', '.'))) && (Number(grade.CijferStr.replace(',', '.')) <= 10) && (Number(grade.CijferStr.replace(',', '.')) >= 1))
.filter((grade, index, self) =>
index === self.findIndex((g) =>
g.CijferKolom.KolomKop === grade.CijferKolom.KolomKop &&
g.CijferKolom.KolomNaam === grade.CijferKolom.KolomNaam &&
g.CijferStr === grade.CijferStr
g?.CijferKolom?.KolomKop === grade.CijferKolom.KolomKop &&
g?.CijferKolom?.KolomNaam === grade.CijferKolom.KolomNaam &&
g?.CijferStr === grade.CijferStr
)
)
.sort((a, b) => new Date(a.DatumIngevoerd) - new Date(b.DatumIngevoerd))
Expand All @@ -193,6 +195,8 @@ async function constructWrapped(lastYearOnly) {
year.assignments = await MagisterApi.assignments.forYear(year) || []
}

years[i] = year

const teacherNames = await getFromStorage('start-teacher-names') || await getFromStorage('teacher-names', 'local') || {}

if (year.examInfo && Object.keys(year.examInfo).length > 0) {
Expand Down Expand Up @@ -427,8 +431,8 @@ async function themeContest() {

event.preventDefault()

if ((await getFromStorage('themeContestJurorMode', 'session')) === 'true') {
const textarea = element('textarea', 'null', document.body, { style: 'position: absolute; z-index: 99999999; top: 50%; left: 50%; translate: -50% -50%; width: 300px; height: 200px; transition: all 200ms;', resize: 'both' })
if ((await getFromStorage('themeContestJurorMode', 'session')) === 'true' || syncedStorage['themeContestJurorMode']) {
const textarea = element('textarea', 'null', document.body, { style: 'position: absolute; z-index: 99999999; top: 50%; left: 50%; translate: -50% -50%; width: 300px; height: 200px; transition: all 200ms;', resize: 'both', innerText: 'alt+klik om te verplaatsen, ctrl+klik om te verbergen' })
document.body.addEventListener('click', (event) => {
if (event.altKey) {
event.preventDefault()
Expand Down
9 changes: 5 additions & 4 deletions src/magister/scripts/today.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ async function today() {
todayWidgets()

async function todayHeader() {
let headerText = element('span', 'st-start-header-text', header, { class: 'st-title' }),
headerGreeting = element('span', 'st-start-header-greeting', header, { class: 'st-title' }),
const headerTextWrapper = element('div', 'st-start-header-text-wrapper', header)
let headerText = element('span', 'st-start-header-text', headerTextWrapper, { class: 'st-title' }),
headerGreeting = element('span', 'st-start-header-greeting', headerTextWrapper, { class: 'st-title' }),
headerButtons = element('div', 'st-start-header-buttons', header),
formattedWeekday = now.toLocaleString(locale, { timeZone: 'Europe/Amsterdam', weekday: 'long' })

Expand Down Expand Up @@ -385,7 +386,7 @@ async function today() {
const events = await MagisterApi.events()

// Display error if the result does not exist or if it is not an array
if (!(events?.constructor === Array)) {
if (!events || !Array.isArray(events)) {
element('i', `st-start-fa`, schedule, { class: 'st-start-icon fa-duotone fa-calendar-circle-exclamation' })
element('span', `st-start-disclaimer`, schedule, { class: 'st-start-disclaimer', innerText: i18n('error') })
return
Expand Down Expand Up @@ -848,7 +849,6 @@ async function today() {
if (type === 'Lijst') widgetTitle.dataset.amount = recentGrades.filter(item => item.unread).length

recentGrades.forEach((item, i) => {
console.log(item)
const gradeElement = element('div', `st-start-widget-grades-${i}`, widgetItemsContainer, { class: 'st-start-widget-grades-item', 'data-unread': item.unread, 'data-hidden': item.hidden, 'data-assignment': item.assignment })
children.push(gradeElement)
if (i === 0) widgetElement.dataset.unread = item.unread
Expand Down Expand Up @@ -895,6 +895,7 @@ async function today() {
})

const scrollPagn = element('div', 'st-start-widget-grades-scroll-pagn', widgetElement)
scrollPagn.inenrText = ''
children.forEach((child, i) => {
const scrollPagnNode = element('div', undefined, scrollPagn, { 'data-current': i === 0 })
scrollPagnNode.addEventListener('click', (event) => {
Expand Down
31 changes: 18 additions & 13 deletions src/magister/styles/today.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,34 @@
grid-area: header;
position: relative;
width: 100%;
display: grid;
grid-template:
'text buttons' 32px
/ 1fr auto;
align-items: center;
height: 84px;
box-sizing: border-box;
display: flex;
padding: 32px 32px 20px;
transition: background-color 200ms, padding-right 200ms, opacity 200ms;
}

#st-start-header-text-wrapper {
flex: 1;
display: flex;
overflow: hidden;
}

#st-start-header-text,
#st-start-header-greeting {
flex: 100% 0 0;
width: 100%;
margin-bottom: 0;
text-wrap: nowrap;
overflow: hidden;
text-overflow: ellipsis;
transition: opacity 300ms;
}

#st-start-header-greeting {
translate: -100%;
}

#st-start-header-text[data-state="visible"],
#st-start-header-greeting[data-state="visible"] {
animation: 150ms flipDownIn 150ms both;
Expand All @@ -81,13 +91,6 @@
color: var(--st-foreground-secondary);
}

#st-start-header-greeting {
position: absolute;
top: 32px;
left: 32px;
padding-right: 6px;
}

#st-start-header-text:after {
content: attr(data-last-letter);
}
Expand Down Expand Up @@ -1171,7 +1174,9 @@ a.st-widget-title {
}

.st-start-widget-grades-item-rslt[data-great=true] {
background: linear-gradient(in hsl longer hue, hsl(0, 100%, 60%) 0 0) 0 0/100% 200%;
background-image: linear-gradient(rgba(255, 0, 0, 1) 0%, rgba(255, 154, 0, 1) 10%, rgba(208, 222, 33, 1) 20%, rgba(79, 220, 74, 1) 30%, rgba(63, 218, 216, 1) 40%, rgba(47, 201, 226, 1) 50%, rgba(28, 127, 238, 1) 60%, rgba(95, 21, 242, 1) 70%, rgba(186, 12, 248, 1) 80%, rgba(251, 7, 217, 1) 90%, rgba(255, 0, 0, 1) 100%);
background-position: 0 0;
background-size: 100% 200%;
background-clip: text;
color: transparent;
animation: great-grade 2s linear infinite;
Expand Down
3 changes: 3 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function awaitElement(querySelector, all = false, duration = 10000, quiet = fals
*/
function getFromStorage(key, location = 'sync') {
return new Promise((resolve, reject) => {
if (location === 'session' && !chrome.storage.session) location = 'local'
chrome.storage[location].get([key], (result) => {
let value = Object.values(result)[0]
value ? resolve(value) : resolve('')
Expand All @@ -165,6 +166,7 @@ function getFromStorage(key, location = 'sync') {
*/
function getFromStorageMultiple(array, location = 'sync', all = false) {
return new Promise((resolve, reject) => {
if (location === 'session' && !chrome.storage.session) location = 'local'
chrome.storage[location].get(all ? null : array.map(e => [e]), (result) => {
result ? resolve(result) : reject(Error('None found'))
})
Expand All @@ -173,6 +175,7 @@ function getFromStorageMultiple(array, location = 'sync', all = false) {

function saveToStorage(key, value, location) {
return new Promise((resolve, reject) => {
if (location === 'session' && !chrome.storage.session) location = 'local'
chrome.storage[location ? location : 'sync'].set({ [key]: value }, resolve())
})
}
Expand Down

0 comments on commit 0abc361

Please sign in to comment.