@ -131,25 +131,9 @@ function editUser(id, event) {
}
function editFilter ( id ) {
function editFilter Test( query ) {
try {
var query = "backend.php?op=pref-filters&method=edit&id=" + param _escape ( id ) ;
if ( dijit . byId ( "feedEditDlg" ) )
dijit . byId ( "feedEditDlg" ) . destroyRecursive ( ) ;
if ( dijit . byId ( "filterEditDlg" ) )
dijit . byId ( "filterEditDlg" ) . destroyRecursive ( ) ;
dialog = new dijit . Dialog ( {
id : "filterEditDlg" ,
title : _ _ ( "Edit Filter" ) ,
style : "width: 600px" ,
test : function ( ) {
var query = "backend.php?" + dojo . formToQuery ( "filter_edit_form" ) + "&savemode=test" ;
if ( dijit . byId ( "filterTestDlg" ) )
dijit . byId ( "filterTestDlg" ) . destroyRecursive ( ) ;
@ -158,61 +142,109 @@ function editFilter(id) {
title : "Test Filter" ,
style : "width: 600px" ,
results : 0 ,
limit : 100 ,
max _offset : 10000 ,
getTestResults : function ( query , offset ) {
var updquery = query + "&offset=" + offse t;
var updquery = query + "&offset=" + offse t + "&limit=" + test _dlg . limi t;
console . log ( "getTestResults:" + offset ) ;
//console.log(updquery);
new Ajax . Request ( "backend.php" , {
parameters : updquery ,
onComplete : function ( transport ) {
console . log ( transport . responseText ) ;
try {
var result = JSON . parse ( transport . responseText ) ;
console . log ( "R:" + result ) ;
//console.log("<<< " + transport.responseText);
if ( result && dijit . byId ( "filterTestDlg" ) && dijit . byId ( "filterTestDlg" ) . open ) {
test _dlg . results += result . size ( ) ;
$ ( "prefFilterProgressMsg" ) . innerHTML = _ _ ( "Looking for articles (%d)..." . replace ( "%d" , offset ) ) ;
console . log ( "got results:" + result . size ( ) ) ;
$ ( "prefFilterProgressMsg" ) . innerHTML = _ _ ( "Looking for articles (%d processed, %f found)..." )
. replace ( "%f" , test _dlg . results )
. replace ( "%d" , offset ) ;
console . log ( offset + " " + test _dlg . max _offset ) ;
for ( var i = 0 ; i < result . size ( ) ; i ++ ) {
$ ( "prefFilterTestResultList" ) . innerHTML += result [ i ] ;
var tmp = new Element ( "table" ) ;
tmp . innerHTML = result [ i ] ;
dojo . parser . parse ( tmp ) ;
$ ( "prefFilterTestResultList" ) . innerHTML += tmp . innerHTML ;
}
if ( test _dlg . results < 30 && offset < test _dlg . max _offset ) {
window . setTimeout ( function ( ) {
//console.log("blaargh");
test _dlg . getTestResults ( query , offset + 30 ) ;
// get the next batch
window . setTimeout ( function ( ) {
test _dlg . getTestResults ( query , offset + test _dlg . limit ) ;
} , 0 ) ;
} else {
} else {
// all done
Element . hide ( "prefFilterLoadingIndicator" ) ;
if ( test _dlg . results == 0 ) {
$ ( "prefFilterTestResultList" ) . innerHTML = "<tr><td align='center'>No recent articles matching this filter have been found.</td></tr>" ;
$ ( "prefFilterProgressMsg" ) . innerHTML = "Articles matching this filter:" ;
} else {
$ ( "prefFilterProgressMsg" ) . innerHTML = _ _ ( "Found %d articles matching this filter:" )
. replace ( "%d" , test _dlg . results ) ;
}
}
} else if ( ! result ) {
console . log ( "getTestResults: can't parse results object" ) ;
Element . hide ( "prefFilterLoadingIndicator" ) ;
notify _error ( "Error while trying to get filter test results." ) ;
} else {
console . log ( "can't parse results object / dialog closed" ) ;
console . log ( "getTestResults: dialog closed, bailing out." ) ;
}
} catch ( e ) {
exception _error ( "editFilterTest/inner" , e ) ;
}
} } ) ;
} ,
href : query } ) ;
dojo . connect ( test _dlg , "on Show ", null , function ( e ) {
dojo . connect ( test _dlg , "on Load ", null , function ( e ) {
test _dlg . getTestResults ( query , 0 ) ;
} ) ;
test _dlg . show ( ) ;
} catch ( e ) {
exception _error ( "editFilterTest" , e ) ;
}
}
function editFilter ( id ) {
try {
var query = "backend.php?op=pref-filters&method=edit&id=" + param _escape ( id ) ;
if ( dijit . byId ( "feedEditDlg" ) )
dijit . byId ( "feedEditDlg" ) . destroyRecursive ( ) ;
if ( dijit . byId ( "filterEditDlg" ) )
dijit . byId ( "filterEditDlg" ) . destroyRecursive ( ) ;
dialog = new dijit . Dialog ( {
id : "filterEditDlg" ,
title : _ _ ( "Edit Filter" ) ,
style : "width: 600px" ,
test : function ( ) {
var query = "backend.php?" + dojo . formToQuery ( "filter_edit_form" ) + "&savemode=test" ;
editFilterTest ( query ) ;
} ,
selectRules : function ( select ) {
$$ ( "#filterDlg_Matches input[type=checkbox]" ) . each ( function ( e ) {