Skip to content

Instantly share code, notes, and snippets.

View nanna-dk's full-sized avatar

Nanna nanna-dk

View GitHub Profile
/**
* Source: https://codyhouse.co/ds/components/info/swipe-content
* To activate the touch gesture detection for a specific element, add the js-swipe class to that element.
*/
const runSwipeContent = () => {
const swipeEl = document.querySelectorAll('.js-swipe');
class SwipeContent {
constructor(element) {
@nanna-dk
nanna-dk / setup.typoscript
Created June 14, 2022 07:10
Typo3 typscript typenum for new, custom pages
page_29051986 = PAGE
page_29051986 {
typeNum = 29051986
config {
xhtml_cleaning = 0
admPanel = 0
disableAllHeaderCode = 1
additionalHeaders = Content-type:text/html
debug = 0
@nanna-dk
nanna-dk / parseFeed.php
Created September 30, 2021 10:20
PHP proxy for xml/rss feeds - sets headers (domains and subdomains) to fix CORS issues. Works with POST and GET.
<?php
/*
* PHP Proxy: Outputs content with appropiate headers to fix CORS issues.
* Responds to both HTTP GET and POST requests
* Usage in javascript: thisFile.php?url=" + encodeURIComponent(feedUrl) + "&mimeType=application/rss+xml";
*/
// Get the url of to be proxied
// Is it a POST or a GET?
if (isset($_POST['url']) || isset($_GET['url'])) {
@nanna-dk
nanna-dk / Scroll-progress-indicator.js
Last active September 17, 2021 11:33
Accessible scroll progress indicator
<script>
document.addEventListener('DOMContentLoaded', () => {
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
if (reduceMotion.matches) {
return;
}
let scrollPosition = 0;
let tick = false;
const scrollProgress = () => {
document.addEventListener('DOMContentLoaded', function() {
var lang = document.documentElement.lang;
var translations;
if (lang == 'da') {
translations = {
'pause': 'Stop afspilning (brug Enter tast)',
'play': 'Afspil (brug Enter tast)'
}
} else {
translations = {
@nanna-dk
nanna-dk / secondsToHms.js
Created April 28, 2021 11:17
Seconds to hours, minutes and seconds
var lang = navigator.language || navigator.userLanguage;
if (lang == 'da' || lang == 'da-DK') {
t = {
"hr": "time",
"hrs": "timer",
"min": "minut",
"mins": "minutter",
"sec": "sekund",
"secs": "sekunder"
}
@nanna-dk
nanna-dk / 23video-events.js
Created October 29, 2020 13:19 — forked from steffentchr/23video-events.js
A sample script for GlueFrame, illustrating how to implement a generic analytics tag, which listens to events from 23 Video player.
(function(){
var identifiedFrames = [];
// Method to run any reporting
var report = function(Player, event, playing, duration) {
Player.get('currentTime', function(currentTime){
Player.get('duration', function(duration){
console.log(event, playing, currentTime, duration);
});
});
@nanna-dk
nanna-dk / multiple-slick-slideshows.js
Created January 29, 2020 14:22
Multiple slick sliders
$(function () {
var $slideshow = $(".carousel");
$slideshow.each(function () {
if ($(this).is(".type-one-carousel")) {
$(this).slick({
dots: true,
infinite: true,
slidesToShow: 2
@nanna-dk
nanna-dk / get-average-color-from-image.js
Last active September 24, 2019 09:15
Get average color of image via Javascript
Setting the BODY's background to the average color in the following image:
<img id="i" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBKRXhpZgAASUkqAAgAAAADABoBBQABAAAAMgAAABsBBQABAAAAOgAAACgBAwABAAAAAgAAAAAAAAAAcDg5gJaYAABwODmAlpgA/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxERExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAqgDiAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX2
@nanna-dk
nanna-dk / svg.html
Created March 12, 2019 10:09
Change opacity of an area based on mouse position
<!DOCTYPE html>
<html>
<head>
<style> .one{
opacity:.5;
}
</style>
</head>