Skip to content
GitLab
Erkunden
Anmelden
Registrieren
Primärnavigation
Suchen oder aufrufen …
Projekt
Html Snippets
Verwalten
Aktivität
Mitglieder
Labels
Planen
Tickets
1
Ticketübersichten
Meilensteine
Wiki
Code
Merge Requests
0
Repository
Branch
Commits
Tags
Repository-Diagramm
Revisionen vergleichen
Code-Schnipsel
Build
Pipelines
Aufgaben
Pipeline-Zeitpläne
Artefakte
Bereitstellung
Releases
Paket-Registry
Betreiben
Umgebungen
Terraform-Module
Überwachen
Vorfälle
Service-Desk
Analysieren
Wertschöpfungskettenanalyse
Mitwirkenden-Analyse
CI/CD-Analyse
Repository-Analysen
Hilfe
Hilfe
Support
GitLab-Dokumentation
GitLab-Pläne vergleichen
Community-Forum
Zu GitLab beitragen
Feedback geben
Tastenkürzel
?
Code-Schnipsel
Gruppen
Projekte
Show more breadcrumbs
QUIQQER
Html Snippets
Commits
6e4b9c8e
Commit
6e4b9c8e
erstellt
vor 8 Monaten
von
Jan Wennrich
Dateien durchsuchen
Optionen
Downloads
Einfaches Diff
Merge branch 'next-2.x' into 'main'
Release See merge request
!28
Übergeordnete
77802b5f
03e6bfcc
No related branches found
Branches enthält Commit
Tags
2.0.3
Tags enthält Commit
2 Merge Requests
!31
Update 'next-3.x' with latest changes from 'main'
,
!28
Release
Pipeline
#9314
mit Warnungen bestanden mit Phasen
Phase:
Phase:
in 1 Minute und 9 Sekunden
Änderungen
3
Pipelines
1
Leerzeichenänderungen ausblenden
Inline
Nebeneinander
3 geänderte Dateien
bin/backend/Snippets.js
+1
-1
1 Ergänzung, 1 Löschung
bin/backend/Snippets.js
bin/frontend/gdprReader.js
+45
-30
45 Ergänzungen, 30 Löschungen
bin/frontend/gdprReader.js
src/QUI/HtmlSnippets/SnippetTemplateEvent.php
+13
-11
13 Ergänzungen, 11 Löschungen
src/QUI/HtmlSnippets/SnippetTemplateEvent.php
werden angezeigt
mit
59 Ergänzungen
und
42 Löschungen
bin/backend/Snippets.js
+
1
−
1
Zeige Datei @
6e4b9c8e
...
...
@@ -184,7 +184,7 @@ define('package/quiqqer/html-snippets/bin/backend/Snippets', [
if
(
!
this
.
$Project
)
{
return
;
}
console
.
log
(
123
);
require
([
'
package/quiqqer/html-snippets/bin/backend/controls/windows/AddSnippet
'
],
(
AddSnippet
)
=>
{
...
...
This diff is collapsed.
Zum Erweitern klicken.
bin/frontend/gdprReader.js
+
45
−
30
Zeige Datei @
6e4b9c8e
(
function
()
{
'
use strict
'
;
const
loadNode
=
function
(
Node
)
{
if
(
Node
.
getAttribute
(
'
data-qui-html-snippet-gdpr-loaded
'
))
{
return
;
}
const
processSnippetNodes
=
function
(
nodes
)
{
// Gather all HTML snippet nodes ("template" elements with a specific "data-" attribute)
const
SnippetsNodeList
=
document
.
querySelectorAll
(
'
template[data-qui-html-snippet="gdpr"]
'
);
Node
.
innerHTML
=
atob
(
Node
.
innerHTML
);
const
scripts
=
Array
.
from
(
Node
.
getElementsByTagName
(
'
script
'
)
);
SnippetsNodeList
.
forEach
((
SnippetNode
)
=>
{
const
gdprCategory
=
SnippetNode
.
getAttribute
(
'
data-qui-html-snippet-gdpr-category
'
);
scripts
.
forEach
((
script
)
=>
{
const
newScript
=
document
.
createElement
(
'
script
'
);
newScript
.
textContent
=
script
.
textContent
;
// Only decode (and execute) the snippet node, if the corresponding gdpr category was accepted
window
.
GDPR
.
waitForCookieCategoryAcceptance
(
gdprCategory
).
then
(()
=>
{
decodeSnippetNode
(
SnippetNode
);
});
});
};
const
decodeSnippetNode
=
function
(
SnippetNode
)
{
// The node's inner HTML is base64 encoded, turn it back to normal HTML
SnippetNode
.
innerHTML
=
atob
(
SnippetNode
.
innerHTML
);
// The snippet code is in a wrapping <template> node and thus isn't interpreted
// Therefore we have to move all nodes inside this template snippet node into the document
// We do that by iterating over all direct children of the template element and...
Array
.
from
(
SnippetNode
.
content
.
children
).
forEach
(
ChildNode
=>
{
let
NodeToInsert
=
ChildNode
;
let
i
,
len
,
attribute
;
// ...if it is a script tag it needs special treatment
if
(
ChildNode
.
tagName
===
'
SCRIPT
'
)
{
// "script" tags are not executed when moved from the snippet node to the document
// Therefore a new element has to be created instead
// The new element is executed when added to the document
NodeToInsert
=
createExecutableCopyOfScriptNode
(
ChildNode
);
for
(
i
=
0
,
len
=
script
.
attributes
.
length
;
i
<
len
;
i
++
)
{
attribute
=
script
.
attributes
[
i
];
newScript
.
setAttribute
(
attribute
.
name
,
attribute
.
value
);
// Remove the original script node as we are using the copy now
ChildNode
.
remove
();
}
script
.
parentNode
.
replaceChild
(
newScript
,
script
);
// ...moving the child node from inside the template snippet node in front of the snippet node
SnippetNode
.
insertAdjacentElement
(
'
beforebegin
'
,
NodeToInsert
);
});
Node
.
setAttribute
(
'
data-qui-html-snippet-gdpr-loaded
'
,
1
);
Node
.
style
.
display
=
''
;
// ...and deleting the now empty snippet node
SnippetNode
.
remove
()
;
};
const
fetchNodes
=
function
(
nodes
)
{
nodes
.
forEach
((
Node
)
=>
{
const
gdprCategory
=
Node
.
getAttribute
(
'
data-qui-html-snippet-gdpr-category
'
);
const
createExecutableCopyOfScriptNode
=
function
(
ScriptNode
)
{
const
ExecutableScriptNode
=
document
.
createElement
(
'
script
'
);
if
(
window
.
GDPR
.
isCookieCategoryAccepted
(
gdprCategory
))
{
loadNode
(
Node
);
}
else
{
window
.
GDPR
.
waitForCookieCategoryAcceptance
(
gdprCategory
).
then
(()
=>
{
loadNode
(
Node
);
});
}
// Copy the script's text content (the JavaScript code)
ExecutableScriptNode
.
textContent
=
ScriptNode
.
textContent
;
// Copy all the script's attributes
Array
.
from
(
ScriptNode
.
attributes
).
forEach
(
ScriptAttribute
=>
{
ExecutableScriptNode
.
setAttribute
(
ScriptAttribute
.
name
,
ScriptAttribute
.
value
);
});
return
ExecutableScriptNode
;
};
fetchNodes
(
document
.
querySelectorAll
(
'
[data-qui-html-snippet="gdpr"]
'
)
);
processSnippetNodes
(
);
window
.
whenQuiLoaded
().
then
(()
=>
{
fetchNodes
(
document
.
querySelectorAll
(
'
[data-qui-html-snippet="gdpr"]
'
));
});
window
.
whenQuiLoaded
().
then
(
processSnippetNodes
);
})();
This diff is collapsed.
Zum Erweitern klicken.
src/QUI/HtmlSnippets/SnippetTemplateEvent.php
+
13
−
11
Zeige Datei @
6e4b9c8e
...
...
@@ -67,17 +67,19 @@ class SnippetTemplateEvent
continue
;
}
// consider gdpr status
$div
=
'<script '
;
$div
.
=
' data-qui-html-snippet="gdpr"'
;
$div
.
=
' data-qui-html-snippet-gdpr-category="'
.
$snippet
[
'gdpr'
]
.
'"'
;
$div
.
=
' style="display: none"'
;
$div
.
=
' type="text/plain"'
;
$div
.
=
'>'
;
$div
.
=
base64_encode
(
$snippet
[
'snippet'
]);
$div
.
=
'</script>'
;
$Collector
->
append
(
$div
);
$snippetGdprCategory
=
$snippet
[
'gdpr'
];
$snippetContentEncoded
=
base64_encode
(
$snippet
[
'snippet'
]);
$snippetHtml
=
<<<EOF
<template
data-qui-html-snippet="gdpr"
data-qui-html-snippet-gdpr-category="$snippetGdprCategory"
>
$snippetContentEncoded
</template>
EOF;
$Collector
->
append
(
$snippetHtml
);
}
}
}
This diff is collapsed.
Zum Erweitern klicken.
Vorschau
0%
Wiederholen
oder
Neue Datei anhängen
.
Abbrechen
You are about to add
0
people
to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Kommentar speichern
Abbrechen
Bitte
registrieren
oder
Anmelden
zum Kommentieren