Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

we have ourselves an app

  • Loading branch information...
commit c942228f93b17a8939be216e824647222cf174e2 1 parent af48913
Emerson Lackey authored
View
125 css/app.css
@@ -0,0 +1,125 @@
+html {
+ background: #eeeeee url('../images/background.jpg') 250px 0px repeat-x;
+ height: 100%;
+}
+
+body {
+ height: 100%;
+ background: url('../images/sidebar-background.jpg') 0px 0px repeat-y;
+ font-family: HelveticaNeue-Light, HelveticaNeue, Helvetica, Arial, sans-serif;
+ font-size: 12px;
+}
+
+#topmenu {
+ width: 100%;
+ height: 23px;
+ position: relative;
+ background: url('../images/topmenu.png') repeat-x;
+}
+
+#loader {
+ position: absolute;
+ display: none;
+ left: 30px;
+ top: 4px;
+}
+
+#topmenu ul {
+ padding: 5px 0 0 20px;
+}
+
+#topmenu li {
+ display: inline;
+ margin-right: 15px;
+}
+
+#topmenu li.abort {
+ margin-right: 150px;
+}
+
+#topmenu a, #topmenu a:visited, #topmenu a:active {
+ color: #fff;
+ padding: 1px 10px;
+ font-weight: bold;
+ text-decoration: none;
+}
+
+#topmenu a:hover {
+ background: #000;
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-radius: 8px;
+}
+
+#ajax-controls {
+ position: absolute;
+ left: 45px;
+}
+
+#localstore-controls {
+ position: absolute;
+ right: 0px;
+}
+
+#wrapper {
+ position: relative;
+}
+
+#sidebar {
+ position: absolute;
+ padding: 20px 0 20px 20px;
+ width: 380px;
+ background: url('../images/sidebar-background.jpg') 0px 0px repeat-y;
+}
+
+#content {
+ max-width: 100%;
+ padding: 20px 20px 20px 420px;
+}
+
+/* SIDEBAR */
+#nav ul {
+ font-weight: bold;
+ padding: 6px 0 0 10px;
+}
+
+#nav li a {
+ padding: 1px 8px;
+ text-decoration: none;
+}
+
+#nav li a:hover {
+ background: #bac6d6;
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-radius: 8px;
+}
+
+#nav a.current {
+ background: #ebedaf;
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-radius: 8px;
+}
+
+#nav a.current:hover {
+ background: #ebedaf;
+}
+
+#nav li a{
+ font-weight: bold;
+}
+
+#nav ul li a {
+ font-size: 12px;
+ font-weight: normal;
+}
+
+#nav li {
+ padding: 0px 0px 6px 0;
+}
+
+#nav a {
+ font-size: 13px;
+ color: #111111;
+}
View
61 css/code.css
@@ -0,0 +1,61 @@
+pre {
+ overflow: auto;
+}
+pre.code, pre.plain {
+ background: none repeat scroll 0 0 #F0F0F0;
+ display: none;
+ line-height: 1.1em;
+ overflow: auto;
+ padding: 1em 30px;
+}
+pre.diff {
+ width: 100em;
+}
+pre.shell {
+ background: none repeat scroll 0 0 black;
+ color: white;
+}
+ol.code {
+ background: #fff;
+ border-color: #F0F0F0 #D3D3D0 #D3D3D0;
+ border-top: 1px solid #D3D3D0;
+ border-right: 1px solid #D3D3D0;
+ border-style: solid;
+ border-width: 1.8em 1px 1px;
+ color: #939399;
+ font-size: 0.75em;
+ line-height: 1.8em;
+ list-style-position: inside;
+ margin: 0 0 1em;
+ overflow: auto;
+ padding: 3px 0;
+ text-align: left;
+}
+ol.code li {
+ float: left;
+ margin: 0;
+ padding: 0 0 0 1%;
+ white-space: nowrap;
+ width: 99%;
+}
+ol.code li.even {
+ background: none repeat scroll 0 0 #F3F3F0;
+}
+ol.code li code {
+ color: #CC3300;
+ font: 1.2em courier,monospace;
+ padding-left: 0.5em;
+ white-space: pre;
+}
+.code .comment {
+ color: #939399;
+}
+.code .default {
+ color: #4444CC;
+}
+.code .keyword {
+ color: #337733;
+}
+.code .string {
+ color: #CC3300;
+}
View
62 css/docs.css
@@ -0,0 +1,62 @@
+#content .node-options {
+ display: none;
+}
+
+#content .comments {
+ display: none;
+}
+
+#content a, #content a:hover, #content a:visited {
+ color: #08C;
+ text-decoration: none;
+}
+
+#content strong {
+ font-weight: bold;
+}
+
+#content em {
+ font-style: italic;
+}
+
+#content p {
+ padding-bottom: 12px;
+ line-height: 150%;
+}
+
+#content h2 {
+ font-size: 24px;
+ margin-bottom: 15px;
+ padding-bottom: 3px;
+ border-bottom: 1px dashed #dedede;
+}
+
+#content h3 {
+
+}
+
+#content ul {
+ padding-left: 35px;
+}
+
+#content ul li {
+ list-style: disc;
+ line-height: 150%;
+ padding-bottom: 8px;
+}
+
+#content ol {
+ padding-left: 35px;
+}
+
+#content ol li {
+ list-style: decimal;
+ line-height: 150%;
+ padding-bottom: 8px;
+}
+
+#content pre.code {
+ border: 1px solid #dedede;
+ padding: 15px;
+ background: #fff;
+}
View
52 css/reset.css
@@ -0,0 +1,52 @@
+/* v1.0 | 20080212 */
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ font-size: 100%;
+ vertical-align: baseline;
+ background: transparent;
+}
+body {
+ line-height: 1;
+}
+ol, ul {
+ list-style: none;
+}
+blockquote, q {
+ quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+
+/* remember to define focus styles! */
+:focus {
+ outline: 0;
+}
+
+/* remember to highlight inserts somehow! */
+ins {
+ text-decoration: none;
+}
+del {
+ text-decoration: line-through;
+}
+
+/* tables still need 'cellspacing="0"' in the markup */
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
View
BIN  images/background.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  images/background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  images/loader.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  images/sidebar-background.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  images/topmenu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
48 index.html
@@ -7,7 +7,12 @@
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="js/dump.js"></script>
- <script type="text/javascript" src="js/new-app.js"></script>
+ <script type="text/javascript" src="js/app.js"></script>
+
+ <link rel="stylesheet" type="text/css" href="css/reset.css" />
+ <link rel="stylesheet" type="text/css" href="css/docs.css" />
+ <link rel="stylesheet" type="text/css" href="css/code.css" />
+ <link rel="stylesheet" type="text/css" href="css/app.css" />
<title>CakeDocs Extreme</title>
@@ -15,23 +20,36 @@
<body>
- <div id="controls">
- <a id="start" href="#">Start</a>
- <a id="pause" href="#">Pause</a>
- </div>
-
- <hr />
-
- <div id="nav">
- </div><!-- #nav -->
+ <div id="topmenu">
+
+ <img id="loader" src="images/loader.gif" width="16" height="16" alt="loading..." />
+
+ <ul id="ajax-controls">
+ <li><a id="start" href="#">Fetch Menu</a></li>
+ <li><a id="pause" href="#">Abort</a></li>
+ </ul>
+
+ <ul id="localstore-controls">
+ <li><a id="save" href="#">Save to Localstore</a></li>
+ <li><a id="load" href="#">Load from Localstore</a></li>
+ <li><a id="clear" href="#">Clear Localstore</a></li>
+ </ul>
+
+ </div><!-- #top-menu -->
- <div id="doc">
- </div><!-- #doc -->
+ <div id="wrapper">
- <hr />
+ <div id="sidebar">
+ <ul id="nav">
+ </ul><!-- #nav -->
+ </div><!-- #sidebar -->
- <div id="debug">
- </div><!-- #debug -->
+ <div id="content">
+ <div id="doc">
+ </div><!-- #doc -->
+ <!-- #content -->
+
+ </div><!-- #wrapper -->
</body>
</html>
View
326 js/app.js
@@ -1,8 +1,252 @@
-(function($) {
- // jQuery on an empty object, we are going to use this as our Queue
- var ajaxQueue = $({});
+/*
+* Useful Variables
+* ================
+* Used as configs, flags, and an array to store our menu
+*/
+var CONFIG = {
+ cake_url: 'http://book.cakephp.org',
+ local_url: 'http://localhost'
+};
+
+var FLAGS = {
+ ajax_complete: false,
+ menu_loaded: false,
+ started: false
+};
+
+
+var ajaxQueue = $({});
+var currentRequest = false;
+
+var MENU = [];
+var PAGES = {};
+
+
+/*
+* Application Code
+* ================
+* The actual application code starts here
+*/
+$(document).ready(function() {
+
+ // INIT
+ if(localStorage.getItem('menu')) {
+ MENU = JSON.parse(localStorage.getItem('menu'));
+ paint_menu();
+ }
+
+ // $('body').css('height', $(window).height());
+
+ // CLICK EVENTS
+ $('#start').click(function(e) {
+ localStorage.removeItem('menu');
+ $('#nav').empty();
+ MENU = [];
+ populate_menu();
+ return false;
+ });
+
+ $('#pause').click(function(e) {
+ ajaxQueue.clearQueue();
+ currentRequest.abort();
+ return false;
+ });
+
+ $('#save').click(function() {
+ localStorage.setItem('menu', JSON.stringify(MENU));
+ return false;
+ });
+
+ $('#load').click(function() {
+ MENU = JSON.parse(localStorage.getItem('menu'));
+ return false;
+ });
+
+ $('#clear').click(function() {
+ localStorage.clear();
+ $('#nav').empty();
+ MENU = [];
+ return false;
+ });
+
+ $('#nav a').live('click', function() {
+
+ var this_href = this.href;
+ console.log(PAGES[this.href]);
+
+ if(!localStorage.getItem(this_href)) {
+ $('#nav a.current').removeClass('current');
+ $(this).addClass('current');
+ $.ajax({
+ url: 'load.php?url='+this.href,
+ data: null,
+ type: 'GET',
+ beforeSend: function() {
+ $('#nav a.current').append(" <span class='loading'>loading...</span>");
+ },
+ success: function(data) {
+ $('#nav a.current').find("span").remove();
+ $('#doc').html(data);
+ var images = $('#doc').find('img');
+ $.each(images, function(index, image) {
+ var src = image.src;
+ var new_src = src.replace(CONFIG['local_url'], CONFIG['cake_url']);
+ image.src = new_src; //'http://book.cakephp.org'+image.src;
+ });
+ localStorage.setItem(this_href, data);
+ }
+ });
+ }
+ else{
+ $('#nav a.current').removeClass('current');
+ $(this).addClass('current');
+ $('#doc').html(localStorage.getItem(this_href));
+ var images = $('#doc').find('img');
+ $.each(images, function(index, image) {
+ var src = image.src;
+ var new_src = src.replace(CONFIG['local_url'], CONFIG['cake_url']);
+ image.src = new_src; //'http://book.cakephp.org'+image.src;
+ });
+ }
+ // $('#doc').load('load.php?url='+this.href);
+ return false;
+ });
+
+});
- $.ajaxQueue = function(ajaxOpts) {
+// AJAX spinner
+$(document).ajaxSend(function() {
+ $('#loader').fadeIn(100);
+});
+$(document).ajaxStop(function() {
+ $('#loader').fadeOut(50);
+});
+
+/*
+* Logic Code
+* ==========
+* Various code called from the application code
+*/
+var populate_menu = function(node) {
+
+ paint_menu();
+
+ // If we were not provided with a node argument
+ if(!node) {
+
+ // retrieve the parent links
+ if(MENU.length == 0) {
+ $.ajaxQueue({
+ url: 'load.php?menu=1&url='+CONFIG['cake_url'],
+ data: null,
+ type: 'GET',
+ success: function(data) {
+ var parent_links = $(data).find('#toc ul a');
+ $.each(parent_links, function(index, item) {
+ var fixed_url = item['href'].replace(CONFIG['local_url'], CONFIG['cake_url']);
+ var node = {title: item['text'], href: fixed_url, scanned: false, children: []};
+ MENU.push(node);
+ });
+ populate_menu();
+ }
+ });
+ }
+
+ // recurisvly process the child links
+ else {
+ $.each(MENU, function(index, item) {
+ $.ajaxQueue({
+ url: 'load.php?menu=1&url='+item['href'],
+ data: null,
+ type: 'GET',
+ success: function(data) {
+ var child_links = $(data).find('#toc a.selected').next('ul').children('li').children('a');
+ $.each(child_links, function(index, child_link) {
+ var fixed_url = child_link['href'].replace(CONFIG['local_url'], CONFIG['cake_url']);
+ var child_node = {title: child_link['text'], href: fixed_url, scanned: false, children: []};
+ item['children'].push(child_node);
+ populate_menu(child_node); // starts the recursive deepth search...
+ });
+ }
+ });
+ });
+ }
+
+ }
+
+ // If we were supplied with a node argument
+ else{
+ $.ajaxQueue({
+ url: 'load.php?menu=1&url='+node['href'],
+ data: null,
+ type: 'GET',
+ success: function(data) {
+
+ var child_links = $(data).find('#toc a.selected').next('ul').children('li').children('a');
+
+ // if this node has childern
+ if( child_links.length != 0 ) {
+ // recursively process the nodes
+ $.each(child_links, function(index, item) {
+ var fixed_url = item['href'].replace(CONFIG['local_url'], CONFIG['cake_url']);
+ var child_node = {title: item['text'], href: fixed_url, scanned: false, children: [] };
+ // console.log(child_node, child_node['title']);
+ node['children'].push(child_node);
+ populate_menu(child_node);
+ });
+
+ }
+ else {
+ // move down to the next node
+ }
+
+ }
+ });
+ }
+
+ paint_menu();
+
+};
+
+var paint_menu = function() {
+ var output = [];
+ $.each(MENU, function(index, item) {
+ output.push(generate_menu(item));
+ });
+ $('#nav').html( output.join('') );
+};
+
+var generate_menu = function(item, last_item) {
+
+ var output = []; // output buffer
+ var child_count = item['children'].length - 1;
+
+
+
+ output.push("<li><a href='"+item['href']+"'>"+item['title']+"</a>");
+ if(child_count > 0) {
+ output.push("<ul>");
+ $.each(item['children'], function(index, child_item) {
+ // console.log('index: '+index+', child_count:'+child_count, 'index == child_count?');
+ if(index == child_count) {
+ output.push( generate_menu(child_item, true) );
+ }
+ else {
+ output.push( generate_menu(child_item))
+ }
+ });
+ output.push("</ul>");
+ }
+ else{
+ // if(last_item) {
+ // output.push("</ul>");
+ // }
+ output.push("</li>");
+ }
+ return output.join('');
+};
+
+$.ajaxQueue = function(ajaxOpts) {
// hold the original complete function
var oldComplete = ajaxOpts.complete;
@@ -18,76 +262,6 @@
};
// run the query
- $.ajax(ajaxOpts);
+ currentRequest = $.ajax(ajaxOpts);
});
- };
-
-})(jQuery);
-
-var config = {
- cake_domain: 'http://book.cakephp.org',
- local_domain: 'http://localhost'
-};
-
-var navigation = [];
-var timer = false;
-
-$('document').ready(function() {
-
- init();
-
-});
-
-// Initialize our application
-var init = function() {
- $.ajaxQueue({url:'load.php?url='+config['cake_domain'], data: null, type: 'GET', success: function(data) {
-
- // Scrape the parent items
- var links = $(data).find('#toc ul a');
-
- console.log(navigation, 'top level');
-
- // Loop through the parents
- $.each(links, function(index, item) {
-
- // Add each parent to our navigation array
- var fixed_url = item['href'].replace(config['local_domain'], config['cake_domain']);
-
- var node = {title: item['text'], href: fixed_url, scanned: false };
-
- get_children(node);
-
- navigation.push( node );
-
- console.log(navigation, 'process nav');
-
- });
- console.log(navigation, 'final nav');
-
- }});
-};
-
-// Returns true if the navigation array has unscanned links
-var get_children = function(node) {
-
- $.ajaxQueue({url:'load.php?url='+node.href, data: null, type: 'GET', success: function(data) {
-
- var collector = [];
- var child_items = $(data).find('#toc a.selected').next('ul').children('li').children('a');
- $.each(child_items, function(index, item) {
-
- var fixed_url = item['href'].replace(config['local_domain'], config['cake_domain']);
- var child_node = {title: item['text'], href: fixed_url, scanned: false };
-
- console.log(child_node, 'processing child');
-
- get_children(child_node);
-
- collector.push(child_node);
- });
-
- node['children'] = collector;
- node['scanned'] = true;
- }});
-
-};
+ };
View
24 load.php
@@ -1,18 +1,20 @@
<?php
+
require 'simple_html_dom.php';
+
if(!empty($_GET['url'])) {
- $url = $_GET['url'];
+ $url = $_GET['url'];
$html = file_get_html($url);
- $menu = $html->find('#side', 0);
- echo($menu);
- // $handle = fopen($url, 'r');
- // if($handle):
- // while(!feof($handle)):
- // $buffer = fgets($handle, 4096);
- // echo $buffer;
- // endwhile;
- // fclose($handle);
- // endif;
+
+ if(!empty($_GET['menu'])) {
+ $output = $html->find('#side', 0);
+ }
+ else{
+ $output = $html->find('#body .view', 0);
+ }
+
+ echo($output);
+
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.