All my js files now pass eslint tests
This commit is contained in:
parent
765a314a7d
commit
a27268bcbb
31 changed files with 39 additions and 37 deletions
|
|
@ -1,3 +1,4 @@
|
|||
/* global alertify, store */
|
||||
var feature = {
|
||||
addEventListener : !!window.addEventListener,
|
||||
querySelectorAll : !!document.querySelectorAll
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* global Autolinker */
|
||||
//the autlinker object
|
||||
var autolinker = new Autolinker();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* global L */
|
||||
//This code runs on page load and looks for <div class="map">, then adds map
|
||||
var mapDivs = document.querySelectorAll('.map');
|
||||
for (var i = 0; i < mapDivs.length; i++) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* global L */
|
||||
if ('geolocation' in navigator) {
|
||||
var button = document.querySelector('#locate');
|
||||
if (button.addEventListener) {
|
||||
|
|
@ -81,7 +82,7 @@ function addMap(latitude, longitude, places) {
|
|||
var noLocation = document.createElement('option');
|
||||
noLocation.setAttribute('selected', 'selected');
|
||||
noLocation.setAttribute('value', 'no-location');
|
||||
noLocText = document.createTextNode('Select no location');
|
||||
var noLocText = document.createTextNode('Select no location');
|
||||
noLocation.appendChild(noLocText);
|
||||
selectEl.appendChild(noLocation);
|
||||
form.insertBefore(selectEl, div);
|
||||
|
|
@ -194,8 +195,16 @@ function addMap(latitude, longitude, places) {
|
|||
method: 'post',
|
||||
body: formData
|
||||
})
|
||||
.then(status)
|
||||
.then(json)
|
||||
.then(function (response) {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
return Promise.reject(new Error(response.statusText));
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (placeJson) {
|
||||
//create the slug from the url
|
||||
var urlParts = placeJson.split('/');
|
||||
|
|
@ -206,7 +215,7 @@ function addMap(latitude, longitude, places) {
|
|||
form.removeChild(document.querySelector('#place-latitude'));
|
||||
form.removeChild(document.querySelector('#place-longitude'));
|
||||
var labels = document.querySelectorAll('.place-label');
|
||||
for (i = 0; i < labels.length; ++i) {
|
||||
for (var i = 0; i < labels.length; ++i) {
|
||||
form.removeChild(labels[i]);
|
||||
}
|
||||
form.removeChild(document.querySelector('#place-submit'));
|
||||
|
|
@ -270,15 +279,3 @@ function getLongitudeFromMapboxMarker(latlng) {
|
|||
|
||||
return location[1];
|
||||
}
|
||||
|
||||
function status(response) {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
return Promise.reject(new Error(response.statusText));
|
||||
}
|
||||
}
|
||||
|
||||
function json(response) {
|
||||
return response.json();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* global L */
|
||||
var button = document.querySelector('#locate');
|
||||
|
||||
if (button.addEventListener) {
|
||||
|
|
|
|||
70
public/build/assets/js/form-save-14b9f120ac.js
Normal file
70
public/build/assets/js/form-save-14b9f120ac.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* global alertify, store */
|
||||
var feature = {
|
||||
addEventListener : !!window.addEventListener,
|
||||
querySelectorAll : !!document.querySelectorAll
|
||||
};
|
||||
if(feature.addEventListener && feature.querySelectorAll) {
|
||||
init();
|
||||
}
|
||||
function init() {
|
||||
var keys = getKeys();
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (store.get(keys[i])) {
|
||||
var formId = keys[i].split('~')[1];
|
||||
document.getElementById(formId).value = store.get(keys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
var timerId = window.setInterval(function() {
|
||||
var saved = false;
|
||||
var inputs = document.querySelectorAll('input[type=text], textarea');
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
var key = getFormElement(inputs[i]).id + '~' + inputs[i].id;
|
||||
if (store.get(key) !== inputs[i].value && inputs[i].value !== '') {
|
||||
store.set(key, inputs[i].value);
|
||||
saved = true;
|
||||
}
|
||||
}
|
||||
if (saved === true) {
|
||||
alertify.logPosition('top right');
|
||||
alertify.success('Auto saved text');
|
||||
}
|
||||
}, 5000);
|
||||
var forms = document.querySelectorAll('form');
|
||||
for (var f = 0; f < forms.length; f++) {
|
||||
var form = forms[f];
|
||||
form.addEventListener('submit', function() {
|
||||
window.clearInterval(timerId);
|
||||
var formId = form.id;
|
||||
var storedKeys = store.keys();
|
||||
for (var i = 0; i < storedKeys.length; i++) {
|
||||
if (storedKeys[i].indexOf(formId) > -1) {
|
||||
store.remove(storedKeys[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function getKeys() {
|
||||
var keys = [];
|
||||
var formFields = document.querySelectorAll('input[type=text], textarea');
|
||||
for (var f = 0; f < formFields.length; f++) {
|
||||
var parent = getFormElement(formFields[f]);
|
||||
if (parent !== false) {
|
||||
var key = parent.id + '~' + formFields[f].id;
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
function getFormElement(elem) {
|
||||
if (elem.nodeName.toLowerCase() !== 'body') {
|
||||
var parent = elem.parentNode;
|
||||
if (parent.nodeName.toLowerCase() === 'form') {
|
||||
return parent;
|
||||
} else {
|
||||
return getFormElement(parent);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
BIN
public/build/assets/js/form-save-14b9f120ac.js.br
Normal file
BIN
public/build/assets/js/form-save-14b9f120ac.js.br
Normal file
Binary file not shown.
BIN
public/build/assets/js/form-save-14b9f120ac.js.gz
Normal file
BIN
public/build/assets/js/form-save-14b9f120ac.js.gz
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26
public/build/assets/js/links-c394f9c920.js
Normal file
26
public/build/assets/js/links-c394f9c920.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* global Autolinker */
|
||||
//the autlinker object
|
||||
var autolinker = new Autolinker();
|
||||
|
||||
//the youtube regex
|
||||
var ytidregex = /watch\?v=([A-Za-z0-9\-_]+)/;
|
||||
|
||||
//grab the notes and loop through them
|
||||
var notes = document.querySelectorAll('.e-content');
|
||||
for (var i = 0; i < notes.length; i++) {
|
||||
//get Youtube ID
|
||||
var ytid = notes[i].textContent.match(ytidregex);
|
||||
if (ytid !== null) {
|
||||
var id = ytid[1];
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.classList.add('youtube');
|
||||
iframe.setAttribute('src', '//www.youtube.com/embed/' + id);
|
||||
iframe.setAttribute('frameborder', 0);
|
||||
iframe.setAttribute('allowfullscreen', 'true');
|
||||
notes[i].appendChild(iframe);
|
||||
}
|
||||
//now linkify everything
|
||||
var orig = notes[i].innerHTML;
|
||||
var linked = autolinker.link(orig);
|
||||
notes[i].innerHTML = linked;
|
||||
}
|
||||
BIN
public/build/assets/js/links-c394f9c920.js.br
Normal file
BIN
public/build/assets/js/links-c394f9c920.js.br
Normal file
Binary file not shown.
BIN
public/build/assets/js/links-c394f9c920.js.gz
Normal file
BIN
public/build/assets/js/links-c394f9c920.js.gz
Normal file
Binary file not shown.
16
public/build/assets/js/maps-a6a01a253b.js
Normal file
16
public/build/assets/js/maps-a6a01a253b.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* global L */
|
||||
//This code runs on page load and looks for <div class="map">, then adds map
|
||||
var mapDivs = document.querySelectorAll('.map');
|
||||
for (var i = 0; i < mapDivs.length; i++) {
|
||||
var mapDiv = mapDivs[i];
|
||||
var latitude = mapDiv.dataset.latitude;
|
||||
var longitude = mapDiv.dataset.longitude;
|
||||
L.mapbox.accessToken = 'pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w';
|
||||
var map = L.mapbox.map(mapDiv, 'jonnybarnes.gnoihnim')
|
||||
.setView([latitude, longitude], 15)
|
||||
.addLayer(L.mapbox.tileLayer('jonnybarnes.gnoihnim', {
|
||||
detectRetina: true
|
||||
}));
|
||||
L.marker([latitude, longitude]).addTo(map);
|
||||
map.scrollWheelZoom.disable();
|
||||
}
|
||||
BIN
public/build/assets/js/maps-a6a01a253b.js.br
Normal file
BIN
public/build/assets/js/maps-a6a01a253b.js.br
Normal file
Binary file not shown.
BIN
public/build/assets/js/maps-a6a01a253b.js.gz
Normal file
BIN
public/build/assets/js/maps-a6a01a253b.js.gz
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue