|
@@ -1,28 +1,36 @@
|
|
|
$(function() {
|
|
|
|
|
|
+
|
|
|
+ $('select[name="document"]').change(function(e){
|
|
|
+ console.log("document selection",this);
|
|
|
+ $('iframe').attr('src', this.value);
|
|
|
+ });
|
|
|
+
|
|
|
$.getJSON('build/toc.json', function(data){
|
|
|
- // console.log(data);
|
|
|
- for (book of data) {
|
|
|
- // console.log(book);
|
|
|
- // var $optgroup = $('<optgroup>').attr('label', book.label);
|
|
|
- // for (page of book.pages) {
|
|
|
+ console.log(data);
|
|
|
+ for (book in data) {
|
|
|
+ console.log(data[book]);
|
|
|
+ // var $optgroup = $('<optgroup>').attr('label', data[book].label);
|
|
|
+ // for (page of data[book].pages) {
|
|
|
// // console.log(page);
|
|
|
- // $optgroup.append($('<option>').attr('value', book.label+'/'+page.file).text(book.label+' : '+page.label));
|
|
|
+ // $optgroup.append($('<option>').attr('value', data[book].label+'/'+page.file).text(data[book].label+' : '+page.label));
|
|
|
// }
|
|
|
$('[name="document"]').append(
|
|
|
$('<option>')
|
|
|
- .attr('value', book.file).text(book.label)
|
|
|
+ .attr('value', data[book].file).text(data[book].label)
|
|
|
);
|
|
|
}
|
|
|
- })
|
|
|
|
|
|
- $('select[name="document"]').change(function(e){
|
|
|
- // console.log(e);
|
|
|
- // var optionSelected = $("option:selected", this);
|
|
|
- // var valueSelected = ;
|
|
|
- // console.log(this.value);
|
|
|
- $('iframe').attr('src', this.value);
|
|
|
- });
|
|
|
+ console.log(window.location.hash);
|
|
|
+
|
|
|
+ var hash = parseInt(window.location.hash.replace('#',''));
|
|
|
+ console.log(hash);
|
|
|
+
|
|
|
+ var value = $('[name="document"] option:eq('+hash+')').attr('value');
|
|
|
+ console.log('value', value);
|
|
|
+
|
|
|
+ $('[name="document"]').val(value).change();
|
|
|
+ })
|
|
|
|
|
|
// activate toolbar events when iframe is loaded
|
|
|
$('iframe').load(function() {
|