// мне кажется, что ждать полной загрузки страницы тут незачем
document.addEventListener('DOMContentLoaded', () => {
new Slider({
images: ".slider__galary img",
btnPrev: ".btnPrev",
btnNext: ".btnNext",
rate: false
});
});
// хелпер для прослушивания событий
class EventListener {
constructor(ctx, handlers, target) {
this.ctx = ctx;
this.handlers = handlers;
Object.keys(handlers).forEach(event => target.addEventListener(event, this));
}
handleEvent(event) {
const {handlers, ctx} = this;
const {type} = event;
if(typeof handlers[type] !== 'function') return;
handlers[type].call(ctx, event);
}
}
class Slider {
construnctor({images, btnPrev, btnNext, rate, time = 1000}) {
this.images = document.querySelectorAll(images);
this.i = 0;
new EventListener(this, {
click: this.prev
}, document.querySelector(btnPrev));
new EventListener(this, {
click: this.next
}, document.querySelector(btnNext));
if(rate) {
setInterval(() => this.next(), time);
}
}
prev() {
this.images[i].classList.remove("showed");
this.i--;
if(this.i < 0){
this.i = this.images.length - 1;
}
this.images[i].classList.add("showed");
}
next() {
this.images[i].classList.remove("showed");
this.i++;
if(this.i >= this.images.length){
this.i = 0;
}
this.images[i].classList.add("showed");
}
}
class Slider {
constructor({images, btnPrev, btnNext, rate, time}) {
this.images = document.querySelectorAll(images);
this.btnPrev = btnPrev;
this.btnNext = btnNext;
this.rate = rate;
this.time = time || 1000;
this.counter = 0;
document.querySelector(this.btnPrev).onclick = this.prev.bind(this);
document.querySelector(this.btnNext).onclick = this.next.bind(this);
if (this.rate) {
setInterval(this.next.bind(this), this.time);
}
}
prev() {
this.images[this.counter].classList.remove("showed");
this.counter--;
if (this.counter < 0) {
this.counter = this.images.length - 1;
}
this.images[this.counter].classList.add("showed");
}
next() {
this.images[this.counter].classList.remove("showed");
this.counter++;
if (this.counter >= this.images.length) {
this.counter = 0;
}
this.images[this.counter].classList.add("showed");
}
}
<html><body>
<a download="9dksk239xwd.txt" id="test" href="#">test</a>
<script type="application/javascript">
var type = 'data:application/octet-stream;base64, ';
var text = 'jxowsjsivneic';
var base = btoa(text);
var res = type + base;
document.getElementById('test').href = res;
</script>
</body></html>
npm uninstall -g create-react-app
npm install create-react-app
class Popup{
constructor(options) {
this.modal = $(options.modal);
this.overlay = $(options.overlay);
this.overlay.on('click', this.close.bind(this));
}
open(content){
this.modal.html(content);
this.modal.addClass('open');
this.overlay.addClass('open');
}
close(){
this.modal.removeClass('open');
this.overlay.removeClass('');
}
}
this.modal = $("options.modal");Зачем кавычки?
this.overlay = $("options.overlay");
function initBlock(name) {
$("#" + name + "__btn").on("click", function() {
var Ups = parseInt($("#" + name + "__val").val());
var Val = parseInt($("#" + name + "__record").html());
var Max = $("#" + name + "__record");
if (Ups >= Val) {
$(Max).html(Ups);
}
});
}
initBlock("one");
initBlock("two");