Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fadhly-permata committed May 26, 2017
1 parent 2971f12 commit 6ca22cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
21 changes: 4 additions & 17 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
specialMime: {
markdown: ['markdown', 'mdown', 'mkdn', 'md', 'mkd', 'mdwn', 'mdtxt', 'mdtext', 'text'],
images: ['jpg', 'jpeg', 'gif', 'png', 'bmp'],
image: ['jpg', 'jpeg', 'gif', 'png', 'bmp'],
markup: ['htm', 'html', 'xhtml']
},
githubDataBuffer: null
Expand Down Expand Up @@ -123,10 +123,10 @@
setHighlight: function(target) {
$('.sidebar ul.nav li').removeClass('active');

var tLi = target.parent();
let tLi = target.parent();
tLi.addClass('active');

var tParent = tLi.parents('li');
let tParent = tLi.parents('li');
while (tParent.length > 0) {
tParent.addClass('active hide-before-after');
tParent = tParent.parents('li');
Expand Down Expand Up @@ -154,27 +154,14 @@
if (!s.useDummyData)
octaDoc.helper.github.getFilesAndDirFromDocDir(function(data) {
dataProcessor(data);
// s.githubDataBuffer = data;

// data = octaDoc.helper.dataParser.sideMenu.menuDataBuilder(data.tree);
// data = octaDoc.ui.sideMenu.build.constructDom(data);

// if (cb) cb(data);
});

else {
_o_.ajax.get({
url: _o_.string.concat('dummy-menu.json?random=', Math.floor(Math.random() * 10000)),
success: function(xhr) {
if (!xhr.responseText) return;

xhr = JSON.parse(xhr.responseText);
// s.githubDataBuffer = xhr;

// xhr = octaDoc.helper.dataParser.sideMenu.menuDataBuilder(xhr.tree);
// xhr = octaDoc.ui.sideMenu.build.constructDom(xhr);

// if (cb) cb(xhr);
dataProcessor(xhr);
}
});
Expand Down Expand Up @@ -288,7 +275,7 @@
$('a#document-title').text(data);
},
content: function(data) {
if (s.specialMime.images.indexOf(data.extension) !== -1) {
if (s.specialMime.image.indexOf(data.extension) !== -1) {
$('div#document-wrapper').html(
_o_.string.format('<img class="center-block" src="data:image/{1};base64,{2}" />', data.extension, data.content)
);
Expand Down
Loading

0 comments on commit 6ca22cf

Please sign in to comment.