-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove redundant Logger service and update controllers for PWA.
Deleted the custom Logger service as it was unnecessary. Introduced preloads for PWA pages in multiple controllers for better page readiness. Also updated dependencies, disabled XSS protection settings, and replaced DeviceMotion component with a simplified version.
- Loading branch information
Showing
111 changed files
with
2,000 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { startStimulusApp } from '@symfony/stimulus-bundle'; | ||
import Timeago from 'stimulus-timeago' | ||
|
||
const app = startStimulusApp(); | ||
// register any custom, 3rd party controllers here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
import hljs from 'highlight.js'; | ||
import 'highlight.js/styles/nord.min.css'; | ||
|
||
export default class extends Controller { | ||
connect() { | ||
hljs.highlightElement(this.element); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
static targets = [ | ||
'downlink', 'downlinkMax', 'effectiveType', 'rtt', 'saveData', 'type', | ||
'downlinkContent', 'downlinkMaxContent', 'effectiveTypeContent', 'rttContent', 'saveDataContent', 'typeContent', | ||
]; | ||
|
||
connect() { | ||
const connection = navigator.connection; | ||
connection.addEventListener('change', this.updateConnectionStatus); | ||
this.updateConnectionStatus(); | ||
} | ||
|
||
updateConnectionStatus = () => { | ||
const connection = navigator.connection; | ||
console.log({bubble: true, details: connection}); | ||
this.dispatch('network-information:change', {bubble: true, details: {connection}}); | ||
this.downlinkTargets.forEach((element) => element.setAttribute('data-network-information-downlink-value', connection.downlink)); | ||
this.downlinkContentTargets.forEach((element) => element.textContent = connection.downlink); | ||
this.downlinkMaxTargets.forEach((element) => element.setAttribute('data-network-information-downlink-max-value', connection.downlinkMax)); | ||
this.downlinkMaxContentTargets.forEach((element) => element.textContent = connection.downlinkMax ?? '...'); | ||
this.effectiveTypeTargets.forEach((element) => element.setAttribute('data-network-information-effective-type-value', connection.effectiveType)); | ||
this.effectiveTypeContentTargets.forEach((element) => element.textContent = connection.effectiveType); | ||
this.rttTargets.forEach((element) => element.setAttribute('data-network-information-rtt-value', connection.rtt)); | ||
this.rttContentTargets.forEach((element) => element.textContent = connection.rtt); | ||
this.saveDataTargets.forEach((element) => element.setAttribute('data-network-information-save-data-value', connection.saveData)); | ||
this.saveDataContentTargets.forEach((element) => element.textContent = connection.saveData ? 'Yes' : 'No'); | ||
this.typeTargets.forEach((element) => element.setAttribute('data-network-information-type-value', connection.type)); | ||
this.typeContentTargets.forEach((element) => element.textContent = connection.type ?? '...'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
import Reveal from 'reveal.js'; | ||
import Markdown from 'reveal.js/plugin/markdown/markdown.esm.js'; | ||
import 'reveal.js/dist/reveal.css'; | ||
import 'reveal.js/dist/theme/serif.css'; | ||
|
||
export default class extends Controller { | ||
deck = null; | ||
connect() { | ||
this.deck = new Reveal({ | ||
plugins: [Markdown], | ||
}); | ||
this.deck.initialize(); | ||
} | ||
|
||
message({detail}) { | ||
const {data} = detail; | ||
if (data.message === 'next') { | ||
this.next(); | ||
} | ||
if (data.message === 'previous') { | ||
this.previous(); | ||
} | ||
} | ||
|
||
next() { | ||
this.deck.next(); | ||
} | ||
|
||
previous() { | ||
this.deck.prev(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
'use strict'; | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
static values = { | ||
continuous: { type: Boolean, default: false }, | ||
grammarString: { type: String, default: null }, | ||
//grammarUri: { type: String, default: null }, | ||
grammarWeight: { type: Number, default: 1 }, | ||
interimResults: { type: Boolean, default: false }, | ||
lang: { type: String, default: 'en-US' }, | ||
maxAlternatives: { type: Number, default: 1 }, | ||
}; | ||
static targets = ['attributeOutput', 'contentOutput']; | ||
|
||
recognition = null; | ||
|
||
connect() { | ||
const supported = 'webkitSpeechRecognition' in window || 'SpeechRecognition' in window; | ||
if (!supported) { | ||
return; | ||
} | ||
|
||
this.recognition = new webkitSpeechRecognition() || new SpeechRecognition(); | ||
if (this.grammarStringValue) { | ||
const speechRecognitionList = new webkitSpeechGrammarList() || new SpeechGrammarList(); | ||
speechRecognitionList.addFromString(this.grammarValue, this.grammarWeightValue); | ||
this.recognition.grammars = speechRecognitionList; | ||
} | ||
this.recognition.continuous = this.continuousValue; | ||
this.recognition.lang = this.langValue; | ||
this.recognition.interimResults = this.interimResultsValue; | ||
this.recognition.maxAlternatives = this.maxAlternativesValue; | ||
this.recognition.addEventListener('result', this.onResult); | ||
this.recognition.addEventListener('audiostart', () => { | ||
this.dispatch('speech-recognition:audiostart'); | ||
}); | ||
this.recognition.addEventListener('audioend', () => { | ||
this.dispatch('speech-recognition:audioend'); | ||
}); | ||
this.recognition.addEventListener('start', () => { | ||
this.dispatch('speech-recognition:start'); | ||
}); | ||
this.recognition.addEventListener('end', () => { | ||
this.dispatch('speech-recognition:end'); | ||
}); | ||
this.recognition.addEventListener('error', (event) => { | ||
this.dispatch('speech-recognition:error', { error: event.error }); | ||
}); | ||
this.recognition.addEventListener('nomatch', () => { | ||
this.dispatch('speech-recognition:nomatch'); | ||
}); | ||
this.recognition.addEventListener('soundstart', () => { | ||
this.dispatch('speech-recognition:soundstart'); | ||
}); | ||
this.recognition.addEventListener('soundend', () => { | ||
this.dispatch('speech-recognition:soundend'); | ||
}); | ||
this.recognition.addEventListener('speechstart', () => { | ||
this.dispatch('speech-recognition:speechstart'); | ||
}); | ||
this.recognition.addEventListener('speechend', () => { | ||
this.dispatch('speech-recognition:speechend'); | ||
}); | ||
} | ||
|
||
start() { | ||
this.recognition.start(); | ||
} | ||
|
||
stop() { | ||
this.recognition.stop(); | ||
} | ||
|
||
onResult = (event) => { | ||
const length = event.results.length; | ||
for (let i = event.resultIndex; i < length; i++) { | ||
const speechRecognitionResult = event.results[i]; | ||
const alternatives = speechRecognitionResult.length; | ||
for (let j = 0; j < alternatives; j++) { | ||
const transcript = speechRecognitionResult[j].transcript.trim(); | ||
if (transcript === '') { | ||
continue; | ||
} | ||
this.dispatch('speech-recognition:result', { transcript: transcript, isFinal: speechRecognitionResult.isFinal, confidence: speechRecognitionResult[j].confidence }); | ||
this.attributeOutputTargets.forEach((element) => element.setAttribute('data-speech-recognition', transcript)); | ||
this.contentOutputTargets.forEach((element) => element.textContent += transcript+'\n'); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
connect() { | ||
this.populateVoiceList(); | ||
} | ||
|
||
locales = () => { | ||
return speechSynthesis.getVoices().map((voice) => voice.lang); | ||
} | ||
|
||
voices = ({params}) => { | ||
const voices = speechSynthesis.getVoices() | ||
.filter((voice) => params.locale ? voice.lang === params.locale : true) | ||
.filter((voice) => params.type === 'distant' ? voice.localService === false : true) | ||
.filter((voice) => params.type === 'local' ? voice.localService === true : true) | ||
; | ||
console.log(voices); | ||
|
||
return voices; | ||
} | ||
|
||
speak = ({params}) => { | ||
const utterance = new SpeechSynthesisUtterance(params.text); | ||
utterance.voice = speechSynthesis.getVoices().find((voice) => voice.name === params.voice); | ||
utterance.lang = params.locale || 'en-US'; | ||
utterance.rate = params.rate || 1; | ||
utterance.pitch = params.pitch || 1; | ||
speechSynthesis.speak(utterance); | ||
} | ||
|
||
populateVoiceList = () => { | ||
if (typeof speechSynthesis === "undefined") { | ||
return; | ||
} | ||
speechSynthesis.getVoices(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
connect() { | ||
// Envoie événement au PageDown et au PageUp du clavier | ||
document.addEventListener('keydown', (event) => { | ||
if (event.key === 'PageDown') { | ||
document.getElementById('next').click(); | ||
} else if (event.key === 'PageUp') { | ||
document.getElementById('previous').click(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './bootstrap.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.