From: Marius Gavrilescu Date: Mon, 4 May 2015 10:41:47 +0000 (+0300) Subject: Use const wherever possible in js/ X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=65d5cb3b6007fa0bc758722983b3f0afefc02f2e;p=gruntmaster-page.git Use const wherever possible in js/ --- diff --git a/js/00-strict.js b/js/00-strict.js index e08ecdb..dccfeb1 100644 --- a/js/00-strict.js +++ b/js/00-strict.js @@ -1,2 +1,2 @@ 'use strict'; -var $; +let $; diff --git a/js/05-ki.js b/js/05-ki.js index 59104b4..c2960a0 100644 --- a/js/05-ki.js +++ b/js/05-ki.js @@ -3,7 +3,7 @@ * Copyright (c) 2014 Denis Ciccale (@tdecs) * Released under MIT license */ -!function (b, c, d, e) { +(function (b, c, d, e) { /* * init function (internal use) @@ -68,4 +68,4 @@ // representation instead of an object splice: c.splice } -}(document, [], 'prototype'); +})(document, [], 'prototype'); diff --git a/js/05-makedom.js b/js/05-makedom.js index 68026a1..389fe4c 100644 --- a/js/05-makedom.js +++ b/js/05-makedom.js @@ -1,5 +1,5 @@ function m(html) { - var div = document.createElement("div"); + const div = document.createElement("div"); div.innerHTML = html; return div.firstChild; } diff --git a/js/80-sidebar.js b/js/80-sidebar.js index 505dc0f..2f6ca8a 100644 --- a/js/80-sidebar.js +++ b/js/80-sidebar.js @@ -1,6 +1,6 @@ $(function() { if(!document.getElementById('sidebar')) { - let content = $('main')[0]; + const content = $('main')[0]; content.innerHTML = '
' + content.innerHTML + '
'; content.classList.add('row'); } diff --git a/js/90-divine-format.js b/js/90-divine-format.js index ab5a5f2..da48856 100644 --- a/js/90-divine-format.js +++ b/js/90-divine-format.js @@ -1,4 +1,4 @@ -var ext_table = { +const ext_table = { 'c' : 'C', 'cc' : 'CPP', @@ -30,8 +30,8 @@ var ext_table = { } function divine_format() { - var filename = $('#prog')[0].value; - var ext = /\.([^.]*)$/.exec(filename)[1]; + const filename = $('#prog')[0].value; + const ext = /\.([^.]*)$/.exec(filename)[1]; if(ext_table[ext]) $('#prog_format')[0].value = ext_table[ext]; diff --git a/js/90-form.js b/js/90-form.js index 0b76776..aa5e9ef 100644 --- a/js/90-form.js +++ b/js/90-form.js @@ -1,9 +1,9 @@ $(function(){ - let result = $('#result')[0]; + const result = $('#result')[0]; $('.jsform > input[type="submit"]').on('click', e => { - let form_data = new FormData(this.parentElement); - let form = this.parentNode; - let xhr = new XMLHttpRequest(); + const form_data = new FormData(this.parentElement); + const form = this.parentNode; + const xhr = new XMLHttpRequest(); xhr.open(form.getAttribute('method'), form.getAttribute('action')); xhr.onload = () => result.innerHTML = this.responseText; xhr.onerror = () => result.innerHTML = 'Error!'; diff --git a/js/90-nav.js b/js/90-nav.js index 03dcb82..b4127d6 100644 --- a/js/90-nav.js +++ b/js/90-nav.js @@ -9,8 +9,8 @@ const NAVS = { }; $(function(){ - let path = location.pathname; - for (let nav in NAVS) + const path = location.pathname; + for (const nav in NAVS) if(path.match(NAVS[nav])) $('#nav-' + nav)[0].classList.add('active'); }); diff --git a/js/90-themes.js b/js/90-themes.js index aa2cdc9..a9d9b51 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -9,18 +9,15 @@ function set_style(name, trans){ } $(function() { - var theme_ul = '