This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tabset = function tabset(tabnames, active) { | |
return m("ul", { className: "nav nav-tabs" }, tabnames.map(function (tab) { | |
return m("li", { role: "presentation", className: tab == active() && "active" }, m("a", { onclick: function onclick() { | |
return active(tab); | |
} }, tab)); | |
})); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// React version is here: https://github.com/ccoenraets/react-employee-directory/blob/master/iteration8/js/pageslider-react.js | |
var PageSlider = { | |
controller: function(args) { | |
var ctrl = this; | |
ctrl.history = m.prop([]); | |
ctrl.pages = m.prop([]); | |
ctrl.animating = m.prop(false); | |
ctrl.slidePage = function(page) { | |
var history = ctrl.history(); | |
var pages = ctrl.pages(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://jsfiddle.net/3p90n4mn/2/ | |
https://github.com/jasonmayes/mdl-component-design-pattern | |
https://github.com/Satyam/malt | |
https://github.com/dvcolgan/superflux | |
http://mithril.js.org/components.html#the-observer-pattern |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Ids = [139502, 92769, 57443]; | |
forecasts.model2 = function(Ids) { | |
console.log(Ids); | |
return m.request({ | |
method: 'GET', | |
url: window.location.origin + '/api/', | |
data: { | |
reportIds: Ids | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This version works | |
**/ | |
var dashboard = {}; | |
dashboard.model = function(id) { | |
return m.request({ | |
method: 'GET', | |
url: window.location.origin + '/example/' + id, | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m.route( document.body, "/dashboard/johndoe", { | |
"/dashboard/:userID": { | |
controller : function(){ | |
return m.request( { | |
url : "/permissions/" + m.route.param( "userID" ), | |
deserialize : function( xml ){ | |
return new DOMParser().parseFromString( xml, "text/xml" ); | |
} | |
} ).then( | |
function success(){}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"scope": "source.js", | |
"completions": | |
[ | |
{"trigger": "m\tm() Mithril", "contents": "m('${1:div}',{\n\t${2:style: { \\}}, \n\t${3:config: 'function name'}\n\t},[\n\t\t${4:'Children'}\n\t])"}, | |
{"trigger": "mi\tinput Mithril", "contents": "m('input${1:[type=]}', ${2:oninput:}, value: $3)"}, | |
{"trigger": "ma\tlink Mithril", "contents": "m('a[href=${1:/myroute}]', {config: ${2:m.route}}, ${3:'Myroute'})"}, | |
{"trigger": "mm\tmodule Mithril", "contents": "var mymodule = {};\n\nmymodule.vm = ${1:'Object literal \\{\\} or function Constructor'}\n\nmymodule.controller = function (options) {\n\t${2:mymodule.vm.init();}\n};\n\nmymodule.view = function (ctrl) {\n\treturn ${3:'view here'};\n}\nm.module(document${4:.body}, mymodule);"}, | |
{"trigger": "mp\tgetter/setter Mithril", "contents" : "m.prop(${1:'initial value'});"}, | |
{"trigger": "mw\tevent handler Mithril", "contents": "m.withAttr(${1:'string here'}, ${2:callback here})"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i=0; i<num; i ++) { | |
operation(); | |
} | |
//Equivalent to | |
if (num <= 0) {return;} //or just return see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return | |
operation() | |
return repeat(operation, --num) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i=0;i<list.length;i++) { | |
console.log(list[i]); | |
} | |
//Equivalent to: | |
//list.forEach(function (i) { | |
//console.log(i) | |
//}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bracket = []; | |
for (var d=0; d<list.length;d++){ | |
if (path.extname(list[d]) === ".".concat(ext)) { | |
bracket.push(list[d]); | |
} | |
} | |
//bracket = list.filter(function (d) { | |
// return path.extname(d) === ".".concat(ext); | |
//}); |