Skip to content

Commit

Permalink
Merge pull request #9 from Martinski4GitHub/master
Browse files Browse the repository at this point in the history
Fixes & Improvements
  • Loading branch information
Martinski4GitHub authored Sep 23, 2024
2 parents fbbd0a9 + bc56382 commit c230bd1
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 69 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# scMerlin

## v2.5.6
### Updated on June 28, 2024 by @decoderman with updates from @Martinski4GitHub
## v2.5.7
### Updated on 2024-Sep-22 by @decoderman with updates from @Martinski4GitHub

## About
scMerlin allows you to easily control the most common services/scripts on your router. scMerlin also augments your router's WebUI with a Sitemap and dynamic submenus for the main left menu of Asuswrt-Merlin.

Expand Down
25 changes: 17 additions & 8 deletions scmerlin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## https://github.com/jackyaz/scMerlin ##
## ##
######################################################
# Last Modified: 2024-Jun-28
# Last Modified: 2024-Sep-22
#-----------------------------------------------------

########## Shellcheck directives ###########
Expand All @@ -27,8 +27,8 @@
### Start of script variables ###
readonly SCRIPT_NAME="scMerlin"
readonly SCRIPT_NAME_LOWER="$(echo "$SCRIPT_NAME" | tr 'A-Z' 'a-z' | sed 's/d//')"
readonly SCM_VERSION="v2.5.6"
readonly SCRIPT_VERSION="v2.5.6"
readonly SCM_VERSION="v2.5.7"
readonly SCRIPT_VERSION="v2.5.7"
SCRIPT_BRANCH="master"
SCRIPT_REPO="https://raw.githubusercontent.com/decoderman/$SCRIPT_NAME/$SCRIPT_BRANCH"
readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME_LOWER.d"
Expand Down Expand Up @@ -321,8 +321,10 @@ Update_Check(){
echo "$doupdate,$localver,$serverver"
}

Update_Version(){
if [ -z "$1" ]; then
Update_Version()
{
if [ $# -eq 0 ] || [ -z "$1" ]
then
updatecheckresult="$(Update_Check)"
isupdate="$(echo "$updatecheckresult" | cut -f1 -d',')"
localver="$(echo "$updatecheckresult" | cut -f2 -d',')"
Expand Down Expand Up @@ -371,7 +373,8 @@ Update_Version(){
fi
fi

if [ "$1" = "force" ]; then
if [ "$1" = "force" ]
then
serverver=$(/usr/sbin/curl -fsL --retry 3 "$SCRIPT_REPO/$SCRIPT_NAME_LOWER.sh" | grep "SCRIPT_VERSION=" | grep -m1 -oE 'v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})')
Print_Output true "Downloading latest version ($serverver) of $SCRIPT_NAME" "$PASS"
Update_File shared-jy.tar.gz
Expand Down Expand Up @@ -2157,7 +2160,7 @@ then
fi

##----------------------------------------##
## Modified by Martinski W. [2024-Apr-29] ##
## Modified by Martinski W. [2024-Sep-22] ##
##----------------------------------------##
case "$1" in
install)
Expand Down Expand Up @@ -2306,7 +2309,13 @@ case "$1" in
exit 0
;;
develop)
SCRIPT_BRANCH="develop"
if false ## The "develop" branch is NOT available on this repository ##
then
SCRIPT_BRANCH="develop"
else
SCRIPT_BRANCH="master"
printf "\n${REDct}The 'develop' branch is NOT available. Updating from the 'master' branch...${CLEARct}\n"
fi
SCRIPT_REPO="https://raw.githubusercontent.com/decoderman/$SCRIPT_NAME/$SCRIPT_BRANCH"
Update_Version force
exit 0
Expand Down
15 changes: 7 additions & 8 deletions scmerlin_www.asp

Large diffs are not rendered by default.

99 changes: 49 additions & 50 deletions scmerlin_www.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ Chart.Tooltip.positioners.cursor = function(chartElements,coordinates){
return coordinates;
};

var $j = jQuery.noConflict(); //avoid conflicts on John's fork (state.js)

function SetCurrentPage(){
function SetCurrentPage()
{
document.form.next_page.value = window.location.pathname.substring(1);
document.form.current_page.value = window.location.pathname.substring(1);
}
Expand All @@ -37,29 +36,29 @@ function initial()
Draw_Chart_NoData('jffsUsage','Data loading...');
Draw_Chart_NoData('MemoryUsage','Data loading...')
Draw_Chart_NoData('SwapUsage','No swap file configured');
$j('#sortTableCron').empty();
$j('#sortTableCron').append(BuildSortTableHtmlNoData());
$j('#sortTableProcesses').empty();
$j('#sortTableProcesses').append(BuildSortTableHtmlNoData());

$('#sortTableCron').empty();
$('#sortTableCron').append(BuildSortTableHtmlNoData());
$('#sortTableProcesses').empty();
$('#sortTableProcesses').append(BuildSortTableHtmlNoData());

var vpnserverstablehtml='';
for(var i = 1; i < 3; i++){
vpnserverstablehtml += BuildVPNServerTable(i);
}
$j('#table_config').after(vpnserverstablehtml);
$('#table_config').after(vpnserverstablehtml);

var vpnclientstablehtml='';
for(var i = 1; i < 6; i++){
vpnclientstablehtml += BuildVPNClientTable(i);
}
$j('#table_config').after(vpnclientstablehtml);
$('#table_config').after(vpnclientstablehtml);

var servicectablehtml='';
for(var i = 0; i < srvnamelist.length; i++){
servicectablehtml += BuildServiceTable(srvnamelist[i],srvdesclist[i],srvnamevisiblelist[i],i);
}
$j('#table_config').after(servicectablehtml);
$('#table_config').after(servicectablehtml);

document.formScriptActions.action_script.value='start_scmerlingetaddonpages;start_scmerlingetcronjobs';
document.formScriptActions.submit();
Expand All @@ -78,10 +77,10 @@ function initial()
function ScriptUpdateLayout(){
var localver = GetVersionNumber('local');
var serverver = GetVersionNumber('server');
$j('#scmerlin_version_local').text(localver);
$('#scmerlin_version_local').text(localver);

if(localver != serverver && serverver != 'N/A'){
$j('#scmerlin_version_server').text('Updated version available: '+serverver);
$('#scmerlin_version_server').text('Updated version available: '+serverver);
showhide('btnChkUpdate',false);
showhide('scmerlin_version_server',true);
showhide('btnDoUpdate',true);
Expand All @@ -93,7 +92,7 @@ function reload(){
}

function update_status(){
$j.ajax({
$.ajax({
url: '/ext/scmerlin/detect_update.js',
dataType: 'script',
error: function(xhr){
Expand All @@ -107,12 +106,12 @@ function update_status(){
document.getElementById('imgChkUpdate').style.display = 'none';
showhide('scmerlin_version_server',true);
if(updatestatus != 'None'){
$j('#scmerlin_version_server').text('Updated version available: '+updatestatus);
$('#scmerlin_version_server').text('Updated version available: '+updatestatus);
showhide('btnChkUpdate',false);
showhide('btnDoUpdate',true);
}
else{
$j('#scmerlin_version_server').text('No update available');
$('#scmerlin_version_server').text('No update available');
showhide('btnChkUpdate',true);
showhide('btnDoUpdate',false);
}
Expand All @@ -132,7 +131,7 @@ function CheckUpdate(){
function DoUpdate(){
document.form.action_script.value = 'start_scmerlindoupdate';
document.form.action_wait.value = 15;
$j('#auto_refresh').prop('checked',false);
$('#auto_refresh').prop('checked',false);
if (tmout != null) clearTimeout(tmout);
showLoading();
document.form.submit();
Expand All @@ -148,7 +147,7 @@ function RestartService(servicename){
}

function service_status(servicename){
$j.ajax({
$.ajax({
url: '/ext/scmerlin/detect_service.js',
dataType: 'script',
error: function(xhr){
Expand Down Expand Up @@ -285,18 +284,18 @@ function BuildSortTableHtml(type) {
/**----------------------------------------**/
function Get_NTPWatchdogEnabled_File()
{
$j.ajax({
$.ajax({
url: '/ext/scmerlin/watchdogenabled.htm',
dataType: 'text',
error: function(xhr)
{
document.form.scMerlin_NTPwatchdog.value = 'Disable';
$j('#scMerlin_NTPwatchdog_Status').text('Currently: DISABLED');
$('#scMerlin_NTPwatchdog_Status').text('Currently: DISABLED');
},
success: function(data)
{
document.form.scMerlin_NTPwatchdog.value = 'Enable';
$j('#scMerlin_NTPwatchdog_Status').text('Currently: ENABLED');
$('#scMerlin_NTPwatchdog_Status').text('Currently: ENABLED');
}
});
}
Expand All @@ -308,7 +307,7 @@ function Save_NTPWatchdog()
{
document.form.action_script.value = 'start_scmerlin_NTPwatchdog' + document.form.scMerlin_NTPwatchdog.value;
document.form.action_wait.value = 4;
$j('#auto_refresh').prop('checked',false);
$('#auto_refresh').prop('checked',false);
if (tmout != null) clearTimeout(tmout);
showLoading();
document.form.submit();
Expand All @@ -320,18 +319,18 @@ function Save_NTPWatchdog()
/**-------------------------------------**/
function Get_DNSmasqWatchdogEnabled_File()
{
$j.ajax({
$.ajax({
url: '/ext/scmerlin/tailtaintdnsenabled.htm',
dataType: 'text',
error: function(xhr)
{
document.form.scMerlin_DNSmasqWatchdog.value = 'Disable';
$j('#scMerlin_DNSmasqWatchdog_Status').text('Currently: DISABLED');
$('#scMerlin_DNSmasqWatchdog_Status').text('Currently: DISABLED');
},
success: function(data)
{
document.form.scMerlin_DNSmasqWatchdog.value = 'Enable';
$j('#scMerlin_DNSmasqWatchdog_Status').text('Currently: ENABLED');
$('#scMerlin_DNSmasqWatchdog_Status').text('Currently: ENABLED');
}
});
}
Expand All @@ -343,7 +342,7 @@ function Save_DNSmasqWatchdog()
{
document.form.action_script.value = 'start_scmerlin_DNSmasqWatchdog' + document.form.scMerlin_DNSmasqWatchdog.value;
document.form.action_wait.value = 4;
$j('#auto_refresh').prop('checked',false);
$('#auto_refresh').prop('checked',false);
if (tmout != null) clearTimeout(tmout);
showLoading();
document.form.submit();
Expand Down Expand Up @@ -516,7 +515,7 @@ function SetNTPReadyCheckButtonState (enableState, theWaitMsg)
/**-------------------------------------**/
function Get_NTPReadyCheck_Option()
{
$j.ajax({
$.ajax({
url: '/ext/scmerlin/NTP_Ready_Config.htm',
dataType: 'text',
error: function(xhr)
Expand All @@ -525,7 +524,7 @@ function Get_NTPReadyCheck_Option()
NTPReadyCheck.prevOptionValue = 'DISABLED';
WaitMsgPopupBox.CloseMsg();
SetNTPReadyCheckButtonState (true, null);
$j('#scMerlin_NTPcheck_Status').text('Currently: DISABLED');
$('#scMerlin_NTPcheck_Status').text('Currently: DISABLED');
},
success: function(data)
{
Expand Down Expand Up @@ -568,7 +567,7 @@ function Get_NTPReadyCheck_Option()
theMsg = NTPReadyCheck.disabledDoneMsg;
}
}
$j('#scMerlin_NTPcheck_Status').text('Currently: ' + theCheckSetting);
$('#scMerlin_NTPcheck_Status').text('Currently: ' + theCheckSetting);
WaitMsgPopupBox.CloseMsg();
if (theMsg != '') { AlertMsgBox.ShowAlert (theMsg); }
SetNTPReadyCheckButtonState (true, null);
Expand Down Expand Up @@ -618,7 +617,7 @@ function Save_NTPReadyCheck_Option()
}

function load_addonpages(){
$j.ajax({
$.ajax({
url: '/ext/scmerlin/addonwebpages.htm',
dataType: 'text',
error: function(xhr){
Expand Down Expand Up @@ -649,15 +648,15 @@ function load_addonpages(){
addonpageshtml += BuildAddonPageTable(sortedAddonPages[i].NAME,sortedAddonPages[i].URL,i);
}

$j('#table_config').after(addonpageshtml);
$('#table_config').after(addonpageshtml);

AddEventHandlers();
}
});
}

function get_cronlist_file(){
$j.ajax({
$.ajax({
url: '/ext/scmerlin/scmcronjobs.htm',
dataType: 'text',
error: function(xhr){
Expand Down Expand Up @@ -696,7 +695,7 @@ function ParseCronJobs(data){
}

function get_proclist_file(){
$j.ajax({
$.ajax({
url: '/ext/scmerlin/top.htm',
dataType: 'text',
error: function(xhr){
Expand Down Expand Up @@ -756,14 +755,14 @@ function SetCookie(cookiename,cookievalue){
}

function AddEventHandlers(){
$j('.collapsible-jquery').off('click').on('click',function(){
$j(this).siblings().toggle('fast',function(){
if($j(this).css('display') == 'none'){
SetCookie($j(this).siblings()[0].id,'collapsed');
$('.collapsible-jquery').off('click').on('click',function(){
$(this).siblings().toggle('fast',function(){
if($(this).css('display') == 'none'){
SetCookie($(this).siblings()[0].id,'collapsed');
}
else{
SetCookie($j(this).siblings()[0].id,'expanded');
if($j(this).siblings()[0].id == 'routermemory'){
SetCookie($(this).siblings()[0].id,'expanded');
if($(this).siblings()[0].id == 'routermemory'){
Draw_Chart('MemoryUsage');
if(parseInt(mem_stats_arr[5]) != 0){
Draw_Chart('SwapUsage');
Expand All @@ -772,24 +771,24 @@ function AddEventHandlers(){
Draw_Chart_NoData('SwapUsage','No swap file configured');
}
}
else if($j(this).siblings()[0].id == 'routerstorage'){
else if($(this).siblings()[0].id == 'routerstorage'){
Draw_Chart('nvramUsage');
Draw_Chart('jffsUsage');
}
}
})
});

$j('.collapsible-jquery').each(function(index,element){
if(GetCookie($j(this)[0].id,'string') == 'collapsed'){
$j(this).siblings().toggle(false);
$('.collapsible-jquery').each(function(index,element){
if(GetCookie($(this)[0].id,'string') == 'collapsed'){
$(this).siblings().toggle(false);
}
else{
$j(this).siblings().toggle(true);
$(this).siblings().toggle(true);
}
});

$j('#auto_refresh').off('click').on('click',function(){ToggleRefresh();});
$('#auto_refresh').off('click').on('click',function(){ToggleRefresh();});
}

function SortTable(tableid,arrayid,sorttext,sortname,sortdir){
Expand Down Expand Up @@ -841,10 +840,10 @@ function SortTable(tableid,arrayid,sorttext,sortname,sortdir){
}
}

$j('#'+tableid).empty();
$j('#'+tableid).append(BuildSortTableHtml(tableid));
$('#'+tableid).empty();
$('#'+tableid).append(BuildSortTableHtml(tableid));

$j('#'+tableid).find('.sortable').each(function(index,element){
$('#'+tableid).find('.sortable').each(function(index,element){
if(element.innerHTML == window[sortname]){
if(window[sortdir] == 'asc'){
element.innerHTML = window[sortname]+' ↑';
Expand Down Expand Up @@ -893,7 +892,7 @@ function getNum(val){
}

function ToggleRefresh(){
if($j('#auto_refresh').prop('checked') == true){
if($('#auto_refresh').prop('checked') == true){
get_proclist_file();
}
else{
Expand Down
Loading

0 comments on commit c230bd1

Please sign in to comment.