33 lines
885 B
JavaScript
33 lines
885 B
JavaScript
class incommon{
|
|
$(name){
|
|
return document.querySelector(name);
|
|
}
|
|
_(name){
|
|
return document.querySelectorAll(name);
|
|
}
|
|
|
|
customMethods(){
|
|
Element.prototype.add=function(name){
|
|
this.classList.add(name)
|
|
}
|
|
Element.prototype.remove=function(name){
|
|
this.classList.remove(name)
|
|
}
|
|
Element.prototype.none = function() {
|
|
this.style.display = "none"
|
|
}
|
|
Element.prototype.show = function() {
|
|
this.style.display = "block"
|
|
}
|
|
}
|
|
getRandom(min, max) {
|
|
const floatRandom = Math.random()
|
|
const difference = max - min
|
|
const random = Math.round(difference * floatRandom)
|
|
const randomWithinRange = random + min
|
|
return randomWithinRange
|
|
}
|
|
}
|
|
|
|
let { $, _ ,customMethods,getRandom} = new incommon()
|
|
customMethods() |