File: /www/wwwroot/bs.kntsleep.com/system/web/common/js/global.js
var at = window.location.hash.match(/#_alert=(.+?),(red|green|blue|yellow|gold)/);
if(at){
_alert(decodeURI(at[1]),at[2]);
window.location.hash = window.location.hash.replace(at[0],'');
}
function _alert(str, type){
var date = new Date();
now = date.getTime();
$('body').append('<h6 class="alert '+type+'" time="'+now+'" style="z-index:'+now+';"><b>'+str.replace(/</g,'<').replace(/>/g,'>')+'</b></h6>');
tha = $('h6.alert[time="'+now+'"]');
tha.animate({top:78,opacity:1},288);
(function(tha){
window.setTimeout(function(){
tha.remove();
},
tha.hasClass('green')?3000:2000);
})(tha);
}
function _finput(obj){
obj.each(function(){
$(this).after('<div class="file_input">'+$(this)[0].outerHTML+'<input type="text" placeholder="'+$(this).attr('placeholder')+'" /><i class="fa fa-folder-open-o"></i></div>');
$(this).remove();
})
}
_finput($('dl.form8 input[name^="params"][type="file"]'));
$(document).on('change','div.file_input input[type=file]',function(e){
files = e.target.files;
if(files.length>0){
$(this).next('input[type=text]').val(files[0].name);
}
}).on('change','select[tight]',function(){
select = $(this);
$.get($G['relative']+'system/web/common/tight/'+$(this).attr('tight')+'.json',function(data){
parent = select.attr('parent');
val = select.val();
if(val!==""){
for(k in data){
if(k.match(new RegExp('^'+parent+',')) && data[k]==val){
select.nextAll('select[tight]').remove();
id = k.split(',')[1];
option = '';
for(k2 in data){
if(k2.match(new RegExp('^'+id+','))){
option += '<option value="'+data[k2]+'">'+data[k2]+'</option>';
}
}
if(option){
newsel = $(select[0].outerHTML);
ph = newsel.attr('ph');
ph = ph?JSON.parse(ph):[];
newsel.attr('parent',id);
newsel.attr('required','required');
newsel.html('<option value="">'+ph[select.index()+1]+'</option>'+option);
select.after(newsel);
}
break;
}
}
}else{
select.nextAll('select[tight]').remove();
}
},'json');
});
{if:(config.member_open)}
$('*[collect*="_"]').click(function(){
ct = $(this).attr('collect');
if(ma = ct.match(/^(\d+)_(\d+)$/)){
$.post(
$G['relative']+'api/member/?action=collect&func=add&jsonmsg=true&lang='+$G['lang'],
{
type: ma[1],
id: ma[2]
},
function(data){
_alert(data.msg,data.state.match(/^\w+$/)?'red':'green');
},
'json'
);
}
});
{/if}