Skip to content

Commit

Permalink
Merge remote-tracking branch 'davehunt/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
temp authored and temp committed May 12, 2012
2 parents af5d162 + 1d15492 commit 5b86a05
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 18 deletions.
122 changes: 122 additions & 0 deletions admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
$count = 0;
function get_current_options()
{
$contents = file_get_contents('options.json');
$contents_array = json_decode($contents, TRUE);
GLOBAL $count;
foreach($contents_array as $an_array)
{
foreach($an_array as $key => $value)
{
if($key !== '')
{
if($value === 1)
echo '<input type="text" name="tags[]" value="' . $key . '"><input type="checkbox" name="true[' . $count . ']" checked><br>';
else
echo '<input type="text" name="tags[]" value="' . $key . '"><input type="checkbox" name="true[' . $count . ']"><br>';

$count++;
}
}
}
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CodeMachine</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<!-- Le styles -->
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="http://twitter.github.com/bootstrap/assets/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-57-precomposed.png">

<script language="Javascript">
function addInput(divName){
var newdiv = document.createElement('div');
newdiv.innerHTML = '<input type="text" name="tags[]" value=""><input type="checkbox" name="true[<?php echo $count;?>]"><br>';
document.getElementById(divName).appendChild(newdiv);
webcounter++;
}
</script>
</head>

<body>

<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">CodeMachine</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>

<div class="container">

<h1>Admin</h1>
<p>Edit the options file, below.</p>

<form action="write_json.php" method="post">
<div id="options">
<?php
get_current_options();
?>
</div>
<input type="button" value="Add another option" onClick="addInput('options');"><br>
<input type="submit" class="btn btn-success btn-large" value="Save Options" style="margin-top: 20px">
</form>
<div id="options">
</div>
</div> <!-- /container -->

<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://twitter.github.com/bootstrap/assets/js/jquery.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-transition.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-alert.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-modal.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-dropdown.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-scrollspy.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-tab.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-tooltip.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-popover.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-button.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-collapse.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-carousel.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-typeahead.js"></script>

</body>
</html>
23 changes: 13 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

<h1>code machine</h1>

<p class="score">Score: <span id="counter">0</span></p>

<ul class="machine">
<li>
<ul class="roller">
<li>1</li>
<li>2</li>
<li>3</li>
<li>?</li>
<li>?</li>
<li>?</li>
<li>4</li>
<li>5</li>
<li>6</li>
Expand All @@ -29,9 +31,9 @@ <h1>code machine</h1>
</li>
<li>
<ul class="roller">
<li>1</li>
<li>2</li>
<li>3</li>
<li>?</li>
<li>?</li>
<li>?</li>
<li>4</li>
<li>5</li>
<li>6</li>
Expand All @@ -43,9 +45,9 @@ <h1>code machine</h1>
</li>
<li>
<ul class="roller">
<li>1</li>
<li>2</li>
<li>3</li>
<li>?</li>
<li>?</li>
<li>?</li>
<li>4</li>
<li>5</li>
<li>6</li>
Expand All @@ -59,8 +61,9 @@ <h1>code machine</h1>

<div class="answers">
<a href="#start" class="button" id="start">Start</a>
<a href="#reset" class="button" id="reset">Reset</a>

<a href="" id="more-info">Find out more on MDN!</a>
<a href="" class="more-info">Find out more on MDN!</a>
</div>

<script src="options.json"></script>
Expand Down
32 changes: 28 additions & 4 deletions library/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ h1 {
text-align: center;
text-shadow: 3px 3px 0 #666;
}
a#start {
background: green;
.score {
color: #fff;
font-size: 2em;
margin: 0 30px;
text-align: right;
}
.button {
border: solid 1px rgba(0, 0, 0, 0.6);
border-radius: 4px;
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6), 0 0 4px rgba(255, 255, 255, 0.6), inset 0 25px 0 rgba(255, 255, 255, 0.1);
Expand All @@ -60,6 +65,9 @@ a#start {
text-shadow: rgba(0, 0, 0, 0.7);
width: 200px;
}
a#start {
background: green;
}
a#start:hover {
background: lime;
color: #000;
Expand All @@ -73,6 +81,22 @@ a#start.disabled:hover {
background: #666;
color: #888;
}
a#reset {
background: maroon;
}
a#reset:hover {
background: red;
color: #000;
text-decoration: none;
}
a#reset.disabled {
background: #666;
color: #888;
}
a#reset.disabled:hover {
background: #666;
color: #888;
}
.machine {
list-style-type: none;
margin: 50px 0 50px 30px;
Expand Down Expand Up @@ -140,10 +164,10 @@ a#start.disabled:hover {
text-shadow: 2px 2px 0 #fff;
width: auto;
}
.answers a {
.more-info {
display: block;
margin: 0 auto;
}
.answers a:hover {
.more-info:hover {
text-decoration: underline;
}
38 changes: 34 additions & 4 deletions library/less/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ h1 {
text-shadow:3px 3px 0 #666;
}

a#start {
background:green;
.score {
color:#fff;
font-size:2em;
margin:0 30px;
text-align:right;
}

.button {
border:solid 1px rgba(0,0,0,0.6);
border-radius:4px;
box-shadow:0 0 0 1px rgba(255,255,255,0.6), 0 0 4px rgba(255,255,255,0.6), inset 0 25px 0 rgba(255,255,255,0.1);
Expand All @@ -57,7 +63,11 @@ a#start {
padding:12px 0;
text-align:center;
text-shadow:rgba(0,0,0,0.7);
width:200px;
width:200px;
}

a#start {
background:green;

&:hover {
background:lime;
Expand All @@ -76,6 +86,26 @@ a#start {
}
}


a#reset {
background:maroon;

&:hover {
background:red;
color:#000;
text-decoration:none;
}

&.disabled {
background:#666;
color:#888;

&:hover {
background:#666;
color:#888;
}
}
}
.machine {
list-style-type:none;
margin:50px 0 50px 30px;
Expand Down Expand Up @@ -155,7 +185,7 @@ a#start {

}

.answers a {
.more-info {
display:block;
margin:0 auto;

Expand Down
29 changes: 29 additions & 0 deletions write_json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
$tags = $_POST['tags'];
$true = $_POST['true'];
$count = 0;
$echoing = '[';

foreach($_POST['tags'] as $a_tag)
{
if(isset($true[$count]))
$echoing.= '{"' . $a_tag . '" : 1},';
else
$echoing.= '{"' . $a_tag . '" : 0},';

$count++;
}

$echoing = substr($echoing, 0, -1);

$echoing.= ']';

unlink('options.json');

$myfile = 'options.json';
$fh = fopen($myfile, 'w');
fwrite($fh, $echoing);
fclose($fh);

header( 'Location: admin.php' ) ;
?>

0 comments on commit 5b86a05

Please sign in to comment.