Changeset 11
Legend:
- Unmodified
- Added
- Removed
-
trunk/index.php
r10 r11 36 36 { 37 37 $Output = '<div>'. 38 //'<a href="'.$this->Link('/tance/').'">Tance</a> '.39 //'<a href="'.$this->Link('/skoly/').'">Školy</a> '.40 //'<a href="'.$this->Link('/seznamka/').'">Seznamka</a> '.38 '<a href="'.$this->Link('/runners').'">Runners</a> '. 39 '<a href="'.$this->Link('/teams').'">Teams</a> '. 40 '<a href="'.$this->Link('/families').'">Families</a>'; 41 41 '</div>'; 42 42 return($Output); … … 118 118 for ($i = 0; $i < 2; $i++) 119 119 { 120 $Queries = array(); 121 $Page = $i * $MaxCount / $ItemsPerPage; 122 echo($Page.' '); 123 $Response = $this->QueryRunners('all', $Page, null, null, null, $MaxCount); 124 foreach ($Response['items'] as $Item) 125 { 126 if (($Item['Type'] == 'child') or ($Item['Type'] == 'woman') or ($Item['Type'] == 'man')) 120 $Queries = array(); 121 $Page = $i * $MaxCount / $ItemsPerPage; 122 $Response = $this->QueryRunners('all', $Page, null, null, null, $MaxCount); 123 foreach ($Response['items'] as $Item) 127 124 { 128 if ( !array_key_exists($Item['ChipNumber'], $Runners))125 if (($Item['Type'] == 'child') or ($Item['Type'] == 'woman') or ($Item['Type'] == 'man')) 129 126 { 130 if ( $Item['TeamId'] == null)127 if (!array_key_exists($Item['ChipNumber'], $Runners)) 131 128 { 132 $TeamId = null; 133 } else 129 if ($Item['TeamId'] == null) 130 { 131 $TeamId = null; 132 } else 133 { 134 if (!array_key_exists($Item['TeamId'], $Teams)) 135 { 136 $TeamId = $NextTeamId; 137 $Queries[] = $this->Database->GetInsert('Team', array( 138 'Id' => $TeamId, 139 'Name' => '', 140 'WebId' => $Item['TeamId'], 141 )); 142 $Teams[$Item['TeamId']] = array('Id' => $TeamId, 'Distance' => -1); 143 $NextTeamId++; 144 } else 145 $TeamId = $Teams[$Item['TeamId']]['Id']; 146 } 147 148 $Gender = 0; 149 if ($Item['Type'] == 'man') $Gender = 1; 150 if ($Item['Type'] == 'woman') $Gender = 2; 151 if ($Item['Type'] == 'child') $Gender = 3; 152 $RunnerId = $NextRunnerId; 153 $Queries[] = $this->Database->GetInsert('Runner', array( 154 'Id' => $RunnerId, 155 'Name' => $Item['Name'], 156 'Gender' => $Gender, 157 'Team' => $TeamId, 158 'ChipNumber' => $Item['ChipNumber'], 159 )); 160 $Runners[$Item['ChipNumber']] = array('Id' => $RunnerId, 'Distance' => -1); 161 $NextRunnerId++; 162 } else 163 $RunnerId = $Runners[$Item['ChipNumber']]['Id']; 164 165 if ($Runners[$Item['ChipNumber']]['Distance'] < $Item['OverallDistance']) 166 $Queries[] = $this->Database->GetInsert('RunnerStat', array( 167 'Time' => TimeToMysqlDateTime($Time), 168 'Runner' => $RunnerId, 169 'Distance' => $Item['OverallDistance'], 170 'Rank' => $Item['Pos'], 171 'Money' => $Item['Money'], 172 )); 173 } else 174 if (($Item['Type'] == 'team') or ($Item['Type'] == 'rodina')) 175 { 176 if (!array_key_exists($Item['GroupId'], $Teams)) 134 177 { 135 if (!array_key_exists($Item['TeamId'], $Teams)) 136 { 178 if ($Item['Type'] == 'rodina') $IsFamily = 1; 179 else $IsFamily = 0; 180 $Queries[] = $this->Database->GetInsert('Team', array( 181 'Id' => $NextTeamId, 182 'Name' => $Item['Name'], 183 'WebId' => $Item['GroupId'], 184 'IsFamily' => $IsFamily, 185 )); 137 186 $TeamId = $NextTeamId; 138 $Queries[] = $this->Database->GetInsert('Team', array( 139 'Id' => $TeamId, 140 'Name' => '', 141 'WebId' => $Item['TeamId'], 142 )); 143 $Teams[$Item['TeamId']] = array('Id' => $TeamId, 'Distance' => -1); 187 $Teams[$Item['GroupId']] = array('Id' => $NextTeamId, 'Distance' => -1); 144 188 $NextTeamId++; 145 189 } else 146 $TeamId = $Teams[$Item['TeamId']]['Id']; 147 } 148 149 $Gender = 0; 150 if ($Item['Type'] == 'man') $Gender = 1; 151 if ($Item['Type'] == 'woman') $Gender = 2; 152 if ($Item['Type'] == 'child') $Gender = 3; 153 $RunnerId = $NextRunnerId; 154 $Queries[] = $this->Database->GetInsert('Runner', array( 155 'Id' => $RunnerId, 156 'Name' => $Item['Name'], 157 'Gender' => $Gender, 190 $TeamId = $Teams[$Item['GroupId']]['Id']; 191 192 if ($Teams[$Item['GroupId']]['Distance'] < $Item['OverallDistance']) 193 $Queries[] = $this->Database->GetInsert('TeamStat', array( 194 'Time' => TimeToMysqlDateTime($Time), 158 195 'Team' => $TeamId, 159 'ChipNumber' => $Item['ChipNumber'], 196 'Distance' => $Item['OverallDistance'], 197 'Rank' => $Item['Pos'], 198 'Money' => $Item['Money'], 160 199 )); 161 $Runners[$Item['ChipNumber']] = array('Id' => $RunnerId, 'Distance' => -1); 162 $NextRunnerId++; 163 } else 164 $RunnerId = $Runners[$Item['ChipNumber']]['Id']; 165 166 if ($Runners[$Item['ChipNumber']]['Distance'] < $Item['OverallDistance']) 167 $Queries[] = $this->Database->GetInsert('RunnerStat', array( 168 'Time' => TimeToMysqlDateTime($Time), 169 'Runner' => $RunnerId, 170 'Distance' => $Item['OverallDistance'], 171 'Rank' => $Item['Pos'], 172 'Money' => $Item['Money'], 173 )); 174 } else 175 if ($Item['Type'] == 'team') 176 { 177 if (!array_key_exists($Item['GroupId'], $Teams)) 178 { 179 $Queries[] = $this->Database->GetInsert('Team', array( 180 'Id' => $NextTeamId, 181 'Name' => $Item['Name'], 182 'WebId' => $Item['GroupId'], 183 )); 184 $TeamId = $NextTeamId; 185 $Teams[$Item['GroupId']] = array('Id' => $NextTeamId, 'Distance' => -1); 186 $NextTeamId++; 187 } else 188 $TeamId = $Teams[$Item['GroupId']]['Id']; 189 190 if ($Teams[$Item['GroupId']]['Distance'] < $Item['OverallDistance']) 191 $Queries[] = $this->Database->GetInsert('TeamStat', array( 192 'Time' => TimeToMysqlDateTime($Time), 193 'Team' => $TeamId, 194 'Distance' => $Item['OverallDistance'], 195 'Rank' => $Item['Pos'], 196 'Money' => $Item['Money'], 197 )); 198 } 199 } 200 print_r($Queries); 201 $this->Database->Transaction($Queries); 202 } 203 } 204 205 function ShowTeams() 200 } 201 } 202 //print_r($Queries); 203 $this->Database->Transaction($Queries); 204 } 205 } 206 207 function ShowFamilies() 206 208 { 207 209 $Output = ''; 208 209 $DbResult = $this->Database->query('SELECT * FROM Team'); 210 $DbRow = $DbResult->fetch_assoc(); 211 $Output .= '<h4 style="text-align: center;">Teams</h4>'; 212 213 $Where = '1'; 210 $Output .= '<div class="page-title">Families</div>'; 211 212 $Where = 'IsFamily=1'; 214 213 215 214 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE '.$Where); … … 224 223 array('Name' => 'Distance', 'Title' => 'Distance'), 225 224 array('Name' => 'Money', 'Title' => 'Money'), 225 array('Name' => 'DistanceRunner', 'Title' => 'Distance per runner'), 226 array('Name' => 'MoneyRunner', 'Title' => 'Money per runner'), 226 227 array('Name' => 'Rank', 'Title' => 'Rank'), 227 228 ); … … 231 232 $DbResult = $this->Database->select('Team', '*, '. 232 233 '(SELECT COUNT(*) FROM Runner WHERE Runner.Team=Team.Id) AS RunnersCount, '. 233 '0 AS Distance, '. 234 '0 AS Money, '. 235 '0 AS Rank', 236 //'(SELECT SUM(Distance) FROM Runner WHERE Runner.Team=Team.Id) AS Distance, '. 237 //'(SELECT SUM(Money) FROM Runner WHERE Runner.Team=Team.Id) AS Money ', 234 '(SELECT TeamStat.Distance FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY TeamStat.Time DESC LIMIT 1) AS Distance, '. 235 '(SELECT TeamStat.Money FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) AS Money, '. 236 '(SELECT TeamStat.Time FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) AS Time, '. 237 '(SELECT TeamStat.Rank FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) AS Rank, '. 238 'ROUND((SELECT TeamStat.Distance FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY TeamStat.Time DESC LIMIT 1) / (SELECT COUNT(*) FROM Runner WHERE Runner.Team=Team.Id), 1) AS DistanceRunner, '. 239 'ROUND((SELECT TeamStat.Money FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) / (SELECT COUNT(*) FROM Runner WHERE Runner.Team=Team.Id)) AS MoneyRunner', 238 240 $Where.$Order['SQL'].$PageList['SQLLimit']); 239 241 while($Item = $DbResult->fetch_assoc()) 240 242 { 241 if ($Item['Name'] == '') $Item['Name'] = ' Without team';243 if ($Item['Name'] == '') $Item['Name'] = 'Family '.$Item['WebId']; 242 244 $Output .= '<tr>'. 243 '<td><a href="'.$this->Link('/ team/'.$Item['Id'].'/').'">'.$Item['Name'].'</a></td>'.245 '<td><a href="'.$this->Link('/family/'.$Item['Id'].'/').'">'.$Item['Name'].'</a></td>'. 244 246 '<td>'.$Item['RunnersCount'].'</td>'. 245 247 '<td>'.$Item['Distance'].'</td>'. 246 248 '<td>'.$Item['Money'].'</td>'. 249 '<td>'.$Item['DistanceRunner'].'</td>'. 250 '<td>'.$Item['MoneyRunner'].'</td>'. 247 251 '<td>'.$Item['Rank'].'</td>'. 248 252 '</tr>'; … … 255 259 } 256 260 257 function Show Team()261 function ShowFamily() 258 262 { 259 263 $Output = ''; … … 262 266 if ((count($this->PathItems) > 0) and ($this->PathItems[count($this->PathItems) - 1] != '')) 263 267 $TeamId = $this->PathItems[count($this->PathItems) - 1]; 264 if (!is_numeric($TeamId)) die(' TeamId needs to be numeric');265 266 $DbResult = $this->Database->query('SELECT * FROM Team WHERE Id='.$TeamId );268 if (!is_numeric($TeamId)) die('FamilyId needs to be numeric'); 269 270 $DbResult = $this->Database->query('SELECT * FROM Team WHERE Id='.$TeamId.' AND IsFamily=1'); 267 271 $DbRow = $DbResult->fetch_assoc(); 268 $Output .= '< h4 style="text-align: center;">Team '.$DbRow['Name'].'</h4>';272 $Output .= '<div class="page-title">Family '.$DbRow['Name'].'</div>'; 269 273 270 274 … … 313 317 } 314 318 319 function ShowTeams() 320 { 321 $Output = ''; 322 $Output .= '<div class="page-title">Teams</div>'; 323 324 //$Where = 'Name != ""'; 325 $Where = 'IsFamily=0'; 326 327 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE '.$Where); 328 $DbRow = $DbResult->fetch_row(); 329 $PageList = GetPageList($DbRow[0]); 330 331 $Output .= '<div id="list_content">'; 332 $Output .= $PageList['Output']; 333 $TableColumns = array( 334 array('Name' => 'Name', 'Title' => 'Name'), 335 array('Name' => 'RunnersCount', 'Title' => 'Runners'), 336 array('Name' => 'Distance', 'Title' => 'Distance'), 337 array('Name' => 'Money', 'Title' => 'Money'), 338 array('Name' => 'DistanceRunner', 'Title' => 'Distance per runner'), 339 array('Name' => 'MoneyRunner', 'Title' => 'Money per runner'), 340 array('Name' => 'Rank', 'Title' => 'Rank'), 341 ); 342 $Order = GetOrderTableHeader($TableColumns, 'Distance', 1); 343 $Output .= '<table class="WideTable">'; 344 $Output .= $Order['Output']; 345 $DbResult = $this->Database->select('Team', '*, '. 346 '(SELECT COUNT(*) FROM Runner WHERE Runner.Team=Team.Id) AS RunnersCount, '. 347 '(SELECT TeamStat.Distance FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY TeamStat.Time DESC LIMIT 1) AS Distance, '. 348 '(SELECT TeamStat.Money FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) AS Money, '. 349 '(SELECT TeamStat.Time FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) AS Time, '. 350 '(SELECT TeamStat.Rank FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) AS Rank, '. 351 'ROUND((SELECT TeamStat.Distance FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY TeamStat.Time DESC LIMIT 1) / (SELECT COUNT(*) FROM Runner WHERE Runner.Team=Team.Id), 1) AS DistanceRunner, '. 352 'ROUND((SELECT TeamStat.Money FROM TeamStat WHERE TeamStat.Team=Team.Id ORDER BY Time DESC LIMIT 1) / (SELECT COUNT(*) FROM Runner WHERE Runner.Team=Team.Id)) AS MoneyRunner', 353 $Where.$Order['SQL'].$PageList['SQLLimit']); 354 while($Item = $DbResult->fetch_assoc()) 355 { 356 if ($Item['Name'] == '') $Item['Name'] = 'Team '.$Item['WebId']; 357 $Output .= '<tr>'. 358 '<td><a href="'.$this->Link('/team/'.$Item['Id'].'/').'">'.$Item['Name'].'</a></td>'. 359 '<td>'.$Item['RunnersCount'].'</td>'. 360 '<td>'.$Item['Distance'].'</td>'. 361 '<td>'.$Item['Money'].'</td>'. 362 '<td>'.$Item['DistanceRunner'].'</td>'. 363 '<td>'.$Item['MoneyRunner'].'</td>'. 364 '<td>'.$Item['Rank'].'</td>'. 365 '</tr>'; 366 } 367 $Output .= '</table>'; 368 $Output .= $PageList['Output']; 369 $Output .= '</div>'; 370 371 return($Output); 372 } 373 374 function ShowTeam() 375 { 376 $Output = ''; 377 378 $TeamId = 1; 379 if ((count($this->PathItems) > 0) and ($this->PathItems[count($this->PathItems) - 1] != '')) 380 $TeamId = $this->PathItems[count($this->PathItems) - 1]; 381 if (!is_numeric($TeamId)) die('TeamId needs to be numeric'); 382 383 $DbResult = $this->Database->query('SELECT * FROM Team WHERE Id='.$TeamId); 384 $DbRow = $DbResult->fetch_assoc(); 385 $Output .= '<div class="page-title">Team '.$DbRow['Name'].'</div>'; 386 387 388 $Where = 'Team='.$TeamId; 389 390 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Runner` WHERE '.$Where); 391 $DbRow = $DbResult->fetch_row(); 392 $PageList = GetPageList($DbRow[0]); 393 394 $Gender = array('', 'Male', 'Female', 'Child'); 395 $Output .= '<div id="list_content">'; 396 $Output .= $PageList['Output']; 397 $TableColumns = array( 398 array('Name' => 'Name', 'Title' => 'Name'), 399 array('Name' => 'Gender', 'Title' => 'Gender'), 400 array('Name' => 'Distance', 'Title' => 'Distance'), 401 array('Name' => 'Money', 'Title' => 'Money'), 402 array('Name' => 'Rank', 'Title' => 'Rank'), 403 array('Name' => 'Time', 'Title' => 'Last change'), 404 ); 405 $Order = GetOrderTableHeader($TableColumns, 'Distance', 1); 406 $Output .= '<table class="WideTable">'; 407 $Output .= $Order['Output']; 408 $DbResult = $this->Database->select('Runner', '*, '. 409 '(SELECT RunnerStat.Distance FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Distance'. 410 ', (SELECT RunnerStat.Money FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Money'. 411 ', (SELECT RunnerStat.Time FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Time'. 412 ', (SELECT RunnerStat.Rank FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Rank', 413 $Where.$Order['SQL'].$PageList['SQLLimit']); 414 while($MeetItem = $DbResult->fetch_assoc()) 415 { 416 $Output .= '<tr>'. 417 '<td><a href="'.$this->Link('/runner/'.$MeetItem['Id'].'/').'">'.$MeetItem['Name'].'</a></td>'. 418 '<td>'.$Gender[$MeetItem['Gender']].'</td>'. 419 '<td>'.$MeetItem['Distance'].'</td>'. 420 '<td>'.$MeetItem['Money'].'</td>'. 421 '<td>'.$MeetItem['Rank'].'</td>'. 422 '<td>'.HumanDateTime(MysqlDateTimeToTime($MeetItem['Time'])).'</td>'. 423 '</tr>'; 424 } 425 $Output .= '</table>'; 426 $Output .= $PageList['Output']; 427 $Output .= '</div>'; 428 429 return($Output); 430 } 431 432 function ShowRunners() 433 { 434 $Output = ''; 435 $Output .= '<div class="page-title">Runners</div>'; 436 437 $Where = '1'; 438 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Runner` WHERE '.$Where); 439 $DbRow = $DbResult->fetch_row(); 440 $PageList = GetPageList($DbRow[0]); 441 442 $Gender = array('', 'Male', 'Female', 'Child'); 443 $Output .= '<div id="list_content">'; 444 $Output .= $PageList['Output']; 445 $TableColumns = array( 446 array('Name' => 'Name', 'Title' => 'Name'), 447 array('Name' => 'Gender', 'Title' => 'Gender'), 448 array('Name' => 'Distance', 'Title' => 'Distance'), 449 array('Name' => 'Money', 'Title' => 'Money'), 450 array('Name' => 'Rank', 'Title' => 'Rank'), 451 array('Name' => 'Time', 'Title' => 'Last change'), 452 ); 453 $Order = GetOrderTableHeader($TableColumns, 'Distance', 1); 454 $Output .= '<table class="WideTable">'; 455 $Output .= $Order['Output']; 456 $DbResult = $this->Database->select('Runner', '*, '. 457 '(SELECT RunnerStat.Distance FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Distance'. 458 ', (SELECT RunnerStat.Money FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Money'. 459 ', (SELECT RunnerStat.Time FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Time'. 460 ', (SELECT RunnerStat.Rank FROM RunnerStat WHERE RunnerStat.Runner=Runner.Id ORDER BY Time DESC LIMIT 1) AS Rank', 461 $Where.$Order['SQL'].$PageList['SQLLimit']); 462 while($Item = $DbResult->fetch_assoc()) 463 { 464 $Output .= '<tr>'. 465 '<td><a href="'.$this->Link('/runner/'.$Item['Id'].'/').'">'.$Item['Name'].'</a></td>'. 466 '<td>'.$Gender[$Item['Gender']].'</td>'. 467 '<td>'.$Item['Distance'].'</td>'. 468 '<td>'.$Item['Money'].'</td>'. 469 '<td>'.$Item['Rank'].'</td>'. 470 '<td>'.HumanDateTime(MysqlDateTimeToTime($Item['Time'])).'</td>'. 471 '</tr>'; 472 } 473 $Output .= '</table>'; 474 $Output .= $PageList['Output']; 475 $Output .= '</div>'; 476 477 return($Output); 478 } 479 315 480 function ShowRunner() 316 481 { … … 325 490 $DbResult = $this->Database->query('SELECT * FROM Runner WHERE Id='.$RunnerId); 326 491 $DbRow = $DbResult->fetch_assoc(); 327 $Output .= '<div style="text-align: center;">Runner '.$DbRow['Name'].'</div>';492 $Output .= '<div class="page-title">Runner '.$DbRow['Name'].'</div>'; 328 493 329 494 … … 331 496 332 497 // Show detailed stats 333 $Output .= '<div style="text-align: center">Detailed</div>';498 $Output .= '<div class="section-title">Detailed</div>'; 334 499 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `RunnerStat` WHERE '.$Where); 335 500 $DbRow = $DbResult->fetch_row(); … … 383 548 $PageList = GetPageList($DbRow[0]); 384 549 385 $Output .= '<div style="text-align: center">Daily</div>';550 $Output .= '<div class="section-title">Daily</div>'; 386 551 $Output .= '<div id="list_content">'; 387 552 $Output .= $PageList['Output']; … … 425 590 } 426 591 592 function ShowMain() 593 { 594 return ""; 595 } 596 427 597 function ShowPage($Content) 428 598 { … … 462 632 { 463 633 if($this->PathItems[0] == 'sync') $Output .= $this->ShowSync(); 464 //else if($this->PathItems[0] == 'empty') $Output .= $this->ShowEmpty();634 else if($this->PathItems[0] == 'empty') $Output .= $this->ShowEmpty(); 465 635 else if($this->PathItems[0] == 'runner') $Output .= $this->ShowRunner(); 636 else if($this->PathItems[0] == 'runners') $Output .= $this->ShowRunners(); 466 637 else if($this->PathItems[0] == 'team') $Output .= $this->ShowTeam(); 467 else $Output .= $this->ShowTeams(); 468 } else $Output .= $this->ShowTeams(); 638 else if($this->PathItems[0] == 'teams') $Output .= $this->ShowTeams(); 639 else if($this->PathItems[0] == 'family') $Output .= $this->ShowFamily(); 640 else if($this->PathItems[0] == 'families') $Output .= $this->ShowFamilies(); 641 else $Output .= $this->ShowMain(); 642 } else $Output .= $this->ShowMain(); 469 643 if (!$this->NoFullPage) 470 644 { -
trunk/style.css
r8 r11 67 67 text-align: center; 68 68 } 69 70 .page-title 71 { 72 font-weight: bold; 73 text-align: center; 74 padding-bottom: 10px; 75 } 76 77 .section-title 78 { 79 font-weight: normal; 80 text-align: center; 81 }
Note:
See TracChangeset
for help on using the changeset viewer.