div.innerHTML = html;
return div.firstChild;
}
+
+function q(selector) {
+ return document.querySelector(selector);
+}
}
$(function() {
- modal = $('.modal')[0];
- backdrop = $('.backdrop')[0];
+ modal = q('.modal');
+ backdrop = q('.backdrop');
$(modal).on('transitionend', el => {
if(!document.body.classList.contains('modal-open'))
modal.classList.add('hidden');
$(function() {
if(!document.getElementById('sidebar')) {
- const content = $('main')[0];
+ const content = q('main');
content.innerHTML = '<div class="col-md-9">' + content.innerHTML + '</div><aside id="sidebar" class="col-md-3"></aside>';
content.classList.add('row');
}
}
function divine_format() {
- const filename = $('#prog')[0].value;
+ const filename = q('#prog').value;
const ext = /\.([^.]*)$/.exec(filename)[1];
if(ext_table[ext])
- $('#prog_format')[0].value = ext_table[ext];
+ q('#prog_format').value = ext_table[ext];
}
$(() => $('#prog').on('change', divine_format));
$(function(){
- const result = $('#result')[0];
+ const result = q('#result');
$('.jsform > input[type="submit"]').on('click', e => {
const form_data = new FormData(this.parentElement);
const form = this.parentNode;
$(function(){
- const nav = $('nav')[0];
+ const nav = q('nav');
nav.classList.add('hidden-xs');
- $('#title')[0].insertAdjacentHTML('beforebegin', '<div class="text-center visible-xs-block">Tap title to toggle menu</div>');
+ q('#title').insertAdjacentHTML('beforebegin', '<div class="text-center visible-xs-block">Tap title to toggle menu</div>');
$('#title').on('click', () => nav.classList.toggle('hidden-xs'));
});
const path = location.pathname;
for (const nav in NAVS)
if(path.match(NAVS[nav]))
- $('#nav-' + nav)[0].classList.add('active');
+ q('#nav-' + nav).classList.add('active');
});
setTimeout(() => document.body.classList.remove('transition-color'), 1000);
}
$('link[title]').each(e => e.disabled = true);
- $('link[title="' + name + '"]')[0].disabled = false;
+ q('link[title="' + name + '"]').disabled = false;
localStorage.setItem("theme", name);
}
'<li><a role="button" data-theme="cyborg">Black</a>' +
'<li><a role="button" data-theme="slate">Grey</a>' +
'<li><a role="button" data-theme="readable">White</a></ul>';
- const sidebar = $('#sidebar')[0];
+ const sidebar = q('#sidebar');
sidebar.insertBefore(m(theme_ul), sidebar.firstChild);
$('#themes a').on('click', e => set_style(e.target.dataset.theme, true));
});
data.contests.forEach(e => contests[e.contest] = 1);
clean_tracker();
- $('#tracker_userlink')[0].innerHTML = data.name;
- $('#tracker_solved')[0].innerHTML = solvednr;
- $('#tracker_attempted')[0].innerHTML = attemptednr;
- $('#tracker_contests')[0].innerHTML = data.contests.length;
- $('#tracker_log')[0].setAttribute('href', '/log/?owner=' + user);
+ q('#tracker_userlink').innerHTML = data.name;
+ q('#tracker_solved').innerHTML = solvednr;
+ q('#tracker_attempted').innerHTML = attemptednr;
+ q('#tracker_contests').innerHTML = data.contests.length;
+ q('#tracker_log').setAttribute('href', '/log/?owner=' + user);
if(location.pathname == '/pb/')
$('table .name a').each(el => {
function start_tracking(user){
localStorage.setItem('tracker_username', user);
- $('#tracker_userlink')[0].setAttribute('href', '/us/' + user);
- $('#tracker_userlink')[0].innerHTML = user;
+ q('#tracker_userlink').setAttribute('href', '/us/' + user);
+ q('#tracker_userlink').innerHTML = user;
tracker.classList.remove('hidden');
update_tracker();
const lastfetch = localStorage.getItem('tracker_lastfetch');
$(function(){
tracker = m('<div id="tracker" class="hidden">Tracking <a id="tracker_userlink"></a>.<br><a id="tracker_stop" role="button">Stop tracking</a><br><a id="tracker_log">Job log</a><dl class="dl-horizontal"><dt>Solved</dt> <dd id="tracker_solved">?</dd><dt>Attempted</dt> <dd id="tracker_attempted">?</dd><dt>Contests</dt> <dd id="tracker_contests">?</dd></dl></div>');
- const sidebar = $('#sidebar')[0];
+ const sidebar = q('#sidebar');
sidebar.insertBefore(tracker, sidebar.firstChild);
$('#tracker_stop').on('click', stop_tracking);
$('#track_user').on('click', function() { stop_tracking(); start_tracking(this.dataset.user) });
$(function(){
- const sidebar = $('#sidebar')[0];
+ const sidebar = q('#sidebar');
const login = document.createElement('div');
login.innerHTML = '<a role="button" id="login" class="show">Log in</a>';
sidebar.insertBefore(login, sidebar.firstChild);