'use strict';
var _POS = {};
(function () {
navigator.geolocation.getCurrentPosition(function (position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
_POS.lat = lat;
_POS.lng = lng;
});
}()); // <== тут добавлен вызов функции
(function () {
navigator.geolocation.getCurrentPosition(function (position) {
/*
* инициализировать модули и функции использующие
* данные подученные от навигатора надо тут
*
*/
});
}());
var auto = [
{
marka: "BMW",
model: "4k",
cuzov: "A",
},
{
marka: "Merc",
model: "4k",
cuzov: "B",
},
{
marka: "Audi",
model: "3k",
cuzov: "C",
},
{
marka: "Toyota",
model: "1k",
cuzov: "D",
},
{
marka: "Lexus",
model: "2k",
cuzov: "E",
},
{
marka: "Rang",
model: "3k",
cuzov: "F",
},
{
marka: "BMW",
model: "4k",
cuzov: "G",
},
{
marka: "BMW",
model: "2k",
cuzov: "Y",
},
{
marka: "Audi",
model: "3k",
cuzov: "U",
}
];
var marka = ["Audi", "Rang", "Merc"];
var model = ["4k", "2k", "3k"];
var cuzov = [];
var params = { marka, model, cuzov };
var activeKeys = Object.keys(params).filter(key => params[key].length);
var rez1 = auto.filter(x => activeKeys.every(key => params[key].includes(x[key])) );
console.log(rez1);
function Parallel(settings) {
this.parallelJobs = settings.parallelJobs;
this.results;
this.tasks = [];
this.onDone;
this.index = 0;
this.activeJobs = 0;
this.start = function() {
this.results = Array(this.tasks.length);
for (var i = 0; i < Math.min(this.parallelJobs, this.tasks.length); i++) {
this.next();
}
}
this.next = function(result) {
var index = this.index;
this.activeJobs++;
this.tasks[this.index](function(result) {
this.onResult(result, index);
}.bind(this));
this.index++;
}
this.onResult = function(result, index) {
this.results[index] = result;
this.activeJobs --;
if(this.tasks[this.index]) {
this.next();
} else if (this.activeJobs === 0) {
this.onDone(this.results);
}
}
this.job = function (step) {
this.tasks.push(step);
return this;
};
this.done = function (onDone) {
this.onDone = onDone;
this.start();
};
};
var filteredArray = sourceArray.filter(function(e) {
return e.someKey !== null && e.someKey !== undefined;
});
export const routes = [
{
component: Home,
path: '/',
},
{
component: Roster,
path: '/roster',
},
{
component: Schedule,
path: '/schedule',
},
];
export default function SwitchWithRoutes({ routes }) {
return (
<Switch>
{routes.map((route, i) => (
<Route
key={i}
exact={route.path === '/'}
path={route.path}
component={route.component}
/>
)}
</Switch>
);
}
const objects = [
{status: 'approved', message: '123'},
{status: 'declined', message: '3123123'},
{status: 'approved', message: '3434342'},
{status: 'approved', message: 'asdsdfdad'},
];
const result = objects.reduce(function(acc, el, i) {
if (el.status === 'approved') {
acc.message += (!i ? '': '\n') + el.message;
}
return acc;
}, {
status: 'approved',
message: '',
});
const obj = {
operation: {
status: "success",
text: "Approved"
} ,
anotherOperation: {
status: "success",
text: "Approved"
},
op: {
status: "error",
text: "Declined, because..."
}
};
const textsArray = Object.values(obj).filter(el => el.status === 'error').map(el => el.text);
// результат: ["Declined, because..."]
body.no-scroll {
overflow-y: hidden;
}
.overlay {
display: none;
}
.overlay.active {
display: block;
}
$('.menu-toggle').click(toggleMobileMenu);
$(document).keyup(function(e){
if (e.keyCode == 27 && $('#Mobile-menu').hasClass('open')) {
toggleMobileMenu();
}
});
function toggleMobileMenu() {
$('body').toggleClass('no-scroll');
$('.overlay').toggleClass('active');
$('#Mobile-menu').toggleClass('open');
}
<Route path="/more/:id" component={More}/>
<Link to={`more/${this.props.itemId}`} className="descr">подробнее</Link>
export default function More(props){
const { id } = props.match.params;
const item =props.items[id];
const { id, title, descr, img, price } = item;
return(
<div className="more__info">
...
</div>
);
}
localhost:3000/more_id1
localhost:3000/more/1
const c = a.map((i, el) => ({ selector: `#${el.id}`}));
var a = $("span[id ^= call]"),
c = [];
for (var i = 0; i < a.length; i++) {
let b = {
selector:"#" + a.eq(i).attr("id"),
};
c.push(b);
}