Skip to content

Commit c8fb4d3

Browse files
committed
rework all documentation so that it can be published both on jsonselect.org and is viewable on github
1 parent 271d5bb commit c8fb4d3

File tree

7 files changed

+1394
-22
lines changed

7 files changed

+1394
-22
lines changed

JSONSelect_1.md renamed to JSONSelect.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
# JSONSelect 1
1+
**WARNING**: This document is a work in progress, just like JSONSelect itself.
2+
View or contribute to the latest version [on github](http://github.com/lloyd/JSONSelect/blob/master/JSONSelect.md)
23

3-
## Features
4+
# JSONSelect
45

5-
JSONSelect level 1 includes the following constructs, mostly from CSS3
6-
but with some differences.
6+
1. [introduction](#introduction)
7+
1. [language overview](#overview)
8+
1. [grouping](#grouping)
9+
1. [selectors](#selectors)
10+
1. [pseudo classes](#pseudo)
11+
1. [combinators](#combinators)
12+
1. [planned additions](#additions)
13+
1. [grammar](#grammar)
14+
15+
## Introduction<a name="introduction"></a>
16+
17+
## Language Overview<a name="overview"></a>
718

819
* `string` -- type selectors
920
* `*` -- the universal type selector
@@ -23,8 +34,27 @@ but with some differences.
2334
* `object string` -- a descendant combinator
2435
* `#bar > string` -- a child combinator
2536

37+
## Grouping<a name="grouping"></a>
38+
39+
## Selectors<a name="selectors"></a>
40+
41+
## Psuedo Classes<a name="pseudo"></a>
42+
43+
## Combinators<a name="combinators"></a>
44+
45+
## Planned Additions<a name="additions"></a>
46+
47+
* `boolean#enabled ~ #email` -- a general sibling operator,
48+
*without the ordering requirement*
49+
* `:not()`
50+
* `:has()`
51+
* `[=value]` a node with a value of exactly `value`
52+
* `[^=value]` a node whose value starts with `value`
53+
* `[$=value]` a node whose value ends with `value`
54+
* `[*=value]` a node whose value contains the substring `value`
55+
2656

27-
## A Semi-Formal Grammar
57+
## Grammar<a name="grammar"></a>
2858

2959
(Adapted from [CSS3](http://www.w3.org/TR/css3-selectors/#descendant-combinators) and
3060
[json.org](http://json.org/))

JSONSelect_2.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

site/JSONSelect.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../JSONSelect.md

site/css/style.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ div.content {
7777
font-size: 90%;
7878
}
7979

80+
#docs {
81+
margin-top: 140px;
82+
}
83+
8084
#splash .sample tt {
8185
font-size: 90%;
8286
padding: 0 .2em 0 .2em;
@@ -172,4 +176,3 @@ pre.doc {
172176
padding-top: 2em;
173177
}
174178

175-
#cred > pre {

site/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,15 @@
107107
<p><a href="http://json.org/">JSON</a> and <a href="http://www.w3.org/TR/css3-selectors/">CSS3 Selectors</a> are the prerequisites to JSONSelect's existence, so thanks to you guys too.</p>
108108
<p></p>
109109
</div>
110+
<div style="display: none" id="docs" class="content">
111+
Loading documentation...
112+
</div>
110113
</div>
111114

115+
112116
<a href="https://github.com/lloyd/JSONSelect"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://d3nwyuy0nl342s.cloudfront.net/img/4c7dc970b89fd04b81c8e221ba88ff99a06c6b61/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub"></a>
113117
</body>
118+
<script src="js/showdown.js"></script>
114119
<script src="js/jquery-1.6.1.min.js"></script>
115120
<script src="js/jquery.ba-hashchange.min.js"></script>
116121
<script src="js/jsonselect.js"></script>

site/js/nav.js

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,63 @@
11
$(document).ready(function() {
2-
// Bind the event.
3-
$(window).hashchange(function(){
4-
// Alerts every time the hash changes!
5-
$("#main > .content").hide();
2+
var docsLoaded = false;
3+
4+
$(window).hashchange(function(e){
5+
e.preventDefault();
6+
e.stopPropagation();
7+
68
if (location.hash === "#tryit") {
9+
$("#main > .content").hide();
710
$("#tryit input").val("").keyup();
811
$("#tryit").fadeIn(400, function() {
912
$("#tryit input").val(".languagesSpoken .language").keyup();
1013
});
1114
} else if (location.hash === "#cred") {
1215
$("#main > .content").hide();
1316
$("#cred").fadeIn(400);
14-
} else {
17+
} else if (location.hash === '#overview' || location.hash === '') {
18+
$("#main > .content").hide();
1519
$("#splash").fadeIn(400);
20+
} else if (location.hash.substr(0,5) === "#docs") {
21+
function showIt() {
22+
var where = window.location.hash.substr(6);
23+
console.log("scrollIt: " + where);
24+
if (!where) {
25+
$("#docs").fadeIn(400);
26+
} else {
27+
$("#docs").show();
28+
var dst = $("a[name='" + where + "']");
29+
if (dst.length) {
30+
console.log("want scrolltop: ", dst.offset().top - 100);
31+
$('html, body').animate({scrollTop:dst.offset().top - 100}, 500);
32+
}
33+
}
34+
}
35+
$("#main > .content").hide();
36+
if (!docsLoaded) {
37+
$.get("JSONSelect.md").success(function(data) {
38+
var converter = new Showdown.converter();
39+
$("#docs").html(converter.makeHtml(data));
40+
$("#docs a").each(function() {
41+
var n = $(this).attr('href');
42+
if (typeof n === 'string' && n.substr(0,1) === '#') {
43+
$(this).attr('href', "#docs/" + n.substr(1));
44+
}
45+
});
46+
docsLoaded = true;
47+
showIt();
48+
}).error(function() {
49+
$("#docs").text("Darnit, error fetching docs...").fadeIn(400);
50+
});
51+
} else {
52+
showIt();
53+
}
54+
} else {
1655
}
56+
return false;
1757
});
1858

1959
// Trigger the event (useful on page load).
60+
if (window.location.hash === "")
61+
window.location.hash = "#overview";
2062
$(window).hashchange();
2163
});

0 commit comments

Comments
 (0)