This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startJobAt(hh, mm, code) { | |
var interval = 0; | |
var today = new Date(); | |
var todayHH = today.getHours(); | |
var todayMM = today.getMinutes(); | |
if ((todayHH > hh) || (todayHH == hh && todayMM > mm)) { | |
var midnight = new Date(); | |
midnight.setHours(24,0,0,0); | |
interval = midnight.getTime() - today.getTime() + | |
(hh * 60 * 60 * 1000) + (mm * 60 * 1000); |
- Related Setup: https://gist.github.com/hofmannsven/6814278
- Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
- Interactive Beginners Tutorial: http://try.github.io/
- Git Cheatsheet by GitHub: https://services.github.com/on-demand/downloads/github-git-cheat-sheet/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="style.css"> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<input type="text"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://codepen.io/erratir/pen/xxKYevd | |
// MVP — Presenter — создает модель и отображение, после чего отвечает за связывание их между собой: | |
// слушает изменения в каждом из них и вызывает обновления | |
// user-view.js | |
const render = (html) => { | |
const element = document.createElement(`div`); | |
element.innerHTML = html; | |
return element; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://codepen.io/erratir/pen/aboqxKZ | |
// MVC — Controller — создает модель и отображение и знакомит их между собой, дальше модель и отображение общаются напрямую | |
// user-view.js | |
const render = (html) => { | |
const element = document.createElement(`div`); | |
element.innerHTML = html; | |
return element; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Вписывает изображение в рамку | |
* @param {object} frame Размеры рамки | |
* @param {object} image Размеры изображения | |
* @return {{width: number, height: number}} | |
*/ | |
const resize = (frame, image) => { | |
const ratioWidth = 1 / (image.width / frame.width); | |
const ratioHeights = 1 / (image.height / frame.height); |
(перевод, оригинал)
Поиграть с разметкой Markdown можно на демо-странице.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the current URL of the selected Chrome tab. | |
* Useful for Chrome/Chromium extensions. | |
* @return {Promise<any>} | |
*/ | |
const getCurrentUrl = () => { | |
return new Promise((resolve, reject) => { | |
chrome.tabs.query({"active": true, "currentWindow": true}, (tabs) => { | |
resolve(tabs[0].url); | |
}); |
#Introduction
Developing Chrome Extensions is REALLY fun if you are a Front End engineer. If you, however, struggle with visualizing the architecture of an application, then developing a Chrome Extension is going to bite your butt multiple times due the amount of excessive components the extension works with. Here are some pointers in how to start, what problems I encounter and how to avoid them.
Note: I'm not covering chrome package apps, which although similar, work in a different way. I also won't cover the page options api neither the new brand event pages. What I explain covers most basic chrome applications and should be enough to get you started.