add com..

This commit is contained in:
wlh
2015-01-07 22:49:23 +08:00
parent b690d5bdbf
commit e31afd76bb
14 changed files with 412 additions and 11 deletions
+109 -1
View File
@@ -1,17 +1,125 @@
(function(global){
var calendar_codeshow = document.getElementById('calendar_codeshow');
var guid_codeshow = document.getElementById('guid_codeshow');
var cookie_codeshow = document.getElementById('cookie_codeshow');
var tip_codeshow = document.getElementById('tip_codeshow');
var mask_codeshow = document.getElementById('mask_codeshow');
//日历
var canlendar = new Calendar('calendar',new Date('2015-1'));
canlendar.showUI(function(date){
document.getElementById('calendar_time').innerHTML = date;
});
//GUID
var guid_textarea = document.getElementById('guid_textarea');
guid_textarea.value = guid.create();
//mask
new Mask('mask_container').show();
//tip
Tip('tip_avatar', {
content: '<img src="img/avatar.png"/>',
height: 200,
width:200
});
setShow('calendar_codeshow');
//初始化hash
var hash = window.location.hash;
if(hash){
switch(hash){
case '#calendar':
setShow('calendar_codeshow');
break;
case '#guid':
setShow('guid_codeshow');
break;
case '#cookie':
setShow('cookie_codeshow');
break;
case '#tip':
setShow('tip_codeshow');
break;
case '#mask':
setShow('mask_codeshow');
break;
default:
setShow('calendar_codeshow');
break;
}
}
document.getElementById('calendar_menu').onclick = function(){
window.location.hash = 'calendar';
setShow('calendar_codeshow');
};
//GUID
document.getElementById('guid').onclick = function(){
alert(11);
window.location.hash = 'guid';
setShow('guid_codeshow');
};
document.getElementById('guid_genrator').onclick = function(){
guid_textarea.value = guid.create();
};
//cookie
document.getElementById('cookie').onclick = function(){
window.location.hash = 'cookie';
setShow('cookie_codeshow');
};
document.getElementById('allCookie').value = JSON.stringify(cookie.getCookies());
document.getElementById('setCookie').onclick = function(){
var name = document.getElementById('cookie_name').value || '';
var value = document.getElementById('cookie_value').value || '';
if(name && value){
cookie.set(name, value);
}
document.getElementById('allCookie').value = JSON.stringify(cookie.getCookies());
};
document.getElementById('tip').onclick = function(){
window.location.hash = 'tip';
setShow('tip_codeshow');
};
document.getElementById('mask').onclick = function(){
window.location.hash = 'mask';
setShow('mask_codeshow');
};
//控制div的显示与隐藏
function setShow(name){
calendar_codeshow.style.display = 'none';
guid_codeshow.style.display = 'none';
cookie_codeshow.style.display = 'none';
tip_codeshow.style.display = 'none';
mask_codeshow.style.display = 'none';
switch(name){
case 'calendar_codeshow':
calendar_codeshow.style.display = 'block';
break;
case 'guid_codeshow':
guid_codeshow.style.display = 'block';
break;
case 'cookie_codeshow':
cookie_codeshow.style.display = 'block';
break;
case 'tip_codeshow':
tip_codeshow.style.display = 'block';
break;
case 'mask_codeshow':
mask_codeshow.style.display = 'block';
break;
default:
break;
}
};
})(this);