Created
October 6, 2014 13:38
-
-
Save alherd-by/a52a9ec9e2c056b021fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html id="day"> | |
<head> | |
<script type="text/javascript">(function(){ | |
var | |
d=(new Date({$time}*1000)).getHours(); | |
document.documentElement.id=d>=23||d<9?"night":"day"; | |
})();</script> | |
<meta charset="utf-8"/> | |
<title>box.unet.by</title> | |
<link rel="stylesheet" type="text/css" href="{$tpl_home}/css/global.css"/> | |
<!--[if IE 8]><link rel="stylesheet" type="text/css" href="{$tpl_home}/css/ie8fix.css"/><script type="text/javascript" src="{$tpl_home}/scripts/ie8fix.js"></script><![endif]--> | |
<style type="text/css"> | |
#track-name > a:hover,#image-name a:hover{ | |
text-decoration: underline; | |
} | |
</style> | |
<script type="text/javascript" src="{$tpl_home}/scripts/history.js"></script> | |
</head> | |
<body> | |
<div id="body"> | |
<div style="padding:0 1px;"> | |
<div style="position: relative;"> | |
<div id="backing"> | |
<div id="image-container"> | |
<img id="image" style="display: none;"/> | |
</div> | |
<div id="error-container"><div id="error-wrapper"></div></div> | |
<div id="image-name"><div><a target='_blank'></a><div id="get-url"><a href="#">Получить ссылку</a><span><input type="text"><div id="copy-hint">Теперь нажмите Ctrl+C<span></span></div></span></div></div></div> | |
<button id="closer"><span class="icon icon-close"></span></button> | |
<div id="video-container"></div> | |
</div> | |
</div> | |
</div> | |
<div id="load" class="center"> | |
<p><form action="/uploader" method="post" enctype="multipart/form-data" id="form" style="position: relative;display: inline-block;"> | |
<span style="position: relative;display:inline-block;"> | |
<input id="button" type="button" value="Загрузить файл через браузер"/> | |
<input name="file" id="file" multiple="multiple" type="file" value=""/> | |
</span> | |
<input data-table="tips" type="button" id="tips" value="?"/> | |
<input type="button" id="errors" value="!" style="display: none;"/> | |
</form></p> | |
<div style="display: none;"> | |
<p class="margin">или</p> | |
<div class="width-wrap"><p><input type="search" value="" id="url"/><label for="url" class="input-hint">по URL-адресу в Интернете</label></p></div> | |
</div> | |
<p style="margin:4em 0 0;" class="mouse-info">Можно также перетащить его мышью прямо сюда</p> | |
<div id="loading" class="progress" data-table="loading" style="display: none"> | |
<div class="progress-wrap"> | |
<p id="progressbar"></p> | |
<span id="progresstext" class="progress-text"> | |
<span id="progressfilename" class="text-wrap"></span> | |
<span id="progresspercent"></span> | |
</span> | |
</div> | |
</div> | |
</div> | |
<div class="left" id="list"> | |
<div class="list-wrap"> | |
<div> | |
<table id="table-loading"> | |
<thead> | |
<tr> | |
<td>Имя загружаемого файла</td> | |
<td class="even right">Размер</td> | |
<td class="ago">Состояние</td> | |
</tr> | |
</thead> | |
<tbody id="loadingList"></tbody> | |
</table> | |
</div> | |
<div> | |
<table id="table-tips"> | |
<thead> | |
<tr> | |
<td>Информация</td> | |
</tr> | |
</thead> | |
<tbody> | |
<tr><td>Размер каждого файла — до 200 МБ. <span class="mouse-info">Файлы можно перетаскивать мышью в это окно.</span></td></tr> | |
<tr><td><p> | |
Можно загружать | |
<span class="bold">архивы</span> (rar, zip, 7z), | |
<span class="bold">музыку</span> (mp3, wav, mid, wma), | |
<span class="bold">текст и таблицы</span> (txt, log, doc, docx, rtf, xls, xlsx, pdf), | |
<span class="bold">образы</span> (iso, mds, mdf, ngr), | |
<span class="bold">изображения и модели</span> (jpg, png, bmp, gif, psd, cdr, fly) и | |
<span class="bold">видео</span> (mp4, avi, mov, mpg, wmv, flv). | |
</p></td></tr> | |
<tr><td>Сразу после загрузки Вы сможете прослушать/просмотреть загруженный файл.</td></tr> | |
<tr><td>Чтобы вернуться назад к списку файлов, кликните в любой области экрана.</td></tr> | |
<tr><td>Чтобы просмотреть, что находится в очереди, кликните по индикатору загрузки.</td></tr> | |
</tbody> | |
</table> | |
</div> | |
<div class="active"> | |
<table id="table-current"> | |
<thead> | |
<tr> | |
<td>Имя файла</td> | |
<td class="even right">Размер</td> | |
<td class="ago">Загружено</td> | |
</tr> | |
</thead> | |
<tbody id="currentList"> | |
{assign var="filecounter" value=0} | |
{foreach from=$list item=item} | |
{assign var="filecounter" value=$filecounter+1} | |
{if strrpos($item->filename,'.')===false} | |
{assign var="ext" value=""} | |
{else} | |
{assign var="ext" value=substr($item->filename, strrpos($item->filename,".")+1)} | |
{/if} | |
{if $filecounter>6}{break}{/if} | |
<tr> | |
<td class="text-wrap"> | |
<a | |
data-ext="{$ext}" | |
href="/b/{$item->id}" | |
id="file-{$item->id}" | |
data-mime="{$item->mime}" | |
{assign var="type5" value={$item->mime|substr:0:5}} | |
{if $type5=="audio" && in_array(strtolower($ext),array('mp3','mp4','ogg','wav'))} | |
class="play" | |
{elseif $type5=="video" && in_array(strtolower($ext),array('mp4','webm','ogv','flv','mov'))} | |
class="play" | |
{elseif $type5=="image" && in_array(strtolower($ext),array('jpg','jpeg','png','gif','bmp'))} | |
class="view" | |
{else} | |
class="link" | |
{/if} | |
target="_blank" | |
data-name="{$item->filename}" | |
data-direct="/f/{(intval($item->id / 1000))}/{$item->tmp_name}" | |
data-download="/d/{$item->id}" | |
data-preview="" | |
> | |
<span class="text">{$item->filename}</span> | |
<span class="icon"></span> | |
</a> | |
</td> | |
<td class="even right">{$item->size}</td> | |
<td data-time="{$item->time}"> </td> | |
</tr> | |
{/foreach} | |
</tbody> | |
</table> | |
</div> | |
</div> | |
</div> | |
<div id="pane"> | |
<table style="width: 100%;border:none;border-spacing: 0;border-collapse: collapse;"> | |
<tr> | |
<td style="width:0;padding-right:1em;"> | |
<button id="playpause"> | |
<span class="icon icon-play"></span> | |
</button> | |
</td> | |
<td style="vertical-align: middle;width:100%;"> | |
<div> | |
<div id="track-name"><a target='_blank'></a><div id="get-url2"><a href="#">Получить ссылку</a><span><input type="text"><div id="copy-hint2">Теперь нажмите Ctrl+C<span></span></div></span></div></div> | |
<table style="width:100%;height:1.5em;"> | |
<tr> | |
<td style="padding:0 1em;vertical-align: middle;cursor:pointer;"> | |
<div class="progressbar"> | |
<div class="done"></div> | |
<div id="playback-handle" class="handle"></div> | |
</div> | |
</td> | |
<td style="padding:0 1em;width:4em;vertical-align: middle;cursor:pointer;"> | |
<div class="progressbar"> | |
<div class="done volume"></div> | |
<div id="playback-volume" class="handle"></div> | |
</div> | |
</td> | |
</tr> | |
</table> | |
</div> | |
</td> | |
<td style="width:0;padding-left:1em;"> | |
<button id="playback-close"> | |
<span class="icon icon-close"></span> | |
</button> | |
</td> | |
</tr> | |
</table> | |
</div> | |
</div> | |
<script type="text/javascript" src="{$tpl_home}/scripts/global.js"></script> | |
<script type="text/javascript" src="{$tpl_home}/scripts/sendfile.js"></script> | |
<script type="text/javascript" src="{$tpl_home}/scripts/audioPlayer.js"></script> | |
<script type="text/javascript" src="{$tpl_home}/scripts/videoPlayer.js"></script> | |
<script type="text/javascript"> | |
(function(){ | |
//TODO поисправлять ошибки, созникающие во время перетаскивания в браузер, когда идёт воспроизведение | |
var | |
sender=fileSender(), | |
MAX_FILES=6; | |
var | |
IDS=(function(){ | |
var | |
a={ }, k,q; | |
q=document.querySelectorAll("*[id]"); | |
for(k=q.length;k--;){ | |
a[q[k].id]=q[k]; | |
} | |
return a; | |
})(); | |
var | |
LANG={ | |
s_b:"Б", | |
s_kb:"КБ", | |
s_mb:"МБ", | |
s_gb:"ГБ", | |
s_tb:"ГБ", | |
s_pb:"ПБ", | |
queued:"В очереди", | |
loading:"Загружается" | |
}, | |
FEATURES={ | |
formdata:("FormData" in window) | |
}, | |
COMMON={ | |
openFileDialog:function(e){ IDS.file.click();e.stopPropagation(); }, | |
submitForm:function(){ | |
var | |
k,l; | |
if(FEATURES.formdata){ | |
for(k=0,l=IDS.file.files.length;k<l;k++){ | |
manager.create({ "file":IDS.file.files[k] }); | |
} | |
} | |
else{ | |
k=IDS.file; | |
createNewFileInput(k); | |
manager.create(k); | |
} | |
if(this.className=="safari"){ | |
safariWinDropFix(); | |
} | |
} | |
}, | |
safariWinDropFix, | |
createNewFileInput=function(hSource){ | |
IDS.file=document.createElement("input"); | |
IDS.file.type="file"; | |
IDS.file.id="file"; | |
IDS.file.name="file"; | |
IDS.file.addEventListener("change",COMMON.submitForm,false); | |
IDS.file.style.cssText=hSource.style.cssText; | |
hSource.parentNode.replaceChild(IDS.file,hSource); | |
}, | |
convertSize=function(iBytes){ | |
var | |
dims=["b","kb","mb","gb","tb","pb"], | |
c=0,c2=0; | |
while(iBytes>=1024){ | |
c++; | |
iBytes/=1024; | |
} | |
while(Math.pow(10,c2)<iBytes){ | |
c2++; | |
} | |
c2=Math.pow(10,Math.max(0,3-c2)); | |
return (Math.round(iBytes*c2)/c2)+" "+LANG["s_"+dims[c]]; | |
}, | |
getTimeName=window.helpers.getTimeName; | |
var | |
manager=(function(){ | |
var | |
cookie=window.helpers.cookie, | |
//TODO удалить default после отладки | |
session=cookie.PHPSESSID || "default", | |
fileCount=cookie.fileCounter || 0, | |
active=null, | |
queue=[], | |
clickHandlerRemove=function(){ | |
this.link.cancel(); | |
}, | |
createRecord=function(sName,sSize,sInfo,oLink){ | |
var | |
tr=document.createElement("tr"); | |
tr.name=(tr.nameLayer=tr.appendChild(document.createElement("td"))).appendChild(document.createElement("span")). | |
appendChild(document.createTextNode(sName) | |
); | |
tr.name.parentNode.appendChild(document.createElement("span")).className="icon"; | |
tr.size=(tr.sizeLayer=tr.appendChild(document.createElement("td"))).appendChild(document.createTextNode(sSize)); | |
tr.info=(tr.infoLayer=tr.appendChild(document.createElement("td"))).appendChild(document.createTextNode(sInfo)); | |
tr.nameLayer.className="text-wrap"; | |
tr.sizeLayer.className="even right"; | |
tr.name.parentNode.className="remove"; | |
tr.name.parentNode.link=oLink; | |
tr.name.parentNode.addEventListener("click",clickHandlerRemove); | |
tr.record=this; | |
return tr; | |
}, | |
generateId=function(){ | |
return session+"_"+ (++fileCount); | |
}, | |
parseInfo=function(mData){ | |
var | |
k; | |
if(mData instanceof Element){ | |
return { | |
name:mData.value.substr(Math.max(mData.value.lastIndexOf("/"),mData.value.lastIndexOf("\\"))+1), | |
size:"" | |
}; | |
} | |
else{ | |
for(k in mData){ | |
return { | |
name:mData[k].name, | |
size:convertSize(mData[k].size) | |
}; | |
} | |
} | |
}, | |
processQueue=function(){ | |
var | |
a=(active?1:0), | |
k=Math.max(0,IDS.loadingList.childNodes.length+a-1), | |
l=Math.min(queue.length+a,MAX_FILES); | |
for(;k<l;k++){ | |
IDS.loadingList.appendChild(queue[k-a].layer); | |
} | |
if(!active && queue.length){ | |
queue[0].upload(); | |
} | |
else{ | |
if(!active){ | |
IDS.loading.style.display="none"; | |
mode.setMode("current"); | |
if(IDS["error-container"].firstChild.childNodes.length){ | |
IDS["errors"].click(); | |
} | |
} | |
} | |
}, | |
removeChildren=function(hRoot){ | |
var | |
t; | |
while(t=hRoot.lastChild){ | |
hRoot.removeChild(t); | |
} | |
}, | |
loadHandler=function(oData){ | |
var | |
a,d=document,t; | |
if(!oData || oData.error && oData.error.error){ | |
t="Невозможно загрузить файл <span>"+active.parsed.name+"</span>: "; | |
switch(oData && oData.error && oData.error.error){ | |
case 1://формат файла не поддерживается | |
t+="формат файла не поддерживается"; | |
break; | |
case 2://слишком длинное имя файла | |
t+="слишком длинное имя файла"; | |
break; | |
default: | |
t+="причина не установлена"; | |
} | |
t+="."; | |
IDS["error-container"].firstChild.appendChild(document.createElement("p")).innerHTML=t; | |
IDS.errors.style.display=""; | |
IDS.loadingList.removeChild(active.layer); | |
} | |
else{ | |
while(IDS.currentList.childNodes.length>=6){ | |
IDS.currentList.removeChild(IDS.currentList.lastChild); | |
} | |
IDS.currentList.insertBefore(active.layer,IDS.currentList.firstChild); | |
active.layer.info.textContent=""; | |
active.layer.infoLayer.setAttribute("data-time",(new Date)/1000); | |
timeUpdater(); | |
if(oData){ | |
if(!active.parsed.size){ | |
active.layer.size.textContent=active.parsed.size=convertSize(oData.size); | |
} | |
removeChildren(active.layer.nameLayer); | |
a=active.layer.nameLayer.appendChild(d.createElement("a")); | |
a.href=oData['url_browse']; | |
a.target="_blank"; | |
var | |
ext='', | |
mime5=oData.type.toLowerCase().substr(0,5); | |
if(oData['filename'].indexOf('.')!=-1){ | |
ext=oData['filename'].substr(oData['filename'].lastIndexOf('.')+1).toLowerCase(); | |
} | |
if(mime5=="audio" && ['mp3','mp4','ogg','wav'].indexOf(ext)!=-1){ | |
a.className="play"; | |
} | |
else if(mime5=="video" && ['mp4','webm','ogv','flv','mov'].indexOf(ext)!=-1){ | |
a.className="play"; | |
} | |
else if(mime5=="image" && ['jpg','jpeg','png','gif','bmp'].indexOf(ext)!=-1){ | |
a.className="view"; | |
} | |
else{ | |
a.className="link"; | |
} | |
a.setAttribute("data-name",oData['filename']); | |
a.setAttribute("data-mime",oData['type']); | |
a.setAttribute("data-direct",oData['url']); | |
a.setAttribute("data-browse",oData['url_browse']); | |
a.setAttribute("data-download",oData['url_download']); | |
a.setAttribute("data-preview",''); | |
(t=a.appendChild(d.createElement("span"))).className="text"; | |
t.appendChild(d.createTextNode(oData.filename)); | |
a.appendChild(d.createElement("span")).className="icon"; | |
a.addEventListener("click",openHandler); | |
} | |
} | |
if(!oData){ console.log("Response was not parsed."); } | |
active=null; | |
processQueue(); | |
}, | |
uploadHandler=function(oData){ | |
if(!active){ | |
return; | |
} | |
var | |
percent=oData.received/oData.size, | |
v=Math.round(percent*1000)/10; | |
if(v==(v|0)){ | |
v+=".0%"; | |
} | |
else{ | |
v+="%"; | |
} | |
IDS.progressfilename.innerHTML=active.parsed.name; | |
IDS.progresspercent.innerHTML=" — "+v; | |
IDS.progressbar.style.width=v; | |
if(!oData){ console.log("Response was not parsed."); } | |
if(!active.parsed.size && oData){ | |
active.layer.size.textContent=active.parsed.size=convertSize(oData.size); | |
} | |
}, | |
openHandler=function(e){ | |
var | |
w, | |
info=getInfoFromLink(this); | |
if(e.ctrlKey || e.shiftKey || e.altKey){ | |
return; | |
} | |
if(!(e.target.nodeName.toLowerCase()=="span" && e.target.className=="icon")){ | |
if(browseFile(info,e)){ | |
forward(info); | |
} | |
} | |
else{ | |
window.open(info[2],'_blank'); | |
e.preventDefault(); | |
} | |
}, | |
Record=function Record(mData){ | |
this.data=mData; | |
this.parsed=parseInfo.call(this,mData); | |
this.layer=createRecord.call(this,this.parsed.name,this.parsed.size,LANG.queued,this); | |
this.layer.link=this; | |
this.id=generateId(); | |
if(!queue.length && !active){ | |
IDS.loading.style.display=""; | |
mode.setMode("loading"); | |
} | |
queue.push(this); | |
processQueue(); | |
}; | |
//TODO перейти на extend | |
Record.prototype={ | |
cancel:function(){ | |
if(active==this){ | |
sender.cancel(this.uploader); | |
active=null; | |
} | |
else{ | |
queue.splice(queue.indexOf(this),1); | |
} | |
this.layer.parentNode.removeChild(this.layer); | |
this.layer=null; | |
processQueue(); | |
}, | |
upload:function(){ | |
active=this; | |
queue.splice(queue.indexOf(this),1); | |
this.layer.info.textContent=LANG.loading; | |
IDS.form.action="/uploader?X-Progress-ID="+this.id; | |
this.uploader=sender.send(this.data,IDS.form,loadHandler,uploadHandler,this.id); | |
} | |
}; | |
if(!FEATURES.formdata){ | |
IDS.file.removeAttribute("multiple"); | |
} | |
(function(){ | |
var k,a; | |
while(k=IDS.loadingList.lastChild){ | |
IDS.loadingList.removeChild(k); | |
} | |
for(k=IDS.currentList.firstElementChild;k;k=k.nextElementSibling){ | |
a=k.getElementsByTagName("a"); | |
if(!a || !a[0]){ | |
console.log("Структура записи сломана (не найден <a>). Проверь ещё раз."); | |
} | |
else{ | |
a[0].addEventListener("click",openHandler,false); | |
} | |
a=k.getElementsByTagName("td")[1]; | |
if(!a){ | |
console.log("Структура записи сломана (не найден 2-й <td>). Проверь ещё раз."); | |
} | |
else{ | |
a.innerHTML=convertSize(a.innerHTML-0); | |
} | |
} | |
window.onunload=function(){ | |
window.helpers.saveCookie("fileCounter",fileCount,false); | |
}; | |
})(); | |
return { | |
create:function(mData){ | |
new Record(mData); | |
}, | |
cancel:function(){ } | |
}; | |
})(), | |
mode=(function(){ | |
var | |
mode="current", | |
prevMode=null, | |
tables=["current","loading","tips"], | |
tableLink={ }, | |
sp=function(e){ | |
e.stopPropagation(); | |
}, | |
turnOnHighlight=function(){ | |
this.className+=" highlighted"; | |
IDS.backing.className="highlighted"; | |
}, | |
turnOffHighlight=function(){ | |
if(mode in IDS){ | |
IDS[mode].className=IDS[mode].className.replace(/ highlighted/g,""); | |
} | |
IDS.backing.className=""; | |
}, | |
overHandler=function(){ | |
setActiveTable(this.getAttribute("data-table"),false); | |
}, | |
outHandler=function(){ | |
if(mode!=this.getAttribute("data-table")){ | |
setActiveTable(mode,false); | |
} | |
}, | |
clickHandler=function(e){ | |
if(mode!="current"){ | |
turnOffHighlight(); | |
} | |
setActiveTable(this.getAttribute("data-table"),true); | |
if(mode in IDS){ | |
turnOnHighlight.call(this); | |
} | |
e.stopPropagation(); | |
}, | |
setActiveTable=function(sName,bNewMode,bForceHighlight){ | |
var k; | |
for(k in tableLink){ | |
tableLink[k].parentNode.className=""; | |
} | |
tableLink[sName].parentNode.className="active"; | |
if(bNewMode){ | |
if(mode!=sName){ | |
prevMode=mode; | |
mode=sName; | |
} | |
} | |
if(bForceHighlight){ | |
if(mode!="current"){ | |
turnOnHighlight.call(IDS[sName]); | |
} | |
else{ | |
turnOffHighlight(); | |
} | |
} | |
}, | |
intf={ | |
setMode:function(sName){ | |
setActiveTable(sName,true,true); | |
} | |
}; | |
(function(){ | |
var k; | |
for(k=tables.length; k--;){ | |
tableLink[tables[k]]=document.getElementById("table-"+tables[k]); | |
} | |
})(); | |
with(IDS){ | |
tips.addEventListener("mouseover",overHandler,false); | |
tips.addEventListener("click",clickHandler,false); | |
tips.addEventListener("mouseout",outHandler,false); | |
loading.addEventListener("mouseover",overHandler,false); | |
loading.addEventListener("click",clickHandler,false); | |
loading.addEventListener("mouseout",outHandler,false); | |
list.addEventListener("click",sp,false); | |
backing.addEventListener("click",sp,false); | |
file.addEventListener("click",sp,false); | |
document.body.addEventListener("click",function(){ | |
turnOffHighlight(); | |
setActiveTable("current",true); | |
},false); | |
form.addEventListener("click",sp,false); | |
} | |
return intf; | |
})(), | |
ignoreBack=false, | |
getInfoFromLink=function(link){ | |
return [ | |
link.getAttribute('data-name'),//имя файла | |
link.getAttribute('data-mime'), | |
link.getAttribute('data-direct'),//прямая ссылка на файл (для плееров) | |
link.getAttribute('data-browse'),//ссылка на страницу | |
link.getAttribute('data-download'),//ссылка на загрузку (для ссылки плееров) | |
link.className.indexOf('link')==-1 | |
]; | |
}, | |
browseFile=function(fileinfo,e){ | |
var | |
media=false; | |
if(!fileinfo){ | |
return false; | |
} | |
switch(fileinfo[1].substr(0,5) ){ | |
case "audio": | |
media=true; | |
if(fileinfo[5]){ | |
playerManager.playAudio(fileinfo[2],fileinfo[0],fileinfo[2],fileinfo[1]); | |
e && e.preventDefault(); | |
break; | |
} | |
case "video": | |
media=true; | |
if(fileinfo[5]){ | |
playerManager.playVideo(fileinfo[2],fileinfo[0],fileinfo[2],fileinfo[1]); | |
e&&e.preventDefault(); | |
break; | |
} | |
case "image": | |
media=true; | |
if(fileinfo[5]){ | |
playerManager.viewImage(fileinfo[2],fileinfo[0],fileinfo[2]); | |
e&&e.preventDefault(); | |
break; | |
} | |
default: | |
if(!fileinfo[5] || media){ | |
window.open(fileinfo[4],'_blank'); | |
e&&e.preventDefault(); | |
return false; | |
} | |
} | |
return true; | |
}, | |
timeUpdater=function(){ | |
var k=IDS.currentList.firstElementChild, v; | |
for(; k; k=k.nextElementSibling){ | |
if(v=k.lastElementChild.getAttribute("data-time")){ | |
if(!k.lastElementChild.firstChild){ | |
k.lastElementChild.appendChild(document.createTextNode('')); | |
} | |
k.lastElementChild.firstChild.textContent=getTimeName(v-0); | |
} | |
} | |
}, | |
playerManager=(function(){ | |
var | |
watcher=(function(){ | |
var | |
intervalID=0; | |
return { | |
start:function(){ | |
if(!intervalID){ | |
intervalID=setInterval(watcherHandler,50); | |
} | |
}, | |
stop:function(){ | |
if(intervalID){ | |
clearInterval(intervalID); | |
intervalID=0; | |
} | |
} | |
}; | |
})(), | |
watcherHandler=function(){ | |
var | |
pos=0; | |
try{ | |
switch(playerMode){ | |
case "v": | |
pos=videoPlayer.getPosition(); | |
break; | |
case "a": | |
pos=audioPlayer.getPosition(); | |
break; | |
} | |
} | |
catch(e){ | |
console.log(e); | |
watcher.stop(); | |
} | |
pos=(pos||0)*100+"%"; | |
IDS["playback-handle"].style.left=pos; | |
IDS["playback-handle"].previousElementSibling.style.width=pos; | |
}, | |
playerMode=null,//"v","i","a" | |
playing=false, | |
changingSource=false, | |
audioPlayer=new AudioPlayer, | |
videoPlayer=new VideoPlayerSimple(IDS["video-container"]), | |
toggleHandler=function(){ | |
IDS["playpause"].firstElementChild.className="icon icon-"+(!playing?"play":"pause"); | |
}, | |
clickHandler=function(){ | |
pause(); | |
toggleHandler(); | |
}, | |
play=function(sUrl,sMode,sName,sMime,sDownload){ | |
stop(); | |
switch(playerMode=sMode){ | |
case "v": | |
changingSource=true; | |
IDS.body.className="pane fullsize video"; | |
videoPlayer.play(sUrl,sMime); | |
IDS["track-name"].firstChild.innerHTML=1; | |
break; | |
case "a": | |
changingSource=true; | |
IDS.body.className="pane"; | |
audioPlayer.play(sUrl,sMime); | |
IDS["track-name"].firstChild.innerHTML=1; | |
break; | |
} | |
IDS["track-name"].firstChild.innerHTML=sName;//"<a href='"+sDownload+"' target='_blank'>"+sName+"</a>" | |
IDS["track-name"].firstChild.href=sDownload; | |
IDS["get-url2"].firstChild.href=sDownload; | |
IDS["get-url2"].lastChild.firstChild.value=IDS["get-url2"].firstChild.href; | |
IDS["get-url2"].firstChild.style.display=""; | |
IDS["get-url2"].firstChild.nextSibling.style.display="none"; | |
//IDS["track-name"].appendChild(document.createTextNode(sName||"")); | |
playing=true; | |
toggleHandler(); | |
}, | |
pause=function(){ | |
switch(playerMode){ | |
case "v": | |
videoPlayer.pause(); | |
playing=videoPlayer.isPlaying(); | |
break; | |
case "a": | |
audioPlayer.pause(); | |
playing=audioPlayer.isPlaying(); | |
break; | |
} | |
}, | |
seek=function(nPos){ | |
switch(playerMode){ | |
case "v": | |
videoPlayer.seek(nPos); | |
break; | |
case "a": | |
audioPlayer.seek(nPos); | |
break; | |
} | |
}, | |
stop=function(){ | |
switch(playerMode){ | |
case "v": | |
videoPlayer.pause(true); | |
break; | |
case "a": | |
audioPlayer.pause(true); | |
break; | |
} | |
playerMode=null; | |
IDS["body"].className=""; | |
}, | |
setVolume=function(nVolume){ | |
switch(playerMode){ | |
case "v": | |
videoPlayer.setVolume(nVolume); | |
break; | |
case "a": | |
audioPlayer.setVolume(nVolume); | |
break; | |
} | |
IDS["playback-volume"].previousElementSibling.style.width= | |
IDS["playback-volume"].style.left= | |
-nVolume*100+"%"; | |
}, | |
dontClearErrors=false, | |
intf, | |
closeHandlerImage, | |
closeHandlerAV; | |
videoPlayer.onready=audioPlayer.onready=function(){ | |
videoPlayer.setVolume(100); | |
audioPlayer.setVolume(100); | |
IDS["playback-volume"].previousElementSibling.style.width= | |
IDS["playback-volume"].style.left="100%"; | |
}; | |
videoPlayer.onplay=audioPlayer.onplay=function(){ | |
changingSource=false; | |
playing=true; | |
toggleHandler(); | |
watcher.start(); | |
}; | |
videoPlayer.onpause=audioPlayer.onpause=function(){ | |
if(changingSource){ | |
return; | |
} | |
playing=false; | |
toggleHandler(); | |
watcher.stop(); | |
}; | |
videoPlayer.onstop=audioPlayer.onstop=function(){ | |
if(changingSource){ | |
return; | |
} | |
stop(); | |
watcher.stop(); | |
}; | |
videoPlayer.onerror=audioPlayer.onerror=function(iCode){ | |
var | |
messages={ | |
1:"Формат воспроизведения не поддерживается", | |
2:"Файл не найден на сервере", | |
3:"Неизвестная ошибка" | |
}; | |
IDS["track-name"].firstChild.removeAttribute('href'); | |
IDS["track-name"].firstChild.innerHTML=messages[iCode||3]||""; | |
/*alert("Ошибка: "+messages[iCode||3]);*/ | |
setTimeout(function(){ | |
changingSource=false; | |
},100); | |
}; | |
IDS["playback-handle"].parentNode.parentNode.addEventListener("click",function(e){ | |
var | |
rect=IDS["playback-handle"].parentNode.getBoundingClientRect(); | |
seek(-Math.max(0,Math.min(e.pageX-rect.left,rect.width))/rect.width) | |
}); | |
IDS["playback-volume"].parentNode.parentNode.addEventListener("click",function(e){ | |
var | |
rect=IDS["playback-volume"].parentNode.getBoundingClientRect(); | |
setVolume(-Math.max(0,Math.min(e.pageX-rect.left,rect.width))/rect.width); | |
}); | |
IDS["playback-close"].addEventListener("click",closeHandlerAV=function(e){ | |
if(changingSource){ | |
return; | |
} | |
if(e){ | |
forward(null); | |
} | |
stop(); | |
watcher.stop(); | |
if(!ignoreBack){ | |
//history.back(); | |
ignoreBack=true; | |
setTimeout(function(){ | |
ignoreBack=false; | |
},0); | |
} | |
}); | |
IDS["closer"].addEventListener("click",closeHandlerImage=function(e){ | |
if(e){ | |
forward(null); | |
} | |
IDS.body.className=IDS.body.className.indexOf('pane')==-1?"":'pane'; | |
IDS["error-container"].style.display=""; | |
if(!dontClearErrors){ | |
IDS["error-container"].firstChild.innerHTML=""; | |
} | |
else{ | |
if(IDS["error-container"].firstChild.childNodes.length){ | |
IDS.errors.style.display=""; | |
} | |
} | |
IDS["image-name"].style.display="none"; | |
IDS.image.style.display="none"; | |
if(!ignoreBack){ | |
//history.back(); | |
ignoreBack=true; | |
setTimeout(function(){ | |
ignoreBack=false; | |
},0); | |
} | |
}); | |
IDS["errors"].addEventListener("click",function(){ | |
intf.showErrors(); | |
}); | |
(function(){ | |
IDS.playpause.addEventListener("click",clickHandler); | |
})(); | |
return intf={ | |
playAudio:function(sUrl,sName,sDownload,sMime){ | |
play(sUrl,"a",sName,sMime,sDownload); | |
}, | |
playVideo:function(sUrl,sName,sDownload,sMime){ | |
play(sUrl,"v",sName,sMime,sDownload); | |
}, | |
viewImage:function(sUrl,sName,sDownload){ | |
IDS.image.src=sUrl; | |
IDS.body.className+=" fullsize"; | |
IDS.image.style.display=""; | |
IDS["image-name"].style.display=""; | |
IDS["image-name"].firstChild.firstChild.innerHTML=sName;//"<a href='"+sDownload+"' target='_blank'>"+sName+"</a>"; | |
IDS["image-name"].firstChild.firstChild.href=sDownload; | |
IDS["get-url"].firstChild.href=sDownload; | |
IDS["get-url"].lastChild.firstChild.value=IDS["get-url"].firstChild.href; | |
IDS["get-url"].firstChild.style.display=""; | |
IDS["get-url"].firstChild.nextSibling.style.display="none"; | |
IDS.image.parentNode.replaceChild(IDS.image,IDS.image); | |
}, | |
showErrors:function(){ | |
IDS.errors.style.display="none"; | |
IDS.body.className+=" fullsize"; | |
mode.setMode("current"); | |
IDS["error-container"].style.display="block"; | |
}, | |
closeAll:function(){ | |
dontClearErrors=true; | |
closeHandlerAV(); | |
closeHandlerImage(); | |
dontClearErrors=false; | |
forward(null); | |
}, | |
whatIsOpen:function(){ | |
return playerMode; | |
} | |
} | |
})(), | |
noForward=false, | |
forward=function(info){ | |
if(!noForward){ | |
history.pushState(info,'box.unet.by'+(info?': файл '+info[0]:''),info?info[3]:'/'); | |
document.title='box.unet.by'+(info?': файл '+info[0]:''); | |
} | |
}; | |
window.addEventListener('popstate',function(e){ | |
noForward=true; | |
if(playerManager.whatIsOpen()!='a'){ | |
playerManager.closeAll(); | |
} | |
if(location.pathname!='/'){ | |
if(history.state){ | |
browseFile(history.state); | |
} | |
document.title='box.unet.by'+(history.state?': файл '+history.state[0]:''); | |
} | |
else{ | |
document.title='box.unet.by'; | |
} | |
noForward=false; | |
},false); | |
(function(){ | |
var | |
k, a, | |
operaPresto=window.helpers.browser=="opera" && | |
window.helpers.engine=="presto" && | |
window.opera.version().split(".")[0]-0<12, | |
dragMode=null; | |
if(operaPresto){ | |
IDS.file.style.cssText="left:0;top:0;opacity:0;z-index:auto;cursor:pointer;display:inline-block;width:100%;padding-left:0;padding-right:0;"; | |
} | |
if(FEATURES.formdata){ | |
if(window+""=="[object DOMWindow]" && navigator.platform.toLowerCase().indexOf("win")==0){ | |
IDS.file.className="safari"; | |
document.documentElement.addEventListener("dragover",function(e){ | |
var dt=e.dataTransfer; | |
if(dragMode===null){ | |
if(dragMode=dt&& | |
(dt.files&&dt.files.length>0||Array.prototype.indexOf.call(dt.types,"Files")!= -1)){ | |
IDS.body.className+=" here"; | |
playerManager.closeAll(); | |
} | |
} | |
if(!dt){ | |
return; | |
} | |
if(dragMode!==null){ | |
//e.preventDefault(); | |
if(dragMode){ | |
dt.dropEffect="link"; | |
dt.effectAllowed="all"; | |
} | |
else{ | |
dt.dropEffect="none"; | |
dt.effectAllowed="none"; | |
} | |
} | |
}); | |
document.documentElement.addEventListener("dragleave",otherHandler=function(e){ | |
var w=Math.max(document.documentElement.clientWidth, | |
document.body.clientWidth), h=Math.max(document.documentElement.clientHeight, | |
document.body.clientHeight), x=e.clientX, y=e.clientY; | |
if(dragMode!==null&&( x<=0||y<=0||x>=w||y>=h)){ | |
IDS.body.className=IDS.body.className.replace(/ ?here/g,""); | |
dragMode=null; | |
} | |
}); | |
safariWinDropFix=function(){ | |
IDS.body.className=IDS.body.className.indexOf('pane')==-1?"":'pane'; | |
dragMode=null; | |
createNewFileInput(IDS.file); | |
IDS.file.className="safari"; | |
}; | |
} | |
else{ | |
document.documentElement.addEventListener("dragover",function(e){ | |
var dt=e.dataTransfer; | |
if(dragMode===null){ | |
if(dragMode=dt && (dt.files && dt.files.length>0 || Array.prototype.indexOf.call(dt.types,"Files")!= -1)){ | |
playerManager.closeAll(); | |
IDS.body.className="here"; | |
} | |
} | |
if(!dt){ | |
return; | |
} | |
if(dragMode!==null){ | |
e.preventDefault(); | |
if(dragMode){ | |
dt.dropEffect="link"; | |
dt.effectAllowed="all"; | |
} | |
else{ | |
dt.dropEffect="none"; | |
dt.effectAllowed="none"; | |
} | |
} | |
}); | |
document.documentElement.addEventListener("dragleave",function(e){ | |
var | |
w=Math.max(document.documentElement.clientWidth, | |
document.body.clientWidth), | |
h=Math.max(document.documentElement.clientHeight, | |
document.body.clientHeight), | |
x=e.clientX, | |
y=e.clientY; | |
if(dragMode!==null&&( x<=0||y<=0||x>=w||y>=h)){ | |
IDS.body.className=IDS.body.className.replace(/ ?here/g,""); | |
dragMode=null; | |
} | |
}); | |
document.body.addEventListener("drop",function(e){ | |
var dt=e.dataTransfer, k, l; | |
e.preventDefault(); | |
e.stopPropagation(); | |
if(dragMode!==null){ | |
IDS.body.className=""; | |
dragMode=null; | |
} | |
if(dt){ | |
try{ | |
for(k=0, l=dt.files.length; k<l; k++){ | |
if(dt.files[k].type || dt.files[k].name.indexOf('.')!=-1){ | |
manager.create({ file:dt.files[k] }); | |
} | |
} | |
} | |
catch(e){ | |
} | |
} | |
}); | |
} | |
} | |
else{ | |
//TODO выключить текст о перетаскивании мышью | |
a=document.querySelectorAll(".mouse-info"); | |
for(k=a.length;k--;){ | |
a[k].style.display="none"; | |
} | |
} | |
for(k=IDS.currentList.firstChild;k;){ | |
if(k.nodeType!=1){ | |
k=k.nextSibling; | |
if(k){ | |
IDS.currentList.removeChild(k.previousSibling); | |
k=k.nextSibling; | |
} | |
else{ | |
IDS.currentList.removeChild(IDS.currentList.lastChild); | |
break; | |
} | |
} | |
} | |
})(); | |
var | |
hndlrs={ | |
'click':function(e){ | |
e.preventDefault(); | |
this.style.display="none"; | |
this.nextSibling.style.display=""; | |
//this.nextSibling.firstChild.select(); | |
this.nextSibling.firstChild.focus(); | |
}, | |
'copy':function(e){ | |
var | |
t=this; | |
setTimeout(function(){ | |
t.firstChild.style.display=""; | |
t.firstChild.nextSibling.style.display="none"; | |
},0); | |
}, | |
'focus':function(){ | |
this.select(); | |
}, | |
'keydown':function(e){ | |
if(e.keyCode==27 && !e.shiftKey && !e.ctrlKey && !e.altKey){ | |
hndlrs.copy.call(this,e); | |
} | |
} | |
} | |
IDS["get-url"].firstChild.addEventListener('click',hndlrs.click,false); | |
IDS["get-url"].addEventListener('copy',hndlrs.copy,false); | |
IDS["get-url"].lastChild.firstChild.addEventListener('focus',hndlrs.focus,false); | |
IDS["get-url"].addEventListener('keydown',hndlrs.keydown,false); | |
IDS["get-url2"].firstChild.addEventListener('click',hndlrs.click,false); | |
IDS["get-url2"].addEventListener('copy',hndlrs.copy,false); | |
IDS["get-url2"].lastChild.firstChild.addEventListener('focus',hndlrs.focus,false); | |
IDS["get-url2"].addEventListener('keydown',hndlrs.keydown,false); | |
setInterval(timeUpdater,5000); | |
timeUpdater(); | |
IDS.button.addEventListener("click",COMMON.openFileDialog,false); | |
IDS.file.addEventListener("change",COMMON.submitForm,false); | |
{if isset($fileinfo)} | |
{assign var="mime5" value={$fileinfo.mime|substr:0:5}} | |
{if strrpos($fileinfo.filename,'.')===false} | |
{assign var="ext" value=""} | |
{else} | |
{assign var="ext" value=substr($fileinfo.filename, strrpos($fileinfo.filename,"."))+1} | |
{/if} | |
{if | |
$mime5=="audio" && in_array(strtolower($ext),array('mp3','mp4','ogg','wav')) || | |
$mime5=="video" && in_array(strtolower($ext),array('mp4','webm','ogv','flv','mov')) || | |
$mime5=="image" && in_array(strtolower($ext),array('jpg','jpeg','png','gif','bmp')) | |
} | |
window.history.replaceState( | |
[ | |
'{$fileinfo.filename}', | |
'{$fileinfo.mime}', | |
'{$fileinfo.url}', | |
'{$fileinfo.url_browse}', | |
'{$fileinfo.url_download}' | |
], | |
'box.unet.by: файл '+'{$fileinfo.filename}', | |
'{$fileinfo.url_browse}' | |
); | |
browseFile(history.state); | |
{/if} | |
{/if} | |
})(); | |
</script> | |
<!-- Yandex.Metrika counter --> | |
<script type="text/javascript"> | |
(function (d, w, c) { | |
(w[c] = w[c] || []).push(function() { | |
try { | |
w.yaCounter25690628 = new Ya.Metrika({ | |
id:25690628, | |
webvisor:true, | |
clickmap:true, | |
trackLinks:true, | |
accurateTrackBounce:true, | |
trackHash:true}); | |
} catch(e) { } | |
}); | |
var n = d.getElementsByTagName("script")[0], | |
s = d.createElement("script"), | |
f = function () { n.parentNode.insertBefore(s, n); }; | |
s.type = "text/javascript"; | |
s.async = true; | |
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; | |
if (w.opera == "[object Opera]") { | |
d.addEventListener("DOMContentLoaded", f, false); | |
} else { f(); } | |
})(document, window, "yandex_metrika_callbacks"); | |
</script> | |
<noscript><div><img src="//mc.yandex.ru/watch/25690628" style="position:absolute; left:-9999px;" alt="" /></div></noscript> | |
<!-- /Yandex.Metrika counter --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment