eslint errors fix

pull/2197/head
maxgrapps 6 years ago
parent bb7a36317f
commit 972cc159d6
  1. 96
      apps/block_scout_web/assets/js/pages/favorites.js
  2. 34
      apps/block_scout_web/assets/js/pages/network-search.js

@ -1,59 +1,57 @@
import $ from 'jquery'
var favoritesQuantity = 0,
favoritesContainer = $(".js-favorites-tab"),
favoritesNetworksUrls = [];
favoritesContainer = $('.js-favorites-tab'),
favoritesNetworksUrls = []
if (localStorage.getItem("favoritesNetworksUrls") === null) {
localStorage.setItem("favoritesNetworksUrls", JSON.stringify(favoritesNetworksUrls));
if (localStorage.getItem('favoritesNetworksUrls') === null) {
localStorage.setItem('favoritesNetworksUrls', JSON.stringify(favoritesNetworksUrls))
} else {
favoritesNetworksUrls = JSON.parse(localStorage.getItem("favoritesNetworksUrls"));
favoritesNetworksUrls = JSON.parse(localStorage.getItem('favoritesNetworksUrls'))
}
$(document).on("change", ".network-selector-item-favorite input[type='checkbox']", function () {
var networkUrl = $(this).attr("data-url"),
thisStatus = $(this).is(":checked"),
parent = $(".network-selector-item[data-url='" + networkUrl +"'").clone(),
workWith = $(".network-selector-item[data-url='" + networkUrl +"'");
// Add new checkbox status to same network in another tabs
$(".network-selector-item-favorite input[data-url='" + networkUrl +"']").prop("checked", thisStatus);
// Push or remove favorite networks to array
var found = $.inArray(networkUrl, favoritesNetworksUrls);
if (found < 0 && thisStatus == true) {
favoritesNetworksUrls.push(networkUrl);
} else {
var index = favoritesNetworksUrls.indexOf(networkUrl);
if(index!=-1){
favoritesNetworksUrls.splice(index, 1);
}
}
// Append or remove item from 'favorites' tab
if (thisStatus == true) {
favoritesContainer.append(parent[0]);
$(".js-favorites-tab .network-selector-tab-content-empty").hide();
} else {
var willRemoved = favoritesContainer.find(workWith);
willRemoved.remove();
if (favoritesNetworksUrls.length == 0) {
$(".js-favorites-tab .network-selector-tab-content-empty").show();
}
}
// Push to localstorage
var willBePushed = JSON.stringify(favoritesNetworksUrls)
localStorage.setItem("favoritesNetworksUrls", willBePushed);
});
$(document).on('change', ".network-selector-item-favorite input[type='checkbox']", function () {
var networkUrl = $(this).attr('data-url'),
thisStatus = $(this).is(':checked'),
parent = $(".network-selector-item[data-url='" + networkUrl + "'").clone(),
workWith = $(".network-selector-item[data-url='" + networkUrl + "'")
// Add new checkbox status to same network in another tabs
$(".network-selector-item-favorite input[data-url='" + networkUrl + "']").prop('checked', thisStatus)
// Push or remove favorite networks to array
var found = $.inArray(networkUrl, favoritesNetworksUrls)
if (found < 0 && thisStatus == true) {
favoritesNetworksUrls.push(networkUrl)
} else {
var index = favoritesNetworksUrls.indexOf(networkUrl)
if (index != -1) {
favoritesNetworksUrls.splice(index, 1)
}
}
// Append or remove item from 'favorites' tab
if (thisStatus == true) {
favoritesContainer.append(parent[0])
$('.js-favorites-tab .network-selector-tab-content-empty').hide()
} else {
var willRemoved = favoritesContainer.find(workWith)
willRemoved.remove()
if (favoritesNetworksUrls.length == 0) {
$('.js-favorites-tab .network-selector-tab-content-empty').show()
}
}
// Push to localstorage
var willBePushed = JSON.stringify(favoritesNetworksUrls)
localStorage.setItem('favoritesNetworksUrls', willBePushed)
})
if (favoritesNetworksUrls.length > 0) {
$(".js-favorites-tab .network-selector-tab-content-empty").hide();
for (var i = 0; i < favoritesNetworksUrls.length + 1; i++) {
$(".network-selector-item[data-url='" + favoritesNetworksUrls[i] +"'").find("input").prop("checked", true);
var parent = $(".network-selector-item[data-url='" + favoritesNetworksUrls[i] +"'").clone();
favoritesContainer.append(parent[0]);
}
$('.js-favorites-tab .network-selector-tab-content-empty').hide()
for (var i = 0; i < favoritesNetworksUrls.length + 1; i++) {
$(".network-selector-item[data-url='" + favoritesNetworksUrls[i] + "'").find('input').prop('checked', true)
var parent = $(".network-selector-item[data-url='" + favoritesNetworksUrls[i] + "'").clone()
favoritesContainer.append(parent[0])
}
}

@ -1,21 +1,21 @@
import $ from 'jquery'
var networkSearchInput = $(".network-selector-search-input"),
networkSearchInputVal = "";
var networkSearchInput = $('.network-selector-search-input'),
networkSearchInputVal = ''
$(networkSearchInput).on("input", function() {
networkSearchInputVal = $(this).val();
$(networkSearchInput).on('input', function () {
networkSearchInputVal = $(this).val()
$.expr[":"].Contains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
if (networkSearchInputVal == "") {
$(".network-selector-item").show();
} else {
$(".network-selector-item").hide();
$(".network-selector-item:Contains('" + networkSearchInputVal + "')").show();
}
});
$.expr[':'].Contains = $.expr.createPseudo(function (arg) {
return function (elem) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0
}
})
if (networkSearchInputVal == '') {
$('.network-selector-item').show()
} else {
$('.network-selector-item').hide()
$(".network-selector-item:Contains('" + networkSearchInputVal + "')").show()
}
})

Loading…
Cancel
Save