$(function() { // our document model - stores the datastructure generated from docurium var Docurium = Backbone.Model.extend({ defaults: {'version': 'unknown'}, initialize: function() { this.loadVersions() }, loadVersions: function() { $.getJSON("project.json", function(data) { docurium.set({'versions': data.versions, 'github': data.github, 'signatures': data.signatures, 'name': data.name, 'groups': data.groups}) if(data.name) { $('#site-title').text(data.name + ' API') document.title = data.name + ' API' } docurium.setVersionPicker() docurium.setVersion() }) }, setVersionPicker: function () { vers = docurium.get('versions') $('#version-list').empty().hide() for(var i in vers) { version = vers[i] vlink = $('').attr('href', '#' + version).append(version).click( function() { $('#version-list').hide(100) }) $('#version-list').append($('
  • ').append(vlink)) } vlink = $('').attr('href', '#' + 'p/changelog').append("Changelog").click ( function () { $('#version-list').hide(100) }) $('#version-list').append($('
  • ').append(vlink)) }, setVersion: function (version) { if(!version) { version = _.first(docurium.get('versions')) } if(docurium.get('version') != version) { docurium.set({'version': version}) $('#site-title').attr('href', '#' + version) docurium.loadDoc() } }, loadDoc: function() { version = this.get('version') $.ajax({ url: version + '.json', context: this, dataType: 'json', success: function(data){ this.set({'data': data}) Backbone.history.start() } }) }, collapseSection: function(data) { $(this).next().toggle(100) return false }, showIndexPage: function(replace) { version = docurium.get('version') ws.navigate(version, {replace: replace}) data = docurium.get('data') content = $('.content') content.empty() content.append($('

    ').append("Public API Functions")) sigHist = docurium.get('signatures') // Function Groups for (var i in data['groups']) { group = data['groups'][i] content.append($('

    ').addClass('funcGroup').append(group[0])) list = $('

    ').addClass('functionList') for(var j in group[1]) { fun = group[1][j] link = $('').attr('href', '#' + groupLink(group[0], fun)).append(fun) if(sigHist[fun].changes[version]) { link.addClass('changed') } if(version == _.first(sigHist[fun].exists)) { link.addClass('introd') } list.append(link) if(j < group[1].length - 1) { list.append(', ') } } content.append(list) } }, getGroup: function(gname) { var groups = docurium.get('data')['groups'] for(var i in groups) { if(groups[i][0] == gname) { return groups[i] } } }, showFun: function(gname, fname) { group = docurium.getGroup(gname) fdata = docurium.get('data')['functions'] gname = group[0] functions = group[1] content = $('.content') content.empty() // Show Function Name content.append($('

    ').addClass('funcTitle').append(fname)) if(fdata[fname]['description']) { sub = content.append($('

    ').addClass('funcDesc').append( ' ' + fdata[fname]['description'] )) } // Show Function Arguments argtable = $('').addClass('funcTable') args = fdata[fname]['args'] for(var i=0; i') row.append($('
    ').attr('valign', 'top').attr('nowrap', true).append(this.hotLink(arg.type))) row.append($('').attr('valign', 'top').addClass('var').append(arg.name)) row.append($('').addClass('comment').append(arg.comment)) argtable.append(row) } content.append(argtable) // Show Function Return Value retdiv = $('
    ').addClass('returns') retdiv.append($('

    ').append("returns")) rettable = $('').addClass('funcTable') retrow = $('') rettable.append(retrow) retdiv.append(rettable) ret = fdata[fname]['return'] retrow.append($('
    ').attr('valign', 'top').append(this.hotLink(ret.type))) if(ret.comment) { retrow.append($('').addClass('comment').append(ret.comment)) } content.append(retdiv) // Show Non-Parsed Function Comments if (fdata[fname]['comments']) content.append($('
    ').append(fdata[fname]['comments'])) // Show Function Signature ex = $('').addClass('params') ex.append(this.hotLink(fdata[fname]['return']['type'] + ' ' + fname + '(' + fdata[fname]['argline'] + ');')) example = $('
    ').addClass('example') example.append($('

    ').append("signature")) example.append(ex) content.append(example) // Show Function History sigs = $('
    ').addClass('signatures') sigs.append($('

    ').append("versions")) sigHist = docurium.get('signatures')[fname] var list = $('