Skip to content

Instantly share code, notes, and snippets.

@lutzissler
lutzissler / jquery.flash.js
Created June 3, 2013 09:58
Flash/blink elements by fading in/out. Use it with care!
$.fn.flash = function (options) {
options = $.extend({
animation: 200,
off: 0,
on: 1000
}, options || {});
var elems = $(this),
f = function () {
elems
.animate({opacity: 0}, options.animation)
@lutzissler
lutzissler / jquery.wrapgroups.js
Last active October 12, 2015 18:58
Wrap groups of matched elements (jQuery)
(function ($) {
// From http://forloop.co.uk/blog/wrap-child-elements-in-groups-in-jquery
// Modified to work much simpler
$.fn.wrapGroups = function(options) {
options = $.extend({
groupSize : false,
groupCount: false,
wrapper : '<div>'
}, options || {});
var elems = $(this),
@lutzissler
lutzissler / function.tidy_office_html.php
Created July 31, 2012 07:32
Tidy HTML inserted by copy/pasting from Microsoft office (PHP)
// Regexps courtesy of 1st class media
// http://www.1stclassmedia.co.uk/developers/clean-ms-word-formatting.php
function tidy_office_html($str) {
$replacements = array(
'/<!--.*?-->/s' => '',
'/<o:p>\s*<\/o:p>/s' => '',
'/<o:p>.*?<\/o:p>/s' => "&nbsp;",
'/\s*mso-[^:]+:[^;"]+;?/i' => '',
'/\s*MARGIN: 0cm 0cm 0pt\s*;/i' => '',
'/\s*MARGIN: 0cm 0cm 0pt\s*"/i' => '',