반응형

React — A JavaScript UI library

React

Homepage: http://facebook.github.io/react/
GitHub: https://github.com/facebook/react
Docs: http://facebook.github.io/react/docs/getting-started.html

 

Declarative

React uses a declarative paradigm that makes it easier to reason about your application.

Efficient

React computes the minimal set of changes necessary to keep your DOM up-to-date.

Flexible

React works with the libraries and frameworks that you already know.

Getting Started

JSFiddle

The easiest way to start hacking on React is using the following JSFiddle Hello Worlds

Starter Kit

Download the starter kit to get started.

반응형
반응형

parseURI — Split any URL into logical parts

parseURI lets you split any URL into all of its parts. It has a loose mode that’s great for working with user input, and a strict mode that adheres to RFC 3986.

parseURI

 

반응형

'프로그래밍 > Web' 카테고리의 다른 글

gumby2-backbone-bootstrap  (0) 2013.06.24
Flatdoc — Simple websites for open source projects  (0) 2013.06.24
Codeblock.js— A better code learning environment  (0) 2013.06.20
PreloadJS  (0) 2013.06.20
Angular.JS 의 구조와 특징  (0) 2013.06.13
반응형

JSHint 2.0 — JavaScript error detection

JSHint 2.0 helps you detect errors and possible issues in JavaScript code. It can even be used to enforce coding conventions.

JSHint

 

반응형
반응형

Codeblock.js — A better code learning environment

Codeblock.js makes it possible to embed editable, runnable JavaScript code blocks. Your visitors will have an easier time learning if they can experiment directly with the code.

Codeblock.js

 

반응형
반응형

http://www.catswhocode.com/blog/useful-jquery-code-snippets

 

Smooth scrolling to #anchor

On your site footer, it is very useful to provide a quick way for your visitors to scroll back to the top of the page. Here is a simple way to smooth scroll to a #anchor of your choice.

 

// HTML:
// <h1 id="anchor">Lorem Ipsum</h1>
// <p><a href="#anchor" class="topLink">Back to Top</a></p>


$(document).ready(function() {

	$("a.topLink").click(function() {
		$("html, body").animate({
			scrollTop: $($(this).attr("href")).offset().top + "px"
		}, {
			duration: 500,
			easing: "swing"
		});
		return false;
	});

});

Source: http://snipplr.com/view/26739/jquery–smooth-scroll-to-anchor/

Image resizing using jQuery

Although you should resize your images on server side (using PHP and GD for example) it can be useful to be able to resize images using jQuery. Here’s a handy code snippet to do it.

$(window).bind("load", function() {
	// IMAGE RESIZE
	$('#product_cat_list img').each(function() {
		var maxWidth = 120;
		var maxHeight = 120;
		var ratio = 0;
		var width = $(this).width();
		var height = $(this).height();
	
		if(width > maxWidth){
			ratio = maxWidth / width;
			$(this).css("width", maxWidth);
			$(this).css("height", height * ratio);
			height = height * ratio;
		}
		var width = $(this).width();
		var height = $(this).height();
		if(height > maxHeight){
			ratio = maxHeight / height;
			$(this).css("height", maxHeight);
			$(this).css("width", width * ratio);
			width = width * ratio;
		}
	});
	//$("#contentpage img").show();
	// IMAGE RESIZE
});

Source: http://snipplr.com/view/62552/mage-resize/

Load content on scroll automatically

Some websites such as Twitter loads content on scroll. Which means that all content is dynamically loaded on a single page as long as you scroll down.

Here’s how you can replicate this effect on your website:

var loading = false;
$(window).scroll(function(){
	if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){
		if(loading == false){
			loading = true;
			$('#loadingbar').css("display","block");
			$.get("load.php?start="+$('#loaded_max').val(), function(loaded){
				$('body').append(loaded);
				$('#loaded_max').val(parseInt($('#loaded_max').val())+50);
				$('#loadingbar').css("display","none");
				loading = false;
			});
		}
	}
});

$(document).ready(function() {
	$('#loaded_max').val(50);
});

Source: http://fatfolderdesign.com/173/content-load-on-scroll-with-jquery

Test Password Strength

When building forms, it’s a very good practice to provide verifications on the front-end first so the visitor do not have to submit the form endlessly to correct problems. This code snippet is using regular expressions to test if a password is strong enough. Of course, don’t forget to validate your forms on the server side as well!

$('#pass').keyup(function(e) {
     var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\W).*$", "g");
     var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
     var enoughRegex = new RegExp("(?=.{6,}).*", "g");
     if (false == enoughRegex.test($(this).val())) {
             $('#passstrength').html('More Characters');
     } else if (strongRegex.test($(this).val())) {
             $('#passstrength').className = 'ok';
             $('#passstrength').html('Strong!');
     } else if (mediumRegex.test($(this).val())) {
             $('#passstrength').className = 'alert';
             $('#passstrength').html('Medium!');
     } else {
             $('#passstrength').className = 'error';
             $('#passstrength').html('Weak!');
     }
     return true;
});

Source: http://css-tricks.com/snippets/jquery/password-strength/

Equalize heights of div elements

Equalizing heights of div elements is not possible (or very hacky) to do in pure CSS, so jQuery is here to help. The code below will automatically adjust the heights of div elements according to the higher one.

var maxHeight = 0;

$("div").each(function(){
   if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
});

$("div").height(maxHeight);

Source: http://css-tricks.com/snippets/jquery/equalize-heights-of-divs/

Simple and efficient png fix for IE6

In 2013, IE6 is finally almost gone and people are using newer browsers. But still, in some situations you have to care about this horrible browser and provide a IE6-compliant website. As IE6 can’t deal with png transparency, here’s a super simple jQuery hack to force png rendering.

Just add a .pngfix class to anything you want fixed or put in some other jQuery selector.

$('.pngfix').each( function() {
   $(this).attr('writing-mode', 'tb-rl');
   $(this).css('background-image', 'none');
   $(this).css( 'filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="path/to/image.png",sizingMethod="scale")');
});

Source: http://itknowledgeexchange.techtarget.com/itanswers/

Parsing json with jQuery

Parsing json data with jQuery is not complicated at all. Here is an efficient example on how to parse json data and append it to your web page.

function parseJson(){
	//Start by calling the json object, I will be using a 
        //file from my own site for the tutorial 
	//Then we declare a callback function to process the data
	$.getJSON('hcj.json',getPosts);
 
	//The process function, I am going to get the title, 
        //url and excerpt for 5 latest posts
	function getPosts(data){
 
		//Start a for loop with a limit of 5 
		for(var i = 0; i < 5; i++){
			//Build a template string of 
                        //the post title, url and excerpt
			var strPost = '<h2>' 
				      + data.posts[i].title
				      + '</h2>'
				      + '<p>'
				      + data.posts[i].excerpt
				      + '</p>'
				      + '<a href="'
				      + data.posts[i].url
				      + '" title="Read '
				      + data.posts[i].title
				      + '">Read ></a>';
 
			//Append the body with the string
			$('body').append(strPost);
 
		}
	}
 
}
 
//Fire off the function in your document ready
$(document).ready(function(){
	parseJson();				   
});

Source: http://hankchizljaw.co.uk/tutorials/parse-json-with-jquery-snippet/06/05/2012/

Alternating Row Colors

On big lists or tables, alternating row colors can drastically improve readability. Here’s how to alternate row colors on a list of elements using some jQuery. You can use any HTML element you like, td, tr, li, etc…

//jquery
  $('div:odd').css("background-color", "#F4F4F8");
  $('div:even').css("background-color", "#EFF1F1");


//html example
<div>Row 1</div>
<div>Row 2</div>
<div>Row 3</div>
<div>Row 4</div>

Facebook like image preloader

Ever noticed how fast images load when paging through a Facebook photo album? This is because Facebook is preloading each of these images into your browser’s cache before you even view them. Here’s how you can achieve a similar behavior on your website using some jQuery magic.

var nextimage = "/images/some-image.jpg";
$(document).ready(function(){
window.setTimeout(function(){
var img = $("<img>").attr("src", nextimage).load(function(){
//all done
});
}, 100);
});

Source: http://www.nealgrosskopf.com/tech/thread.php?pid=77

Make entire div clickable

Here’s an easy way to make the parent div of a link clickable. Let’s say you have this html code:

<div class="myBox">
     blah blah blah.
    <a href="http://google.com">link</a>
</div>

The following lines of jQuery will make the entire div clickable:

$(".myBox").click(function(){
     window.location=$(this).find("a").attr("href"); 
     return false;
});

Source: http://css-tricks.com/snippets/jquery/make-entire-div-clickable/

반응형
반응형

PreloadJS is a library to make working with asset preloading easier. It provides a consistent API for loading different file types, automatic detection of XHR (XMLHttpRequest) availability with a fallback to tag-base loading, composite progress events, and a plugin model to assist with preloading in other libraries such as SoundJS.

 

https://github.com/CreateJS/PreloadJS

 

Support and Resources

Built by gskinner.com, and is released for free under the MIT license, which means you can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a requirement.

반응형
반응형

OpenWeatherMap - free weather data and forecast API

 

http://openweathermap.org/

 

 

OpenWeatherMap is a free service that provides weather data and a forecast API that can be used with any mapping services. Data includes current weather, weekly forecast, wind, clouds, precipitation, and more.

OpenWeatherMap

 

 

The OpenWeatherMap service provides free weather data and forecast API suitable for any cartographic services like web and smartphones applications. Ideology is inspired by OpenStreetMap and Wikipedia that make information free and available for everybody. OpenWeatherMap provides wide range of weather data such as map with current weather, week forecast, precipitation, wind, clouds, data from weather stations and many others. Weather data is recieved from global meterological broadcast services and more than 40 000 weather stations.

 

Getting current weather data

Using this kind of requests you can get weather data in any location on the earth. The current weather data are updated online based on data from more than 40,000 weather stations. All weather data can be obtained in JSON, XML or HTML format.

You can search weather data by different ways:

  • By city name
  • By geographic coordinats
  • By city ID

Examples of JSON format:

Examples of XML format:

To get data in XML or HTML formats you need to use mode = xml or html. Example:

Data format:

You can use different types of metric systems by units = metric or imperial
Example: api.openweathermap.org/data/2.5/weather?q=London&mode=xml&units=metric

Multilingual support:

You can use lang parameter to get output in your language. We support the following languages that you can use with the corresponded lang values: English - en, Russian - ru, Italian - it, Spanish - sp, Ukrainian - ua, German - de, Portuguese - pt, Romanian - ro, Polish - pl, Finnish - fi, Dutch - nl, French - fr, Bulgarian - bg, Swedish - se, Chinese Traditional - zh_tw, Chinese Simplified - zh_cn, Turkish - tr
Example: http://api.openweathermap.org/data/2.5/forecast/daily?id=524901&lang=zh_cn

Call back function for JavaScript code:

To use JavaScrip code you can transfer callback functionName to JSONP callback.
Example: api.openweathermap.org/data/2.5/weather?q=London,uk&callback=test

More about data returned:

 


You can recieve weather forecast in any location on the earth. The flexible algorithm of weather calculation let us provide weather data not only for cities but for any geographic coordinates. It is important for megapolices, for example, where weather is different on opposit city edges. You can get forecast data every 3 hours or daily. The 3 hours forecast is available for 5 days. Daily forecast is available for 14 days. All weather data can be obtained in JSON or XML format.

You can search weather data by different ways:

  • By city name
  • By geographic coordinats
  • By city ID

Getting forecast data every 3 hours


Getting daily forecast weather data

You can get weather forecast for 14 days. All weather data can be obtained in JSON or XML format.

Examples:


You can search weather data by different ways:

  • By city name. Put the city name or its part and get the list of the most proper cities in the world. Example - Lon or Lond or London. The more precise city name you put the more precise list you will get. To make it more precise put the city's name or its part, comma, the name of the county or 2-letter country code. You will get all proper cities in chosen county. The order is important - the first is city name than comma than county. Example - Lon, UK or Lon, GB or London, GB or Lon, England.
  • By geographic coordinats.

Seaching by city name

api.openweathermap.org/data/2.5/find?q=London&units=metric&mode=xml

Seaching by geographic coordinats

api.openweathermap.org/data/2.5/find?lat=57&lon=-2.15

Data output format:

Restriction output:

To limit number of listed cities please setup cnt parameter api.openweathermap.org/data/2.5/find?lat=57&lon=-2.15&cnt=3

Accuracy:

To setup accuracy level please use type parameter that have two values - accurate and like. In case of accurate value you will get results that exactly equivalent to your searching word. In case of like value the result is searching by substring. type ['accurate', 'like']
Example


 

Metric systems:


반응형

'프로그래밍' 카테고리의 다른 글

[EDITOR] Sublime 2.0.2 Update  (0) 2013.07.10
컬쳐랜드 오류에 대해서...  (0) 2013.06.20
SSO(Single Sign On)  (0) 2013.06.14
drupal - 드루팔  (0) 2013.06.11
문자메시지 피싱(SMS phising, 스미싱)  (0) 2013.06.10
반응형

Bootstrap

Sleek, intuitive, and powerful front-end framework for faster and easier web development.

 

http://twitter.github.io/bootstrap/

 

Github : https://github.com/twitter/bootstrap

 

Download : http://twitter.github.io/bootstrap/assets/bootstrap.zip

 

Less.js : The dynamic stylesheet language.

Less.js : http://lesscss.org

                https://github.com/cloudhead/less.js

 

 

Bootstrap : Scaffolding (http://twitter.github.io/bootstrap/scaffolding.html)

 - built on responsive 12-column grids, layouts, and components.

    부트스트랩에는 컬럼,레이아웃,컴포넌트가 있어서 구현에 용이하다.

 

 

Customize and download : http://twitter.github.io/bootstrap/customize.html

 : 필요한 요소들만 선택해서 다운로드 받을 수 있다.

 

Javascript : componets to life-now with 13 custom jQuery plugins.

 : 자바스크립트 플러그인이 포함되어 있다.

  http://twitter.github.io/bootstrap/javascript.html

반응형

+ Recent posts