Lavorazzi su js e css per criteri di ricerca

This commit is contained in:
pezcurrel 2020-01-05 05:46:29 +01:00
parent b8e9218112
commit d1cd526056
2 changed files with 438 additions and 106 deletions

View file

@ -8,12 +8,17 @@ buildmenu($menu);
require('include/myconn.php');
// praticamente una macro
function hspech($str) {
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}
function nully($val,$fem,$filter,$ntext=null) {
if (!is_null($val)) {
if ($filter=='strip') {
return(strip_tags($val,'<a><br><ol><ul><li>'));
} elseif ($filter=='htmlent') {
return(htmlentities($val));
return(strip_tags($val,'<a><br><ol><ul><li><p><i><b><strong><em><small>'));
} elseif ($filter=='htmlchars') {
return(hspech($val));
} elseif ($filter=='timestamp') {
return(strftime('%a %d %b %Y, %T',$val));
} elseif ($filter=='email') {
@ -21,7 +26,7 @@ function nully($val,$fem,$filter,$ntext=null) {
} elseif ($filter=='url') {
return('<a href="'.strip_tags($val).'" target="_blank">'.strip_tags($val).'</a>');
} elseif ($filter=='image') {
return('<img src="'.str_replace('"','\\"',strip_tags($val)).'" width="294">');
return('<img src="'.str_replace('"','\\"',strip_tags($val)).'">');
} elseif ($filter=='boolt') {
if ($val)
return('<span class="good">Si</span>');
@ -89,32 +94,43 @@ $cols=array(
'Email'=>array('name'=>'Email di contatto','type'=>'text'),
'Software'=>array('name'=>'Software','type'=>'text'),
'Version'=>array('name'=>'Versione','type'=>'text'),
'UserCount'=>array('name'=>'Utenti','type'=>'number'),
'StatusCount'=>array('name'=>'Stati','type'=>'number'),
'DomainCount'=>array('name'=>'Istanze note','type'=>'number'),
'ActiveUsersMonth'=>array('name'=>'Utenti attivi (mese)','type'=>'number'),
'ActiveUsersHalfYear'=>array('name'=>'Utenti attivi (6 mesi)','type'=>'number'),
'UserCount'=>array('name'=>'Utenti','type'=>'int'),
'StatusCount'=>array('name'=>'Stati','type'=>'int'),
'DomainCount'=>array('name'=>'Istanze note','type'=>'int'),
'ActiveUsersMonth'=>array('name'=>'Utenti attivi (mese)','type'=>'int'),
'ActiveUsersHalfYear'=>array('name'=>'Utenti attivi (6 mesi)','type'=>'int'),
'Thumb'=>array('name'=>'Logo','type'=>'text'),
'RegOpen'=>array('name'=>'Registrazioni aperte','type'=>'bool'),
'RegReqApproval'=>array('name'=>'Approvazione registrazioni','type'=>'bool'),
'MaxTootChars'=>array('name'=>'Limite caratteri','type'=>'number'),
'MaxTootChars'=>array('name'=>'Limite caratteri','type'=>'int'),
'AdmAccount'=>array('name'=>'Account admin','type'=>'text'),
'AdmDisplayName'=>array('name'=>'Nome account admin','type'=>'text'),
'AdmCreatedAt'=>array('name'=>'Data creazione account admin','type'=>'timestamp'),
'AdmURL'=>array('name'=>'Pagina delladmin','text'),
'AdmAvatar'=>array('name'=>'Avatar admin','text'),
'AdmNote'=>array('name'=>'Note delladmin','text')
'AdmCreatedAt'=>array('name'=>'Data creazione account admin','type'=>'time'),
'AdmURL'=>array('name'=>'Pagina delladmin','type'=>'text'),
'AdmAvatar'=>array('name'=>'Avatar admin','type'=>'text'),
'AdmNote'=>array('name'=>'Note delladmin','type'=>'text'),
'InstLangs'=>array('name'=>'Lingue dichiarate','type'=>'select'),
'InstOurLangs'=>array('name'=>'Lingue impostate da noi','type'=>'select'),
'InstFinancing'=>array('name'=>'Modalità di finanziamento','type'=>'select'),
'InstPolicies'=>array('name'=>'Restrizioni sui contenuti','type'=>'select'),
'InstTags'=>array('name'=>'Tags','type'=>'select'),
);
$fieldselopts='';
foreach ($cols as $key=>$val) {
$fieldselopts.='<option value="'.$key.'§'.$val['type'].'">'.$val['name'].'</option>';
}
$res=mysqli_query($link,'SELECT *, Instances.ID AS IID FROM Instances LEFT JOIN Places ON Places.ID=PlaceID ORDER BY URI ASC LIMIT 50')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($res)<1) {
$out='<p>Nessuna istanza da mostrare.</p>'.N;
} else {
$out='<table id="bigtab">'.N;
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
$out.='<tbody>'.N;
$out='';
while ($row=mysqli_fetch_assoc($res)) {
$out.='<table class="bigtab">'.N;
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
$out.='<tbody>'.N;
$out.='<tr><td colspan="2" class="insthead">'.$row['URI'].'</td></tr>'.N;
$attr=booly($cols['Blacklisted']['name'].': ',$row['Blacklisted'],false,true).N;
$attr.=booly($cols['New']['name'].': ',$row['New'],true).N;
@ -123,24 +139,6 @@ if (mysqli_num_rows($res)<1) {
$attr.=booly($cols['Visible']['name'].': ',$row['Visible']).N;
/* $attr.=booly($cols['RegOpen']['name'].': ',$row['RegOpen']).N;
$attr.=booly($cols['RegReqApproval']['name'].': ',$row['RegReqApproval'],true,true).N;*/
$sres=mysqli_query($link,'SELECT SUM(Statuses) AS tstatuses, SUM(Logins) AS tlogins, SUM(Registrations) AS tregs FROM InstActivity WHERE InstID='.$row['IID'])
or muoribene(mysqli_error($link),false);
$tot=mysqli_fetch_assoc($sres);
$sres=mysqli_query($link,'SELECT * FROM InstActivity WHERE InstID='.$row['IID'].' ORDER BY Week DESC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectheader">Attività delle ultime 12 settimane</div>'.N;
$attr.='<div class="colsectcont">Totale stati: '.$tot['tstatuses'].'<br>Totale accessi: '.$tot['tlogins'].'<br>Totale registrazioni: '.$tot['tregs'].'</div>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<div class="colsectcont"> '.strftime('%a %d %b %Y',$srow['Week']).' </div>'.N;
($tot['tstatuses']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tstatuses']*$srow['Statuses']);
$attr.='<div class="percstatuses" style="width:'.$width.'%;">'.$srow['Statuses'].'&nbsp;stati</div>'.N;
($tot['tlogins']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tlogins']*$srow['Logins']);
$attr.='<div class="perclogins" style="width:'.$width.'%;">'.$srow['Logins'].'&nbsp;accessi</div>'.N;
($tot['tregs']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tregs']*$srow['Registrations']);
$attr.='<div class="percregs" style="width:'.$width.'%;">'.$srow['Registrations'].'&nbsp;registrazioni</div>'.N;
}
}
$sres=mysqli_query($link,'SELECT * FROM InstChecks WHERE InstID='.$row['IID'].' ORDER BY Time DESC')
or muoribene(mysqli_error($link),false);
$csres=mysqli_num_rows($sres);
@ -153,36 +151,141 @@ if (mysqli_num_rows($res)<1) {
$width=str_replace(',','.',100/$csres*$bene);
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check: '.round($width,1).'%</div>';
$attr.='<div class="percbg"><div class="percfg" style="width:'.$width.'%;"></div></div>'.N;
mysqli_data_seek($sres,0);
$srow=mysqli_fetch_assoc($sres);
$attr.='<div class="colsectcont">Ultimo check '.strftime('%e %b %Y, %T',$srow['Time']).': '.(($srow['Status']) ? '<span class="good">OK</span>' : '<span class="bad">KO</span>').'</div>';
} else {
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check</div>';
$attr.='<div class="colsectcont nully">Non disponibile (?!?!?!)</div>'.N;
}
$attr.='<div class="colsectheader">Attività delle ultime 12 settimane</div>'.N;
$sres=mysqli_query($link,'SELECT SUM(Statuses) AS tstatuses, SUM(Logins) AS tlogins, SUM(Registrations) AS tregs FROM InstActivity WHERE InstID='.$row['IID'])
or muoribene(mysqli_error($link),false);
$tot=mysqli_fetch_assoc($sres);
$sres=mysqli_query($link,'SELECT * FROM InstActivity WHERE InstID='.$row['IID'].' ORDER BY Week DESC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont">Stati: '.$tot['tstatuses'].'<br>Accessi: '.$tot['tlogins'].'<br>Registrazioni: '.$tot['tregs'].'</div>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<div class="colsectcontb">'.strftime('%e %b %Y',$srow['Week']).'</div>'.N;
($tot['tstatuses']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tstatuses']*$srow['Statuses']);
$attr.='<div class="percstatuses" style="width:'.$width.'%;">'.$srow['Statuses'].'&nbsp;stati</div>'.N;
($tot['tlogins']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tlogins']*$srow['Logins']);
$attr.='<div class="perclogins" style="width:'.$width.'%;">'.$srow['Logins'].'&nbsp;accessi</div>'.N;
($tot['tregs']==0) ? $width=0 : $width=str_replace(',','.',100/$tot['tregs']*$srow['Registrations']);
$attr.='<div class="percregs" style="width:'.$width.'%;">'.$srow['Registrations'].'&nbsp;registrazioni</div>'.N;
}
} else {
$attr.='<div class="colsectcont nully">Non disponibile</div>'.N;
}
$attr.='<div class="colsectheader">Hashtags più usati durante lultima settimana</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstTrends WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$attr.='<div class="colsectcont"><ol>'.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='<li><a href="'.$srow['URL'].'">'.hspech($srow['Name']).'</a></li>'.N;
}
$attr.='</ol></div>'.N;
} else {
$attr.='<div class="colsectcont nully">Non disponibili</div>'.N;
}
$out.='<tr><td class="tdattr">'.$attr.'</td><td>'.N;
$out.='<p><span class="field">'.$cols['URI']['name'].':</span> <a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></p>'.N;
$out.='<p><span class="field">'.$cols['Title']['name'].':</span> '.nully($row['Title'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['OurDesc']['name'].':</span> '.nully($row['OurDesc'],true,'htmlent').'</p>'.N;
$out.='<p><span class="field">'.$cols['ShortDesc']['name'].':</span> '.nully($row['ShortDesc'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['LongDesc']['name'].':</span> '.nully($row['LongDesc'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['PlaceID']['name'].':</span> '.nully($row['PlaceID'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['Email']['name'].':</span> '.nully($row['Email'],true,'email').'</p>'.N;
$out.='<p><span class="field">'.$cols['Software']['name'].':</span> '.nully($row['Software'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['Version']['name'].':</span> '.nully($row['Version'],true,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['UserCount']['name'].':</span> '.nully($row['UserCount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['StatusCount']['name'].':</span> '.nully($row['StatusCount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['DomainCount']['name'].':</span> '.nully($row['DomainCount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['ActiveUsersMonth']['name'].':</span> '.nully($row['ActiveUsersMonth'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['ActiveUsersHalfYear']['name'].':</span> '.nully($row['ActiveUsersHalfYear'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['Thumb']['name'].':</span> '.nully($row['Thumb'],true,'image').'</p>'.N;
$out.='<p><span class="field">'.$cols['RegOpen']['name'].':</span> '.nully($row['RegOpen'],false,'boolt').'</p>'.N;
$out.='<p><span class="field">'.$cols['RegReqApproval']['name'].':</span> '.nully($row['RegReqApproval'],false,'boolf').'</p>'.N;
$out.='<p><span class="field">'.$cols['MaxTootChars']['name'].':</span> '.nully($row['MaxTootChars'],false,'strip','500').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmAccount']['name'].':</span> '.nully($row['AdmAccount'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmDisplayName']['name'].':</span> '.nully($row['AdmDisplayName'],false,'strip').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmCreatedAt']['name'].':</span> '.nully($row['AdmCreatedAt'],true,'timestamp').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmURL']['name'].':</span> '.nully($row['AdmURL'],true,'url').'</p>'.N;
$out.='<p><span class="field">'.$cols['AdmAvatar']['name'].':</span> '.nully($row['AdmAvatar'],true,'image').'</p>'.N;
$out.='<p style="border: none; margin: 0; padding: 0;"><span class="field">'.$cols['AdmNote']['name'].':</span> '.nully($row['AdmNote'],false,'strip').'</p>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['URI']['name'].':</span> <a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Title']['name'].':</span> '.nully($row['Title'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Thumb']['name'].':</span> '.nully($row['Thumb'],true,'image').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['ShortDesc']['name'].':</span> '.nully($row['ShortDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['LongDesc']['name'].':</span> '.nully($row['LongDesc'],true,'strip').'</div>'.N;
// 'strip' o 'htmlent' per la descrizione nostra?
$out.='<div class="baloo"><span class="ourfield">'.$cols['OurDesc']['name'].':</span> '.nully($row['OurDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.$cols['PlaceID']['name'].':</span> '.nully($row['PlaceID'],true,'strip').'</div>'.N;
$sres=mysqli_query($link,'SELECT * FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Code'].' ['.ucfirst(locale_get_display_name($srow['Code'])).']');
}
$out.='<div class="baloo"><span class="field">'.$cols['InstLangs']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="field">'.$cols['InstLangs']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=LangID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Code'].' ['.ucfirst(locale_get_display_name($srow['Code'],'it')).']');
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstOurLangs']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstOurLangs']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Type']).' ('.hspech($row['Details']).')';
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstFinancing']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstFinancing']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstPolicies']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstPolicies']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),false);
if (mysqli_num_rows($sres)>0) {
$i=0;
$buf=array();
while ($srow=mysqli_fetch_assoc($sres)) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstTags']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstTags']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
}
$out.='<div class="baloo"><span class="field">'.$cols['Email']['name'].':</span> '.nully($row['Email'],true,'email').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Software']['name'].':</span> '.nully($row['Software'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Version']['name'].':</span> '.nully($row['Version'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['UserCount']['name'].':</span> '.nully($row['UserCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['StatusCount']['name'].':</span> '.nully($row['StatusCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['DomainCount']['name'].':</span> '.nully($row['DomainCount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['ActiveUsersMonth']['name'].':</span> '.nully($row['ActiveUsersMonth'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['ActiveUsersHalfYear']['name'].':</span> '.nully($row['ActiveUsersHalfYear'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['RegOpen']['name'].':</span> '.nully($row['RegOpen'],false,'boolt').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['RegReqApproval']['name'].':</span> '.nully($row['RegReqApproval'],false,'boolf').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['MaxTootChars']['name'].':</span> '.nully($row['MaxTootChars'],false,'strip','500').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmAccount']['name'].':</span> '.nully($row['AdmAccount'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmDisplayName']['name'].':</span> '.nully($row['AdmDisplayName'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmCreatedAt']['name'].':</span> '.nully($row['AdmCreatedAt'],true,'timestamp').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmURL']['name'].':</span> '.nully($row['AdmURL'],true,'url').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['AdmAvatar']['name'].':</span> '.nully($row['AdmAvatar'],false,'image').'</div>'.N;
$out.='<div><span class="field">'.$cols['AdmNote']['name'].':</span> '.nully($row['AdmNote'],false,'strip').'</div>'.N;
$out.='</td></tr>'.N;
$out.='</tbody>'.N;
$out.='</table>'.N;
}
$out.='</tbody>'.N;
$out.='</table>'.N;
$out.='<div style="height:36px;"></div>';
}
mysqli_close($link);
@ -191,7 +294,7 @@ mysqli_close($link);
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Main Menu</title>
<title>Mastodon Startpage Admin - Istanze</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
@ -228,6 +331,162 @@ function golang(lang) {
document.location.href=loc.substr(0,loc.length-3);
}
}
function truncsel(el) {
var sel=document.getElementById(el), len=sel.length, i=0;
for (i=len-1; i>=0; i--)
sel.remove(i);
}
function addselopt(el,val,txt) {
option=document.createElement('option');
option.value=val;
option.text=txt;
el.add(option);
}
function inpdisif(index) {
var source=document.getElementById('condsel'+index);
var dest=document.getElementById('valueinp'+index);
var conds=['IS NULL','IS NOT NULL'];
if (conds.includes(source.value)) {
dest.disabled=true;
// dest.style='display:none';
} else {
dest.disabled=false;
// dest.style='display:block';
}
}
function popusels(index) {
console.log('Index: '+index);
var val=document.getElementById('fieldsel'+index).value, type=val.replace(/^.*§/,''), option;
val=val.replace(/§.*$/,'');
var condsel=document.getElementById('condsel'+index);
var valsel=document.getElementById('valuesel'+index);
var valinp=document.getElementById('valueinp'+index);
if (type=='bool') {
truncsel('condsel'+index);
addselopt(condsel,'IS','è');
addselopt(condsel,'IS NOT','non è');
truncsel('valuesel'+index);
addselopt(valsel,'TRUE','vero');
addselopt(valsel,'FALSE','falso');
addselopt(valsel,'NULL','non definito');
valinp.style='display:none';
valinp.disabled=true;
valsel.style='display:block';
valsel.disabled=false;
condsel.removeAttribute('onchange');
} else if (type=='text') {
truncsel('condsel'+index);
addselopt(condsel,'LIKE','contiene');
addselopt(condsel,'NOT LIKE','non contiene');
addselopt(condsel,'=','è uguale a');
addselopt(condsel,'!=','è diverso da');
addselopt(condsel,'IS NOT NULL','è definito');
addselopt(condsel,'IS NULL','non è definito');
valsel.style='display:none';
valsel.disabled=true;
valinp.style='display:block';
valinp.disabled=false;
condsel.setAttribute('onchange','inpdisif('+index+');');
} else if (type=='int' || type=='time') {
truncsel('condsel'+index);
addselopt(condsel,'>=','maggiore o uguale a');
addselopt(condsel,'<=','minore o uguale a');
addselopt(condsel,'>','maggiore di');
addselopt(condsel,'<','minore di');
addselopt(condsel,'=','uguale a');
addselopt(condsel,'!=','diverso da');
addselopt(condsel,'IS NOT NULL','è definito');
addselopt(condsel,'IS NULL','non è definito');
valsel.style='display:none';
valsel.disabled=true;
valinp.style='display:block';
valinp.disabled=false;
condsel.setAttribute('onchange','inpdisif('+index+');');
} else {
alert('Attenziò: non so che farmene del tipo "'+type+'": diglielo, al programmatore.');
}
}
function addrow(index) {
var table=document.getElementById('plancia');
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
var newcell4=newrow.insertCell(4);
var newcell5=newrow.insertCell(5);
var newcell6=newrow.insertCell(6);
var newcell7=newrow.insertCell(7);
newcell0.innerHTML='<select class="openpar"><option value="null"></option><option value="(">(</option><option value="((">((</option><option value="(((">(((</option></select>';
newcell1.innerHTML='<select class="fieldsel"><?php echo($fieldselopts); ?></select>';
newcell2.innerHTML='<select class="condsel"></select>';
newcell3.innerHTML='<select class="valuesel" style="display:none;"></select>\n<input type="text" class="valueinp" maxlength="256" style="display:none;">';
newcell4.innerHTML='<select class="closepar"><option value="null"></option><option value=")">)</option><option value="))">))</option><option value=")))">)))</option></select>';
newcell5.innerHTML='<select class="andor"><option value="AND">E</option><option value="OR">O</option></select>';
newcell6.innerHTML='<img class="plus" src="imgs/plus.svg">';
newcell7.innerHTML='<img class="minus" src="imgs/minus.svg">';
synctai();
popusels(index);
}
function synctai() {
var i=0;
var table=document.getElementById('plancia');
var nodes=table.querySelectorAll('.minus');
var cnodes=nodes.length;
for (i=0; i<cnodes; i++)
// +1 sempre per via della row iniziale
nodes[i].setAttribute('onclick','remrow('+(i+1)+');');
nodes=table.querySelectorAll('.plus');
for (i=0; i<cnodes; i++)
// +2 perché la devi aggiungere dopo la corrente
nodes[i].setAttribute('onclick','addrow('+(i+2)+');');
// da qui in poi faccio a scendere per non avere mai id e nomi duplicati
cnodes--;
nodes=table.querySelectorAll('.openpar');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','openpar'+(i+1));
nodes[i].setAttribute('name','openpar'+(i+1));
}
nodes=table.querySelectorAll('.fieldsel');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','fieldsel'+(i+1));
nodes[i].setAttribute('name','fieldsel'+(i+1));
nodes[i].setAttribute('onchange','popusels('+(i+1)+');');
}
nodes=table.querySelectorAll('.condsel');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','condsel'+(i+1));
nodes[i].setAttribute('name','condsel'+(i+1));
}
nodes=table.querySelectorAll('.valuesel');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','valuesel'+(i+1));
nodes[i].setAttribute('name','valuesel'+(i+1));
}
nodes=table.querySelectorAll('.valueinp');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','valueinp'+(i+1));
nodes[i].setAttribute('name','valueinp'+(i+1));
}
nodes=table.querySelectorAll('.closepar');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','closepar'+(i+1));
nodes[i].setAttribute('name','closepar'+(i+1));
}
nodes=table.querySelectorAll('.andor');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','andor'+(i+1));
nodes[i].setAttribute('name','andor'+(i+1));
nodes[i].disabled=false;
}
if (cnodes>0)
nodes[cnodes].disabled=true;
}
function remrow(index) {
var table=document.getElementById('plancia');
table.deleteRow(index);
synctai();
}
//-->
</script>
</head>
@ -241,16 +500,26 @@ function golang(lang) {
</div>
</nav>
<div id="fullscreenm">
<div id="middlerow">
<?php echo($out); ?>
</div>
</div>
<div id="footer">
<form action="edinst.php" name="addinst" method="post">
<table><tr><td>Aggiungi unistanza:</td><td><input type="text" name="URI" maxlength="512"></td><td><input type="button" value="Vai" onClick="ckaif();"></td></tr></table>
</form>
</div>
<div id="fullscreen">
<div id="middlerow">
<form method="post" id="f">
<table id="plancia">
<tr><td colspan="8"><input type="button" value="Aggiungi condizioni" class="ctrlbut" onclick="addrow(document.getElementById('plancia').rows.length);"></td></tr>
</table>
</form>
<?php echo($out); ?>
</div>
</div>
</body>
</html>

View file

@ -13,7 +13,7 @@ body {
font-family: Arial, Helvetica, Sans-Serif, sans;
font-size: 12pt;
margin: 0;
padding: 5px;
padding: 0;
height: 100%
}
h1,h2,h3,h4,h5,h6 {
@ -34,26 +34,26 @@ ul {
p {
margin-bottom: 10px;
}
#bigtab {
.bigtab {
background-color: white;
font-size: 10pt;
margin-left: auto;
margin-right: auto;
max-width: 100%;
margin-bottom: 40px;
/*max-width: 100%;*/
margin-top: 36px;
}
#bigtab thead {
.bigtab thead {
padding: 3px;
/* position: sticky;
top: 40px;*/
top: 36px;*/
color: white;
height: 30px;
}
#bigtab th {
.bigtab th {
background-color: #916f6f;
border-radius: 5px;
}
#bigtab .insthead {
.bigtab .insthead {
padding: 3px;
color: white;
height: 30px;
@ -65,23 +65,33 @@ p {
font-size: 12pt;
font-weight: bold;
}
#bigtab td {
.bigtab img {
max-width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}
/*720x1280*/
.bigtab td {
padding: 3px;
text-align: left;
vertical-align: top;
word-break: break-word;
width: 300px;
width: 360px;
min-width: 360px;
background-color: lightgrey;
border-radius: 5px;
}
#bigtab td p {
.bigtab .tdattr {
width: 110px;
min-width: 110px;
}
.baloo {
width: 100%;
margin-bottom: 3px;
padding-bottom: 3px;
border-bottom: 1px solid grey;
}
#bigtab .tdattr {
width: 110px;
}
.good, .bad, .neut {
padding: 1px;
margin-bottom: 3px;
@ -96,17 +106,20 @@ p {
.neut {
background-color: #FFCCAA;
}
.field {
.field, .ourfield {
padding: 1px;
border-radius: 3px;
background-color: #FFEEAA;
color: black;
}
.ourfield {
background-color: #FFB380;
}
.percstatuses, .perclogins, .percregs {
height: 12px;
line-height: 12px;
vertical-align: middle;
font-size: 6pt;
font-size: 8pt;
word-break: keep-all;
overflow-x: visible;
}
@ -119,34 +132,45 @@ p {
.percregs {
background-color: #80B3FF;
}
.colsectheader, .colsectcont {
.colsectheader, .colsectcont, .colsectcontb {
width: 100%;
font-size: 6pt;
font-size: 8pt;
text-align: center;
}
.colsectheader {
border-top: 1px solid grey;
margin-top: 5px;
padding-top: 3px;
margin-top: 10px;
font-weight: bold;
background-color: #C8B7B7;
border-radius: 3px;
padding: 1px;
}
.colsectcont ol {
text-align: left;
padding-left: 0;
margin-left: 12px;
}
.colsectcontb {
margin-top: 2px;
font-weight: bold;
background-color: #BBBBBB;
border-radius: 3px;
padding: 1px;
}
.percbg, .percfg {
margin-top: 2px;
width: 100%;
height: 16px;
height: 14px;
background-color: #C83737;
border-radius: 3px;
}
.percfg {
background-color: #44AA00;
}
#fullscreen, #fullscreenm {
#fullscreen {
width: 100%;
height: 100%;
display: table;
}
#fullscreenm {
padding-top: 40px;
}
#middlerow {
display: table-cell;
vertical-align: middle;
@ -199,7 +223,7 @@ input {
}
.button {
font-size: 11pt;
height: 40px;
height: 36px;
}
#popup {
z-index: 1;
@ -232,12 +256,12 @@ input {
#footer {
color: white;
position: fixed;
height: 40px;
height: 36px;
width: 100%;
bottom: 0;
left: 0;
background-color: rgba(0,0,0,0.85);
line-height: 40px;
line-height: 36px;
vertical-align: middle;
}
.nully {
@ -246,18 +270,18 @@ input {
}
#hmenu {
font-size: 14pt;
font-size: 12pt;
background-color: rgba(0,0,0,0.85);
color: white;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 40px;
height: 36px;
margin: 0;
padding: 0;
/*box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.4);*/
/*padding-left: 40px;*/
/*padding-left: 36px;*/
z-index: 2;
/*display: none;*/
}
@ -269,7 +293,7 @@ input {
}
#hmenu ul li {
width: 80pt;
height: 40px;
height: 36px;
text-align: center;
display: table-cell;
vertical-align: middle;
@ -281,13 +305,13 @@ input {
}
#hmenu ul li a {
width: 80pt;
line-height: 40px;
line-height: 36px;
display: block;
color: #3088D4;
}
#hmenu .ula {
position: absolute;
top: 40px;
top: 36px;
background-color: rgba(0,0,0,0.85);
display: none;
}
@ -295,16 +319,16 @@ input {
background-color: rgba(0,0,0,0.85);
left: 80pt;
position: relative;
top: -40px;
top: -36px;
display: none;
}
#hmenu .ula li, .ulb li {
width: 80pt;
height: 40px;
height: 36px;
display: block;
float: none;
text-align: center;
line-height: 40px;
line-height: 36px;
vertical-align: middle;
}
#hmenu .ula li:hover, .ulb li:hover {
@ -322,3 +346,42 @@ input {
text-decoration: none;
}
#plancia {
position: fixed;
left: 50%;
transform: translateX(-50%);
margin-top: 36px;
max-width: 100%;
background-color: rgba(0,0,0,0.85);
padding: 1px;
border-radius: 0 0 7px 7px;
font-size: 9pt;
color: #3088D4;
}
#plancia select, input, button {
margin: 0;
height: 24px;
font-size: 8pt;
}
#plancia input {
width: 120px;
}
/* questi li definisco e li applico solo per avere qualcosa su cui fare "querySelectorAll" */
#plancia .openpar, .fieldsel, .condsel, .valuesel, .valueinp, .andor, .plusminus, .closepar { }
#plancia .minus, .plus {
width: 22px;
height: 22px;
}
#plancia .minus:hover, .plus:hover {
cursor: pointer;
}
#plancia .ctrlbut {
width: 100%;
}
@media only screen and (max-width:720px) {
.bigtab td {
width: 244px;
min-width: 244px;
}
}