From 3f6259fa09bed93bee067b887b53e5f809829220 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Wed, 4 Jun 2014 22:18:42 +0000 Subject: [PATCH] various tweaks --- CONTROL/control | 2 +- webif/plugin/sweeper/schema.js | 18 +++++++---- webif/plugin/sweeper/script.js | 56 +++++++++++++++++++--------------- webif/plugin/sweeper/style.css | 12 ++++---- 4 files changed, 51 insertions(+), 37 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index afb2baf..7e180ba 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: sweeper Priority: optional Section: misc -Version: 1.0.12 +Version: 1.0.13 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif(>=1.0.14-2) diff --git a/webif/plugin/sweeper/schema.js b/webif/plugin/sweeper/schema.js index 8796850..32e3e45 100644 --- a/webif/plugin/sweeper/schema.js +++ b/webif/plugin/sweeper/schema.js @@ -103,33 +103,39 @@ var schema = { 'continue': { 'class': 'all', argtype: 'none', - desc: 'Continue to next rule' + desc: 'Continue on to next rule', + showcont: false }, stop: { 'class': 'all', argtype: 'none', - desc: 'Do nothing and stop processing rules' + desc: 'Do nothing and stop processing rules', + showcont: false }, move: { 'class': 'all', argtype: 'folder', - desc: 'Move recording to folder...' + desc: 'Move recording to folder...', + showcont: true }, movecreate: { 'class': 'all', argtype: 'folder', - desc: 'Move recording to folder (creating if necessary)' + desc: 'Move recording to folder (creating if necessary)', + showcont: true }, fileunder: { 'class': 'folder', argtype: 'folder', - desc: 'Merge into first folder of same name found under...' + desc: 'Merge into first folder of same name found under...', + showcont: true }, fileundercreate: { 'class': 'folder', argtype: 'folder', desc: 'Merge into or create folder of ' + - 'same name found under...' + 'same name found under...', + showcont: true } } }; diff --git a/webif/plugin/sweeper/script.js b/webif/plugin/sweeper/script.js index 199240e..97a7d72 100644 --- a/webif/plugin/sweeper/script.js +++ b/webif/plugin/sweeper/script.js @@ -1,4 +1,6 @@ +var mroot = '(Media Root)'; + function quot(str) { if (!str) @@ -87,7 +89,7 @@ function ruleconf(rule) $(rule).find('tr.clause').each(function(i) { cmd = $(this).find('th').attr('cmd'); c = schema.criterion[cmd]; - val = $.trim($(this).find('td').text()); + val = $.trim($(this).find('td.val').text()); if (getters[c.type]) val = getters[c.type](cmd, val); @@ -95,8 +97,8 @@ function ruleconf(rule) }); act = $(rule).find('tr.action th').attr('cmd'); - arg = $.trim($(rule).find('tr.action td').text()); - if (schema.action[act].argtype == 'folder' && arg == 'Media Root') + arg = $.trim($(rule).find('tr.action td.val').text()); + if (schema.action[act].argtype == 'folder' && arg == mroot) arg = ''; if (act != 'continue') s += 'action {' + act + ' ' + quot(arg) + '}'; @@ -116,9 +118,14 @@ function conffile() return s; } -function rawrefresh(rule) +function rulerefresh(rule) { - $(rule).find('.raw').html(ruleconf(rule)); + rule.find('.raw').html(ruleconf(rule)); + rule.find('tr.clause td.title').text('And:').first().text('If:'); + if (rule.find('tr.clause').length < 1) + rule.find('tr.action td.title').text('Always:'); + else + rule.find('tr.action td.title').text('Then:'); } function criterion(data) @@ -126,7 +133,7 @@ function criterion(data) var c = schema.criterion[data.cmd]; var s; - s = '' + + s = 'And:' + '' + c.desc + ''; if (setters[c.type]) @@ -150,15 +157,20 @@ function action(data) var s; if (c.argtype == 'folder' && !data.arg) - data.arg = 'Media Root'; + data.arg = mroot; s = '' + + 'Then:' + '' + c.desc + '' + '' + data.arg + '' + '' + '' + ''; + if (c.showcont) + s += 'Else:' + + 'Continue on to next rule.'; + return s; } @@ -175,11 +187,6 @@ function addrule(id, data) .addClass('rule') .removeClass('hidden'); - // Only Firefox seems to have problems with top-right button - // placement. - if (navigator.userAgent.indexOf("Firefox") != -1) - rule.find('span.legendright').css('top', '-20px'); - rule.find('span.comment').html(data.name); if (data.type == 'folder') rule.find('.commentleft > span.folder').show(); @@ -189,18 +196,19 @@ function addrule(id, data) var $c = rule.find('table.criteria'); $.each(data.criteria, function(key, val) { - $($c).find('tbody').append(criterion(val)); + $c.find('tbody').append(criterion(val)); }); + $c.find('td.title:first').text('If:'); rule.find('table.action tbody').append(action(data.action)); - rule.find('.raw').html(data.raw); - $('#ruleset').append(rule); rule.find('button.addcriterion') .button({icons: { primary: "ui-icon-plus"}}); + rulerefresh(rule); + return rule; } @@ -316,7 +324,7 @@ function edit_clause(obj) case 'substr': edit_text(target, title, val, function(obj, text) { $(obj).text(text); - rawrefresh($(obj).closest('div.rule')); + rulerefresh($(obj).closest('div.rule')); changed(1); }); break; @@ -329,7 +337,7 @@ function edit_clause(obj) } edit_int(target, title, b[0], b[1], function(obj, op, val) { $(obj).text(op + ' ' + val); - rawrefresh($(obj).closest('div.rule')); + rulerefresh($(obj).closest('div.rule')); changed(1); }); break; @@ -337,7 +345,7 @@ function edit_clause(obj) edit_select(target, title, schema.criterion[cmd].select, getters.select(cmd, val), function(obj, val) { $(obj).text(setters.select(cmd, val)); - rawrefresh($(obj).closest('div.rule')); + rulerefresh($(obj).closest('div.rule')); changed(1); }); break; @@ -483,6 +491,7 @@ $('#ruleset') arg: schema.criterion[val].def })); changed(1); + rulerefresh(rule); }); }) .on('click', 'a.editcomment', function(e) { @@ -552,8 +561,7 @@ $('#ruleset') if (schema.action[cmd].argtype == 'none') arg = ''; - if (schema.action[cmd].argtype == 'folder' && - arg == 'Media Root') + if (schema.action[cmd].argtype == 'folder' && arg == mroot) arg = ''; $('#edit_action_act').val(cmd); @@ -573,10 +581,10 @@ $('#ruleset') cmd = $('#edit_action_act').val(); arg = $('#edit_action_arg').val(); - rule.find('tr.action').replaceWith( - action({cmd: cmd, arg: arg})); + rule.find('table.action tbody').empty() + .append(action({cmd: cmd, arg: arg})); $(this).dialog('close'); - rawrefresh(rule); + rulerefresh(rule); changed(1); }, "Close": function() { @@ -596,7 +604,7 @@ $('#ruleset') var rule = $(el).closest('div.rule'); $(el).closest('tr.clause').fadeOut('slow', function() { $(this).remove(); - rawrefresh(rule); + rulerefresh(rule); changed(1); }); }); diff --git a/webif/plugin/sweeper/style.css b/webif/plugin/sweeper/style.css index f221752..4d46b47 100644 --- a/webif/plugin/sweeper/style.css +++ b/webif/plugin/sweeper/style.css @@ -39,7 +39,7 @@ div.raw color: #ff4000; background: transparent; bottom: 5px; - right: 5px; + right: 12px; } div#buttons @@ -47,17 +47,17 @@ div#buttons padding-top: 1em; } -th.title +td.title,th.title { line-height: 1em; text-align: left !important; background: #eee !important; } -fieldset +div.rule { - width: 95%; position: relative; + width: 95%; } span.comment @@ -69,8 +69,8 @@ span.comment span.legendright { position: absolute; - top: 0px; - right: 5px; + top: 3px; + right: 8px; background-color: #f8f8f8; padding: 0 5px; }