This file contains hidden or 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
function convertValueType ( $value ) { | |
$valueConvert = intval($value); | |
if ($value === "0") { | |
$value = intval($value); | |
} else if ($value === true || $value === "true") { | |
$value = true; | |
} else if ($value === false || $value === "false") { | |
$value = false; | |
} else if ($value === null || $value === "null") { |
This file contains hidden or 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
<?php | |
$html = "My name is {name}, {forname} !"; | |
$replaceBy = array( | |
"{name}" => "John", | |
"{forname}" => "Doe", | |
); | |
$html = str_replace(array_keys($replaceBy), array_values($replaceBy), $html); | |
var_dump($html); |
This file contains hidden or 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
<?php | |
// On check d'abord si on a déjà était "routé" par le système de langue en "fr" ou "en" (ou les langues disponible) | |
$url = trim($_SERVER['REQUEST_URI'], "/"); | |
// On définis les langues possibles | |
$langList = ["fr", "en"]; | |
// On prépare le regex qui va vérifier si l'url contient le "routage" par la langue | |
$langRegex = ""; | |
$langRegex1 = array_map(function($value) { return "$value$"; }, $langList); | |
$langRegex2 = array_map(function($value) { return "$value\/"; }, $langList); |
This file contains hidden or 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
<!-- https://codepen.io/w-jerome/pen/ggyedz --> | |
<ul class="accordion__list"> | |
<li class="accordion__item"> | |
<div class="accordion__header"> | |
<span class="accordion__title"> | |
Item | |
</span> | |
<button type="button" class="accordion__btn" style="margin-left:20px;">▾</button> | |
</div> |
This file contains hidden or 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
function canGoFullscreen() { | |
var el = document.body; | |
var check = typeof el.requestFullscreen !== 'undefined' || | |
typeof el.mozRequestFullScreen !== 'undefined' || | |
typeof el.webkitRequestFullscreen !== 'undefined' || | |
typeof el.msRequestFullscreen !== 'undefined' || | |
typeof document.exitFullscreen !== 'undefined' || | |
typeof document.mozCancelFullScreen !== 'undefined' || | |
typeof document.webkitExitFullscreen !== 'undefined'; |
This file contains hidden or 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
// vanillaJS : window.scrollTo(0,0) | |
var $links = document.querySelectorAll('a[href*="#"]'); | |
for (var i = 0; i < $links.length; i++) { | |
$links[i].onclick = function() { | |
var selector = this.href.split('#')[1]; | |
var $target = document.querySelector('#'+selector); |
This file contains hidden or 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
function addClass (el, className) { | |
if (typeof el !== 'object' || typeof className !== 'string') { return } | |
if (el.classList) { | |
el.classList.add(className); | |
} else { | |
el.className += ' ' + className; | |
} | |
} |
This file contains hidden or 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
var $section = document.querySelectorAll('.section'), | |
currentSectionID = '', | |
scroll; | |
window.onscroll = function() { | |
scroll = document.body.scrollTop; | |
for (var i = 0; i < $section.length; i++) { | |
if (currentSectionID !== $section[i].id) { |
This file contains hidden or 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
<!-- | |
https://stackoverflow.com/questions/45396280/customizing-increment-arrows-on-input-of-type-number-using-css | |
https://www.w3schools.com/jsref/met_number_stepup.asp | |
--> | |
<link media="all" rel="stylesheet" href="./style.css"> | |
<div> | |
<button type="button" onclick="this.parentNode.querySelector('[type=number]').stepDown();"> | |
- |
This file contains hidden or 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
var browser = (navigator.userAgent.indexOf("Chrome") > -1) ? 'chrome' : (navigator.userAgent.indexOf("Safari") > -1) ? 'safari' : (navigator.userAgent.indexOf("Opera") > -1) ? 'opera' : (navigator.userAgent.indexOf("Firefox") > -1) ? 'firefox' : (navigator.userAgent.indexOf("MSIE") > -1 || navigator.userAgent.indexOf("Trident") > -1) ? 'ie' : 'unknow'; |
OlderNewer