[html] html5 storage - Local, Session

Having fun with HTML5 — Local Storage and Session Storage


API

The full API spec­i­fi­ca­tion for the local­Stor­age and ses­sion­Stor­age objects can be found here. At the time of writ­ing, this is how the com­mon Stor­age inter­face look:

image

Demo

I’ve put together a quick demo here to illus­trate how to detect and use the local and ses­sion stor­age to get, set, remove and clear stored items (well, basi­cally, cov­ers each of the avail­able meth­ods on the Stor­age inter­face above).

The page itself is sim­ple and crude, just a cou­ple of <div> and most impor­tantly two tables which I use to show all the key value pairs stored in the local and ses­sion storage:

image

Intro­duc­ing the new place­holder attribute

You might have noticed that the two text boxes had place­holder text sim­i­lar to that famil­iar search box in Firefox:

text boxes with place holder text Firefox search box

This is done using HTML5’s place­holder attribute for the <input> tag:

1
2
<input id="keyText" placeholder="Enter key"/>
<input id="valueText" placeholder="Enter value"/>

Nice and easy, eh? ;-)

Set­ting an item

To add a new key value pair or update the value asso­ci­ated with an exist­ing key, you just have to call the setItem method on the intended stor­age object:

1
2
3
4
5
6
7
8
9
10
11
12
13
// adds a new key to both local and session storage
function setKey() {
    var key = $("#keyText").val();
    var value = $("#valueText").val();
 
    if (Modernizr.localstorage) {
        localStorage.setItem(key, value);
    }
    if (Modernizr.sessionstorage) {
        sessionStorage.setItem(key, value);
    }
    showKeys();
}
Remov­ing an item

Ear­lier in the showStorageKeys(type, table) func­tion, I added a row to the rel­e­vant table for each key value pair in the stor­age includ­ing a but­ton with a han­dler for the onclick event. The han­dlers are cre­ated with the cor­rect stor­age type (“local” or “ses­sion”) and key for the cur­rent row baked in already so that they will call the removeItem(type, key) func­tion with the cor­rect parameters:

1
2
3
4
5
6
7
// removes an item with the specified key from the specified type of storage
function removeItem(type, key) {
    // get the specified type of storage, i.e. local or session
    var storage = window[type + 'Storage'];
    storage.removeItem(key);
    showKeys();
}
Clear­ing all items

Finally, the ’”Clear” but­tons under­neath the tables call the clear­LocalKeys() and clearS­es­sion­Keys() func­tion to remove all the key value pairs in the cor­re­spond­ing storage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function clearLocalKeys() {
    clearKeys("local");
}
 
function clearSessionKeys() {
    clearKeys("session");
}
 
// clear all the held keys in the specified type of storage
function clearKeys(type) {
    // get the specified type of storage, i.e. local or session
    var storage = window[type + 'Storage'];
 
    // clear the keys
    storage.clear();
 
    showKeys();
}

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/05/03 22:13 2011/05/03 22:13
, , ,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/6139

[javascript] Carousel - Step carousel

Step Carousel Viewer v1.9


Description: Step Carousel Viewer displays images or even rich HTML by side scrolling them left or right. Users can step to any specific panel on demand, or browse the gallery sequentially by stepping through x number of panels each time. A smooth sliding animation is used to transition between steps. And fear not in taming this script to go exactly where you want it to- two public methods, two custom event handlers, and three "status" variables are here for that purpose. Some highlights of this script:

  • Contents for the Step Carousel Viewer can be defined either directly inline on the page or via Ajax and extracted from an external file instead.

  • Ability to specify whether panels should wrap after reaching the two ends, or stop at the first/last panel.

  • Panel persistence supported, so the last viewed panel can be remembered and recalled within the same browser session.

  • Ability for Carousel to auto rotate as dictated by the new parameter: autostep: {enable:true, moveby:1, pause:3000} During this mode, Carousel pauses onMouseover, resumes onMouseout, and clicking Carousel halts auto rotation altogether.

  • Option to specify two navigational images that's automatically positioned to the left and right of the Carousel Viewer to move the panels back and forth.

  • Ability to auto generate pagination images based on the total number of panels within a Carousel and positioned anywhere on the page. v1.8 feature

  • The contents of a Carousel can be updated on demand after the page has loaded with new contents from an external file. v1.8 feature

Demo #1: Auto rotation enabled (every 3 seconds, 1 panel each time), left/right nav buttons enabled, pagination buttons enabled.

Demo #2: Wrap around enabled ("slide"), left/right nav buttons enabled, pagination buttons enabled, status variables enabled.

Current Panel: 1 Total Panels: 5

Back 1 Panel Forward 1 Panel
To 1st Panel Forward 2 Panels

Demo #3: Wrap around enabled ("pushpull"), variable content widths, moves 2 panels at a time, illustration of new content loaded on demand.

1
2
3
4
5

Back Forward
Currently showing panels: 3 to 5



크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/05/03 19:38 2011/05/03 19:38
,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/6138

http://wowslider.com/ajax-jquery-slide ··· emo.html

WOW Slider - jQuery Carousel & Slider

WOW Slider is a jQuery Image Slider with stunning visual effects and fancy templates.

Features

  • # Awesome and unique transitions: Blinds, Fly, Squares, Explosion, Fade, Slices, Basic
  • # Stylish pre-made designs: Noir, Pulse, Crystal, Noble, Chrome, Block
  • # Lightweight (4-12Kb uncompressed)
  • # Prev/Next controls
  • # Bullet navigation
  • # Customizable speed, delay, size etc.
  • # Cross-browser compatibility
  • # Search engine friendly
  • # Clean and valid markup

More Info: http://wowslider.com/
Live Demos: http://wowslider.com/automatic-jquery- ··· emo.html
http://wowslider.com/ajax-jquery-slide ··· emo.html
http://wowslider.com/jquery-slider-cry ··· emo.html


Recent Demos

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/05/03 19:35 2011/05/03 19:35
, , ,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/6137

2011.04.26 남산3호터널 명동방면, 남산케이블카 입구
사용자 삽입 이미지사용자 삽입 이미지사용자 삽입 이미지
사용자 삽입 이미지사용자 삽입 이미지

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/05/03 19:09 2011/05/03 19:09
, ,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/6136

2011.04.30 4월의 마지막날. 비 많이 오던...
국립민속박물관뜰안에서~
사용자 삽입 이미지사용자 삽입 이미지
사용자 삽입 이미지사용자 삽입 이미지
사용자 삽입 이미지

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/05/03 19:06 2011/05/03 19:06
,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/6135

승마경기에서 장애물은 장애물이 아니라
승마라는 경기를 있게 해주는 결정적 요소다.
장애물을 넘었기 때문에 승마경기를 했다고 할 수 있는 것이다.
꿈도 마찬가지다. 장애물은 옵션이 아니다.
장애물이 있기 때문에 승마경기가 성립되는 것이고,
장애물이 있기 때문에 꿈을 이룰 가치가 있는 것이다.
-채인영, ‘꿈 PD 채인영입니다’에서

자신의 재능을 살려 꿈을 제대로 찾아간다면 그리고
그 길을 묵묵히 꾸준하게 걸어간다면 하늘은 반드시 우리를 도와줍니다.
장애물이 있기 때문에 우리는
하늘이, 우주가, 신이 우리 자신을 돕고 있음을 알게 되는 것입니다.
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/05/03 19:01 2011/05/03 19:01
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/6134

우리 곁에서
꽃이 피어난다는 것은
얼마나 놀라운 생명의 신비인가.
곱고 향기로운 우주가 문을 열고 있는 것이다.
잠잠하던 숲에서 새들이 맑은 목청으로
노래하는 것은 우리들 삶에
물기를 보태주는 가락이다.


- 법정의《산방한담》중에서 -


* 계절을 모르고
물기 없이 살던 때가 저에게도 있었습니다.
꽃이 피는지 지는지, 새소리가 나는지 마는지...
마냥 줄달음만 치던 시절, 돌이켜 보면
아쉽고 억울하기 짝이 없습니다.
삶이 건조해서 물기가 마르면
감성도 사랑도 마릅니다.
생명도 마릅니다.
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2011/05/03 19:00 2011/05/03 19:00
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/6133


블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2011/05   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Statistics Graph

Site Stats

Total hits:
240034
Today:
686
Yesterday:
712