Skip to content

Instantly share code, notes, and snippets.

@obojdi
Created August 11, 2016 11:31
Show Gist options
  • Save obojdi/f73cd424b6e67878d79dd96c7aef3f9d to your computer and use it in GitHub Desktop.
Save obojdi/f73cd424b6e67878d79dd96c7aef3f9d to your computer and use it in GitHub Desktop.
Пепячиватель текста
//подставить в el DOM-селектор попячиваемого элемента
function pepyachka(el) {
if (typeof window.jQuery == "undefined") {
var g = document.createElement('script');
g.type = "text/javascript";
g.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js";
document.head.appendChild(g);
}
var
a = document.createElement('link'),
b = jQuery(el).text(),
c = b.split("")
a.rel = 'stylesheet';
a.href = 'http://pepyaka.su/css/pepyaka-font.css';
document.head.appendChild(a);
jQuery(el).text('')
for (var l in c) {
jQuery('<span class="pepka pep' + Math.floor(Math.random() * c.length) + '">' + c[l] + '</span>').appendTo(jQuery(el));
}
jQuery('.pepka').wrapAll('<div class="pepyaka"/>')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment