Last active
April 21, 2016 20:58
-
-
Save hapticdata/0d6eb8a6396b8aa528d7479734997ec1 to your computer and use it in GitHub Desktop.
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 css = require('dom-css'), | |
tmpl = require('../../views/client/object-list.jade'), | |
watchProperty = require('watch-property'); | |
class ObjectListView { | |
constructor(title){ | |
this.title = title; | |
this.domElement = document.createElement('div'); | |
this.domElement.classList.add('object-list'); | |
css(this.domElement, { | |
position: 'fixed', | |
bottom: 0, | |
right: 10, | |
minWidth: 150, | |
color: 'white', | |
fontSize: '50%', | |
backgroundColor: 'rgba(0,0,0,0.75)' | |
}); | |
} | |
css(styles) { | |
css(this.domElement, styles); | |
return this; | |
} | |
set(object) { | |
this.domElement.innerHTML = tmpl({ | |
title: this.title, | |
object: object | |
}); | |
return this; | |
} | |
} | |
module.exports = ()=> ObjectListView.apply({}, arguments); | |
exports.ObjectListView = ObjectListView; | |
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
mixin list(object, level, maxLevels) | |
- level = level || 0 | |
- maxLevels = maxLevels || 2; | |
each val, key in object | |
if typeof val !== 'function' | |
tr | |
td= key | |
- val = typeof val === 'number' ? Math.floor(val*10000) / 10000 : val; | |
td #{typeof val !== 'object' ? val : ''} | |
if typeof val === 'object' && level < maxLevels | |
+list(val, level++) | |
if title | |
h3= title | |
table | |
+list(object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment