Skip to content

Instantly share code, notes, and snippets.

// Handles JavaScript history management and callbacks. To use, register a
// regexp that matches the history hash with its corresponding callback:
//
// dc.history.register(/^#search/, controller.runSearch);
//
// And then you can save arbitrary history fragments.
//
// dc.history.save('search/freedom/p3');
//
DV.history = {
# TODO: Think of a name for this crazy thing.
# Functions:
square: x => x * x.
sum: x, y => x + y.
odd: x => x % 2 is 0.
even: x => x % 2 aint 0.
(function(){
var square = function(x) {
return (x * x);
};
var sum = function(x, y) {
return (x + y);
};
var odd = function(x) {
return ((x % 2) === 0);
};
updateNavigation : function(sections) {
DV.Schema.data.chapters = [];
_.each(sections, function(sec) {
sec.id = _.uniqueId();
sec.pages = '' + sec.start_page + '-' + sec.end_page;
_.each(_.range(sec.start_page-1, sec.end_page), function(i){
DV.Schema.data.chapters[i] = sec.id;
});
});
DV.controller.models.chapters.chapters = DV.Schema.data.chapters;
dc.ui.Dialog = dc.View.extend({
className : 'dialog',
callbacks : [
['.cancel', 'click', 'cancel'],
['.ok', 'click', 'confirm']
],
constructor : function(options) {
<div class="title"><%= title %></div>
<% if (text) { %>
<div class="text"><%= text %></div>
<% } %>
<% if( mode == 'prompt' || mode == 'short_prompt') { %>
<div class="<%= mode %>">
<% if( mode == 'prompt') { %>
<textarea class="content"></textarea>
<% } else { %>
<input class="content" type="text" value="" />
/////////////////////////////////////////////////////////////////////////////
// The public DocumentViewer API. Available for other scripts to access:
/////////////////////////////////////////////////////////////////////////////
// Return the total number of pages in the document.
DV.controller.numberOfPages = function() {
return this.models.document.totalPages;
};
// Change the documents' sections, re-rendering the navigation. "sections"
redraw : function(stopResetOfPosition){
// console.log('forcing')
this.pages['p0'].draw({ force: true });
this.pages['p1'].draw({ force: true });
this.pages['p2'].draw({ force: true });
if(this.application.state != 'InitialLoad' && !stopResetOfPosition){
this.application.helpers.jumpTo(this.application.models.document.currentIndex());
}
},
# Any list of expressions or method body, seperated by line breaks or semis.
Expressions:
Expression { result = Nodes.new(val) }
| Expressions Terminator Expression { result = val[0] << val[2] }
| Expressions Terminator { result = val[0] }
| Terminator Expressions { result = val[1] }
;
state 67
5) Expressions : Expressions _ Terminator Expression
6) Expressions : Expressions _ Terminator
7) Expressions : Terminator Expressions _
"\n" shift, and go to state 23
"\n" [reduce using rule 7 (Expressions)]
";" shift, and go to state 29
";" [reduce using rule 7 (Expressions)]