Skip to content

Commit

Permalink
build all urls with a function so that we can toggle which 'k' group …
Browse files Browse the repository at this point in the history
…to look at without switching context mode, and vice-versa
  • Loading branch information
iamcal committed Apr 15, 2013
1 parent 54f03d5 commit 0c145f0
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions index.php
Expand Up @@ -240,6 +240,23 @@ function get_line_class($x){
return 'fail';
}

function build_url($args){

$use = $_GET;
foreach ($args as $k => $v){
if (is_null($v)){
unset($use[$k]);
}else{
$use[$k] = $v;
}
}

list($base) = explode('?', $_SERVER['REQUEST_URI']);

if (!count($use)) return $base;
return $base . '?' . http_build_query($use);
}

include('head.txt');
?>
<style>
Expand Down Expand Up @@ -298,13 +315,10 @@ function get_line_class($x){
<div class="selnav">
<div style="float: right">
<?
list($base) = explode('?', $_SERVER['REQUEST_URI']);
$link = build_url(array('show_all' => null, 'show_less' => null));
if ($max_context && $is_collapsed) $link = build_url(array('show_all' => 1, 'show_less' => null));
if (!$max_context && !$is_collapsed) $link = build_url(array('show_all' => null, 'show_less' => 1));

if ($max_context){
$link = $is_collapsed ? "{$base}?show_all=1" : $base;
}else{
$link = $is_collapsed ? $base : "{$base}?show_less=1";
}
$label = $is_collapsed ? "Show All" : "Show Diffs";

echo "<a href=\"{$link}\">{$label}</a>";
Expand All @@ -320,11 +334,9 @@ function get_line_class($x){
if ($k == $key){
$bits[] = "<b>$label</b>";
}else{
if ($k == $default_key){
$bits[] = "<a href=\"./\">$label</a>";
}else{
$bits[] = "<a href=\"./?k=$kk\">$label</a>";
}
$link = build_url(array('k' => ($k == $default_key) ? null : $kk ));

$bits[] = "<a href=\"{$link}\">$label</a>";
}
}

Expand Down

0 comments on commit 0c145f0

Please sign in to comment.