• 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>


  • Fruitsnow

    <script src="fruitsnow.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"></script>
    <script type="text/javascript">
    //<![CDATA[
    window.onload = function() {

    function timeouts() {
    setTimeout(function () {
    fruitfall();
    timeouts();
    }, 10000);
    }
    timeouts();
    fruitfall();

    var rotation = function (){
    jQuery(".auglis1").rotate({
    angle:0,
    animateTo:360,
    duration: 2000,
    callback: rotation,
    easing: function (x,t,b,c,d){
    return c*(t/d)+b;
    }
    });
    }
    rotation();

    var rotation2 = function (){
    jQuery(".auglis2").rotate({
    angle:360,
    animateTo:0,
    duration: 2000,
    callback: rotation2,
    easing: function (x,t,b,c,d){
    return c*(t/d)+b;
    }
    });
    }
    rotation2();

    };
    //]]>
    </script>

    fruitsnow.js

    for (i=1; i<9; i++){
    jQuery("#clickban").after("<img id='br"+i+"' class='auglis"+Math.floor((Math.random() * 2) + 1)+"' src='/augli/"+i+".png' style='width:100px;z-index:-1;position:absolute;right:30px;top:-200px;'>");
    }

    function rightfall(kurs){
    setTimeout(function(){
    var bar1 = jQuery('#br'+kurs);
    bar1.animate({top: jQuery(document).height()-200}, Math.floor((Math.random() * 10000) + (10000)), "linear", function() {
    //bar1.hide();
    bar1.css("top","-200px");
    });
    }, Math.floor((Math.random() * 8000) + ((kurs-1)*2000)));
    }

    for (i=1; i<9; i++){
    jQuery("#clickban").after("<img id='fr"+i+"' class='auglis"+Math.floor((Math.random() * 2) + 1)+"' src='/augli/"+i+".png' style='width:100px;z-index:-1;position:absolute;left:30px;top:-200px;'>");
    }

    function leftfall(kurs){
    setTimeout(function(){
    var bar1 = jQuery('#fr'+kurs);
    bar1.animate({top: jQuery(document).height()-200}, Math.floor((Math.random() * 10000) + (10000)), "linear", function() {
    //bar1.hide();
    bar1.css("top","-200px");
    });
    }, Math.floor((Math.random() * 8000) + ((kurs-1)*2000)));
    }

    function fruitfall(){
    for (i=1; i<9; i++){
    rightfall(i);
    leftfall(i);
    }
    }


  • Background Video

    <video autoplay loop poster="polina.jpg" id="bgvid">
    <source src="polina.webm" type="video/webm">
    <source src="polina.mp4" type="video/mp4">
    </video>

    video#bgvid {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    -webkit-transform: translateX(-50%) translateY(-50%);
    transform: translateX(-50%) translateY(-50%);
    background: url(polina.jpg) no-repeat;
    background-size: cover;
    }

    @media screen and (max-device-width: 800px) {
    body { background: url(polina.jpg) #000 no-repeat center center fixed; }
    #bgvid { display: none; }
    }

    http://demosthenes.info/blog/777/Create-Fullscreen-HTML5-Page-Background-Video


  • GA event tracking

    ga('send','event','lapa','facebook','clicked')
    ga('send','event','title','title2',{'nonInteraction': 1});


  • popup loga izmēra mainīšana

    function resizeVideoPage(){
    var width = 800;
    var height = 600;
    window.resizeTo(width, height);
    window.moveTo(((screen.width - width) / 2), ((screen.height - height) / 2));
    }


  • 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);
    }
    });


  • Seko mums draugiem.lv

    <script type="text/javascript" src="//sekomums.lv/cb.lv.js"></script>
    <script type="text/javascript" src="//draugiem.lv/api/api.js"></script>
    <script type="text/javascript">function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}; r(function(){new ConversionsBox("Pat%C4%ABk%20radio%20SPIN%20FM%3F%20Seko%20mums%20ar%C4%AB%20Draugiem.lv!%20","mans-nosaukums");});</script>


  • 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()))
    }