Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.controller = () => {
m.redraw.strategy('diff');
// use flexible routing to support nested route calls (f.i. in the dialog and tabs examples)
const route = getRouteBase(m.route());
const link = linkMap[route];
app.vm.module(getNewModule(link));
const linkName = link && link.name ? link.name : 'index';
app.vm.moduleName = linkName;
const baseTitle = 'Polythene Examples';
document.title = linkName ? (baseTitle + ': ' + linkName) : baseTitle;
};
*/
var m = require('mithril'),
sugartags = require('../server/mithril.sugartags.node.js')(m),
bindings = require('../server/mithril.bindings.node.js')(m),
store = require('../server/store.js'),
//getParam = require('../server/get')
home = require('../c/home'),
user = require('../c/user');
// Expose to window
// if(typeof window !== "undefined") {
// window.m = m;
// }
m.route.mode = "pathname";
m.route(document.body, '/', {
"/": {
controller: home.home,
view: function(ctrl){
with(sugartags) {
return DIV({ hover: [ctrl.set(ctrl.rotate, 225), ctrl.set(ctrl.rotate, 0)] }, [
DIV('Hello ', ctrl.name, { rotate: ctrl.rotate }),
A({ href: '/user/1', config: m.route}, "User")
])
}
}
},
"/user/:user_id":{
controller: user.edit,
view: function(ctrl){
with(sugartags) {
return DIV('Hello ' + ctrl.user.name + '! Server: ' + ctrl.isServer)
controller : function() {
/* eslint consistent-return: 0 */
if(config.auth && !valid()) {
return m.route(prefix("/login") + window.location.search);
}
},
setTimeout(function() {
m.route(u);
}, 10);
}
const slide = (opts) => {
const sliderId = opts.slider || DEFAULT_SLIDER_ID;
const vm = getViewModel(sliderId);
if (vm.hasTransition()) {
return;
}
const route = opts.route || m.route();
const id = opts.id || route;
const currentId = vm.currentId();
if (currentId !== undefined && currentId === id && vm.current()) {
return;
}
const transition = {
page: opts.page,
id: id,
route: route,
done: opts.done,
direction: opts.direction || DIRECTION_FORWARD,
duration: opts.duration || DEFAULT_DURATION
};
vm.orientation(opts.rtl ? RTL_ORIENTATION : DEFAULT_ORIENTATION);
if (!vm.current()) {
ctrl.add = function() {
var result;
result = db.child("content/" + ctrl.schema.key).push({
created_at : db.TIMESTAMP,
created_by : db.getAuth().uid
});
m.route(prefix("/content/" + ctrl.schema.key + "/" + result.key()));
};
m('span.subtitle', menuItem.subtitle)
]));
})
]);
let app = {};
app.view = () => {
return m('.index', [
m('h1', 'Content Slider for Mithril'),
menu,
github({home: true})
]);
};
m.route.mode = 'hash';
m.route(document.body, '/', {
'/': app,
'/images': images,
'/vertical': vertical,
'/controls': controls,
'/ltr': ltr,
'/group': group,
'/pages': pages,
'/multiple': multiple
});
this.updateSearch = function(e) {
e.preventDefault();
m.route("/query/"+encodeURIComponent(_this.query()));
};
};
const getNewModule = (ln) => {
if (!ln) {
return null;
}
const dynMod = ln.module;
return dynMod ? (dynMod.subview ? dynMod.subview(m.route()) : dynMod) : null;
};
'/admins': {controller: () => m.route('/admins/all')},
'/admins/all': navPage(require('./pages/admins')),