Skip to content

Instantly share code, notes, and snippets.

View beatrizsmerino's full-sized avatar
🏠
Working from home

Beatriz Sopeña Merino beatrizsmerino

🏠
Working from home
View GitHub Profile
@beatrizsmerino
beatrizsmerino / get-list-class-css.js
Created July 29, 2020 11:15
Get list of Css class use in the HTML file
function getListClassCss() {
let list = [];
let selectorsAll = document.querySelectorAll("[class]");
selectorsAll.forEach((event) => {
let selectorClassAll = event.getAttribute("class").split(" ");
selectorClassAll.forEach(
(classCss) => {
if (classCss.length > 0 && list.indexOf(classCss) < 0) {
@beatrizsmerino
beatrizsmerino / reset.css
Last active June 4, 2020 14:01
Reset css
*,
&:after,
&:before {
margin: 0;
padding: 0;
border-box: box-sizing;
font-family: sans-serif;
}
html, body, div, span, applet, object, iframe,
@beatrizsmerino
beatrizsmerino / _abstracts-mixins-variables-root.scss
Last active May 15, 2020 08:43
How use a variable root css in scss
// ABSTRACTS - MIXINS
// variables-root
// =================================================
// Creation of the mixin: root-prop
@mixin root-prop($prop: null, $value: null) {
@if ($prop and $value) {
#{$prop}: $value;
@beatrizsmerino
beatrizsmerino / folder-files.txt
Last active March 13, 2023 23:46
Commands Git
FOLDERS & FILES
---------------------------
-> Entrar dentro de un directorio
cd <nameFolder>
@beatrizsmerino
beatrizsmerino / index.html
Last active February 10, 2020 15:26
Service worker
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Mi primer Service worker</title>
</head>
@beatrizsmerino
beatrizsmerino / svgMe-javascriptES5.js
Last active March 13, 2023 23:46
Function 'svgMe' with jquery and vanilla javascript. This function converts an `<img>` tag, with a `.svg` extention and a class `svgMe`, into a `<svg>` tag. Example: https://codepen.io/beatrizsmerino/pen/pooMYdw
/**
* @function svgMe
* @description Version with Vanilla Javascript ES5
* Converts an `<img>` tag, with a `.svg` extention and a class `svgMe`, into a `<svg>` tag.
* @return {object} Return the file svg
*/
function svgMe() {
console.info(
"%cSvgMe__javascriptES5",
"padding: 0.2rem 0.5rem; background-color: rgb(17, 176, 200); color: #fff;"
@beatrizsmerino
beatrizsmerino / cleanStorage.js
Created December 26, 2019 23:38
Clean the browser storage to delete the POST variables from the forms and prevent them from being resent when clicking on the button again.
if(window.history.replaceState){
window.history.replaceState(null, null, window.location.href);
}
@beatrizsmerino
beatrizsmerino / verifyNum.js
Last active March 13, 2023 23:46
Verify if it is a number
function validation(num) {
if (num == "undefined" || num == null || num == "") {
console.log("Inserta un número.");
return 0;
} else {
if (isNaN(num) && num !== "") {
console.log("Ups... " + "'" + + num + "'" + " no es un número.");
return 1;
} else {
if (num % 1 == 0) {
@beatrizsmerino
beatrizsmerino / popup.js
Last active October 22, 2019 16:26
Pop up inside the html to position it above all
$(document).ready(function () {
// open popup
$(".popup__button-open").on("click", function () {
var $this = $(this),
$thisPopUp = $this.closest(".swiper-slide").find('.popup');
$thisPopUp.clone().appendTo(".global-locations").addClass("is-view");
@beatrizsmerino
beatrizsmerino / clickTarget-javascript.js
Last active April 2, 2020 15:00
Check element on click
window.addEventListener("click", function (e) {
e.preventDefault();
console.dir(e.target);
});