Skip to content

Instantly share code, notes, and snippets.

@oampo
Created June 10, 2014 15:12
Show Gist options
  • Save oampo/f7c18ce5e76151cbaf93 to your computer and use it in GitHub Desktop.
Save oampo/f7c18ce5e76151cbaf93 to your computer and use it in GitHub Desktop.
Local #crumbs #draft
var Local = function() {
var path = document.location.pathname.split("/");
path = path[4];
var ajax = $.ajax({
url: "/" + path + "/files"
});
ajax.done(this.onGetFiles.bind(this));
this.data = {
description: decodeURI(path) + "#no-index #crumbs",
id: 0,
index: null,
files: {}
}
};
Local.EXTENSION_LANGUAGES = {
md: "Markdown",
html: "HTML",
json: "JSON",
handlebars: "Handlebars",
css: "CSS",
js: "JavaScript"
};
Local.prototype.onGetFiles = function(files) {
for (var i=0; i<files.length; i++) {
var path = files[i];
var filename = path.substr(path.lastIndexOf('/') + 1);
var extension = filename.substr(filename.lastIndexOf('.') + 1);
this.data.files[filename] = {
raw_url: path,
language: Local.EXTENSION_LANGUAGES[extension],
local: true
}
}
main.gist = new Gist(main, this.data);
main.load();
};
main.onFadeInStart = function() {
local = new Local();
};
main.onFadeOutEnd = function() {
local = null;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment