jQuery UI autocomplete mustMatch Ersatz

jQuery UI autocomplete versagt leider, wenn nur Begriffe aus der Liste ausgewählt werden dürfen. Die eingebaute option mustMatch: true funktioniert leider gar nicht. Deshalb eine Funktion, die Abhilfe schafft.

function jQueryUIAutoCompleteMustMatch(input) {
    var found = 0;
    var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( jQuery.trim($(input).val()) ) + "$", "i" );
    jQuery.each($('.ui-autocomplete li'), function(i, val) {
        if(jQuery.trim( $(val).text() ).match( matcher ) ) {
            found = 1;
        }
    });
    if (found) {
        return true;
    }
    else
    {
        $(input).val('');
        return false;
    }
}

Und dann

change: function(event, ui) {
                jQueryUIAutoCompleteMustMatch($(this));
            }

jQuery zoom with all browers

Well all browsers can do the same, except for Firefox. Wired, indeed! However this zoom script works in IE, Firefox,Chrome,Safari.

jQuery(document).ready(function() {
    var currFFZoom = 1;
    var currIEZoom = 100;

    jQuery(".make_greater").click(function(){
        var step;
        //only firefox sux in this case
        if (jQuery.browser.mozilla){
            step = 0.05;
            currFFZoom += step;
            jQuery('.maincontent').css('MozTransform','scale(' + currFFZoom + ','+ currFFZoom + ')');
            jQuery('.maincontent').css('transform-origin','0 0');
        }
        else
        {
            step = 5;
            currIEZoom += step;
            jQuery('body').css('zoom', ' ' + currIEZoom + '%');
        }
    });

    jQuery(".make_smaller").click(function(){
        var step;
        //only firefox sux in this case
        if (jQuery.browser.mozilla){
            step = 0.05;
            currFFZoom -= step;
            jQuery('.maincontent').css('MozTransform','scale(' + currFFZoom + ','+ currFFZoom +')');
            jQuery('.maincontent').css('transform-origin','0 0');
        }
        else
        {
            step = 5;
            currIEZoom -= step;
            jQuery('body').css('zoom', ' ' + currIEZoom + '%');
        }
    });
});
jquery zoom source
jquery zoom

jQuery load and execute javascript / js and css file

if (jQuery('.startseitenslider').length > 0){
        jQuery('head').append('<link>');
        jQuery('head').children(":last").attr({
            rel:    "stylesheet",
            type: "text/css",
            href: "../css/nivo-slider.css"
        });

        function init_slider(){
            //$('#slider').nivoSlider();
        }
        jQuery.getScript("../js/jquery.nivo.slider.pack.js", function(){
            //wait before initialising to prevent intermittent load error
            setTimeout(init_slider,250);
        });
    }

jQuery wait

jQuery.fn.wait = function(time, type) {
    time = time || 1000;
    type = type || "fx";
    return this.queue(type, function() {
        var self = this;
        setTimeout(function() {
            jQuery(self).dequeue();
        }, time);
    });
};
Anwendung:
jQuery(SELECTOR).wait().css('display','block');

MySQL UTF-8 fix Umlaute

Geht ziemlich schnell Sonderzeichen zu reparieren in MySQL! Scheiß Encoding! ;)

UPDATE `table` set
    `column`= REPLACE(`column`,"ß", "ß"),
    `column`= REPLACE(`column`, "ä", "ä"),
    `column`= REPLACE(`column`, "ü", "ü"),
    `column`= REPLACE(`column`, "ö", "ö"),
    `column`= REPLACE(`column`, 'Ä', 'Ä'),
    `column`= REPLACE(`column`, "Ãœ", "Ü"),
    `column`= REPLACE(`column`, "Ö", "Ö"),
    `column`= REPLACE(`column`, '€', '€');

jquery input title hint

jQuery.fn.inputHints=function() {
    // hides the input display text stored in the title on focus
    // and sets it on blur if the user hasn't changed it.

    // show the display text
    jQuery(this).each(function(i) {
        jQuery(this).val(jQuery(this).attr('title')).addClass('hint');
    });

    // hook up the blur & focus
    return jQuery(this).focus(function() {
        if (jQuery(this).val() == jQuery(this).attr('title')){
            jQuery(this).val('').removeClass('hint');
        }
    }).blur(function() {
        if (jQuery(this).val() === ''){
            jQuery(this).val(jQuery(this).attr('title')).addClass('hint');
        }
    });
};

jQuery(document).ready(function() {
    jQuery('input[title]').inputHints();
});

PHP detect IOS / iPhone / iPad / iPod

Very simple

<?php
function is_ios(){
    if (stripos($_SERVER['HTTP_USER_AGENT'],"iPhone")  !== false) {
        return true;
    } elseif (stripos($_SERVER['HTTP_USER_AGENT'],"iPad") !== false) {
        return true;
    } elseif (stripos($_SERVER['HTTP_USER_AGENT'],"iPod") !== false) {
        return true;
    }
    return false;
}
?>

Windows 8 Ruhezustand / Suspend to disk / Hybernate

Leider gibt es inWindows 8 keinen Knopf um Windows in den Ruhezustand zu schicken. Sicherlich startet Windows 8 sehr schnell, aber wenn es darum geht den Zustand von Programmen bei zubehalten, reicht das nicht.
Zum Glück kann man sich eine Verknüpfung auf dem Desktop anlegen: C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState Und schon klappt der Ruhezustand wieder :-)