Skip to content

Instantly share code, notes, and snippets.

View rtivital's full-sized avatar

Vitaly Rtishchev rtivital

  • 17:28 (UTC +04:00)
View GitHub Profile
@rtivital
rtivital / hello.js
Last active February 1, 2017 12:20
const a = 5;
if (a) {
console.log(a);
}
hello
'
import React, { Component } from 'react';
export default class Button extends Component {
constructor(props) {
super(props);
this.state = {
counter: this.props.initialCounter,
counterCounter: 1,
};
var browserCookies = require('./browser-cookies.js');
/**
* Функция сохранения в cookies последний выбранный фильтр:
* «Оригинал», «Хром» или «Сепия»
*/
function saveSelectFilter() {
var selectFilter = document.querySelector('.upload-filter-controls input:checked');
var dateToExpires = new Date(Date.now() + getTimeNearBirthDay()).toUTCString();
browserCookies.setItem('filter', selectFilter.value, dateToExpires); //ругается нет функции setItem
}
// Первый способ
var Table = function(names) {
this.names = names;
this.tbody = document.querySelector('.tbody');
}
Table.prototype.render = function() {
var self = this;
setInterval(function() {
var x = self.tbody.children.length;
@rtivital
rtivital / jq.md
Last active April 11, 2016 19:30

Функция $

Может принимать контекст, исходя из которого будут выбираться элементы. Контекст, как и сам элемент может быть в виде:

  1. Строки (.selector, .context)
  2. DOM-элемента (document.querySelector('.selector'), document.querySelector('.context'))
  3. Коллекции DOM-элементов (document.querySelectorAll('.selector'), document.querySelectorAll('.context')) - в этом случае в качестве контекста выбирается первый подходящий элемент
  4. Объект вида $:
var $p = $('p');
var fn = function() {
return 5 + 3;
};
fn(); // 8
fn(function() {
console.log('Ничего не получается');
}); // 8
// Получечние куки
var filterCookies = browserCookies.get('filter');
if (filterCookies) {
document.getElementById(filterCookies).checked = true;
}
// ...
// делаем свои дела
filterForm.onsubmit = function() {
// ...
function resizeFormIsValid() {
var x = +resizeX.value;
var y = +resizeY.value;
var side = +resizeSize.value;
var imageWidth = currentResizer._image.naturalWidth;
var imageHeight = currentResizer._image.naturalHeight;
var messageWrapper = document.getElementById('upload-resize-message');
if (x + side <= imageWidth && y + side <= imageHeight) {
resizeFwd.disabled = false;