好的,我有以下代码,它将在某些点上为字符串着色,使用 div 内部的 div。
$lines = file("oneModelResults.txt");
$ntArr = array();
$oneHit= array();
// Loop the file data and build an multidimensional associative array
foreach ($lines as $line_num => $columns) {
$line= explode("\t",$columns);
$allModels[$line[3]] = 1;
$oneHit = array(
'hit' => $line[2],
'name' => $line[0],
'score' => $line[1],
'end' => $line[2] + 3,
'model' => $line[3],
'top' => $line[5],
'color' => getcolor(rawtransform($line[1]),$line[4]));
for ($i=0;$i<=3; $i++){
$ntArr[$line[2]+$i][$line[3]][] = $oneHit;
}
}
// Close the file
fclose($fp);
// Generate a random sequence
$seqArr = array('A', 'T', 'C', 'G');
$randseq = array();
for ($i = 0; $i < 1000; $i++) {
$randseq[] = $seqArr[array_rand($seqArr)];
}
//main div for results visual
echo'<div id="coltext" style="font-family:monospace;font-size:17px;background-color:#D0D0D0;color:black;">'."\n";
// Iterate over $allModels and echo checkboxes
foreach ($allModels as $modName => $value) {
echo '<input ModelName="'.$modName.'" type="checkbox" checked="checked"
onclick="toggle.apply(this);" />'.$modName.';
}
// An array to track the current hits
$currentHits = array();
$modelArr=array();
foreach ($randseq as $index => $nuc) {
echo'<div class="seqWrap"title="position:'.($index+1).'">';
// Increment $index
$index++;
// Check whether we are at the start of a new hit
if (isset($ntArr[$index]) and !empty($ntArr[$index])) {
$currentHits[$index] = $ntArr[$index];
}
if (count($currentHits)) {
foreach($currentHits as $modelNameArr){
foreach($modelNameArr as $hit){
$hitCount = count($hit);
$height=25/$hitCount;
$counter=0;
foreach($hit as $hitAttribute){
$top = $height * $counter;
$counter++;
$color=$hitAttribute['color'];
$op=($hitAttribute['score']/1000);
$lborder=($index==$hitAttribute['hit']) ?
"solid white 2px":"solid transparent 2px";
$rborder=($index==$hitAttribute['end']) ?
"solid white 2px":"solid transparent 2px";
echo '<div class="hit" modName="'.$hitAttribute['model'].'"
title="position:'.$newindex.',score:'.$hitAttribute['score'].'"
color="'.$color.'" style="background:'.$color.';
border-right:'.$rborder.';border-left:'.$lborder.';
opacity:'.$op.';height:'.$height.'px;top:'.$top.'px;">';
echo "</div>";
}
}
}
}
//wrap nucleotide in div.
echo'<div class="nucWrap">'.$nuc."</div>";
// Split into 50 character chunks
if (($index % 50 )==0){
echo"<br />";
}
echo "</div>";
$currentHits=array();
}
echo "</div>";
我想说以下内容:如果未选中复选框(具有 classname="ModelName"),则隐藏具有属性“ModName="ModelName"”的 div 即如果 classname =Modname,隐藏 div,但是我认为我的问题正在浏览文档, 。有人可以帮忙吗?