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 :-)

Author Archive

Archives by Month: