Modified controllers to be more effective

This commit is contained in:
2017-10-06 10:33:38 +07:00
parent 8216958622
commit c3be5ebaa3
6 changed files with 22 additions and 110 deletions

View File

@@ -1,18 +0,0 @@
let m = require('mithril')
let post = require('../models/post')
let listAdmin = require('./listAdmin')
var allpost = {
oninit: function() {
post.curStatus = 3
post.loadList()
setInterval(function() {
post.loadList()
}, post.interval)
},
view: function() {
return m(listAdmin)
}
}
module.exports = allpost

View File

@@ -1,18 +0,0 @@
let m = require('mithril')
let post = require('../models/post')
let listAdmin = require('./listAdmin')
var inactivepost = {
oninit: function() {
post.curStatus = 0
post.loadList()
setInterval(function() {
post.loadList()
}, post.interval)
},
view: function() {
return m(listAdmin)
}
}
module.exports = inactivepost

View File

@@ -2,9 +2,9 @@ let m = require('mithril')
let post = require('../models/post')
let listAdmin = require('./listAdmin')
var activepost = {
oninit: function() {
post.curStatus = 1
var showPost = {
oninit: function(vnode) {
post.curStatus = vnode.attrs.status
post.loadList()
setInterval(function() {
post.loadList()
@@ -15,4 +15,4 @@ var activepost = {
}
}
module.exports = activepost
module.exports = showPost

View File

@@ -1,18 +0,0 @@
let m = require('mithril')
let post = require('../models/post')
let listAdmin = require('./listAdmin')
var soonpost = {
oninit: function() {
post.curStatus = 2
post.loadList()
setInterval(function() {
post.loadList()
}, post.interval)
},
view: function() {
return m(listAdmin)
}
}
module.exports = soonpost

View File

@@ -1,19 +1,15 @@
let m = require('mithril')
let allPost = require('./components/allPost')
let activePost = require('./components/activePost')
let soonPost = require('./components/soonPost')
let inactivePost = require('./components/inactivePost')
let secondaryNav = require('./components/secondaryNav')
let showPost = require('./components/showPost')
var root = document.getElementById('mit')
m.mount(document.getElementById('navigasi'), secondaryNav)
m.route(root, '', {
'': allPost,
'/': allPost,
'/active': activePost,
'/soon': soonPost,
'/inactive': inactivePost,
'': { view: function() { return m(showPost, { 'status': 3 }) } },
'/': { view: function() { return m(showPost, { 'status': 3 }) } },
'/active': { view: function() { return m(showPost, { 'status': 1 }) } },
'/soon': { view: function() { return m(showPost, { 'status': 2 }) } },
'/inactive': { view: function() { return m(showPost, { 'status': 0 }) } },
})