Show your code.
Ok mam.
Oceniam z tego: https://codepen.io/Radekol/pen/NYbOro
- //creating a pop up and its elements
Wolłabym normalny jakiś render niż coś co jest budowany przez jQ.
const text =
Czemu przepisujesz do zmiennej?
$('<input>').attr('type','text').addClass('text').prop('disabled', true);
const time = $('<p>').addClass('timer').text('00:00');
const comment = $('<p>').addClass('comment').text('Click spacebar to start.');
const close = $('<div>').addClass('close').text('X');
const count_element = $('<h1>').addClass('counter');
const popUp = $('<div>').addClass('popUp');
prościej można:
const props = [
{ selector: '<div>', text: 'text', classCss: 'text' , props: [{'disabled': true] }
]
$(document).ready( ()=> this.buildUi());
function buildUI() {
props.forEach((prop)=> this.bindtoUI(prop));
}
function bindToUi(prop) {
// tu sie dzieje magia
// jak czegos nie ma to:
if (prop.text)
}
Ta część kodu nie mówi mi absolutnie nic co ma robić:
for (let i=0; i<10; i++) {
let one_tile = $('<div>').addClass('tile');
$(popUp).prepend(one_tile);
}
Wyrzuciłbym do innej metody. Nic mi nie mówi:
tiles.eq(i).text(alfabet[actual_random].toUpperCase());
tiles_value += tiles.eq(i).text();
}
text.prop('disabled', false);
text.focus();
???
let timer = setInterval(function () {
mili++;
if (mili<10) time.text(sec+':0'+mili);
else time.text(sec+':'+mili);
if (mili === 99) {
mili=0;
sec++;
}
Nie łatwiej mu strzykiwać gotową flagę?
Porodzielaj to na sensowne metody, bo kiepsko się to czyta.
I fajnie jakbyś pokazał z githuba kod.