Permalink
Browse files

renamed some files and db tables to be a little more agnostic. also h…

…ooked up the json feed of apps to build the app library
  • Loading branch information...
1 parent 4507524 commit 1d7302bde05510e1a8f9038febd03269c9847dd0 @jasonmcleod committed Jul 20, 2011
Showing with 80 additions and 46 deletions.
  1. +42 −37 index.html
  2. +9 −9 system/php/inc.init.php
  3. +29 −0 system/php/json.apps.php
View
@@ -18,20 +18,19 @@
#container {
position:absolute;
}
- .cover {
- /*float:left;*/
+ .app {
position:absolute;
width:100px;
height:100px;
background:#fafafa;
margin:5px;
}
- .cover h1 {
+ .app h1 {
color:#eee;
vertical-align:middle;
text-align:center;
}
- .cover.selected {
+ .app.selected {
border:2px solid #eee;
}
</style>
@@ -53,41 +52,47 @@
var coverWidth = 360;
var coverHeight = 225;
var margin = 20;
- var perRow = 6;
+ var perRow = 5;
var camera = 0;
var selected = 0;
var wave = true;
var row = -1;
var prevRow = 0;
- var covers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
+
+ //var covers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
+ var apps = [];
$(function() {
- winWidth = $(window).width();
- winHeight = $(window).height();
- coverScale = winWidth / coverWidth / (perRow+1);
- offset = winWidth - (((coverWidth-margin) * coverScale) * perRow);
-
- camera = 0 * ((coverHeight+margin*2) * coverScale) - winHeight/2 + coverHeight/2 - margin*2
-
- var yOffset = -1;
- for(var c = 0; c < covers.length; c++) {
- if(c%perRow==0) { yOffset++; }
- $cover = $('<div class="cover" row="' + yOffset + '" cover="' + c + '"><h1>' + c + '</h1></div>');
- $cover.css({
- left:((coverWidth*coverScale) + margin) * (c%perRow),
- top:yOffset*(coverScale*coverHeight+margin) - camera,
- width:coverWidth*coverScale,
- height:coverHeight*coverScale
- });
- $('#container').append($cover);
- }
-
- var xOffset = $('.cover:eq(' + (perRow-1) + ')').position().left + $('.cover:eq(' + (perRow-1) + ')').width()
-
- $('#container').css({left:(winWidth - xOffset)/2})
-
- $('.cover:first').addClass('selected')
+ $.getJSON('system/php/json.apps.php',function(msg) {
+ apps = msg;
+
+ winWidth = $(window).width();
+ winHeight = $(window).height();
+ coverScale = winWidth / coverWidth / (perRow+1);
+ offset = winWidth - (((coverWidth-margin) * coverScale) * perRow);
+
+ camera = 0 * ((coverHeight+margin*2) * coverScale) - winHeight/2 + coverHeight/2 - margin*2
+
+ var yOffset = -1;
+ for(var a = 0; a < apps.length; a++) {
+ if(a%perRow==0) { yOffset++; }
+ $app = $('<div class="app" row="' + yOffset + '" app="' + a + '"><h1>' + a + '</h1></div>');
+ $app.css({
+ left:((coverWidth*coverScale) + margin) * (a%perRow),
+ top:yOffset*(coverScale*coverHeight+margin) - camera,
+ width:coverWidth*coverScale,
+ height:coverHeight*coverScale
+ });
+ $('#container').append($app);
+ }
+
+ var xOffset = $('.app:eq(' + (perRow-1) + ')').position().left + $('.app:eq(' + (perRow-1) + ')').width()
+
+ $('#container').css({left:(winWidth - xOffset)/2});
+ $('.app:first').addClass('selected');
+
+ });
$(document).keydown(function(e) {
var moved = false;
@@ -111,19 +116,19 @@
// out of range prevention
if(selected<0) { selected=0; }
- if(selected>covers.length-1) { selected = covers.length-1}
+ if(selected>apps.length-1) { selected = apps.length-1}
$('.selected').removeClass('selected');
- $('.cover:eq(' + selected + ')').addClass('selected');
+ $('.app:eq(' + selected + ')').addClass('selected');
row = $('.selected').attr('row')
if(prevRow!=row) {
camera = row * ((coverHeight+margin*2) * coverScale) - winHeight/2 + coverHeight/2 - margin*2
prevRow = row;
+ slideCovers();
}
if(moved) {
- slideCovers();
e.preventDefault();
}
@@ -132,8 +137,8 @@
});
function slideCovers() {
- for(var c = 0; c < covers.length; c++) {
- $this = $('.cover[cover="' + c + '"]');
+ for(var a = 0; a < apps.length; a++) {
+ $this = $('.app[app="' + a + '"]');
setTimeout(function($elm) {
$elm.animate({
top:$elm.attr('row') * ((coverHeight+margin*2) * coverScale) - camera
@@ -142,7 +147,7 @@
duration:wave?1000:500,
easing:wave?'easeOutQuint':'easeOutSine'
})
- },(wave?c*20:20),$this);
+ },(wave?a*20:20),$this);
};
}
View
@@ -1,28 +1,28 @@
<?
error_reporting(E_ALL);
ini_set('show_errors','on');
-
+
$hostname_emu = "localhost";
- $database_emu = "emulators";
+ $database_emu = "iplaywinner";
$username_emu = "root";
- $password_emu = "root";
-
+ $password_emu = "root";
+
$emu = mysql_pconnect($hostname_emu, $username_emu, $password_emu) or trigger_error(mysql_error(),E_USER_ERROR);
-
+
function query($query,$debug=false) {
if($debug) {
- echo "<pre>$query</pre>";
+ echo "<pre>$query</pre>";
}
-
+
global $database_emu, $emu;
$return = array();
-
+
mysql_select_db($database_emu, $emu);
$thisQuery = mysql_query($query, $emu) or die(mysql_error());
$return['total'] = mysql_num_rows($thisQuery);
$return['data'] = mysql_fetch_assoc($thisQuery);
$return['object'] = $thisQuery;
-
+
return $return;
}
?>
View
@@ -0,0 +1,29 @@
+<?
+ include('inc.init.php');
+
+ $rows = query("SELECT * FROM apps ORDER BY title ASC");
+ if($rows['total']>0) {
+
+ $output = "[";
+ do {
+ $output.= "{";
+ foreach($rows['data'] as $key => $value) {
+ if($key!="password") {
+ // if its a number or an array don't wrap it in quotes
+ if(is_numeric($value) || substr($value,0,1)=="[" && substr($value,strlen($value)-1,1) == "]") {
+ $output.= '"' . $key . '":' . $value . ',';
+ } else {
+ $output.= '"' . $key . '":"' . str_replace('"','\"',$value) . '",';
+ }
+ }
+ }
+ $output= substr($output,0,strlen($output)-1);
+ $output.="},\n";
+ } while ($rows['data'] = mysql_fetch_assoc($rows['object']));
+ $output = substr($output,0,strlen($output)-2);
+ $output.= "]";
+
+ echo $output;
+ }
+
+?>

0 comments on commit 1d7302b

Please sign in to comment.