search/replace + dialogue position problems
This commit is contained in:
parent
ab317b57be
commit
cfbd471f7a
@ -1,7 +1,7 @@
|
||||
Package: sweeper
|
||||
Priority: optional
|
||||
Section: misc
|
||||
Version: 2.0.7-7
|
||||
Version: 2.0.8
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hummypkg.org.uk
|
||||
Depends: webif(>=1.2.2-6)
|
||||
|
@ -33,6 +33,14 @@ proc ::sweeper::strcontains {ref val} {
|
||||
>= 0]
|
||||
}
|
||||
|
||||
set ::sweeper::expand_fns {
|
||||
replace {2}
|
||||
}
|
||||
|
||||
proc ::sweeper::expand_replace {ts &ret search replace} {
|
||||
set ret [string map [list $search $replace] $ret]
|
||||
}
|
||||
|
||||
# Expand a string containing tokens
|
||||
proc ::sweeper::expand {ts str {orig ""}} {
|
||||
if {[string first "%" $str] == -1} {
|
||||
@ -97,6 +105,44 @@ proc ::sweeper::expand {ts str {orig ""}} {
|
||||
|
||||
set ret [string map $map $str]
|
||||
log " Expanded \[$str] -> \[$ret]" 2
|
||||
|
||||
foreach {fn params} $::sweeper::expand_fns {
|
||||
log " Looking for %$fn" 2
|
||||
|
||||
lassign $params numargs
|
||||
|
||||
set li -1
|
||||
while {[set i [string first "%$fn" $ret]] >= 0} {
|
||||
if {$i <= $li} break
|
||||
set li $i
|
||||
|
||||
# Fetch the delimiter
|
||||
set chpos $($i + [string length $fn] + 1)
|
||||
set ch [string index $ret $chpos]
|
||||
|
||||
log " - found at $i (delim\[$ch])" 2
|
||||
|
||||
# Extract the arguments
|
||||
set pos $chpos
|
||||
set fnargs {}
|
||||
while {[llength $fnargs] < $numargs} {
|
||||
incr pos
|
||||
set e [string first $ch $ret $pos]
|
||||
if {$e == -1} {
|
||||
log "Error. %$fn - $i/$numargs parameters found."
|
||||
break
|
||||
}
|
||||
lappend fnargs [string range $ret \
|
||||
$pos $($e - 1)]
|
||||
set pos $e
|
||||
}
|
||||
|
||||
set ret [string replace $ret $i $pos]
|
||||
log " - Calling expand_$fn\($fnargs)" 2
|
||||
::sweeper::expand_$fn $ts ret {*}$fnargs
|
||||
}
|
||||
}
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
|
@ -361,12 +361,13 @@ function edit_text(obj, title, text, callback, typ)
|
||||
$('#edit_text').dialog({
|
||||
title: title,
|
||||
height: 'auto', width: 'auto',
|
||||
draggable: false, resizable: false,
|
||||
draggable: true, resizable: false,
|
||||
autoOpen: true,
|
||||
position: {
|
||||
my: 'bottom left',
|
||||
at: 'top right',
|
||||
of: obj
|
||||
of: obj,
|
||||
collision: 'fit'
|
||||
},
|
||||
buttons: {
|
||||
"Save": function() {
|
||||
@ -398,12 +399,13 @@ function edit_int(obj, title, op, val, callback)
|
||||
$('#edit_int').dialog({
|
||||
title: title,
|
||||
height: 'auto', width: 'auto',
|
||||
draggable: false, resizable: false,
|
||||
draggable: true, resizable: false,
|
||||
autoOpen: true,
|
||||
position: {
|
||||
my: 'bottom left',
|
||||
at: 'top right',
|
||||
of: obj
|
||||
of: obj,
|
||||
collision: 'fit'
|
||||
},
|
||||
buttons: {
|
||||
"Save": function() {
|
||||
@ -437,12 +439,13 @@ function edit_select(obj, title, options, val, callback)
|
||||
$('#edit_select').dialog({
|
||||
title: title,
|
||||
height: 'auto', width: 'auto',
|
||||
draggable: false, resizable: false,
|
||||
draggable: true, resizable: false,
|
||||
autoOpen: true,
|
||||
position: {
|
||||
my: 'bottom left',
|
||||
at: 'top right',
|
||||
of: obj
|
||||
of: obj,
|
||||
collision: 'fit'
|
||||
},
|
||||
buttons: {
|
||||
"Save": function() {
|
||||
@ -536,12 +539,13 @@ $('#b_add').button({icons: {primary: "ui-icon-plus"}})
|
||||
e.preventDefault();
|
||||
$('#newrule').dialog({
|
||||
height: 'auto', width: 'auto',
|
||||
draggable: false, resizable: false,
|
||||
draggable: true, resizable: false,
|
||||
autoOpen: true,
|
||||
position: {
|
||||
my: 'bottom left',
|
||||
at: 'top right',
|
||||
of: $(this)
|
||||
of: $(this),
|
||||
collision: 'fit'
|
||||
},
|
||||
buttons: {
|
||||
"Create Rule": function() {
|
||||
@ -738,12 +742,13 @@ function addcriterion(rule, target)
|
||||
|
||||
$('#newcondition').dialog({
|
||||
height: 'auto', width: 'auto',
|
||||
draggable: false, resizable: false,
|
||||
draggable: true, resizable: false,
|
||||
autoOpen: true,
|
||||
position: {
|
||||
my: 'bottom left',
|
||||
at: 'top right',
|
||||
of: target
|
||||
of: target,
|
||||
collision: 'fit'
|
||||
},
|
||||
buttons: {
|
||||
"Add Condition": function() {
|
||||
@ -896,7 +901,8 @@ $('#ruleset')
|
||||
position: {
|
||||
my: 'bottom left',
|
||||
at: 'top right',
|
||||
of: rule
|
||||
of: rule,
|
||||
collision: 'fit'
|
||||
},
|
||||
buttons: {
|
||||
"Save": function() {
|
||||
|
Loading…
Reference in New Issue
Block a user