Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 319977d
Merge: e8f0fef 6cc49f4
Author: Novik <[email protected]>
Date:   Wed Jan 12 15:52:14 2022 +0300

    Merge pull request Novik#2261 from njutn95/patch-1

    Fix the typo/syntax error in the static method call

commit 6cc49f4
Author: njutn95 <[email protected]>
Date:   Wed Jan 12 13:01:27 2022 +0100

    Fix the typo/syntax error in the static method call

commit e8f0fef
Merge: cc8d4b1 13a75f5
Author: Novik <[email protected]>
Date:   Mon Jan 10 14:43:22 2022 +0300

    Merge pull request Novik#2254 from Micdu70/patch-7

    Fix task.php

commit 13a75f5
Author: Micdu70 <[email protected]>
Date:   Mon Jan 10 12:42:10 2022 +0100

    Fix task.php

commit cc8d4b1
Merge: 25580d7 fec4bdd
Author: Novik <[email protected]>
Date:   Mon Jan 10 12:36:59 2022 +0300

    Merge pull request Novik#2253 from stickz/Namespace-Fix

    Fix loading utility classes from namespaces

commit fec4bdd
Author: stickz <[email protected]>
Date:   Mon Jan 10 04:01:07 2022 -0500

    Fix PHP Notice

commit 25580d7
Author: Novik <[email protected]>
Date:   Mon Jan 10 11:28:42 2022 +0300

    fix context menu error

commit 2897543
Merge: 795bd19 bcea8a6
Author: Novik <[email protected]>
Date:   Mon Jan 10 11:07:21 2022 +0300

    Merge pull request Novik#2252 from Micdu70/patch-11

    Add 'copyToClipboard' function in common.js + a few fixes

commit d92e194
Author: stickz <[email protected]>
Date:   Mon Jan 10 02:53:31 2022 -0500

    Go to end of exploded array instead

commit bcea8a6
Author: Micdu70 <[email protected]>
Date:   Sat Jan 8 19:04:30 2022 +0100

    Add 'copyToClipboard' function in common.js + a few fixes

commit d12228d
Author: stickz <[email protected]>
Date:   Mon Jan 10 01:27:00 2022 -0500

    Fix loading utility classes

commit 795bd19
Merge: 0d44ec9 27e4882
Author: Novik <[email protected]>
Date:   Sun Jan 9 14:20:14 2022 +0300

    Merge pull request Novik#2241 from stickz/MemoryLeakFixes

     Improve memory management

commit 0d44ec9
Merge: fd35e22 db16d33
Author: Novik <[email protected]>
Date:   Sun Jan 9 14:07:37 2022 +0300

    Merge pull request Novik#2247 from stickz/Utility2

    Refactor code & implement autoloader

commit db16d33
Author: stickz <[email protected]>
Date:   Sat Jan 8 18:49:52 2022 -0500

    Fix json.php

commit fd35e22
Merge: be26ce3 0d91672
Author: Novik <[email protected]>
Date:   Fri Jan 7 14:24:08 2022 +0300

    Merge pull request Novik#2251 from Micdu70/patch-11

    Fix 'check_port' and 'extsearch' plugins

commit 0d91672
Author: Micdu70 <[email protected]>
Date:   Fri Jan 7 10:46:15 2022 +0100

    Fix 'check_port' and 'extsearch' plugins

commit d815e75
Author: stickz <[email protected]>
Date:   Thu Jan 6 16:53:14 2022 -0500

    Fix third party plugin compatibility

commit 2ec6b86
Author: stickz <[email protected]>
Date:   Thu Jan 6 16:22:21 2022 -0500

    Remove $user arg for paths

commit 3f60a43
Author: stickz <[email protected]>
Date:   Thu Jan 6 16:12:12 2022 -0500

    Remove ruTorrentConfig

commit df7c0d0
Author: stickz <[email protected]>
Date:   Thu Jan 6 16:09:17 2022 -0500

    Fix whitespaces

commit 9f3aee8
Author: stickz <[email protected]>
Date:   Thu Jan 6 16:06:41 2022 -0500

    Revert ruTorrentConfig class

commit be26ce3
Merge: 9be549f 28fa12c
Author: Novik <[email protected]>
Date:   Mon Jan 3 13:20:19 2022 +0300

    Merge pull request Novik#2249 from Micdu70/patch-11

    Fix Novik#2248

commit 28fa12c
Author: Micdu70 <[email protected]>
Date:   Mon Jan 3 10:25:41 2022 +0100

    Fix Novik#2248

commit c63b61a
Author: stickz <[email protected]>
Date:   Sun Jan 2 21:55:53 2022 -0500

    Refactor more code

commit 6429984
Author: stickz <[email protected]>
Date:   Sun Jan 2 13:03:15 2022 -0500

    Refactor code

commit 27e4882
Author: stickz <[email protected]>
Date:   Thu Dec 30 01:20:31 2021 -0500

     Improve memory management
  • Loading branch information
stickz committed Jan 12, 2022
1 parent 9be549f commit b32728c
Show file tree
Hide file tree
Showing 169 changed files with 1,761 additions and 1,613 deletions.
2 changes: 1 addition & 1 deletion conf/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"localhost",
);

$profilePath = '../share'; // Path to user profiles
$profilePath = '../../share'; // Path to user profiles
$profileMask = 0777; // Mask for files and directory creation in user profiles.
// Both Webserver and rtorrent users must have read-write access to it.
// For example, if Webserver and rtorrent users are in the same group then the value may be 0770.
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<script type="text/javascript" src="./js/jquery.flot.js"></script>
<script type="text/javascript" src="./js/graph.js"></script>
<script type="text/javascript" src="./js/plugins.js"></script>
<script type="text/javascript" src="./js/webui.js"></script>
<script type="text/javascript" src="./js/rtorrent.js"></script>
<script type="text/javascript" src="./js/webui.js"></script>
</head>
<body>
<div id="preload"></div>
Expand Down
37 changes: 34 additions & 3 deletions js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,38 @@ function noty(msg,status,noTime)
}
}

function fallbackCopyToClipboard(text)
{
var textarea = document.createElement("textarea");
textarea.textContent = text;
textarea.style.position = "fixed";
document.body.appendChild(textarea);
textarea.select();
try {
var success = document.execCommand("copy");
if(success)
noty( theUILang.copyToClipboardSuccess, "success" );
} catch (err) {
prompt(theUILang.copyToClipboardFailed, text);
} finally {
document.body.removeChild(textarea);
}
}

function copyToClipboard(text)
{
if (!navigator.clipboard)
{
fallbackCopyToClipboard(text);
return;
}
navigator.clipboard.writeText(text).then(function() {
noty( theUILang.copyToClipboardSuccess, "success" );
}, function(err) {
fallbackCopyToClipboard(text);
});
}

function rDirectory()
{
this.dirs = new Array();
Expand Down Expand Up @@ -1591,8 +1623,7 @@ function strip_tags(input, allowed)
// Caveat: doesn't work with Internet Explorer.
(function setBrowserTimezoneCookie()
{
try
{
try {
document.cookie = "browser_timezone="+Intl.DateTimeFormat().resolvedOptions().timeZone
} catch(e) {}
}).apply();
}).apply();
4 changes: 2 additions & 2 deletions js/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ var theContextMenu =
switch($type(val[2]))
{
case "string": a.attr("href","javascript://void();").on('click', function() { eval(val[2]) } ); break;
case "function": a.attr("href","javascript://void();").trigger('click', val[2]); break;
case "function": a.attr("href","javascript://void();").on('click', val[2]); break;
}
li.append(a.on('focus', function() { this.blur(); } ));
}
Expand All @@ -338,7 +338,7 @@ var theContextMenu =
{
case false: a.addClass("dis"); break;
case "string": a.attr("href","javascript://void();").on('click', function() { eval(val[1]) } ); break;
case "function": a.attr("href","javascript://void();").trigger('click', val[1]); break;
case "function": a.attr("href","javascript://void();").on('click', val[1]); break;
}
li.append(a.on('focus', function() { this.blur(); } ));
}
Expand Down
60 changes: 30 additions & 30 deletions js/plugins.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// this function is obsolete

function injectScript(fname,initFunc)
function injectScript(fname,initFunc)
{
var h = document.getElementsByTagName("head").item(0);
s = document.createElement("script");
if(initFunc)
{
{
if(browser.isIE)
s.onreadystatechange = function()
{
if((this.readyState == 'loaded') || (this.readyState == 'complete'))
if((this.readyState == 'loaded') || (this.readyState == 'complete'))
initFunc();
}
else
Expand All @@ -23,32 +23,32 @@ function injectScript(fname,initFunc)
void (h.appendChild(s));
}

function injectCSS(fname)
function injectCSS(fname)
{
var newSS=document.createElement('link');
newSS.rel='stylesheet';
newSS.href=fname;
var newSS=document.createElement('link');
newSS.rel='stylesheet';
newSS.href=fname;
var h = document.getElementsByTagName("head").item(0);
void (h.appendChild(newSS));
}

function injectCSSText(text)
function injectCSSText(text)
{
var style=document.createElement('style');
var style=document.createElement('style');
style.setAttribute("type", "text/css");
if(style.styleSheet)
style.styleSheet.cssText = text;
else
else
style.appendChild(document.createTextNode(text));
var h = document.getElementsByTagName("head").item(0);
void (h.appendChild(style));
}

var thePlugins =
var thePlugins =
{
list: {},
topMenu: [],
restictions:
restictions:
{
cantChangeToolbar: 0x0001,
cantChangeMenu: 0x0002,
Expand Down Expand Up @@ -119,52 +119,52 @@ function rPlugin( name, version, author, descr, restictions, help )
thePlugins.register(this);
}

rPlugin.prototype.markLoaded = function()
rPlugin.prototype.markLoaded = function()
{
this.allStuffLoaded = true;
}

rPlugin.prototype.enable = function()
rPlugin.prototype.enable = function()
{
this.enabled = true;
return(this);
}

rPlugin.prototype.disable = function()
rPlugin.prototype.disable = function()
{
this.enabled = false;
return(this);
}

rPlugin.prototype.launch = function()
rPlugin.prototype.launch = function()
{
this.launched = true;
return(this);
}

rPlugin.prototype.unlaunch = function()
rPlugin.prototype.unlaunch = function()
{
this.launched = false;
return(this);
}

rPlugin.prototype.remove = function()
rPlugin.prototype.remove = function()
{
if($type(this["onRemove"])=="function")
this.onRemove();
this.disable();
return(this);
}

rPlugin.prototype.showError = function(err)
rPlugin.prototype.showError = function(err)
{
if( this.allStuffLoaded )
noty( eval(err), "error" );
else
setTimeout( 'thePlugins.get("'+this.name+'").showError("' + err + '")', 1000 );
}

rPlugin.prototype.langLoaded = function()
rPlugin.prototype.langLoaded = function()
{
try {
if(($type(this["onLangLoaded"])=="function") && this.enabled)
Expand All @@ -178,15 +178,15 @@ rPlugin.prototype.loadLangPrim = function(lang,template,sendNotify)
var self = this;
$.ajax(
{
url: template.replace('{lang}',lang), // this is because plugin.path may be changed during call
url: template.replace('{lang}',lang), // this is because plugin.path may be changed during call
dataType: "script",
cache: true
}).done( function()
{
!sendNotify || self.langLoaded();
}).fail( function()
{
(lang=='en') ?
(lang=='en') ?
(!window.console || console.error( "Plugin '"+self.name+"': localization for '"+lang+"' not found." )) :
self.loadLangPrim('en',template,sendNotify);
});
Expand Down Expand Up @@ -283,7 +283,7 @@ rPlugin.prototype.attachPageToTabs = function(dlg,name,idBefore)
{
if(!dlg.className)
dlg.className = "tab";
theTabs.tabs[dlg.id] = name;
theTabs.tabs[dlg.id] = name;
var newLbl = document.createElement("li");
newLbl.id = "tab_"+dlg.id;
newLbl.innerHTML = "<a href=\"javascript://void();\" onmousedown=\"theTabs.show('"+dlg.id+"');\" onfocus=\"this.blur();\">" + name + "</a>";
Expand All @@ -309,7 +309,7 @@ rPlugin.prototype.renameTab = function(id,name)

rPlugin.prototype.removePageFromTabs = function(id)
{
delete theTabs.tabs[id];
delete theTabs.tabs[id];
$('#'+id).remove();
$('#tab_'+id).remove();
return(this);
Expand All @@ -336,9 +336,9 @@ rPlugin.prototype.addButtonToToolbar = function(id,name,onclick,idBefore)
newBtn.title=name;
newBtn.innerHTML='<div class="top-menu-item" id="'+id+'" onclick="'+onclick+';return(false);"></div>';
$(newBtn).addClass('top-menu-item').on('focus', function(e) { this.blur(); } );
var targetBtn = idBefore ? $$("mnu_"+idBefore) : null;
var targetBtn = idBefore ? $$("mnu_"+idBefore) : null;
if(targetBtn)
targetBtn.parentNode.insertBefore(newBtn,targetBtn);
targetBtn.parentNode.insertBefore(newBtn,targetBtn);
else
{
targetBtn = $$("mnu_settings");
Expand All @@ -352,16 +352,16 @@ rPlugin.prototype.removeButtonFromToolbar = function(id)
{
$("#mnu_"+id).remove();
}
rPlugin.prototype.addSeparatorToToolbar = function(idBefore)

rPlugin.prototype.addSeparatorToToolbar = function(idBefore)
{
if(this.canChangeToolbar())
{
var targetBtn = idBefore ? $$("mnu_"+idBefore) : null;
var sep = document.createElement("DIV");
sep.className = "TB_Separator";
if(targetBtn)
targetBtn.parentNode.insertBefore(sep,targetBtn);
targetBtn.parentNode.insertBefore(sep,targetBtn);
else
{
targetBtn = $$("mnu_settings");
Expand Down Expand Up @@ -410,4 +410,4 @@ rPlugin.prototype.removePaneFromCategory = function(id)
$("#"+id).remove();
$("#"+id+"_cont").remove();
return(this);
}
}
52 changes: 33 additions & 19 deletions js/rtorrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,26 +1180,10 @@ function Ajax(URI, isASync, onComplete, onTimeout, onError, reqTimeout)
global: true
});

request.always(function(data, textStatus, errorThrown)
{
if(theWebUI.deltaTime==0)
{
var diff = 0;
try {
diff = new Date().getTime()-Date.parse(request.getResponseHeader("Date"));
} catch(e) { diff = 0; };
theWebUI.deltaTime = iv(diff);
}
if(theWebUI.serverDeltaTime==0)
{
var timestamp = request.getResponseHeader("X-Server-Timestamp");
if(timestamp != null)
theWebUI.serverDeltaTime = new Date().getTime()-iv(timestamp)*1000;
}
});

request.fail(function(jqXHR, textStatus, errorThrown)
{
Ajax_UpdateTime(jqXHR);

if((textStatus=="timeout") && ($type(onTimeout) == "function"))
onTimeout();
else if($type(onError) == "function")
Expand All @@ -1211,16 +1195,19 @@ function Ajax(URI, isASync, onComplete, onTimeout, onError, reqTimeout)
response = errorThrown;
onError(status+" ["+textStatus+","+stub.action+"]",response);
}
stub = null; // Cleanup memory leak
});

request.done(function(data, textStatus, jqXHR)
{
var responseText = stub.getResponse(data);
Ajax_UpdateTime(jqXHR);

stub.logErrorMessages();
if(stub.listRequired)
Ajax("?list=1", isASync, onComplete, onTimeout, onError, reqTimeout);
else if(!stub.isError())
{
var responseText = stub.getResponse(data);
switch($type(onComplete))
{
case "function":
Expand All @@ -1234,8 +1221,35 @@ function Ajax(URI, isASync, onComplete, onTimeout, onError, reqTimeout)
break;
}
}
responseText = null; // Cleanup memory leak
}
stub = null; // Cleanup memory leak
});

// Nullify ajax request varriables to cleanup up memory leaks
request.onreadystatechange = null;
request.abort = null;
request = null;
}

function Ajax_UpdateTime(jqXHR)
{
if(theWebUI.deltaTime==0)
{
var diff = 0;
try { diff = new Date().getTime()-Date.parse(jqXHR.getResponseHeader("Date")); } catch(e) { diff = 0; };
theWebUI.deltaTime = iv(diff);
diff = null; // Cleanup memory leak
}

if(theWebUI.serverDeltaTime==0)
{
var timestamp = jqXHR.getResponseHeader("X-Server-Timestamp");
if(timestamp != null)
theWebUI.serverDeltaTime = new Date().getTime()-iv(timestamp)*1000;
timestamp = null; // Cleanup memory leak
}
jqXHR = null; // Cleanup memory leak
}

$(document).ready(function()
Expand Down
Loading

0 comments on commit b32728c

Please sign in to comment.