function round(value, exp){
return decimalAdjust('round', value, exp);
}
function ceil(value, exp){
return decimalAdjust('ceil', value, exp);
}
function floor(value, exp){
return decimalAdjust('floor', value, exp);
}
function decimalAdjust(type, value, exp) {
// Если степень не определена, либо равна нулю...
if (typeof exp === 'undefined' || +exp === 0) {
return Math[type](value);
}
value = +value;
exp = +exp;
// Если значение не является числом, либо степень не является целым числом...
if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
return NaN;
}
// Сдвиг разрядов
value = value.toString().split('e');
value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
// Обратный сдвиг
value = value.toString().split('e');
return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
}
// { name: { $exists: true }}
Thing.where('name').exists()
Thing.where('name').exists(true)
Thing.find().exists('name')
// { name: { $exists: false }}
Thing.where('name').exists(false);
Thing.find().exists('name', false);
// '.menu a' я написал от балды, подставь значение верстки как у тебя в шаблоне карта
document.querySelector('.menu a').addEventListener('click', function(event){
event.preventDefault();
event.stopPropagation();
this.href; // По этому параметру можешь определить до куда скролиться
// то есть, какую именно ссылку нажали
document.body.scrollTop; // Меняя значение этой переменной
//страница проскролится до узказанных пикселей
// Плавный scrollTo() можно найти в интернетах.
})
for (row = 0; row < numbers.length; row++) {
for (col = 0; col < numbers[row].length; col++) {
numbers[row][col]= numbers[row][col]%2==0 ? 'even' : 'odd';
}
}
console.log(numbers);
console.log([
[243, 12, 23, 12, 45, 45, 78, 66, 223, 3],
[34, 2, 1, 553, 23, 4, 66, 23, 4, 55],
[67, 56, 45, 553, 44, 55, 5, 428, 452, 3],
[12, 31, 55, 445, 79, 44, 674, 224, 4, 21],
[4, 2, 3, 52, 13, 51, 44, 1, 67, 5],
[5, 65, 4, 5, 5, 6, 5, 43, 23, 4424],
[74, 532, 6, 7, 35, 17, 89, 43, 43, 66],
[53, 6, 89, 10, 23, 52, 111, 44, 109, 80],
[67, 6, 53, 537, 2, 168, 16, 2, 1, 8],
[76, 7, 9, 6, 3, 73, 77, 100, 56, 100]
].map(row => row.map(cell => cell % 2 == 1 ? 'odd' : 'even' )))
$('video').on('loadstart', e => this.pause());
$('video').on('loadeddata' e => this.play());
$ geoiplookup 68.180.228.159
GeoIP Country Edition: US, United States
GeoIP City Edition, Rev 1: US, CA, California, Sunnyvale, 94089, 37.424900, -122.007401, 807, 408
GeoIP ASNum Edition: AS36647 Yahoo
var map = L.map('map').setView([ 37.424900, -122.007401], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);
console.log('Job finished');
function removeFromList (index) {
let todoList = document.getElementById('list');
list.splice(index, 1);
todoList.innerHTML = '';
reconstructList();
};
var links = [];
var casper = require('casper').create();
function getLinks() {
var links = document.querySelectorAll('h3.r a');
return Array.prototype.map.call(links, function(e) {
return e.getAttribute('href');
});
}
casper.start('http://google.fr/', function() {
// Wait for the page to be loaded
this.waitForSelector('form[action="/search"]');
});
casper.then(function() {
// search for 'casperjs' from google form
this.fill('form[action="/search"]', { q: 'casperjs' }, true);
});
casper.then(function() {
// aggregate results for the 'casperjs' search
links = this.evaluate(getLinks);
// now search for 'phantomjs' by filling the form again
this.fill('form[action="/search"]', { q: 'phantomjs' }, true);
});
casper.then(function() {
// aggregate results for the 'phantomjs' search
links = links.concat(this.evaluate(getLinks));
});
casper.run(function() {
// echo results in some pretty fashion
this.echo(links.length + ' links found:');
this.echo(' - ' + links.join('\n - ')).exit();
});
$ casperjs googlelinks.js
20 links found:
- https://github.com/casperjs/casperjs
- https://github.com/casperjs/casperjs/issues/2
- https://github.com/casperjs/casperjs/tree/master/samples
- https://github.com/casperjs/casperjs/commits/master/
- http://www.facebook.com/people/Casper-Js/100000337260665
- http://www.facebook.com/public/Casper-Js
- http://hashtags.org/tag/CasperJS/
- http://www.zerotohundred.com/newforums/members/casper-js.html
- http://www.yellowpages.com/casper-wy/j-s-enterprises
- http://local.trib.com/casper+wy/j+s+chinese+restaurant.zq.html
- http://www.phantomjs.org/
- http://code.google.com/p/phantomjs/
- http://code.google.com/p/phantomjs/wiki/QuickStart
- http://svay.com/blog/index/post/2011/08/31/Paris-JS-10-%3A-Introduction-%C3%A0-PhantomJS
- https://github.com/ariya/phantomjs
- http://dailyjs.com/2011/01/28/phantoms/
- http://css.dzone.com/articles/phantom-js-alternative
- http://pilvee.com/blog/tag/phantom-js/
- http://ariya.blogspot.com/2011/01/phantomjs-minimalistic-headless-webkit.html
- http://www.readwriteweb.com/hack/2011/03/phantomjs-the-power-of-webkit.php