Skip to content

Instantly share code, notes, and snippets.

View hwclass's full-sized avatar

Barış Güler hwclass

View GitHub Profile
@hwclass
hwclass / base.html
Last active January 1, 2016 19:59
Page by Page Namespace with IIFE Code Structure
<!DOCTYPE html>
<html lang="tr" class="no-js">
<head>
<link rel="canonical"/>
<title>Project Name</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="test"/>
<meta name="keywords" content="test"/>
<meta property="fb:app_id" content="229179347121022"/>
@hwclass
hwclass / jquery.equalheight.js
Created April 7, 2014 10:33
Code Update for Equal Height by @micahgodbolt
(function ($) {
$.fn.equalHeight = function () {
var container = this;
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).each(function () {
$el = $(this);
/**
* addEvent() controls event-handling for cross-browser issues
*
* @param <Array> elem
* @param <Array> event
* @param <Function> fn
*
*/
var app = app || {};
@hwclass
hwclass / pubsub
Created June 12, 2014 19:00
A Pub / Sub Sample
var events = (function(){
var topics = {};
return {
subscribe: function(topic, listener) {
// Create the topic's object if not yet created
if(!topics[topic]) topics[topic] = { queue: [] };
// Add the listener to queue
var index = topics[topic].queue.push(listener);
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
@hwclass
hwclass / main.js
Created June 29, 2014 14:45
jQuery init element structural example
var initElement = function (options) {
if (typeof options.el !== 'undefined') {
options.init();
}
}
initElement({
el : document.querySelector('.navdrawer-container'),
val : 'Test element.',
fn : {
@hwclass
hwclass / main.js
Last active August 29, 2015 14:03
Native init element structural example
(function () {
var initElement = function (options) {
var getSize = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
Validator.showErrors = function() {
for(var count=0; count < this.errors.length; count++){
console.log(this.errors[count])
}
}
@hwclass
hwclass / RomanNumber-challange1.js
Last active August 29, 2015 14:10
Some variations to change a number value into Roman type.
var romanValues = new Array(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1);
var romanStrings = new Array("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I");
function calculate(hinduArabicNumber) {
var numb = parseInt(hinduArabicNumber);
if (isNaN(numb)) {
alert("Please enter a number");
return;
}
if ( numb > 9999 || numb < 1) {
@hwclass
hwclass / prot_examp_1
Created January 19, 2015 14:19
JS Prototypal Inheritance Practical Example 1
// Declaring our Animal object
var Animal = function () {
this.name = 'unknown';
this.getName = function () {
return this.name;
}
return this;