• enable cross-origin resource sharing

    htaccess
    Header set Access-Control-Allow-Origin "*"

    Commands

    apachectl -t

    sudo service apache2 reload

    a2enmod headers

    sudo service apache2 restart


  • HTML from capture mobile image

    <input type="file" id="mypic" accept="image/*">

    <form method="post" action="takephoto.php" enctype="multipart/form-data">
    <input type="file" accept="image/*" name="file">
    <input type="submit">
    </form>


  • Fixed Menu

    var nav = jQuery('.secondary-navigation');
    jQuery(window).scroll(function () {
    if (jQuery(this).scrollTop() > 136) {
    nav.css("position","fixed");
    nav.css({"width":(jQuery('#header').width()+'px')}); //header compensation
    jQuery('#header').css("height","136px");
    } else {
    nav.css("position","");
    jQuery('#header').css("height","");
    }
    });


  • Scrollable background

    CSS
    html, body{
    height:100%;
    min-height:100%;
    margin:0;
    padding:0;
    }
    .bg{
    width:100%;
    height:100%;
    background: #fff url(..) no-repeat fixed 0 0;
    overflow:auto;
    }
    <div class="bg">
    < span >..< /span >
    </div>

    Javascript
    $('.bg').scroll(function() {
    var x = $(this).scrollTop();
    $(this).css('background-position', '0% ' + parseInt(-x / 10) + 'px');
    });

    Check working example at http://jsfiddle.net/Vbtts/
    Click this link for the full screen example: http://jsfiddle.net/Vbtts/embedded/result/


  • jQuery ajax pieprasījums

    GET
    $.ajax({
    type:'GET',
    url: 'http://www.kautkas.lv/kautkas.php',
    data: "action=something&id="+id,
    success:function(data){
    $('#lauks').html(data);
    }
    });

    POST
    $.ajax({
    type: "POST",
    url: "ajax.php?",
    data: { idnumurs: "id" },
    success:function(data){
    $("#lauks").val(data);
    }
    });


  • twitter widget

    $("iframe#twitter-widget-0").contents().find('head').append('<style>img.u-photo.avatar{display:none !important;}.header.h-card.p-author{padding-left:0;}</style>');

    i use the “waituntilexists.js” plugin to detect when the content is added to DOM instead of the setTimout(): https://gist.github.com/buu700/4200601

    $("iframe#twitter-widget-0").waitUntilExists(function(){
    $("iframe#twitter-widget-0").contents().find('head').append('<style>img.u-photo.avatar{display:none !important;}.header.h-card.p-author{padding-left:0;}</style>');
    });


  • Exports uz Exceli

    function vissuzexceli(){
    window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('HTML').html()))
    }