Skip to content

Instantly share code, notes, and snippets.

View FreePhoenix888's full-sized avatar
Empty your mind, be formless, shapeless - like water

FreePhoenix888

Empty your mind, be formless, shapeless - like water
View GitHub Profile
@FreePhoenix888
FreePhoenix888 / index.html
Created July 4, 2020 07:54
GeneralIndexHtml
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="css/style.min.css" />
let isMobile = {
Android: function() {return navigator.userAgent.match(/Android/i);},
BlackBerry: function() {return navigator.userAgent.match(/BlackBerry/i);},
iOS: function() {return navigator.userAgent.match(/iPhone|iPad|iPod/i);},
Opera: function() {return navigator.userAgent.match(/Opera Mini/i);},
Windows: function() {return navigator.userAgent.match(/IEMobile/i);},
any: function() {return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());}
};
@FreePhoenix888
FreePhoenix888 / ArrowForDropDownMenu.js
Last active July 4, 2020 08:11
ArrowForDropDownMenu
let body=document.querySelector('body');
if(isMobile.any()){
body.classList.add('touch');
let arrow=document.querySelectorAll('.arrow');
for(i=0; i<arrow.length; i++){
let thisLink=arrow[i].previousElementSibling;
let subMenu=arrow[i].nextElementSibling;
let thisArrow=arrow[i];
thisLink.classList.add('parent');
let isMobile = {
Android: function() {return navigator.userAgent.match(/Android/i);},
BlackBerry: function() {return navigator.userAgent.match(/BlackBerry/i);},
iOS: function() {return navigator.userAgent.match(/iPhone|iPad|iPod/i);},
Opera: function() {return navigator.userAgent.match(/Opera Mini/i);},
Windows: function() {return navigator.userAgent.match(/IEMobile/i);},
any: function() {return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());}
};
let body=document.querySelector('body');
if(isMobile.any()){
@FreePhoenix888
FreePhoenix888 / imagearray.php
Created July 23, 2020 05:53
Image array php
<?php
image = get_field("");
if (!empty(image)) :
?>
<img src="<?php echo image["url"] ?>" alt="<?php echo image["alt"] ?>" class="">
<?php endif ?>
function getLastDayOfMonth(year, month) {
let date = new Date(year, month + 1, 0);
return date.getDate();
}
function getSecondsToday() {
let now = new Date();
let today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
let diff = now - today; // разница в миллисекундах
return Math.round(diff / 1000); // получаем секунды
}
alert( getSecondsToday() );
function getSecondsToTomorrow() {
let now = new Date();
let tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate()+1);
let diff = tomorrow - now;
return Math.round(diff / 1000);
}
function uniqueArray(arr) {
return Array.from(new Set(arr));
}
function aclean(arr) {
let map = new Map();
for (let word of arr) {
// разбиваем слово на буквы, сортируем и объединяем снова в строку
let sorted = word.toLowerCase().split("").sort().join(""); // (*)
map.set(sorted, word);
}
return Array.from(map.values());