Example #1
0
 window.addEventListener('error', function (ev) {
   var err = ev.error || ev
   if(!tabs.has('errors'))
     tabs.add(errors, false)
   var el = h('div.message',
     h('strong', err.message),
     h('pre', err.stack))
   if (errorsContent.firstChild)
     errorsContent.insertBefore(el, errorsContent.firstChild)
   else
     errorsContent.appendChild(el)
 })
Example #2
0
 return function (msg, sbot)  {
   var c = msg.value.content
   if (c.type === 'pub') {
     var address = c.address || {}
     return [
       h('p', 'announced an address for ',
         api.avatar_link(address.key, api.avatar_name(address.key)), ':'),
       h('blockquote',
         h('code', address.host + ':' + address.port)
       )
     ]
   }
 }
Example #3
0
		render: function(context) {
			return(
				h('.form-group',
					h('label.control-label',context.label,
						h('.checkbox',
							h('label',
								h('input',{type:'checkbox',name:context.name,value:context.optionLabel}),
								context.optionLabel
							)
						)
					)
				)
			);
		},
Example #4
0
test("can give it multiple lists and sorts correctly", function (assert) {
    var source = event()
    var container = h("div")
    var one = h("div", "one")
    var two = h("div", "two")
    var three = h("div", "three")
    var four = h("div", "four")

    var list = SortedList(source, container)

    fold(list, function () {})

    assert.deepEqual(text(), [])

    send(source, [one])

    assert.deepEqual(text(), ["one"])

    send(source, [two, one])

    assert.deepEqual(text(), ["two", "one"])

    send(source, [two, three, one])

    assert.deepEqual(text(), ["two", "three", "one"])

    send(source, [two, one])

    assert.deepEqual(text(), ["two", "one"])

    send(source, [two, one, three])

    assert.deepEqual(text(), ["two", "one", "three"])

    send(source, [one, two, three])

    assert.deepEqual(text(), ["one", "two", "three"])

    send(source, [three, two, four, one])

    assert.deepEqual(text(), ["three", "two", "four", "one"])

    assert.end()

    function text() {
        return [].slice.call(container.childNodes).map(function (elem) {
            return elem.textContent
        })
    }
})
Example #5
0
module.exports = function (app, msg, opts) {
  var content
  if (opts && opts.raw) {
    content = h('table', com.prettyRaw.table(app, msg.value.content))
  } else {
    content = getContent(app, msg, opts)
    if (!content) {
      if (!(opts && opts.mustRender))
        return ''
      content = h('table', com.prettyRaw.table(app, msg.value.content))
    }
  }    
  return messageShell(app, msg, content, opts)
}
Example #6
0
module.exports = function (app, opts) {
  opts = opts || {}

  // markup
 
  var feed = h('table.program-feed')
  var feedContainer = infiniscroll(h('.program-feed-container.full-height', feed), { fetchBottom: fetchBottom })

  // message fetch

  var cursor
  function fetchBottom (cb) {
    fetchBottomBy(30)
    function fetchBottomBy (amt) {
      var fetchopts = { reverse: true, type: 'phoenix-program', limit: 30, keys: true, values: true }
      fetchopts.lt = cursor && cursor.value.timestamp
      
      pull(app.ssb.messagesByType(fetchopts), pull.collect(function (err, _msgs) {
        if (_msgs && _msgs.length) {
          // nothing new? stop
          if (cursor && cursor.key === _msgs[_msgs.length - 1].key)
            return (cb && cb())

          // advance cursor
          cursor = _msgs[_msgs.length - 1]

          // filter
          if (opts.filter)
            _msgs = _msgs.filter(opts.filter)

          // render
          _msgs.forEach(function (msg) {
            var el = com.programSummary(app, msg)
            el && feed.appendChild(el)
          })

          // fetch more if needed
          var remaining = amt - _msgs.length
          if (remaining > 0)
            return fetchBottomBy(remaining)
        }

        cb && cb()
      }))
    }
  }
  fetchBottom()

  return feedContainer
}
Example #7
0
		body: function() {
			var preview = h('div',
				h('div#welder-form-runner'),
				h('div#welder-form-results.welder-pre')
			);
			welder.widgets.formRunner( $('#welder-form-runner',preview), { project:options.project, form:fromFromState() } );
			$('#welder-form-runner form',preview).submit( function(e) {
				var values = util.formToObject( $('#welder-form-runner form',preview) );
				$('#welder-form-results',preview).html( JSON.stringify(values,null,4) );
				e.preventDefault();
				return false;
			});
			return preview;
		},
Example #8
0
		render: function(context) {
			return(
				h('.form-group',
					h('label.control-label',context.label),
					h('select.form-control',{name:context.name,multiple:true,size:context.size},
						_.map( context.options, function(val) {
							return(
								h('option',val)
							);
						})
					)
				)
			);
		},
Example #9
0
test("submissions can handle nested objects", function (assert) {
    var elements = {
        foo: {
            bar: h("input")
            , baz: h("input")
        }
        , button: h("button")
        , root: h("div")
    }

    document.body.appendChild(elements.root)
    elements.root.appendChild(elements.button)
    elements.root.appendChild(elements.foo.bar)
    elements.root.appendChild(elements.foo.baz)

    var submits = submissions(elements)
    var list = []
    into(submits, list)

    eve.emit(elements.button, "click", { bubbles: true })

    assert.deepEqual(list, [{
        foo: {
            bar: ""
            , baz: ""
        }
    }])

    elements.foo.bar.value = "bar"
    elements.foo.baz.value = "baz"

    eve.emit(elements.button, "click", { bubbles: true })

    assert.deepEqual(list, [{
        foo: {
            bar: ""
            , baz: ""
        }
    }, {
        foo: {
            bar: "bar"
            , baz: "baz"
        }
    }])

    document.body.removeChild(elements.root)

    assert.end()
})
Example #10
0
exports.screen_view = function (path) {
  if(path === '/private') {
    var id = null
    sbot_whoami(function (err, me) {
      id = me.id
    })

    var div = h('div.column.scroller',
      {style: {'overflow':'auto'}},
      h('div.scroller__wrapper',
        message_compose({type: 'post'}), //header
        content
      )
    )

    var compose = message_compose(
      {type: 'post', recps: [], private: true}, 
      function (msg) {
        msg.recps = [id].concat(msg.mentions).filter(function (e) {
          return ref.isFeed('string' === typeof e ? e : e.link)
        })
        if(!msg.recps.length)
          throw new Error('cannot make private message without recipients - just mention them in the message')
        return msg
      })

    var content = h('div.column.scroller__content')
    var div = h('div.column.scroller',
      {style: {'overflow':'auto'}},
      h('div.scroller__wrapper', compose, content)
    )

    pull(
      sbot_log({old: false}),
      unbox(),
      Scroller(div, content, message_render, true, false)
    )

    pull(
      u.next(sbot_log, {reverse: true, limit: 1000}),
      unbox(),
      Scroller(div, content, message_render, false, false, function (err) {
        if(err) throw err
      })
    )

    return div
  }
}
Example #11
0
	render: function() {
		if(!this.$el) {
			this.$el = $(h("div.welder-ide-save-as",
				h("input.welder-ide-save-as-input",{placeholder: "File name"}),
				h("button.welder-ide-save-as-submit","Submit")
			));
		}
		if (!this.$el.data("has-events")) {
			this.$el
				.data("has-events", true)
				.on("click",".welder-ide-save-as-submit",_.bind(function() { this.submit(); },this));
				;
		}
		return this.$el;
	},
Example #12
0
				_.map(data,function(item) {
					var isDir = item[item.length-1] == "/";
					var classes = ["glyphicon","icon"];
					if(isDir) {
						item = item.substr(0,item.length-1);
						classes.push("glyphicon-expand");
						type = "folder";
					} else {
						classes.push("glyphicon-list-alt");
						type = "file";
					}
					item = item.split("/").pop();
					fpath = path.join(file_path,item);
					return h("li."+type,{"data-path":fpath,"data-status":"closed"},h("i."+classes.join(".")),item);
				})
Example #13
0
function home(opts) {
    return layout(opts.title,
        h("ul", [
            h("li", [
                "Visit the ",
                h("a", { href: "/users" }, "users"),
                " page"
            ]),
            h("li", [
                "Visit the ",
                h("a", { href: "/posts" }, "posts"),
                " page"
            ])
        ]))
}
Example #14
0
const Info = (scale, props) => {
    const height = Math.ceil(192 * scale);
    return h('div.info',
        [
            h('div.logo',
                {
                    style: {
                        height: `${height}px`
                    }
                }
            ),
            Status(scale, props)
        ]
    );
};
Example #15
0
	function render( tasks ) {
		var outputsHtml = "This run produced no outputs.";
		if( ! $.isEmptyObject(tasks) ) {
			outputsHtml = [];
			_.each( tasks, function(task,taskName) {
				var outputs = [];
				_.each( task, function(file) {
					outputs.push(
						h('div',
							h('a',file,
								{
									href:util.downloadHref(tasksUrl+'/'+taskName+'/outputs/'+file,"sendFile=1")
								}
							)
						)
					);
				});

				outputsHtml.push(
					h('div',
						h('a.welder-expandable-link.welder-pointer',taskName,{href:''})
					),
					h('.container.welder-expandable',{style:{display:'none'}},outputs)
				);
			});
		}

		$(selector).html(
			h('div',
				h('div', 
					h('a.welder-pointer','[Expand all]',
						{
							onclick: function() {
								$('.welder-expandable').slideDown();
							}
						}
					)
				),
				h('div', outputsHtml )
			)
		);

		$('.welder-expandable-link',selector).click( function(e) {
			$(this).parent().next('.welder-expandable').slideToggle();
			e.preventDefault();
			return true;
		})
	}
Example #16
0
    this.build = function() {
        visualsElement = container.querySelector('.' + options.selectors.visualsClass)

        if (!visualsElement) {
            visualsElement = h('div.' + options.selectors.visualsClass)

            var buttonsElement = container.querySelector('.' + options.selectors.buttonsClass)

            // make sure it's placed before the buttons
            if (buttonsElement)
                container.insertBefore(visualsElement, buttonsElement)
            else
                container.appendChild(visualsElement)
        }

        visualsElement.classList.add('visuals')
        visualsElement.classList.add('hide')

        correctDimensions()

        !built && initEvents()
        buildChildren()

        // needed for replay handling and container.isParentElementOf()
        self.parentNode = visualsElement.parentNode

        built = true
    }
Example #17
0
function Cell () {
  return h('cell', {
    'data-ng-repeat': 'cell in $ctrl.row',
    'data-turn': '$ctrl.turn',
    'data-cell': 'cell'
  })
}
Example #18
0
    return function () {

      document.head.appendChild(h('style', require('../style.css.json')))

      window.addEventListener('error', window.onError = function (e) {
        document.body.appendChild(h('div.error',
          h('h1', e.message),
          h('big', h('code', e.filename + ':' + e.lineno)),
          h('pre', e.error ? (e.error.stack || e.error.toString()) : e.toString())))
      })

      function hash() {
        return window.location.hash.substring(1)
      }

      console.log(hash() || 'tabs')
      var view = api.screen_view(hash() || 'tabs')


      var screen = view

      window.onhashchange = function (ev) {
        var _view = view
        view = api.screen_view(hash() || 'tabs')

        if(_view) screen.replaceChild(view, _view)
        else      document.body.appendChild(view)
      }

      // document.body.appendChild(sidebar)
      document.body.appendChild(screen)

      return screen
    }
Example #19
0
    return function FileInput(onAdded) {
      return h('input', { type: 'file',
        onchange: function (ev) {
          var file = ev.target.files[0]
          if (!file) return
          var reader = new FileReader()
          reader.onload = function () {
            pull(
              pull.values(split(new Buffer(reader.result), 64*1024)),
              add(function (err, blob) {
                if(err) return console.error(err)
                onAdded({
                  link: blob,
                  name: file.name,
                  size: reader.result.length || reader.result.byteLength,
                  type: mime(file.name)
                })

              })
            )
          }
          reader.readAsArrayBuffer(file)
        }
      })
    }
Example #20
0
    this.build = function() {
        visualsElement = container.querySelector('.' + options.selectors.visualsClass)

        if (!visualsElement) {
            visualsElement = h('div.' + options.selectors.visualsClass)

            var buttonsElement = container.querySelector('.' + options.selectors.buttonsClass)

            // make sure it's placed before the buttons
            if (buttonsElement)
                container.insertBefore(visualsElement, buttonsElement)
            else
                container.appendChild(visualsElement)
        }

        visualsElement.classList.add('visuals')
        visualsElement.classList.add('hide')

        if (!visualsElement.style.width && options.video.width)
            visualsElement.style.width = options.video.width + 'px'

        if (!visualsElement.style.height && options.video.height)
            visualsElement.style.height = options.video.height + 'px'

        !built && initEvents()
        buildChildren()

        built = true
    }
Example #21
0
function linkify(text) {
  var arr = text.split(refRegex)
  for (var i = 1; i < arr.length; i += 2) {
    arr[i] = h('a', {href: '#' + arr[i]}, arr[i])
  }
  return arr
}
Example #22
0
 return function (msg) {
   return updateTimestampEl(h('a.enter.timestamp', {
     href: '#'+msg.key,
     timestamp: msg.value.timestamp,
     title: new Date(msg.value.timestamp)
   }, ''))
 }
Example #23
0
		util.ajax.apiv1( "GET", options.project, '/files/forms', null, function(data) {
			var sortedFormsNames = _(data).sort();
			var formSelect = h('select.form-control',{type:'text',name:'form_name'},
				_.map( sortedFormsNames, function(path) {
					var name = path.split('/').slice(-1)[0];
					name = name.replace('.json','');
					return h('option',name,{name:name});
				})
			);

			util.dialog({
				id: '#welder-open-form-dialog',
				title: 'Open a form',
				width: '80%',
				body: function() {
					return(
						h('.form-group',
							h('label','Form'),
							formSelect
						)
					);
				},
				onOkay: function($body) {
					formName = $body.find('select[name=form_name]').val();
					util.ajax.apiv1( "GET", options.project, '/files/forms/'+formName+'.json', null, function(data) {
						render( JSON.parse(data).components );
					});
				}
			});
		});
Example #24
0
 post: function () { 
   if (!c.text) return
   var div = h('div', { innerHTML: mentions.post(markdown.block(c.text), app, msg) })
   if (div.innerText.length <= 255)
     div.style.fontSize = '150%'
   return div
 }
Example #25
0
 stream.pipe(serializer(through(function (hash) {
   var url =  window.location.origin+'/'+hash
   console.log('opening:', url)
   document.body.appendChild(
     h('iframe', {src: url})
   )
 }))).pipe(stream)
Example #26
0
		this.fileDAO.getContent(file_path,_.bind(function(data) {
			$el
				.data("status","opened")
				.find("i")
					.addClass("glyphicon-collapse-down")
					.removeClass("glyphicon-expand");
			if(!$el.length) return;

			var $folder_browser = $el.append($(h("ul.welder-folder-browser",
				_.map(data,function(item) {
					var isDir = item[item.length-1] == "/";
					var classes = ["glyphicon","icon"];
					if(isDir) {
						item = item.substr(0,item.length-1);
						classes.push("glyphicon-expand");
						type = "folder";
					} else {
						classes.push("glyphicon-list-alt");
						type = "file";
					}
					item = item.split("/").pop();
					fpath = path.join(file_path,item);
					return h("li."+type,{"data-path":fpath,"data-status":"closed"},h("i."+classes.join(".")),item);
				})
			)));

			if(this.onOpenFolder) this.onOpenFolder(data,file_path);
		},this));
Example #27
0
ResultsTable.prototype.renderResult = function(result) {
    var self = this;
    return h('tr', this.fields.map(function(field) {
        var render = self.renderField[field] || Render.default;
        return h('td.field.' + field, render.call(self, field, result));
    }));
};
Example #28
0
exports.screen_view = function (path) {
  if(path === '/notifications') {
    var ids = {}
    var oldest

    sbot_whoami(function (err, me) {
      if (err) return console.error(err)
      ids[me.id] = true
      getFirstMessage(me.id, function (err, msg) {
        if (err) return console.error(err)
        if (!oldest || msg.value.timestamp < oldest) {
          oldest = msg.value.timestamp
        }
      })
    })

    var content = h('div.column.scroller__content')
    var div = h('div.column.scroller',
      {style: {'overflow':'auto'}},
      h('div.scroller__wrapper',
        content
      )
    )

    pull(
      sbot_log({old: false}),
      unbox(),
      notifications(ids),
      pull.filter(),
      Scroller(div, content, message_render, true, false)
    )

    pull(
      u.next(sbot_log, {reverse: true, limit: 100, live: false}),
      unbox(),
      notifications(ids),
      pull.filter(),
      pull.take(function (msg) {
        // abort stream after we pass the oldest messages of our feeds
        return !oldest || msg.value.timestamp > oldest
      }),
      Scroller(div, content, message_render, false, false)
    )

    return div
  }
}
Example #29
0
function crop (d, cb) {
  var data
  var canvas = hypercrop(h('img', {src: d}))

  return h('div.column.avatar_pic',
    canvas,
    //canvas.selection,
    h('div.row.avatar_pic__controls',
      h('button', 'okay', {onclick: function () {
        cb(null, canvas.selection.toDataURL())
      }}),
      h('button', 'cancel', {onclick: function () {
        cb(new Error('canceled'))
      }})
    )
  )
}
Example #30
0
 message_content_mini: function (msg, sbot)  {
   if (typeof msg.value.content === 'string') {
     var icon = api.emoji_url('lock')
     return icon
       ? h('img', {className: 'emoji', src: icon})
       : 'PRIVATE'
   }
 }