45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
|
//import fh from 'filehound';
|
||
|
import fs from 'fs-extra';
|
||
|
//import metadataParser from 'markdown-yaml-metadata-parser';
|
||
|
import _ from 'lodash';
|
||
|
import * as DataEvent from '../../src/com/events/DataEvent';
|
||
|
//const moment = require('moment');
|
||
|
|
||
|
export default class Navigation {
|
||
|
//--------------------------
|
||
|
// constructor
|
||
|
//--------------------------
|
||
|
constructor() {}
|
||
|
//--------------------------
|
||
|
// methods
|
||
|
//--------------------------
|
||
|
start() {}
|
||
|
|
||
|
editMenu(task, item) {
|
||
|
switch (task) {
|
||
|
case DataEvent.MENU_ADD_ITEM:
|
||
|
break;
|
||
|
case DataEvent.MENU_DELETE_ITEM:
|
||
|
fs.readJSON('site/settings.json').then(settings => {
|
||
|
settings.menu = _.remove(settings.menu, m => {
|
||
|
return m.uuid != item.uuid;
|
||
|
});
|
||
|
fs.writeJSON('site/settings.json', settings);
|
||
|
});
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
updatePageStats() {
|
||
|
fs.readJSON('site/settings.json').then(settings => {
|
||
|
settings.library_stats.current_index = ++settings.library_stats.current_index;
|
||
|
settings.library_stats.total_pages = ++settings.library_stats.total_pages;
|
||
|
fs.writeJSON('site/settings.json', settings);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
//--------------------------
|
||
|
// event handlers
|
||
|
//--------------------------
|
||
|
}
|