search/replace + dialogue position problems
This commit is contained in:
parent
ab317b57be
commit
cfbd471f7a
@ -1,7 +1,7 @@
|
|||||||
Package: sweeper
|
Package: sweeper
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: misc
|
Section: misc
|
||||||
Version: 2.0.7-7
|
Version: 2.0.8
|
||||||
Architecture: mipsel
|
Architecture: mipsel
|
||||||
Maintainer: af123@hummypkg.org.uk
|
Maintainer: af123@hummypkg.org.uk
|
||||||
Depends: webif(>=1.2.2-6)
|
Depends: webif(>=1.2.2-6)
|
||||||
|
@ -33,6 +33,14 @@ proc ::sweeper::strcontains {ref val} {
|
|||||||
>= 0]
|
>= 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
|
# Expand a string containing tokens
|
||||||
proc ::sweeper::expand {ts str {orig ""}} {
|
proc ::sweeper::expand {ts str {orig ""}} {
|
||||||
if {[string first "%" $str] == -1} {
|
if {[string first "%" $str] == -1} {
|
||||||
@ -97,6 +105,44 @@ proc ::sweeper::expand {ts str {orig ""}} {
|
|||||||
|
|
||||||
set ret [string map $map $str]
|
set ret [string map $map $str]
|
||||||
log " Expanded \[$str] -> \[$ret]" 2
|
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
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,12 +361,13 @@ function edit_text(obj, title, text, callback, typ)
|
|||||||
$('#edit_text').dialog({
|
$('#edit_text').dialog({
|
||||||
title: title,
|
title: title,
|
||||||
height: 'auto', width: 'auto',
|
height: 'auto', width: 'auto',
|
||||||
draggable: false, resizable: false,
|
draggable: true, resizable: false,
|
||||||
autoOpen: true,
|
autoOpen: true,
|
||||||
position: {
|
position: {
|
||||||
my: 'bottom left',
|
my: 'bottom left',
|
||||||
at: 'top right',
|
at: 'top right',
|
||||||
of: obj
|
of: obj,
|
||||||
|
collision: 'fit'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
"Save": function() {
|
"Save": function() {
|
||||||
@ -398,12 +399,13 @@ function edit_int(obj, title, op, val, callback)
|
|||||||
$('#edit_int').dialog({
|
$('#edit_int').dialog({
|
||||||
title: title,
|
title: title,
|
||||||
height: 'auto', width: 'auto',
|
height: 'auto', width: 'auto',
|
||||||
draggable: false, resizable: false,
|
draggable: true, resizable: false,
|
||||||
autoOpen: true,
|
autoOpen: true,
|
||||||
position: {
|
position: {
|
||||||
my: 'bottom left',
|
my: 'bottom left',
|
||||||
at: 'top right',
|
at: 'top right',
|
||||||
of: obj
|
of: obj,
|
||||||
|
collision: 'fit'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
"Save": function() {
|
"Save": function() {
|
||||||
@ -437,12 +439,13 @@ function edit_select(obj, title, options, val, callback)
|
|||||||
$('#edit_select').dialog({
|
$('#edit_select').dialog({
|
||||||
title: title,
|
title: title,
|
||||||
height: 'auto', width: 'auto',
|
height: 'auto', width: 'auto',
|
||||||
draggable: false, resizable: false,
|
draggable: true, resizable: false,
|
||||||
autoOpen: true,
|
autoOpen: true,
|
||||||
position: {
|
position: {
|
||||||
my: 'bottom left',
|
my: 'bottom left',
|
||||||
at: 'top right',
|
at: 'top right',
|
||||||
of: obj
|
of: obj,
|
||||||
|
collision: 'fit'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
"Save": function() {
|
"Save": function() {
|
||||||
@ -536,12 +539,13 @@ $('#b_add').button({icons: {primary: "ui-icon-plus"}})
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('#newrule').dialog({
|
$('#newrule').dialog({
|
||||||
height: 'auto', width: 'auto',
|
height: 'auto', width: 'auto',
|
||||||
draggable: false, resizable: false,
|
draggable: true, resizable: false,
|
||||||
autoOpen: true,
|
autoOpen: true,
|
||||||
position: {
|
position: {
|
||||||
my: 'bottom left',
|
my: 'bottom left',
|
||||||
at: 'top right',
|
at: 'top right',
|
||||||
of: $(this)
|
of: $(this),
|
||||||
|
collision: 'fit'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
"Create Rule": function() {
|
"Create Rule": function() {
|
||||||
@ -738,12 +742,13 @@ function addcriterion(rule, target)
|
|||||||
|
|
||||||
$('#newcondition').dialog({
|
$('#newcondition').dialog({
|
||||||
height: 'auto', width: 'auto',
|
height: 'auto', width: 'auto',
|
||||||
draggable: false, resizable: false,
|
draggable: true, resizable: false,
|
||||||
autoOpen: true,
|
autoOpen: true,
|
||||||
position: {
|
position: {
|
||||||
my: 'bottom left',
|
my: 'bottom left',
|
||||||
at: 'top right',
|
at: 'top right',
|
||||||
of: target
|
of: target,
|
||||||
|
collision: 'fit'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
"Add Condition": function() {
|
"Add Condition": function() {
|
||||||
@ -896,7 +901,8 @@ $('#ruleset')
|
|||||||
position: {
|
position: {
|
||||||
my: 'bottom left',
|
my: 'bottom left',
|
||||||
at: 'top right',
|
at: 'top right',
|
||||||
of: rule
|
of: rule,
|
||||||
|
collision: 'fit'
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
"Save": function() {
|
"Save": function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user