var arr = [];
var fib = 1;
var sum = 0;
var start = 0;
var x = 10000;
var t = 1000;
fibonaci();
function fibonaci() {
sum = start + fib;
start = fib;
fib = sum;
arr.push(fib);
if (sum <= x) {
circle();
setTimeout(fibonaci, t);
}
}
// центр кружков + разный размер
function circle() {
var count = 50 + parseRandomNumber(50);
document.write(`<div style="width:${count}px;height:${count}px;line-height:${count}px;border-radius:50%;background-color:${color()};text-align:center;">${fib}</div>`);
}
function color() {
var rgba = parseRandomNumber(255);
return `rgb(${rgba}, ${rgba}, ${rgba})`;
}
function parseRandomNumber(x) {
var r = Math.random() * x;
return parseInt(r, 10);
}
Больше информации var $btn = $('.btn'),
localStorageButtons = JSON.parse(localStorage.getItem('buttons')) || {};
if (localStorageButtons) {
$btn.each(function(i) {
$btn.text(localStorageButtons[i]);
});
}
$btn.on('click', function() {
var v = parseInt($(this).text(), 10),
i = $(this).index();
v++;
localStorageButtons[i] = v;
$(this).text(v);
localStorage.setItem('buttons', JSON.stringify(localStorageButtons));
});
function folioChangeStyles(el, mouseenter) {
$('.folio-work_btn', el)
.css({
'background-color': mouseenter ? 'rgba(3,156,253,1)' : 'inherit',
'color' : mouseenter ? '#fff' : 'rgba(3,156,253,1)',
'font-weight' : mouseenter ? 300 : 400
});
};
$('.folio-work').on('mouseenter mouseout', 'a:first-child', function(e) {
folioChangeStyles(e.delegateTarget, (e.type === 'mouseenter'));
});
$(window).on('load scroll', function(e){
var scrolling = (e.type == 'scroll');
if (scrolling) {
var scrollTop = $(this).scrollTop();
if (scrollTop >= 200) {
$('.logotip').css('margin-top', '1px');
$('.navigation').css('margin-top', '7px');
$('#sticky-block').css('height', '54px');
};
} else {
$('.flexslider').flexslider();
// <button type="button" class="nav-touch"></button>
// Если вас такой подход не устраивает и вы хотите оставить ссылку, то раскомментируйте код ниже
$(".nav-touch").on('click', function() {
$(this).next(".navigation").slideToggle(1000);
// return false;
});
}
});
<div class="iphone__container">
<ul class="iphone__list iphone__models">
<li class="iphone__li iphone__model iphone__model_6s" data-model="6S">iPhone 6s</li>
<li class="iphone__li iphone__model iphone__model_6+" data-model="6+">iPhone 6+</li>
</ul>
<ul class="iphone__list iphone__problems">
<li class="iphone__li iphone__problem" data-problem='{"id":"screen","prices":{"6S":"700","6+":"0"}}'>Замена <br/> экрана</li>
<li class="iphone__li iphone__problem" data-problem='{"id":"window","prices":{"6S":"100","6+":"0"}}'>Замена <br/> стекла</li>
</ul>
</div>
<div class="iphone__total">
<span class="iphone__total-title">Стоимость:</span>
<span class="iphone__total-value"></span>
</div>
.iphone__problems {
display: none;
}
var App = {
init: function(){
this.iPhones.init();
},
/**
* iPhones
*/
iPhones: {
init: function(){
// Container
this.container = '.iphone__container';
// List
this.list = '.iphone__list';
// List items
this.li = '.iphone__li';
// Models list
this.models = '.iphone__models';
// Models
this.model = '.iphone__model';
// Problems list
this.problems = '.iphone__problems';
// Problem
this.problem = '.iphone__problem';
// Total
this.total = '.iphone__total';
// Total value
this.totalValue = '.iphone__total-value';
// Active model
this.activeModel = '';
// Sum
this.sum = 0;
// Allowed models
this.allowedModels = ['SE','4','4S','5','5c','5S','6','6+','6s'];
// Action! Action! Action!
$(this.container).on('click', this.li, this.events);
},
/**
* Events
*/
events: function(){
// Link to object
var iPhones = App.iPhones;
// Get clicked element
var $el = $(this);
// Get model
var model = $el.data('model') || false;
// Get problem
var problem = $el.data('problem') || false;
if (model) {
iPhones.activeModel = model;
$(iPhones.list).toggle();
}
if (problem) {
iPhones.getPrice(problem.id, iPhones.activeModel, function(price){
if (problem.prices[iPhones.activeModel] == price) {
$el.addClass('active').off('click');
iPhones.sum += price;
$(iPhones.totalValue).text(iPhones.sum);
} else {
$(iPhones.list).toggle();
alert('Hacking attempt');
}
});
}
},
/**
* Get price
* @param problem
* @param model
* @param cb
*/
getPrice: function(problem, model, cb){
var list = {
'screen': {
'prices': {
'SE': 500,
'4': 400,
'4S': 450,
'5': 500,
'5C': 530,
'5S': 550,
'6': 600,
'6+': 650,
'6S': 700
}
},
'window': {
'prices': {
'SE': 500,
'4': 400,
'4S': 450,
'5': 500,
'5C': 530,
'5S': 550,
'6': 600,
'6+': 700,
'6S': 100
}
}
};
return cb(problem && model ? list[problem].prices[model] : 0);
}
}
};
$(function(){
App.init();
});