+ self.buildFullTOC = function () {
+
+ var build_sections = function (doc) {
+ var res = [];
+ var h1s = doc.find("body").first().children("h1");
+ var slides = doc.find("body").first().children(".sws-slide");
+ var slide_num = 1;
+ var collection = h1s.add(slides);
+ collection.each (function () {
+ if ($(this).is("h1")) {
+ res.push({ 'title' : $(this).text(),
+ 'slide' : slide_num });
+ } else {
+ slide_num++;
+ }
+ });
+ return res;
+ };
+
+ var toc = [];
+
+ var append = function (a,e) {
+ return a.push(e);
+ };
+ var prepend = function (a,e) {
+ return a.unshift(e);
+ };
+
+ var loop = function (doc, dir, add, ignoreFirst) {
+ if (ignoreFirst !== true) {
+ var this_toc = { 'title' : doc.find("title").first().text(),
+ 'sections' : build_sections(doc) };
+ add(toc, this_toc);
+ };
+ var url = doc.find(dir).first().attr("href");
+ if (!SWS.Utils.isUndefined(url) && url != "") {
+ $.ajax({ 'url' : url, 'async' : false ,'success' : function (page) {
+ loop ($(page), dir, add, false);
+ }});
+ };
+ };
+ loop ($(document), ".sws-previous", prepend, false);
+ return toc;
+
+ };
+
+