various tweaks

This commit is contained in:
hummypkg 2014-06-04 22:18:42 +00:00
parent b45db15f85
commit 3f6259fa09
4 changed files with 51 additions and 37 deletions

View File

@ -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)

View File

@ -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
}
}
};

View File

@ -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 = '<tr class=clause>' +
s = '<tr class=clause><td class=title>And:</td>' +
'<th cmd=' + data.cmd + '>' + c.desc + '</th><td class=val>';
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 = '<tr class=action>' +
'<td class=title>Then:</td>' +
'<th cmd=' + data.cmd + '>' + c.desc + '</th>' +
'<td class=val>' + data.arg + '</td>' +
'<td><a class=editaction href=#>' +
'<img src=/img/context/edit.png></a></td>' +
'</tr>';
if (c.showcont)
s += '<tr><td class=title>Else:</td>' +
'<th>Continue on to next rule.</th></tr>';
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);
});
});

View File

@ -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;
}