Added “Disable all advanced criteria”/“Reset all advanced criteria to default” button; other little changes

This commit is contained in:
pezcurrel 2022-12-05 23:01:56 +01:00
parent a07e59d52c
commit a0d7f08a58

View file

@ -27,6 +27,15 @@ if (array_key_exists('advc',$_GET)) {
$_GET['advc']=0;
}
$minudef=10;
$minumax=10000000000;
$maxudef=30000;
$maxumax=10000000000;
$minaudef=10;
$minaumax=10000000;
$minkidef=500;
$minkimax=100000;
echo('</nav>
<div class="scrwide">
<div class="scrwidein">
@ -36,56 +45,114 @@ echo('</nav>
<script language="JavaScript">
let mctrlsh=false;
function shmctrl() {
let mctrl=document.getElementById(\'mctrl\');
let mctrlb=document.getElementById(\'mctrlb\');
let advc=document.getElementById(\'advc\');
let mctrl=document.getElementById("mctrl");
let mctrlb=document.getElementById("mctrlb");
let advc=document.getElementById("advc");
if (mctrlsh) {
//mctrl.style.display=\'none\';
mctrl.style.height=\'0px\';
mctrlb.className=\'litbut\';
mctrlb.value=\''._('Show advanced criteria').'\';
//mctrl.style.display="none";
mctrl.style.height="0px";
//mctrlb.className="litbut";
mctrlb.value="'._('Show advanced criteria').'";
advc.value=0;
mctrlsh=false;
} else {
//mctrl.style.display=\'block\';
mctrl.style.height=mctrl.scrollHeight+\'px\';
mctrlb.className=\'litbuta\';
mctrlb.value=\''._('Hide advanced criteria').'\';
//mctrl.style.display="block";
mctrl.style.height=mctrl.scrollHeight+"px";
//mctrlb.className="litbuta";
mctrlb.value="'._('Hide advanced criteria').'";
advc.value=1;
mctrlsh=true;
}
}
let helpsh='.(($getc==0) ? 'false' : 'true').';
function swhelp() {
let hdiv=document.getElementById(\'help\');
let himg=document.getElementById(\'helpbutt\');
let hdiv=document.getElementById("help");
let himg=document.getElementById("helpbutt");
if (helpsh) {
//hdiv.style.display=\'none\';
hdiv.style.height=\'0px\';
himg.title=\''._('Show introduction').'\';
himg.src=\''.$prepath.'imgs/helpbutti.svg\';
//hdiv.style.display="none";
hdiv.style.height="0px";
himg.title="'._('Show introduction').'";
himg.src="'.$prepath.'imgs/helpbutti.svg";
helpsh=false;
} else {
//hdiv.style.display=\'block\';
hdiv.style.height=hdiv.scrollHeight+\'px\';
himg.title=\''._('Hide introduction').'\';
himg.src=\''.$prepath.'imgs/helpbutta.svg\';
//hdiv.style.display="block";
hdiv.style.height=hdiv.scrollHeight+"px";
himg.title="'._('Hide introduction').'";
himg.src="'.$prepath.'imgs/helpbutta.svg";
helpsh=true;
}
}
function swhelpi(over) {
let himg=document.getElementById(\'helpbutt\'), ia;
let himg=document.getElementById("helpbutt"), ia;
if (helpsh) {
(over) ? ia=\'i\' : ia=\'a\';
(over) ? ia="i" : ia="a";
} else {
(over) ? ia=\'a\' : ia=\'i\';
(over) ? ia="a" : ia="i";
}
himg.src=\''.$prepath.'imgs/helpbutt\'+ia+\'.svg\';
himg.src="'.$prepath.'imgs/helpbutt"+ia+".svg";
}
function swp(pn) {
document.curvf.p.value=pn;
document.curvf.submit();
}
function sethid(obj) {
if (document.getElementById("cb"+obj).checked)
document.getElementById(obj).value=1;
else
document.getElementById(obj).value=0;
ckadvcri();
}
let advcri=true;
function ckadvcri() {
if (document.getElementById("minu").value!='.$minudef.' ||
document.getElementById("maxu").value!='.$maxudef.' ||
document.getElementById("minau").value!='.$minaudef.' ||
document.getElementById("minki").value!='.$minkidef.' ||
document.getElementById("cbnoxious").checked==false ||
document.getElementById("cbcreg").checked==false ||
document.getElementById("cbappr").checked==true ||
document.getElementById("cblcok").checked==true) {
document.getElementById("disadvcrib").value="'._('Reset all advanced criteria to default').'";
advcri=false;
} else {
document.getElementById("disadvcrib").value="'._('Disable all advanced criteria').'";
advcri=true;
}
}
function endisadvcri() {
if (advcri) {
document.getElementById("minu").value="";
document.getElementById("maxu").value="";
document.getElementById("minau").value="";
document.getElementById("minki").value="";
document.getElementById("cbnoxious").checked=false;
document.getElementById("noxious").value=0;
document.getElementById("cbcreg").checked=false;
document.getElementById("creg").value=0;
document.getElementById("cbappr").checked=false;
document.getElementById("appr").value=0;
document.getElementById("cblcok").checked=false;
document.getElementById("lcok").value=0;
} else {
document.getElementById("minu").value='.$minudef.';
document.getElementById("maxu").value='.$maxudef.';
document.getElementById("minau").value='.$minaudef.';
document.getElementById("minki").value='.$minkidef.';
document.getElementById("cbnoxious").checked=true;
document.getElementById("noxious").value=1;
document.getElementById("cbcreg").checked=true;
document.getElementById("creg").value=1;
document.getElementById("cbappr").checked=false;
document.getElementById("appr").value=0;
document.getElementById("cblcok").checked=false;
document.getElementById("lcok").value=0;
}
ckadvcri();
}
</script>
'.N);
@ -223,11 +290,11 @@ function ckgnum($key,$def,$max) {
}
}
ckgnum('minu',10,10000000000);
ckgnum('maxu',30000,10000000000);
ckgnum('minu',$minudef,$minumax);
ckgnum('maxu',$maxudef,$maxumax);
if (is_int($_GET['maxu']) && is_int($_GET['minu']) && $_GET['maxu']<$_GET['minu']) $_GET['maxu']=$_GET['minu'];
ckgnum('minau',10,10000000);
ckgnum('minki',500,100000);
ckgnum('minau',$minaudef,$minaumax);
ckgnum('minki',$minkidef,$minkimax);
$order=array(
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'),
@ -294,51 +361,58 @@ echo('</select>
<div id="mctrl">
<div class="sdrow">
<input type="button" class="litbut" id="disadvcrib" value="'._('Disable all advanced criteria').'" onclick="endisadvcri();">
</div>
<div class="sdrow">
<div class="sdlabel"><label for="minu" title="'._('Include only instances which have at least this number of users (set to empty to disable this criterion)').'">'._('Minimum number of users is').'</label></div>
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="10000000000" class="sinput" value="'.$_GET['minu'].'"></div>
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="'.$minumax.'" class="sinput" value="'.$_GET['minu'].'" onchange="ckadvcri();"></div>
</div>
<div class="sdrow">
<div class="sdlabel"><label for="maxu" title="'._('Include only instances which have at most this number of users (set to empty to disable this criterion)').'">'._('Maximum number of users is').'</label></div>
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="10000000000" class="sinput" value="'.$_GET['maxu'].'"></div>
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="'.$maxumax.'" class="sinput" value="'.$_GET['maxu'].'" onchange="ckadvcri();"></div>
</div>
<div class="sdrow">
<div class="sdlabel"><label for="minau" title="'._('Include only instances which had at least this number of active users during the last 30 days (set to empty to disable this criterion)').'">'._('Minimum number of active users is').'</label></div>
<div class="sdinput"><input type="number" id="minau" name="minau" min="0" max="100000000" class="sinput" value="'.$_GET['minau'].'"></div>
<div class="sdinput"><input type="number" id="minau" name="minau" min="0" max="'.$minaumax.'" class="sinput" value="'.$_GET['minau'].'" onchange="ckadvcri();"></div>
</div>
<div class="sdrow">
<div class="sdlabel"><label for="minki" title="'._('Include only instances which know at least this number of other instances (set to empty to disable this criterion)').'">'._('Minimum number of known instances is').'</label></div>
<div class="sdinput"><input type="number" id="minki" name="minki" min="0" max="100000" class="sinput" value="'.$_GET['minki'].'"></div>
<div class="sdinput"><input type="number" id="minki" name="minki" min="0" max="'.$minkimax.'" class="sinput" value="'.$_GET['minki'].'" onchange="ckadvcri();"></div>
</div>
<div class="sdrow">
<div class="sdlabel"><label for="cbnoxious" title="'._('Exclude noxious instances').'">'._('Exclude noxious').'</label></div>
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cbnoxious" value="1"'.$_GET['cbnoxious'].' onchange="if (this.checked) document.getElementById(\'noxious\').value=1; else document.getElementById(\'noxious\').value=0;">
<input type="checkbox" class="sckbox" id="cbnoxious" value="1"'.$_GET['cbnoxious'].' onchange="sethid(\'noxious\');">
<input type="hidden" id="noxious" name="noxious" value="'.$_GET['noxious'].'">
</div>
</div>
<div class="sdrow">
<div class="sdlabel"><label for="cbcreg" title="'._('Exclude instances which dont accept new registrations').'">'._('Exclude if registrations are closed').'</label></div>
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cbcreg" value="1"'.$_GET['cbcreg'].' onchange="if (this.checked) document.getElementById(\'creg\').value=1; else document.getElementById(\'creg\').value=0;">
<input type="checkbox" class="sckbox" id="cbcreg" value="1"'.$_GET['cbcreg'].' onchange="sethid(\'creg\');">
<input type="hidden" id="creg" name="creg" value="'.$_GET['creg'].'">
</div>
</div>
<div class="sdrow">
<div class="sdlabel"><label for="cbappr" title="'._('Exclude instances on which admin approval is required for registration').'">'._('Exclude if registration requires approval').'</label></div>
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cbappr" value="1"'.$_GET['cbappr'].' onchange="if (this.checked) document.getElementById(\'appr\').value=1; else document.getElementById(\'appr\').value=0;">
<input type="checkbox" class="sckbox" id="cbappr" value="1"'.$_GET['cbappr'].' onchange="sethid(\'appr\');">
<input type="hidden" id="appr" name="appr" value="'.$_GET['appr'].'">
</div>
</div>
<div class="sdrow">
<div class="sdlabel"><label for="cblcok" title="'._('Exclude instances which didnt respond to last check').'">'._('Exclude if offline on last check').'</label></div>
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cblcok" value="1"'.$_GET['cblcok'].' onchange="if (this.checked) document.getElementById(\'lcok\').value=1; else document.getElementById(\'lcok\').value=0;">
<input type="checkbox" class="sckbox" id="cblcok" value="1"'.$_GET['cblcok'].' onchange="sethid(\'lcok\');">
<input type="hidden" id="lcok" name="lcok" value="'.$_GET['lcok'].'">
</div>
</div>
</div>
<script language="JavaScript">
ckadvcri();
</script>
<div class="sdcrow">
<input type="button" class="litbut" id="mctrlb" value="'._('Advanced criteria').'" onclick="shmctrl()">
</div>