@ -131,88 +131,120 @@ 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 ( ) ;
if ( dijit . byId ( "filterTestDlg" ) )
dijit . byId ( "filterTestDlg" ) . destroyRecursive ( ) ;
dia lo g = new dijit . Dialog ( {
id : "filter Edi tDlg",
title : _ _ ( "Edit Filter" ) ,
var test _dlg = new dijit . Dialog ( {
id : "filterTestDlg" ,
title : "Test Filter" ,
style : "width: 600px" ,
results : 0 ,
limit : 100 ,
max _offset : 10000 ,
getTestResults : function ( query , offset ) {
var updquery = query + "&offset=" + offset + "&limit=" + test _dlg . limit ;
test : function ( ) {
var query = "backend.php?" + dojo . formToQuery ( "filter_edit_form" ) + "&savemode=test" ;
console . log ( "getTestResults:" + offset ) ;
if ( dijit . byId ( "filterTestDlg" ) )
dijit . byId ( "filterTestDlg" ) . destroyRecursive ( ) ;
new Ajax . Request ( "backend.php" , {
parameters : updquery ,
onComplete : function ( transport ) {
try {
var result = JSON . parse ( transport . responseText ) ;
var test _dlg = new dijit . Dialog ( {
id : "filterTestDlg" ,
title : "Test Filter" ,
style : "width: 600px" ,
results : 0 ,
max _offset : 10000 ,
getTestResults : function ( query , offset ) {
var updquery = query + "&offset=" + offset ;
if ( result && dijit . byId ( "filterTestDlg" ) && dijit . byId ( "filterTestDlg" ) . open ) {
test _dlg . results += result . size ( ) ;
console . log ( "getTestResults:" + offset ) ;
//console.log(updquery);
console . log ( "got results:" + result . size ( ) ) ;
new Ajax . Request ( "backend.php" , {
parameters : updquery ,
onComplete : function ( transport ) {
$ ( "prefFilterProgressMsg" ) . innerHTML = _ _ ( "Looking for articles (%d processed, %f found)..." )
. replace ( "%f" , test _dlg . results )
. replace ( "%d" , offset ) ;
console . log ( transport. responseTex t) ;
console . log ( offset + " " + test _dlg . max _offse t) ;
var result = JSON . parse ( transport . responseText ) ;
for ( var i = 0 ; i < result . size ( ) ; i ++ ) {
var tmp = new Element ( "table" ) ;
tmp . innerHTML = result [ i ] ;
dojo . parser . parse ( tmp ) ;
console . log ( "R:" + result ) ;
$ ( "prefFilterTestResultList" ) . innerHTML += tmp . innerHTML ;
}
//console.log("<<< " + transport.responseText);
if ( test _dlg . results < 30 && offset < test _dlg . max _offset ) {
if ( result && dijit . byId ( "filterTestDlg" ) && dijit . byId ( "filterTestDlg" ) . open ) {
test _dlg . results += result . size ( ) ;
// get the next batch
window . setTimeout ( function ( ) {
test _dlg . getTestResults ( query , offset + test _dlg . limit ) ;
} , 0 ) ;
$ ( "prefFilterProgressMsg" ) . innerHTML = _ _ ( "Looking for articles (%d)..." . replace ( "%d" , offset ) ) ;
} else {
// all done
console. log ( offset + " " + test _dlg . max _offset ) ;
Element. hide ( "prefFilterLoadingIndicator" ) ;
for ( var i = 0 ; i < result . size ( ) ; i ++ ) {
$ ( "prefFilterTestResultList" ) . innerHTML += result [ i ] ;
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 ) ;
}
if ( test _dlg . results < 30 && offset < test _dlg . max _offset ) {
window . setTimeout ( function ( ) {
//console.log("blaargh");
}
test _dlg . getTestResults ( query , offset + 30 ) ;
} , 0 ) ;
} else {
} else if ( ! result ) {
console . log ( "getTestResults: can't parse results object" ) ;
// all done
Element . hide ( "prefFilterLoadingIndicator" ) ;
}
notify _error ( "Error while trying to get filter test results." ) ;
} else {
console . log ( "can't parse results object / dialog closed" ) ;
}
} else {
console . log ( "getTestResults: dialog closed, bailing out." ) ;
}
} catch ( e ) {
exception _error ( "editFilterTest/inner" , e ) ;
}
} } ) ;
} ,
href : query } ) ;
} } ) ;
} ,
href : query } ) ;
dojo . connect ( test _dlg , "onShow" , null , function ( e ) {
test _dlg . getTestResults ( query , 0 ) ;
} ) ;
dojo . connect ( test _dlg , "onLoad" , 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" ;
test _dlg . show ( ) ;
editFilterTest( query ) ;
} ,
selectRules : function ( select ) {
$$ ( "#filterDlg_Matches input[type=checkbox]" ) . each ( function ( e ) {