mirror of
https://github.com/ronggang/transmission-web-control.git
synced 2025-04-14 16:00:15 +00:00
修复一些BUG,及增加新的安装脚本
1. 修复 #94 中移动UI文字内容显示问题;Fixed #94 Close #92 2. 修复因Cookie引起的界面无法正常显示的问题;Fixed #83 3. 删除Cookie依赖; 4. 增加新的安装脚本及更新方式。
This commit is contained in:
parent
24bfd070f4
commit
9b0604e301
123
release/install-tr-control.sh
Normal file
123
release/install-tr-control.sh
Normal file
|
@ -0,0 +1,123 @@
|
|||
#!/bin/sh
|
||||
ROOT_FOLDER=""
|
||||
WEB_FOLDER=""
|
||||
ORG_INDEX_FILE="index.original.html"
|
||||
INDEX_FILE="index.html"
|
||||
TMP_FOLDER="/tmp/tr-web-control"
|
||||
PACK_NAME="src.tar.gz"
|
||||
WEB_HOST="https://github.com/ronggang/transmission-web-control/raw/master/release/"
|
||||
DOWNLOAD_URL="$WEB_HOST$PACK_NAME"
|
||||
# 安装类型
|
||||
# 1 安装至当前 Transmission Web 所在目录
|
||||
# 2 安装至 TRANSMISSION_WEB_HOME 环境变量指定的目录,参考:https://github.com/transmission/transmission/wiki/Environment-Variables#transmission-specific-variables
|
||||
# 使用环境变量时,如果 transmission 不是当前用户运行的,则需要将 TRANSMISSION_WEB_HOME 添加至 /etc/profile 文件,以达到“永久”的目的
|
||||
INSTALL_TYPE=-1
|
||||
|
||||
# 开始
|
||||
main() {
|
||||
# 判断临时目录是否存在,不存在则创建
|
||||
if [ ! -d "$TMP_FOLDER" ]; then
|
||||
mkdir -p "$TMP_FOLDER"
|
||||
fi
|
||||
|
||||
# 查找目录
|
||||
findWebFolder
|
||||
# 安装
|
||||
install
|
||||
# 清理
|
||||
clear
|
||||
}
|
||||
|
||||
# 查找Web目录
|
||||
findWebFolder() {
|
||||
# 找出web ui 目录
|
||||
echo "Searching Transmission Web Folder..."
|
||||
# 指定一次当前系统的默认目录
|
||||
# 用户如知道自己的 Transmission Web 所在的目录,直接修改这个值,以避免搜索所有目录
|
||||
ROOT_FOLDER="/usr/local/transmission/share/transmission"
|
||||
|
||||
# 判断 TRANSMISSION_WEB_HOME 环境变量是否被定义,如果是,直接用这个变量的值
|
||||
if [ $TRANSMISSION_WEB_HOME ]; then
|
||||
echo "use TRANSMISSION_WEB_HOME: $TRANSMISSION_WEB_HOME"
|
||||
INSTALL_TYPE=2
|
||||
else
|
||||
echo "Looking for folder: $ROOT_FOLDER/web"
|
||||
if [ -d "$ROOT_FOLDER/web" ]; then
|
||||
WEB_FOLDER="$ROOT_FOLDER/web"
|
||||
INSTALL_TYPE=1
|
||||
echo "Folder found. Using it."
|
||||
else
|
||||
echo "Folder not found. Will search the entire /. This will take a while..."
|
||||
ROOT_FOLDER=`find / -name 'web' -type d 2>/dev/null| grep 'transmission/web' | sed 's/\/web$//g'`
|
||||
|
||||
if [ -d "$ROOT_FOLDER/web" ]; then
|
||||
WEB_FOLDER="$ROOT_FOLDER/web"
|
||||
INSTALL_TYPE=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装
|
||||
install() {
|
||||
# 如果目录存在,则进行下载和更新动作
|
||||
if [ $INSTALL_TYPE = 1 ]; then
|
||||
# 下载最新的安装包
|
||||
download
|
||||
echo "Installing..."
|
||||
# 创建web文件夹,从 20171014 之后,打包文件不包含web目录,直接打包为src下所有文件
|
||||
mkdir web
|
||||
# 解压缩包
|
||||
tar -xzf "$PACK_NAME" -C "web"
|
||||
# 如果之前没有安装过,则先将原系统的文件改为
|
||||
if [ ! -f "$WEB_FOLDER/$ORG_INDEX_FILE" -a -f "$WEB_FOLDER/$INDEX_FILE" ]; then
|
||||
mv "$WEB_FOLDER/$INDEX_FILE" "$WEB_FOLDER/$ORG_INDEX_FILE"
|
||||
fi
|
||||
# 复制文件到
|
||||
cp -r web "$ROOT_FOLDER"
|
||||
|
||||
# 设置权限
|
||||
find "$ROOT_FOLDER" -type d -exec chmod o+rx {} \;
|
||||
find "$ROOT_FOLDER" -type f -exec chmod o+r {} \;
|
||||
|
||||
# 安装完成
|
||||
installed
|
||||
elif [ $INSTALL_TYPE = 2 ]; then
|
||||
# 下载最新的安装包
|
||||
download
|
||||
echo "Installing..."
|
||||
# 解压缩包
|
||||
tar -xzf "$PACK_NAME" -C "$TRANSMISSION_WEB_HOME"
|
||||
# 安装完成
|
||||
installed
|
||||
else
|
||||
echo "##############################################"
|
||||
echo "#"
|
||||
echo "# ERROR : Transmisson WEB UI Folder is missing."
|
||||
echo "#"
|
||||
echo "##############################################"
|
||||
fi
|
||||
}
|
||||
|
||||
# 下载最新的安装包
|
||||
download() {
|
||||
cd "$TMP_FOLDER"
|
||||
echo "Downloading Transmission Web Control..."
|
||||
wget "$DOWNLOAD_URL" --no-check-certificate
|
||||
}
|
||||
|
||||
# 安装完成
|
||||
installed() {
|
||||
echo "Transmission Web Control Installation completed!"
|
||||
}
|
||||
|
||||
# 清除工作
|
||||
clear() {
|
||||
# 删除安装包
|
||||
rm "$PACK_NAME"
|
||||
# 删除临时目录
|
||||
rm -rf "$TMP_FOLDER"
|
||||
}
|
||||
|
||||
# 执行
|
||||
main
|
BIN
release/src.tar.gz
Normal file
BIN
release/src.tar.gz
Normal file
Binary file not shown.
|
@ -10,27 +10,26 @@
|
|||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon'/ >
|
||||
<title>Transmission Web Control</title>
|
||||
<!-- Style sheet -->
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.css?v=20170607" />
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/default/easyui.css?v=20170607"/>
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/icon.css?v=20170607"/>
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/style/icon.custom.css?v=20170607"/>
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.css?v=20171015.1" />
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/default/easyui.css?v=20171015.1"/>
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/script/easyui/themes/icon.css?v=20171015.1"/>
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/style/icon.custom.css?v=20171015.1"/>
|
||||
<!-- Base class library -->
|
||||
<script type="text/javascript" src="tr-web-control/script/jquery/jquery-1.12.4.min.js"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/jquery/jquery.form.js"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/jquery/json2.min.js"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/jquery/Base64.js"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/easyui/jquery.easyui.min.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/easyui/jquery.easyui.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/easyui/plugins/jquery.datagrid.drophead.js"></script>
|
||||
<!-- -->
|
||||
<!-- System class library -->
|
||||
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/cookies.min.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/ua-parser.min.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/system.min.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/config.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/plugin.js?v=20170607"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/ua-parser.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/system.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/config.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/plugin.js?v=20171015.1"></script>
|
||||
<script type="text/javascript">
|
||||
var nonpc = [ "console", "mobile", "tablet", "smarttv", "wearable", "embedded" ]
|
||||
if ((nonpc.indexOf($.ua.device.type) != -1 )&&location.search.getQueryString("devicetype")!="computer")
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<meta http-equiv="pragma" content="no-cache" />
|
||||
<title>Transmission Web Control Mobile</title>
|
||||
<!-- Style sheet -->
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.mobile.css?v=20170426" />
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/style/base.mobile.css?v=20171015.1" />
|
||||
<link rel="stylesheet" type="text/css" href="tr-web-control/script/jquery/mobile/jquery.mobile-1.4.5.min.css?v=20170426"/>
|
||||
<!-- Base class library -->
|
||||
<script type="text/javascript" src="tr-web-control/script/jquery/jquery-1.12.4.min.js"></script>
|
||||
|
@ -20,12 +20,12 @@
|
|||
<script type="text/javascript" src="tr-web-control/script/jquery/mobile/jquery.mobile-1.4.5.min.js?v=20170426"></script>
|
||||
<!-- -->
|
||||
<!-- System class library -->
|
||||
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20170411"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/cookies.min.js?v=20170411"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/public.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/cookies.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/ua-parser.min.js?v=20170522"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20170411"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20170411"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/system.mobile.min.js?v=20170426"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/transmission.torrents.min.js?v=20171015.1"></script>
|
||||
<script type="text/javascript" src="tr-web-control/script/min/system.mobile.min.js?v=20171015.1"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Home -->
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
var cookies = {
|
||||
/* ***********************************************
|
||||
'** Function name: Get the value of Cookies
|
||||
'** Parameters:
|
||||
'** strName Cookie name
|
||||
'** strSubName subkey name (if any)
|
||||
'** returns:
|
||||
'** null if no values has been obtained
|
||||
'** cookie values in cookie
|
||||
'** Example:
|
||||
'** var strCookie = getCookie("myCookies","mySubCookies");
|
||||
*************************************************/
|
||||
get:function(strName,strSubName)
|
||||
{
|
||||
var strCookies = document.cookie.split("; ");
|
||||
var intCookiesLength = strCookies.length;
|
||||
var intLength;
|
||||
var strItem,strHead,strCookie;
|
||||
|
||||
for (var i=0; i < intCookiesLength; i++)
|
||||
{
|
||||
// There will be ampersand if there are subprojects
|
||||
if (strCookies[i].indexOf("&") > 0)
|
||||
{
|
||||
// Get head
|
||||
strHead = strCookies[i].split("=");
|
||||
// If we have cookie we seek
|
||||
if (strName == strHead[0])
|
||||
{
|
||||
// Manipulate head information
|
||||
strCookies[i] = strCookies[i].substr(strName.length+1);
|
||||
// Use the & divisible character to get all the children
|
||||
strCookie = strCookies[i].split("&");
|
||||
intLength = strCookie.length;
|
||||
var result = {};
|
||||
for (var j=0;j<intLength ;j++ )
|
||||
{
|
||||
strItem = strCookie[j].split("=");
|
||||
|
||||
//var value = unescape(strItem[1]);
|
||||
var value = JSON.parse(strItem[1]);
|
||||
switch (value)
|
||||
{
|
||||
case "true":
|
||||
result[strItem[0]] = true;
|
||||
break;
|
||||
case "false":
|
||||
result[strItem[0]] = false;
|
||||
break;
|
||||
default:
|
||||
result[strItem[0]] = value;
|
||||
break;
|
||||
}
|
||||
if (strSubName == strItem[0])
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
// If no child name is specified, an object is returned that contains all the children;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// There is no child to determine the value directly
|
||||
else
|
||||
{
|
||||
strItem = strCookies[i].split("=");
|
||||
if (strName == strItem[0])
|
||||
{
|
||||
return unescape(strItem[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Set the cookie content
|
||||
// Value can be an object, such as: key: value
|
||||
,set:function(name,value,expireDays)
|
||||
{
|
||||
var exdate=new Date();
|
||||
if (expireDays==undefined)
|
||||
{
|
||||
expireDays = 0;
|
||||
}
|
||||
exdate.setDate(exdate.getDate()+expireDays);
|
||||
var cookieValue = value;
|
||||
switch (typeof(value))
|
||||
{
|
||||
// Save it per object type
|
||||
case "object":
|
||||
case "function":
|
||||
var arr = new Array();
|
||||
for (var key in value)
|
||||
{
|
||||
//arr.push(key+"="+escape(value[key]));
|
||||
arr.push(key+"="+JSON.stringify(value[key]));
|
||||
}
|
||||
cookieValue = arr.join("&");
|
||||
break;
|
||||
|
||||
default:
|
||||
//cookieValue = escape(value);
|
||||
cookieValue = JSON.stringify(value);
|
||||
break;
|
||||
}
|
||||
document.cookie=name+"=" +cookieValue+((expireDays==0)? "" :"; expires="+exdate.toGMTString());
|
||||
}
|
||||
,remove:function(name)
|
||||
{
|
||||
this.set(name,"",-1);
|
||||
}
|
||||
,all:function()
|
||||
{
|
||||
return document.cookie;
|
||||
}
|
||||
};
|
16
src/tr-web-control/script/min/cookies.min.js
vendored
16
src/tr-web-control/script/min/cookies.min.js
vendored
|
@ -1,16 +0,0 @@
|
|||
var cookies={get:function(e,t){for(var r,i,n,s,a=document.cookie.split("; "),o=a.length,c=0;c<o;c++)if(a[c].indexOf("&")>0){if(n=a[c].split("="),e==n[0]){a[c]=a[c].substr(e.length+1),s=a[c].split("&"),r=s.length
|
||||
for(var u={},f=0;f<r;f++){i=s[f].split("=")
|
||||
var l=JSON.parse(i[1])
|
||||
switch(l){case"true":u[i[0]]=!0
|
||||
break
|
||||
case"false":u[i[0]]=!1
|
||||
break
|
||||
default:u[i[0]]=l}if(t==i[0])return l}return u}}else if(i=a[c].split("="),e==i[0])return unescape(i[1])
|
||||
return null},set:function(e,t,r){var i=new Date
|
||||
void 0==r&&(r=0),i.setDate(i.getDate()+r)
|
||||
var n=t
|
||||
switch(typeof t){case"object":case"function":var s=new Array
|
||||
for(var a in t)s.push(a+"="+JSON.stringify(t[a]))
|
||||
n=s.join("&")
|
||||
break
|
||||
default:n=JSON.stringify(t)}document.cookie=e+"="+n+(0==r?"":"; expires="+i.toGMTString())},remove:function(e){this.set(e,"",-1)},all:function(){return document.cookie}}
|
52
src/tr-web-control/script/min/public.min.js
vendored
52
src/tr-web-control/script/min/public.min.js
vendored
|
@ -1,39 +1,13 @@
|
|||
// Get "query string"
|
||||
//公用函数定义
|
||||
//格式化数字
|
||||
// 根据分钟获取小时
|
||||
// 根据小时获取分钟
|
||||
// Get the cumulative time
|
||||
// Array object sort extension
|
||||
// Generic time - sharing processing functions
|
||||
// jQuery Extended
|
||||
// returns only unique values
|
||||
function getLocalTime(e){return new Date(1e3*parseInt(e)).toLocaleString().replace(/年|月/g,"-").replace(/日/g," ")}function formatLongTime(e,r){var t=new Date(1e3*parseInt(e))
|
||||
return formatDate(t)}function formatDate(e,r){if(r||(r="yyyy-mm-dd hh:nn:ss"),e instanceof Date){var t=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),n=e.getFullYear(),a=n.toString().substring(2),s=e.getMonth()+1,i=s<10?"0"+s:s,u=t[s],o=e.getDate(),c=o<10?"0"+o:o,l=e.getHours(),f=l<10?"0"+l:l,p=e.getMinutes(),h=p<10?"0"+p:p,d=e.getSeconds(),g=d<10?"0"+d:d
|
||||
return r=r.replace(/yyyy/i,n),r=r.replace(/yy/i,a),r=r.replace(/mmm/i,u),r=r.replace(/mm/i,i),r=r.replace(/m/i,s),r=r.replace(/dd/i,c),r=r.replace(/d/i,o),r=r.replace(/hh/i,f),r=r.replace(/h/i,l),r=r.replace(/nn/i,h),r=r.replace(/n/i,p),r=r.replace(/ss/i,g),r=r.replace(/s/i,d)}return""}function formatSize(e,r,t){if(0==e)return 1==r?"":"speed"==t?"0.00 KB/s":"0.00"
|
||||
var n="",a="KB"
|
||||
return e<1024e3?(n=e/1024,a="KB"):e<1048576e3?(n=e/1048576,a="MB"):e<0xfa00000000?(n=e/1073741824,a="GB"):e<0x3e80000000000?(n=e/1099511627776,a="TB"):(n=e/0x4000000000000,a="PB"),"speed"==t&&(a+="/s"),n.formatNumber("###,###,###,###.00 ")+a}function getHoursFromMinutes(e){return("00"+parseInt(e/60,10)).right(2)+":"+("00"+e%60).right(2)}function getMinutesFromHours(e){return 60*parseInt(e.split(":")[0],10)+parseInt(e.split(":")[1],10)}function getTotalTime(e,r){r||(r="%dd %hh %mm %ss ")
|
||||
var t=Math.floor(e/864e5),n=e%864e5,a=Math.floor(n/36e5),s=n%36e5,i=Math.floor(s/6e4),u=s%6e4,o=Math.round(u/1e3),c=r
|
||||
return c=0==t?c.replace(/(%d+\s)/,""):c.replace("%d",t),c=0==a?c.replace(/(%h+\s)/,""):c.replace("%h",a),c=0==i?c.replace(/(%m+\s)/,""):c.replace("%m",i),c=0==o?c.replace(/(%s+\s)/,""):c.replace("%s",o)}function arrayObjectSort(e,r){return function(t,n){var a=t[e],s=n[e]
|
||||
return a<s?"desc"==r?1:-1:a>s?"desc"==r?-1:1:0}}function timedChunk(e,r,t,n,a){var s=e.concat()
|
||||
void 0==n&&(n=25),setTimeout(function(){var i=+new Date
|
||||
do r.call(t,s.shift())
|
||||
while(s.length>0&&+new Date-i<100)
|
||||
s.length>0?setTimeout(arguments.callee,n):a&&a(e)},n)}function uniq(e){var r={}
|
||||
return e.filter(function(e){return!r.hasOwnProperty(e)&&(r[e]=!0)})}String.prototype.getQueryString=function(e,r){void 0==r&&(r="&")
|
||||
var t,n=new RegExp("(^|"+r+"|\\?)"+e+"=([^"+r+"]*)("+r+"|$)")
|
||||
return(t=this.match(n))?unescape(t[2]):null},String.prototype.right=function(e){return this.substr(-e)},Number.prototype.formatNumber=function(e){this.fStr=function(e,t,n){if(""==e||void 0==e)return""==t||void 0==t?"":t
|
||||
var a,i=s=r=""
|
||||
n||(e=e.split("").reverse().join(""),t=t.split("").reverse().join(""))
|
||||
for(var u=j=0;u<t.length;u++,j++)if(s=e.charAt(j),void 0!=s)switch(i=t.charAt(u)){case"#":r+=s,a=u
|
||||
break
|
||||
case"0":r=s||s==i?r+s:r+0,a=u
|
||||
break
|
||||
case".":r+=s==i?s:(j--,i)
|
||||
break
|
||||
case",":r+=s==i?s:(j--,i)
|
||||
break
|
||||
default:r+=i,j--}return j!=e.length&&"0"!=t.charAt(t.length-1)&&a!=t.length&&"0"!=t.charAt(a)&&(r=r.substr(0,a+1)+e.substr(j)+r.substr(a+1)),r=(n?r:r.split("").reverse().join("")).replace(/(^,)|(,$)|(,,+)/g,""),","==r.substr(0,1)&&(r=r.substr(1)),"-,"==r.substr(0,2)&&(r="-"+r.substr(2)),r}
|
||||
var t=this.toString()
|
||||
return 0==t.length?"":void 0==e?this:(e=e.split("."),t=t.split("."),e.length>1?this.fStr(t[0],e[0])+"."+this.fStr(t[1],e[1],1):this.fStr(t[0],e[0]))},function(e){e.fn.fadeInAndOut=function(r,t,n){var a={speed:r,easing:t,fn:n}
|
||||
e.extend(a,e.fn.fadeInAndOut.defaults),this.fadeIn(a.speed).delay(a.speed).fadeOut(a.speed,a.easing,a.fn)},e.fn.fadeInAndOut.defaults={speed:1e3,easing:"swing",fn:null}}(jQuery)
|
||||
String.prototype.getQueryString=function(name,split){if(split==undefined)split="\x26";var reg=new RegExp("(^|"+split+"|\\?)"+name+"\x3d([^"+split+"]*)("+split+"|$)"),r;if(r=this.match(reg))return unescape(r[2]);return null};String.prototype.right=function(len){return this.substr(-len)};
|
||||
Number.prototype.formatNumber=function(f){this.fStr=function(n,f,p){if(n==""||n==undefined)if(f==""||f==undefined)return"";else return f;var fc=s=r="",pos;if(!p){n=n.split("").reverse().join("");f=f.split("").reverse().join("")}for(var i=j=0;i<f.length;i++,j++){s=n.charAt(j);if(s==undefined)continue;fc=f.charAt(i);switch(fc){case "#":r+=s;pos=i;break;case "0":r=s||s==fc?r+s:r+0;pos=i;break;case ".":r+=s==fc?s:(j--,fc);break;case ",":r+=s==fc?s:(j--,fc);break;default:r+=fc;j--}}if(j!=n.length&&f.charAt(f.length-
|
||||
1)!="0"&&pos!=f.length&&f.charAt(pos)!="0")r=r.substr(0,pos+1)+n.substr(j)+r.substr(pos+1);r=(p?r:r.split("").reverse().join("")).replace(/(^,)|(,$)|(,,+)/g,"");if(r.substr(0,1)==",")r=r.substr(1);if(r.substr(0,2)=="-,")r="-"+r.substr(2);return r};var n=this.toString();if(n.length==0)return"";if(f==undefined)return this;f=f.split("."),n=n.split(".");return f.length>1?this.fStr(n[0],f[0])+"."+this.fStr(n[1],f[1],1):this.fStr(n[0],f[0])};
|
||||
function getLocalTime(time){return(new Date(parseInt(time)*1E3)).toLocaleString().replace(/\u5e74|\u6708/g,"-").replace(/\u65e5/g," ")}function formatLongTime(time,formatString){var now=new Date(parseInt(time)*1E3);return formatDate(now)}
|
||||
function formatDate(formatDate,formatString){if(!formatString)formatString="yyyy-mm-dd hh:nn:ss";if(formatDate instanceof Date){var months=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var yyyy=formatDate.getFullYear();var yy=yyyy.toString().substring(2);var m=formatDate.getMonth()+1;var mm=m<10?"0"+m:m;var mmm=months[m];var d=formatDate.getDate();var dd=d<10?"0"+d:d;var h=formatDate.getHours();var hh=h<10?"0"+h:h;var n=formatDate.getMinutes();var nn=n<10?"0"+
|
||||
n:n;var s=formatDate.getSeconds();var ss=s<10?"0"+s:s;formatString=formatString.replace(/yyyy/i,yyyy);formatString=formatString.replace(/yy/i,yy);formatString=formatString.replace(/mmm/i,mmm);formatString=formatString.replace(/mm/i,mm);formatString=formatString.replace(/m/i,m);formatString=formatString.replace(/dd/i,dd);formatString=formatString.replace(/d/i,d);formatString=formatString.replace(/hh/i,hh);formatString=formatString.replace(/h/i,h);formatString=formatString.replace(/nn/i,nn);formatString=
|
||||
formatString.replace(/n/i,n);formatString=formatString.replace(/ss/i,ss);formatString=formatString.replace(/s/i,s);return formatString}else return""}
|
||||
function formatSize(bytes,zeroToEmpty,type){if(bytes==0)if(zeroToEmpty==true)return"";else if(type=="speed")return"0.00 KB/s";else return"0.00";var r="";var u="KB";if(bytes<1E3*1024){r=bytes/1024;u="KB"}else if(bytes<1E3*1048576){r=bytes/1048576;u="MB"}else if(bytes<1E3*1073741824){r=bytes/1073741824;u="GB"}else if(bytes<1E3*1099511627776){r=bytes/1099511627776;u="TB"}else{r=bytes/0x4000000000000;u="PB"}if(type=="speed")u+="/s";return r.formatNumber("###,###,###,###.00 ")+u}
|
||||
function getHoursFromMinutes(minutes){return("00"+parseInt(minutes/60,10)).right(2)+":"+("00"+minutes%60).right(2)}function getMinutesFromHours(hours){return parseInt(hours.split(":")[0],10)*60+parseInt(hours.split(":")[1],10)}
|
||||
function getTotalTime(time,format){if(!format)format="%dd %hh %mm %ss ";var days=Math.floor(time/(24*3600*1E3));var leave1=time%(24*3600*1E3);var hours=Math.floor(leave1/(3600*1E3));var leave2=leave1%(3600*1E3);var minutes=Math.floor(leave2/(60*1E3));var leave3=leave2%(60*1E3);var seconds=Math.round(leave3/1E3);var result=format;if(days==0)result=result.replace(/(%d+\s)/,"");else result=result.replace("%d",days);if(hours==0)result=result.replace(/(%h+\s)/,"");else result=result.replace("%h",hours);
|
||||
if(minutes==0)result=result.replace(/(%m+\s)/,"");else result=result.replace("%m",minutes);if(seconds==0)result=result.replace(/(%s+\s)/,"");else result=result.replace("%s",seconds);return result}function arrayObjectSort(field,sortOrder){return function(object1,object2){var value1=object1[field];var value2=object2[field];if(value1<value2)if(sortOrder=="desc")return 1;else return-1;else if(value1>value2)if(sortOrder=="desc")return-1;else return 1;else return 0}}
|
||||
function timedChunk(items,process,context,delay,callback){var todo=items.concat();if(delay==undefined)delay=25;setTimeout(function(){var start=+new Date;do process.call(context,todo.shift());while(todo.length>0&&+new Date-start<100);if(todo.length>0)setTimeout(arguments.callee,delay);else if(callback)callback(items)},delay)}
|
||||
(function($){$.fn.fadeInAndOut=function(speed,easing,fn){var options={speed:speed,easing:easing,fn:fn};$.extend(options,$.fn.fadeInAndOut.defaults);this.fadeIn(options.speed).delay(options.speed).fadeOut(options.speed,options.easing,options.fn)};$.fn.fadeInAndOut.defaults={speed:1E3,easing:"swing",fn:null}})(jQuery);function uniq(a){var seen={};return a.filter(function(item){return seen.hasOwnProperty(item)?false:seen[item]=true})};
|
||||
|
|
107
src/tr-web-control/script/min/system.min.js
vendored
107
src/tr-web-control/script/min/system.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,10 @@
|
|||
/*! transmission-web-control 2017-09-29 */
|
||||
|
||||
var transmission={SessionId:"",isInitialized:!1,host:"",port:"9091",path:"/transmission/rpc",rpcpath:"../rpc",fullpath:"",on:{torrentCountChange:null,postError:null},username:"",password:"",_status:{stopped:0,checkwait:1,check:2,downloadwait:3,download:4,seedwait:5,seed:6,actively:101},_trackerStatus:{inactive:0,waiting:1,queued:2,active:3},options:{getFolders:!0,getTarckers:!0},headers:{},trackers:{},islocal:!1,downloadDirs:new Array,getSessionId:function(a,b){var c={type:"POST",url:this.fullpath,error:function(c,d,e){var f="";409===c.status&&(f=c.getResponseHeader("X-Transmission-Session-Id"))&&(a.isInitialized=!0,a.SessionId=f,a.headers["X-Transmission-Session-Id"]=f,b&&b())},headers:this.headers};jQuery.ajax(c)},init:function(a,b){jQuery.extend(this,a),this.username&&this.password&&(this.headers.Authorization="Basic "+(new Base64).encode(this.username+":"+this.password)),this.fullpath=this.rpcpath,this.getSessionId(this,b)},exec:function(a,b,c){if(!this.isInitialized)return!1;var d={method:"",arguments:{},tag:""};jQuery.extend(d,a);var e={type:"POST",url:this.fullpath,dataType:"json",data:JSON.stringify(d),success:function(a,d){b&&b(a,c)},error:function(a,b,c){var d="";409===a.status&&(d=a.getResponseHeader("X-Transmission-Session-Id"))?(transmission.SessionId=d,transmission.headers["X-Transmission-Session-Id"]=d,jQuery.ajax(e)):transmission.on.postError&&transmission.on.postError(a)},headers:this.headers};jQuery.ajax(e)},getStatus:function(a){this.exec({method:"session-stats"},function(b){"success"==b.result&&(a&&a(b.arguments),transmission.torrents.count==b.arguments.torrentCount&&transmission.torrents.activeTorrentCount==b.arguments.activeTorrentCount&&transmission.torrents.pausedTorrentCount==b.arguments.pausedTorrentCount||(transmission.torrents.count=b.arguments.torrentCount,transmission.torrents.activeTorrentCount=b.arguments.activeTorrentCount,transmission.torrents.pausedTorrentCount=b.arguments.pausedTorrentCount,transmission._onTorrentCountChange()))})},getSession:function(a){this.exec({method:"session-get"},function(b){"success"==b.result&&a&&a(b.arguments)})},addTorrentFromUrl:function(a,b,c,d){a.match(/^[0-9a-f]{40}$/i)&&(a="magnet:?xt=urn:btih:"+a);var e={method:"torrent-add",arguments:{filename:a,paused:!c}};b&&(e.arguments["download-dir"]=b),this.exec(e,function(a){switch(a.result){case"success":d&&(a.arguments["torrent-added"]?d(a.arguments["torrent-added"]):a.arguments["torrent-duplicate"]&&d({status:"duplicate",torrent:a.arguments["torrent-duplicate"]}));break;case"duplicate torrent":default:d&&d(a.result)}})},addTorrentFromFile:function(a,b,c,d,e){var f=new FileReader;f.onload=function(a){var f=a.target.result,g=f.indexOf("base64,");if(-1!=g){var h=f.substring(g+"base64,".length);transmission.exec({method:"torrent-add",arguments:{metainfo:h,"download-dir":b,paused:c}},function(a){switch(a.result){case"success":d&&d(a.arguments["torrent-added"],e);break;case"duplicate torrent":d&&d("duplicate")}})}},f.readAsDataURL(a)},_onTorrentCountChange:function(){this.torrents.loadSimpleInfo=!1,this.on.torrentCountChange&&this.on.torrentCountChange()},removeTorrent:function(a,b,c){this.exec({method:"torrent-remove",arguments:{ids:a,"delete-local-data":b}},function(a){c&&c(a.result)})},getFreeSpace:function(a,b){this.exec({method:"free-space",arguments:{path:a}},function(a){b&&b(a)})},updateBlocklist:function(a){this.exec({method:"blocklist-update"},function(b){a&&a(b.result)})},renameTorrent:function(a,b,c,d){var e=this.torrents.all[a];if(!e)return!1;this.exec({method:"torrent-rename-path",arguments:{ids:[a],path:b||e.name,name:c}},function(a){d&&d(a)})},closeSession:function(a){this.exec({method:"session-close"},function(b){a&&a(b)})}};
|
||||
var transmission={SessionId:"",isInitialized:false,host:"",port:"9091",path:"/transmission/rpc",rpcpath:"../rpc",fullpath:"",on:{torrentCountChange:null,postError:null},username:"",password:"",_status:{stopped:0,checkwait:1,check:2,downloadwait:3,download:4,seedwait:5,seed:6,actively:101},_trackerStatus:{inactive:0,waiting:1,queued:2,active:3},options:{getFolders:true,getTarckers:true},headers:{},trackers:{},islocal:false,downloadDirs:new Array,getSessionId:function(me,callback){var settings={type:"POST",
|
||||
url:this.fullpath,error:function(request,event,settings){var SessionId="";if(request.status===409&&(SessionId=request.getResponseHeader("X-Transmission-Session-Id"))){me.isInitialized=true;me.SessionId=SessionId;me.headers["X-Transmission-Session-Id"]=SessionId;if(callback)callback()}},headers:this.headers};jQuery.ajax(settings)},init:function(config,callback){jQuery.extend(this,config);if(this.username&&this.password)this.headers["Authorization"]="Basic "+(new Base64).encode(this.username+":"+this.password);
|
||||
this.fullpath=this.rpcpath;this.getSessionId(this,callback)},exec:function(config,callback,tags){if(!this.isInitialized)return false;var data={method:"",arguments:{},tag:""};jQuery.extend(data,config);var settings={type:"POST",url:this.fullpath,dataType:"json",data:JSON.stringify(data),success:function(resultData,textStatus){if(callback)callback(resultData,tags)},error:function(request,event,page){var SessionId="";if(request.status===409&&(SessionId=request.getResponseHeader("X-Transmission-Session-Id"))){transmission.SessionId=
|
||||
SessionId;transmission.headers["X-Transmission-Session-Id"]=SessionId;jQuery.ajax(settings)}else if(transmission.on.postError)transmission.on.postError(request)},headers:this.headers};jQuery.ajax(settings)},getStatus:function(callback){this.exec({method:"session-stats"},function(data){if(data.result=="success"){if(callback)callback(data.arguments);if(transmission.torrents.count!=data.arguments.torrentCount||transmission.torrents.activeTorrentCount!=data.arguments.activeTorrentCount||transmission.torrents.pausedTorrentCount!=
|
||||
data.arguments.pausedTorrentCount){transmission.torrents.count=data.arguments.torrentCount;transmission.torrents.activeTorrentCount=data.arguments.activeTorrentCount;transmission.torrents.pausedTorrentCount=data.arguments.pausedTorrentCount;transmission._onTorrentCountChange()}}})},getSession:function(callback){this.exec({method:"session-get"},function(data){if(data.result=="success")if(callback)callback(data.arguments)})},addTorrentFromUrl:function(url,savepath,autostart,callback){if(url.match(/^[0-9a-f]{40}$/i))url=
|
||||
"magnet:?xt\x3durn:btih:"+url;var options={method:"torrent-add",arguments:{filename:url,paused:!autostart}};if(savepath)options.arguments["download-dir"]=savepath;this.exec(options,function(data){switch(data.result){case "success":if(callback)if(data.arguments["torrent-added"])callback(data.arguments["torrent-added"]);else if(data.arguments["torrent-duplicate"])callback({status:"duplicate",torrent:data.arguments["torrent-duplicate"]});break;case "duplicate torrent":default:if(callback)callback(data.result);
|
||||
break}})},addTorrentFromFile:function(file,savePath,paused,callback,filecount){var fileReader=new FileReader;fileReader.onload=function(e){var contents=e.target.result;var key="base64,";var index=contents.indexOf(key);if(index==-1)return;var metainfo=contents.substring(index+key.length);transmission.exec({method:"torrent-add",arguments:{metainfo:metainfo,"download-dir":savePath,paused:paused}},function(data){switch(data.result){case "success":if(callback)callback(data.arguments["torrent-added"],filecount);
|
||||
break;case "duplicate torrent":if(callback)callback("duplicate");break}})};fileReader.readAsDataURL(file)},_onTorrentCountChange:function(){this.torrents.loadSimpleInfo=false;if(this.on.torrentCountChange)this.on.torrentCountChange()},removeTorrent:function(ids,removeData,callback){this.exec({method:"torrent-remove",arguments:{ids:ids,"delete-local-data":removeData}},function(data){if(callback)callback(data.result)})},getFreeSpace:function(path,callback){this.exec({method:"free-space",arguments:{"path":path}},
|
||||
function(result){if(callback)callback(result)})},updateBlocklist:function(callback){this.exec({method:"blocklist-update"},function(data){if(callback)callback(data.result)})},renameTorrent:function(torrentId,oldpath,newname,callback){var torrent=this.torrents.all[torrentId];if(!torrent)return false;this.exec({method:"torrent-rename-path",arguments:{ids:[torrentId],path:oldpath||torrent.name,name:newname}},function(data){if(callback)callback(data)})},closeSession:function(callback){this.exec({method:"session-close"},
|
||||
function(result){if(callback)callback(result)})}};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,8 @@
|
|||
// Current system global object
|
||||
var system = {
|
||||
version:"1.1 Beta"
|
||||
version:"1.2 Beta"
|
||||
,rootPath: "tr-web-control/"
|
||||
,codeupdate:"20170606"
|
||||
,codeupdate:"20171015"
|
||||
,configHead: "transmission-web-control"
|
||||
// default config, can be customized in config.js
|
||||
,config:{
|
||||
|
@ -2592,10 +2592,11 @@ var system = {
|
|||
,readConfig:function()
|
||||
{
|
||||
this.readUserConfig();
|
||||
var config = cookies.get(this.configHead);
|
||||
if ($.isPlainObject(config))
|
||||
// 将原来的cookies的方式改为本地存储的方式
|
||||
var config = this.getStorageData(this.configHead+'.system');
|
||||
if (config)
|
||||
{
|
||||
this.config = $.extend(this.config, config);;
|
||||
this.config = $.extend(this.config, JSON.parse(config));
|
||||
}
|
||||
|
||||
for (var key in this.storageKeys.dictionary)
|
||||
|
@ -2606,7 +2607,7 @@ var system = {
|
|||
// Save the parameters in cookies
|
||||
,saveConfig:function()
|
||||
{
|
||||
cookies.set(this.configHead,this.config,100);
|
||||
this.setStorageData(this.configHead+'.system',JSON.stringify(this.config));
|
||||
for (var key in this.storageKeys.dictionary)
|
||||
{
|
||||
this.setStorageData(this.storageKeys.dictionary[key],this.dictionary[key]);
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
移动版
|
||||
*/
|
||||
var system = {
|
||||
version:"1.1 Beta"
|
||||
version:"1.2 Beta"
|
||||
,rootPath: "tr-web-control/"
|
||||
,codeupdate:"20170317"
|
||||
,codeupdate:"20171015"
|
||||
,configHead: "transmission-web-control"
|
||||
,config:{
|
||||
autoReload: true
|
||||
,reloadStep: 5000
|
||||
|
@ -104,18 +105,26 @@ var system = {
|
|||
// 从 cookies 里加载配置
|
||||
,readConfig:function()
|
||||
{
|
||||
var config = cookies.get("transmission-web-control");
|
||||
if ($.isPlainObject(config))
|
||||
// 将原来的cookies的方式改为本地存储的方式
|
||||
var config = this.getStorageData(this.configHead+'.system');
|
||||
if (config)
|
||||
{
|
||||
this.config = $.extend(this.config, config);;
|
||||
this.config = $.extend(this.config, JSON.parse(config));
|
||||
}
|
||||
}
|
||||
// 在 cookies 里保存参数
|
||||
,saveConfig:function()
|
||||
{
|
||||
cookies.set("transmission-web-control",this.config,100);
|
||||
this.setStorageData(this.configHead+'.system',JSON.stringify(this.config));
|
||||
}
|
||||
,getStorageData: function(key,defaultValue)
|
||||
{
|
||||
return (window.localStorage[key]==null?defaultValue:window.localStorage[key]);
|
||||
}
|
||||
,setStorageData: function(key,value)
|
||||
{
|
||||
window.localStorage[key] = value;
|
||||
}
|
||||
|
||||
// 连接服务器
|
||||
,connect:function()
|
||||
{
|
||||
|
|
|
@ -115,7 +115,6 @@
|
|||
.iconlabel{
|
||||
display:inline-block;
|
||||
width:auto;
|
||||
height:16px;
|
||||
padding-left:19px;
|
||||
margin-top:2px;
|
||||
text-overflow: ellipsis;
|
||||
|
|
Loading…
Reference in New Issue
Block a user