Animasyonlu Hamburger Menüsü Yapma

<a class=”hamburger menu-btn” href=”javascript:void(0)”><span></span></a> <div class=”main-menu-wrap”> <div class=”main-menu”> <a href=”#”>Home</a> <a href=”#”>About Us</a> <a href=”#”>Services</a> <a href=”#”>Blog</a> <a href=”#”>Get in Touch</a> </div> </div> $(function(){ var clicked = 0; $(‘.menu-btn’).click(function(e){ var screen_height = $(window).height() – $(‘.mob-header’).height(); $(this).toggleClass(‘active’); $(‘body’).toggleClass(‘menu-active’); if (clicked == 0) { $(‘.main-menu-wrap’).height(screen_height); clicked = 1; return; } if (clicked == 1) { $(‘.main-menu-wrap’).removeAttr(‘style’); clicked […]

Read More

İçerikleri Dinamik Olarak Sayfaya Ekleme

$(document).ready(function() { // On the click of the submit button, start the function $(“#loadBtn”).click(function() { // Append the loading image to the div that the content is being loaded within $(“#content”).append(‘<div class=”loading” style=”display:block;”></div>’); // Load the file within the content div $(this).load(“data.html”, function(){ // Hide the loading image once the content has been loaded $(“.loading”, […]

Read More

HTML5 Desktop Notification

<input type=”button” id=”push_notification_button” value=”Push Notification”> <script> $(document).ready(function(){ // push_notification fonksiyonu function push_notification(baslik,icerik,resim,url) { // bildirim opsiyonları var options = { body: icerik, icon: resim, dir : “ltr” }; // bildirim opsiyonları if (!(“Notification” in window)) { // Tarayıcı bildirim özelliğini destekliyor mu? alert(“Tarayıcınız bildirim özelliğini desteklememektedir!”); }else if (Notification.permission === “granted”) { // Daha önce […]

Read More

Currency Switcher

jQuery.ajax( { url: ‘//freegeoip.net/json/’, type: ‘GET’, dataType: ‘jsonp’, success: function(location) { if (location.country_code === ‘GB’) { $(“#currencies”).val(“GBP”); $(“#currencies”).change(); } else if (location.country_code === ‘US’) { $(“#currencies”).val(“USD”); $(“#currencies”).change(); } else { $(“#currencies”).val(“EUR”); $(“#currencies”).change(); } } });

Read More

Check Internet Connection

function doesConnectionExist() { var xhr = new XMLHttpRequest(); var file = “https://www.emretalu.net”; var randomNum = Math.round(Math.random() * 10000); xhr.open(‘HEAD’, file + “?rand=” + randomNum, true); xhr.send(); xhr.addEventListener(“readystatechange”, processRequest, false); function processRequest(e) { if (xhr.readyState == 4) { if (xhr.status >= 200 && xhr.status < 304) { alert(“connection exists!”); } else { alert(“connection doesn’t exist!”); } […]

Read More

jQuery Select Option Sorting Function With LocaleCompare

var sortSelectOptions = function(select, order){ if(order === ‘asc’){ var elements = $(select).children(‘option’).not(‘:first’).get(); elements.sort(function(elm1, elm2){ return $(elm1).text().trim().localeCompare($(elm2).text().trim()); }); $(select).append(elements); }else if(order === ‘desc’){ var elements = $(select).children(‘option’).not(‘:first’).get(); elements.sort(function(elm1, elm2){ return $(elm2).text().trim().localeCompare($(elm1).text().trim()); }); $(select).append(elements); } };

Read More

Cookie Fonksiyonları

(function($){ $.cookie = function(options) { // Default Settings var settings = $.extend({ action : ‘check’, // create or delete cookie_name : ‘cookie’, cookie_value : ‘default’, expiration : ‘Sun, 31 Dec 2017 12:00:00 GMT’, path : ‘/’ }, options); switch(settings.action){ case “create”: create_cookie(); break; case “delete”: delete_cookie(); break; case “check”: return check_for_cookie(); break; case “get”: get_cookie(); […]

Read More

Türkçe Karakter Dönüştürme

function replaceTurkish(text){ var textLower = text.toLowerCase(); var turkish = new Array(“ı”,”ğ”,”ü”,”ş”,”i”,”ö”,”ç”,”I”,”Ğ”,”Ü”,”Ş”,”İ”,”Ö”,”Ç”); var english = new Array(“i”,”g”,”u”,”s”,”i”,”o”,”c”,”i”,”g”,”u”,”s”,”i”,”o”,”c”); for (var i = 0; i < textLower.length; i++){ for(var j = 0; j < 14; j++){ if((textLower.charAt(i)) == turkish[j]){ textLower= textLower.replace((textLower.charAt(i)), english[j]); } } } return textLower; }

Read More

Plaka RegEx

var valid_plate; valid_plate = function(plate) { var regex, v; v = plate.replace(/\s+/g, ”).toUpperCase(); regex = /^(0[1-9]|[1-7][0-9]|8[01])(([A-Z])(\d{4,5})|([A-Z]{2})(\d{3,4})|([A-Z]{3})(\d{2}))$/; return v.match(regex) != null; };

Read More

Add Css Function

function addCss(url) { if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { xhr = new ActiveXObject(“Microsoft.XMLHTTP”); } xhr.open(“GET”, url, false); xhr.send(); var lazyStyle = document.createElement(‘style’); lazyStyle.innerHTML = xhr.responseText; document.head.appendChild(lazyStyle); } addCss(‘https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700&subset=latin,latin-ext’); addCss(‘css/bootstrap.min.css’);

Read More