kde-extraapps/kget/extensions/webinterface/www/index.htm
Ivailo Monev 2ce9cedc53 kget: use GET instead of POST method for requests
KHTTP rejects anything but GET or HEAD, see the following commit in the
kdelibs repo:
362b80c063948406c1de1d74c5e3e77dbd27a9ed

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-08 21:29:16 +03:00

403 lines
13 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2008 Urs Wolfer <uwolfer @ kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="favicon.ico" />
<title>#{KGet Webinterface}</title>
<script type="text/javascript" src="mootools-core-yc.js"></script>
<script type="text/javascript" src="mootools-more.js"></script>
<script type="text/javascript">
//<![CDATA[
window.addEvent('domready', function() {
var slide = new Fx.Slide('settings-container').hide();
function refreshList() {
var request = new Request.JSON({url: 'data.json',
method: "GET",
secure: false,
onComplete: function(jsonObj) {
$(document.body).getElements('div.tool-tip').each(function(elm) { // remove old tooltips
elm.destroy();
});
listDownloads(jsonObj.downloads);
}
}).send();
}
refreshList(); // load it at start
function doAction(action, data) {
var log = $('log-res').empty().addClass('ajax-loading');
var parameters = new Object();
if ((typeof data).toLowerCase() == 'string')
parameters['data'] = data;
else
parameters = data;
parameters['action'] = action;
var addRequest = new Request.HTML({url: 'do',
method: "GET",
update: log,
onComplete: function() {
log.removeClass('ajax-loading');
refreshList();
}}).get(parameters)
}
var listDownloads = function(downloads) {
var downloadsList = $('downloads-list').empty();
var table = new Element('table', {'id': 'download-list-table'});
// header
var headertr = new Element('tr', {'id': 'download-list-table-header'}).injectInside(table);
var headernumber = new Element('td', {'class': 'download-left', 'html': '#{Nr}'}).injectInside(headertr);
var headername = new Element('td', {'class': 'download-left', 'html': '#{File name}'}).injectAfter(headernumber);
var headersize = new Element('td', {'html': 'Size'}).injectAfter(headername);
var headerprogress = new Element('td', {'class': 'download-center', 'html': '#{Finished}'}).injectAfter(headersize);
var headerspeed = new Element('td', {'class': 'download-center', 'html': '#{Speed}'}).injectAfter(headerprogress);
var headerstatus = new Element('td', {'class': 'download-center', 'html': '#{Status}'}).injectAfter(headerspeed);
var headerstartaction = new Element('td', {'html': '#{Start}'}).injectAfter(headerstatus);
var headerstopaction = new Element('td', {'html': '#{Stop}'}).injectAfter(headerstartaction);
var headerremoveaction = new Element('td', {'html': '#{Remove}'}).injectAfter(headerstopaction);
var i = 0;
downloads.each(function(download) {
i++;
var toolTipText = '<h1>' + download.name + '</h1>#{Source:} ' + download.src + '<br />#{Saving to:} ' + download.dest;
var tr = new Element('tr', {'class': 'toolTip download-list-table-item', 'title': toolTipText}).injectInside(table);
var number = new Element('td', {'class': 'download-number', 'html': ((i < 10) ? '0' + i : i)}).injectInside(tr);
var name = new Element('td', {'class': 'download-left', 'html': download.name}).injectAfter(number);
var size = new Element('td', {'html': download.size}).injectAfter(name);
var progress = new Element('td', {'class': 'download-center', 'html': download.progress}).injectAfter(size);
var speed = new Element('td', {'class': 'download-center', 'html': download.speed}).injectAfter(progress);
var status = new Element('td', {'class': 'download-center', 'html': download.status}).injectAfter(speed);
var startaction = new Element('td').injectAfter(status);
var start = new Element('a', {'href': '#', 'html': '<input type="button" value="#{Start}" />'}).injectInside(startaction);
start.addEvent('click', function(e) {
e = new Event(e).stop();
doAction('start', download.src);
});
var stopaction = new Element('td').injectAfter(startaction);
var stop = new Element('a', {'href': '#', 'html': '<input type="button" value="#{Stop}" />'}).injectInside(stopaction);
stop.addEvent('click', function(e) {
e = new Event(e).stop();
doAction('stop', download.src);
});
var removeaction = new Element('td').injectAfter(stopaction);
var remove = new Element('a', {'href': '#', 'html': '<input type="button" value="#{Remove}" />'}).injectInside(removeaction);
remove.addEvent('click', function(e) {
e = new Event(e).stop();
doAction('remove', download.src);
});
var spacer = new Element('tr', {'class': 'download-list-table-spacer'}).injectAfter(tr);
var spacertd = new Element('td').injectInside(spacer);
});
table.inject(downloadsList);
var toolTips = new Tips($$('.toolTip'), {
className: 'tool-tip'
});
}
$('load-downloads').addEvent('click', function(e) {
e = new Event(e).stop();
refreshList();
});
$('new-download-form').addEvent('submit', function(e) {
new Event(e).stop();
doAction('add', {'data': $('url').value, 'group': $('group').value});
$('url').value = '';
});
$('settings-form').addEvent('submit', function(e) {
new Event(e).stop();
$clear(updateTimer);
var interval = parseInt($('interval').value);
if ($('enable-refresh').checked && interval >= 1)
updateTimer = refreshList.periodical(interval * 1000);
var slide = new Fx.Slide('settings-container').toggle();
});
$('settings').addEvent('click', function(e) {
e = new Event(e).stop();
var slide = new Fx.Slide('settings-container').toggle();
});
var updateTimer = refreshList.periodical(10000);
});
//]]>
</script>
<style type="text/css">
body {
font-family: sans-serif;
font-size: 12px;
margin: 0;
background-color: #E8E8E8;
}
a, a:active, a:hover, a:visited {
text-decoration: none;
color: #000000;
}
#interval {
width: 30px;
text-align: center;
}
.tool-tip {
color: #000000;
z-index: 13000;
border: 1px solid #B8B8B8;
background: #F9F9F9;
}
.tool-tip h1 {
font-weight: bold;
font-size: 1.3em;
margin: 0;
color: #323232;
padding: 2px;
background: #DDDDDD;
border-bottom: 1px solid #B8B8B8;
}
#background-top-left, #background-top-right {
position: absolute;
height: 55px;
background-color: #CECECE;
top: 0;
width: 5%;
z-index: -1;
border-bottom: 1px solid #bdbdbd;
}
html>body #background-top-left, html>body #background-top-right {
z-index: 1;
}
#background-top-left {
left: 0;
}
#background-top-right {
right: 0;
}
#container {
width: 90%;
margin: 0px auto;
border: 1px solid #bdbdbd;
border-top-width: 0;
}
#header {
height: 81px;
background: url(header-background.png) repeat-x;
color: #FEFEFE;
}
#header a {
color: #FEFEFE;
}
#logo {
float: left;
margin: 8px;
}
#logo-text {
margin-top: 15px;
margin-left: 5px;
float: left;
font-size: 1.8em;
}
#header-actions {
float: right;
height: 81px;
width: 200px;
text-align: center;
}
.header-action {
padding: 5px;
background: url(header-separator.png) repeat-y;
height: 71px;
float: right;
width: 90px;
cursor: pointer;
}
#new-download {
height: 27px;
background: url(new-download-background.png) repeat-x;
padding: 3px;
padding-top: 10px;
vertical-align:bottom;
padding-left: 8px;
color: #000000;
overflow: hidden; /* workaround for IE */
}
html>body #new-download {
overflow: visible;
}
#url {
width: 250px;
}
#h2-downloads {
background: url(title-border-bottom-downloads.png) no-repeat;
}
#h2-settings {
background: url(title-border-bottom-settings.png) no-repeat;
}
#h2-downloads, #h2-settings {
background-position: bottom left;
margin: 2px;
margin-top: 14px;
padding: 2px;
padding-left: 20px;
}
#download-list {
position: relative;
background-color: #FFFFFF;
min-height: 500px;
padding: 1px;
}
html>body #download-list {
padding: 0;
}
#settings-container {
padding: 1px;
padding-left: 0;
background-color: #F2F0E7;
border-bottom: 1px dotted #b3b3b3;
}
#settings-form-box {
padding: 10px;
padding-left: 20px;
}
#downloads-list {
padding: 10px;
}
#download-list-table {
width: 100%;
border-collapse: collapse;
}
.download-list-table-item td {
height: 40px;
border-top: 1px dotted black;
border-bottom: 1px dotted black;
white-space: nowrap;
vertical-align: middle;
}
.download-list-table-item:hover {
background-color: #efefef;
}
#download-list-table-header td {
height: 30px;
}
.download-list-table-spacer td {
height: 6px;
}
.download-left {
padding-left: 10px;
}
.download-center {
text-align: center;
}
.download-number {
background-color: #EFEFEF;
color: #FF8800;
font-size: 1.4em;
text-align: center;
font-weight: bold;
width: 50px;
}
#footer {
color: #000000;
background-color: #DADADA;
padding: 5px;
font-size: 0.8em;
text-align: center;
border-top: 1px solid #bdbdbd;
}
img {
border-width: 0;
}
input {
border: 1px solid #B0B7C5;
background-color: #FFFFFF;
}
input:hover {
border: 1px solid #000000;
}
.input-button {
cursor: pointer;
background-color: #f1f1f2;
}
.input-checkbox {
border-width: 0;
}
p {
margin: 0;
}
</style>
<script type="text/javascript">
//<![CDATA[
/* IE hack for transparent PNGs */
if (navigator.userAgent.toLowerCase().indexOf('msie') >= 1) {
document.writeln('<style type="text/css">.header-action img, #logo img { behavior: url("iepngfix.htc") }</style>');
}
//]]>
</script>
</head>
<body>
<div id="background-top-left"></div>
<div id="background-top-right"></div>
<div id="container">
<div id="header">
<div id="logo">
<img src="hi64-apps-kget.png" alt="KGet" />
</div>
<div id="logo-text">
<p>KGet<br /><small>#{Webinterface}</small></p>
</div>
<div id="header-actions">
<div class="header-action" id="settings"><img src="preferences-system.png" alt="#{Settings}" /><br />Settings</div>
<div class="header-action" id="load-downloads"><img src="view-refresh.png" alt="#{Refresh}" /><br />Refresh</div>
</div>
</div>
<div id="new-download">
<form id="new-download-form" action="do" method="get">
<p><label for="url">#{Enter URL: }</label><input type="text" name="url" id="url" value="" />&nbsp;<select name="group" id="group">#{groups}</select>&nbsp;<input type="submit" value="#{OK}" class="input-button" /></p>
</form>
<div id="log">
<div id="log-res"></div>
</div>
</div>
<div id="download-list">
<div id="settings-container">
<h2 id="h2-settings">#{Settings}</h2>
<form id="settings-form" action="#" method="get">
<div id="settings-form-box">
<input type="checkbox" name="enable-refresh" id="enable-refresh" checked="checked" class="input-checkox" />
<label for="enable-refresh"> #{Refresh download list every} </label>
<input type="text" name="interval" id="interval" value="2" />
<label for="interval"> #{seconds}</label>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="#{Save Settings}" class="input-button" />
</div>
</form>
</div>
<h2 id="h2-downloads">#{Downloads}</h2>
<div id="downloads-list">
</div>
</div>
<div id="footer">
#{KGet Webinterface | Valid XHTML 1.0 Strict &amp; CSS}
</div>
</div>
</body>
</html>