I used this small script on a page showing a countdown to a date with the oldschool flipclock animation. As it was a multilanguage website i also added an array with several time definitions depending on the language the user has chosen. For all of this the flipdown JS library by PButcher is used.
<script>
document.addEventListener('DOMContentLoaded', () => {
switch('{{ appLanguage }}') {
case "es":
theheadings= ["Días", "horas", "minutos", "segundos"];
break;
case "en":
theheadings= ["Days", "Hours", "Minutes", "Seconds"];
break;
case "de":
theheadings= ["Tage", "Stunden", "Minuten", "Sekunde...
Um heraus zu finden ob der Besucher einer Seite selbige mit seinem Mobiltelefon abruft, hab ich das folgende kleine Javascript entdeckt das mit dem windows.matchmedia Tag arbeitet.
<script>
$(document).ready(function(){
if(window.matchMedia("(max-width: 767px)").matches){
// The viewport is less than 768 pixels wide
alert("This is a mobile device.");
} else{
// The viewport is at least 768 pixels wide
alert("This is a tablet or desktop.");
}
});
</script>
Ich hab nicht nachgeforscht ob matchMedia neben der Seitenbreite noch weitere Daten wie Browser oder device abcheckt, aber fuer eine schnel...
Get the image mime info via PHP of an manual generated object by its ID in the array with images to show them.
<?php
$tid = $_GET['id'];
$map1 = {
1=>'2014/2014-06-28.jpg',
2=>'2014/2014-06-29.jpg',
3=>'2014/2014-06-30.jpg',
4=>'2014/hund.jpg',
5=>'2014/katze.jpg',
6=>'2014/maus.jpg'
}
$path = $map1[$tid];
$str = file_get_contents($path);
echo $str;
?>