npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iobroker.vis-2-widgets-ovarious

v0.1.9

Published

ioBroker vis-2 widgets for adapter ovarious

Downloads

182

Readme

Vis 2 (o)various widgets

Logo

Number of Installations Number of Installations NPM version Downloads

NPM

This adapter contains various vis-2 widgets.

ok, actually, there is only one vis-2 widget, but some more are on my roadmap.

JSON Template Widget

Using this widget, any data point with JSON data can be displayed as desired. The display is done using a template format, which can be thought of as a combined form of HTML code + JavaScript + special tags that control the display of the JSON attributes.

Attribute JSON datapoint

Selection of the data point with the corresponding JSON data.

Attribute Template

The template can be used to determine the appearance of the JSON data. All valid HTML tags (including CSS attributes in style tags) can be used in the template. There are also special tags within which the JSON data is displayed and JavaScript instructions can be executed.

The template system works with certain tags. The tags used have the following meaning

| tag | description | | ----- | ------------------------------------------------------------------- | | <%= | The content of the contained expression / variable will be escaped. | | <%- | The content of the contained expression / variable is unescaped. | | <% | No output, is used for enclosed javascript instructions | | %> | is generally a closing tag that completes one of the previous ones |

Everything that is outside of these tags is displayed exactly as it is or if it is HTML interpreted as HTML. (see e.g. the p-tag, div-tag, small-tag Within the template you have 2 predefined variables available

The JSON data is passed to the template with the prefix data. In addition, the current widgetID is also available as a variable so that it can be specified in individual CSS instructions.

Example object
{
  "onearray": ["one", "two"],
  "oneobject": {
    "attribute1": 1,
    "attribute2": 2
  },
  "onenumber": 123,
  "onetext": "onetwothree"
}

With the above example, attributes could be output as follows

<%- data.onenumber %> <%- data.onetext %>

Result

123 onetwothree

Arrays can be accessed via an index. The index always starts with 0. However, there are also fake arrays where the index does not start with 0 or even consists of text. Here the rules for objects apply. In the example above, this would be

<%- data.onearray[0] %> <%- data.onearray[1] %>
Result
one two

If you try to output an array directly without an index, the template outputs all elements separated by commas

<%- data.onearray %>

Result

one,two

Arrays can also consist of a collection of objects. The example here contains only a simple array. An example of arrays with objects will be given later.

<% for (var i = 0; i < data.onearray.length ; i++ ) { %> <%- data.onearray[i] %> <% } %>

Result

one two

Objects can contain individual attributes, arrays or objects again. This means that JSON data can be nested to any depth.

Attributes of an object can be addressed using dot notation or bracket notation. The dot notation only works if the attribute conforms to certain naming conventions (first character must be a letter, rest numbers or letters or underscore). The bracket notation also works for attributes that do not conform to the naming convention.

Dot notation

<%- data.oneobject.attribute1 %>

Bracket notation

<%- data.oneobject["attribute1"] %>

Result for both examples

1

Loop over the attributes of an object

<% for (var prop in data.oneobject) { %> <%- "data.oneobject." + prop + " = " + data.oneobject[prop] %> <% } %>

Result

data.oneobject.attribute1 = 1 data.oneobject.attribute2 = 2

Advanced use case

In the examples above, only the pure output was covered. The template can now also be enriched with HTML tags to achieve a specific layout. Here is an example:

<h3>Output</h3>
<style>
  .mycssclassproperty {
    color: green;
  }
  .mycssclassdata {
    color: red;
  }
</style>
<% for (var prop in data.oneobject) { %>
<div>
  <span class="mycssclassproperty"><%- "data.oneobject." + prop + " = " %></span>
  <span class="mycssclassdata"><%- data.oneobject[prop] %></span>
</div>
<% } %>

Result

data.oneobject.attribute1 = 1 data.oneobject.attribute2 = 2

Changelog

0.1.9 (2024-09-09)

  • fix wrong translation

0.1.8 (2024-07-28)

  • improve icon
  • remove versions from io-package.json

0.1.7 (2024-07-28)

  • fix widget addressing

0.1.6 (2024-07-28)

  • fix widget addressing

0.1.5 (2024-07-28)

  • fix adapter checker issues

0.1.4 (2024-07-28)

  • fix things from adapter checker

0.1.3 (2024-07-27)

  • add icon
  • add documentation

0.1.2 (2024-07-27)

  • prepare release

0.1.1 (2024-07-27)

  • fix widget addressing

0.1.0 (2024-07-27)

  • initial Release

License

The MIT License (MIT)

Copyright (c) 2024 oweitman [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.