Skip to content

Instantly share code, notes, and snippets.

View lorashfuko's full-sized avatar

lorashfuko lorashfuko

View GitHub Profile
@lorashfuko
lorashfuko / Букмарклет копирует Title
Last active May 10, 2016 16:57
Букмарклет копирует содержимое мета-тега Title в буфер обмена
javascript:(function () {
var body = document.querySelector("body");
var range = document.createRange();
var text = document.createElement("P");
var title = document.querySelector("title");
if (title) {
text.innerHTML = title.textContent;
body.appendChild(text);
range.selectNode(text);
window.getSelection().addRange(range);
@lorashfuko
lorashfuko / Букмарклет: копирует description документа
Last active May 10, 2016 16:52
Букмарклет копирует description документа в буфер обмена
javascript:(function () {
var body = document.querySelector("body");
var range = document.createRange();
var text = document.createElement("P");
var description = document.querySelector('meta[name="description"]');
if (description) {
text.innerHTML = description.content;
body.appendChild(text);
range.selectNode(text);
window.getSelection().addRange(range);
@lorashfuko
lorashfuko / gist:9b3a5fe58cc9a066af89
Created June 30, 2015 15:11
Авто-скрол по клику наверх (jQuery)
jQuery(document).ready(function(){
jQuery("#scroll-up").hide();
jQuery(function () {
jQuery(window).scroll(function () {
if (jQuery(this).scrollTop() > 1000) {
jQuery('#scroll-up').fadeIn();
} else {
jQuery('#scroll-up').fadeOut();
}
});
@lorashfuko
lorashfuko / gist:13ce782bfcc65dc119b3
Last active February 2, 2017 19:38
Мигающий фавикон из двух картинок
<link id="favicon" rel="icon" href="путь/до/картинки1.jpg" type="image/x-icon" data="путь/до/картинки2.jpg" />
function faviconPulse (time){
var favicon = jQuery("#favicon"),
href = favicon.attr('href');
if (favicon.attr('data')) {
var inter = setInterval(function(){
if (favicon.attr('href') == href) {
favicon.attr('href', favicon.attr('data'));
//*************Обрезаем по символьно**************************************//
public static function limitChars($str, $limit = 100, $endChar = NULL, $preserveWords = FALSE)
{
$endChar = ($endChar === NULL) ? '&#8230;' : $endChar;
$limit = (int) $limit;
if (trim($str) === '' OR strlen($str) <= $limit)
return $str;
<script>
var scripts = new Array('путь/до/файла.js');
var css = new Array('путь/до/styles.css');
function downloadJSAtOnload() {
var element;
for(var i = 0; i < scripts.length; i++){
element = document.createElement("script");
element.src = scripts[i];
element.type = 'text/javascript';
jQuery(document).ready(function () {
//код jQuery
//функция вызова таймера
function get_timer() {
//Дата для обратного отсчета
var date_new = new Date(2015,3,12);
//Объект даты для обратного отсчета
::-webkit-scrollbar {
height: 12px;
width: 12px;
background: #969696;
-webkit-border-radius: 1ex;
}
::-webkit-scrollbar-thumb {
background: #2B2B2B;
-webkit-border-radius: 1ex;
//CSS
.loader {
background: none repeat scroll 0 0 #ffffff;
bottom: 0;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;