function promiseWrapper(url) {
return new Promise(resolve => {
const xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.send();
xhr.onload = () => {
resolve(xhr.response);
};
});
}
async function getData() {
const [res1] = await promiseWrapper(url1);
const [res2] = await promiseWrapper(url2);
return res1 + res2;
}
.pipe(concat('main.css'))
?.pipe(stylus({
compress: true
}))
const Input = (props) => (
<input type="text" onChange={props.handleChange} />
)
const Output = (props) => (
<div>{props.text}</div>
)
class App extends React.Component {
constructor (props) {
super(props)
this.state = {}
this.handleChange = this.handleChange.bind(this)
}
handleChange (e) {
this.setState({
value: e.target.value
})
}
render () {
return (
<div>
<Input handleChange={this.handleChange} />
<Output text={this.state.value} />
</div>
)
}
}
var perPage = 3, // кол-во элементов открывать по клику
offset = 0,
listBox = document.querySelector('.b-tag'),
list = listBox.querySelector('.b-tag__list'),
listItems = [].slice.call(list.querySelectorAll('li')),
listCnt = listItems.length,
moreBut = document.createElement('a');
moreBut.className = 'b-tag__link b-tag__link--more';
moreBut.textContent = 'Еще';
listBox.appendChild(moreBut);
moreBut.addEventListener('click', function(e) {
e.preventDefault();
listItems.slice(offset, (offset = perPage + offset)).forEach(function(li) {
li.style.display = 'list-item';
});
if (offset >= listCnt) {
this.style.display = 'none';
}
}, false);
moreBut.click();
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder = new google.maps.Geocoder();
var address = 'London, UK';
if (geocoder) {
geocoder.geocode({ 'address': address }, function (response, status) {
if (status == google.maps.GeocoderStatus.OK) {
responseCoords = new google.maps.LatLng(response.results[0].geometry.location.lat, response.results[0].geometry.location.lng);
calcRoute(responseCoords);
}
});
}
</script>