app/data.js
/**
 * Init new activity to display on the watch
 * @param {Object} metric - info line displayed
 * @param {Boolean} asked - the user asked for this changes; to distinguish from init
 */
Init new activity to display on the watch
@param {Object} metric - info line displayed
@param {Boolean} asked - the user asked for this changes; to distinguish from init
Init new activity to display on the watch @param { Object } metric - info line displayed @param { Boolean } asked - the user asked for this changes ; to distinguish from init
function initActivity({ metric, asked }) {
  if (!asked) {
    const savedData = settings.getData(`metric${metric.metricNumber}`);
    if (savedData) {
      metric.activity = savedData.activity ?
        savedData.activity : metric.activity;
      metric.format = savedData.format ?
        savedData.format : metric.format;
      metric.color = savedData.color ?
        savedData.color : metric.color;
    }
  }
  metric.activity = permissions.getNextAllowedActivity(metric.activity);
  const activity = activities[metric.activity];
  const textElem = document.getElementById(`metric${metric.metricNumber}`)
  const icon = document.getElementById(`metric${metric.metricNumber}-img`);
  if (activity.icon) {
    icon.style.visibility = 'visible';
    icon.style.opacity = 1;
    textElem.x = layout.getTextX({ icon: true });
    icon.href = activity.icon;
    icon.style.fill = activity.iconFill ? activity.iconFill : 'white';
    icon.x = layout.getIconX();
    icon.y = layout.getIconY({ metricNumber: metric.metricNumber });
  } else {
    icon.style.visibility = 'hidden';
    textElem.x = layout.getTextX({ icon: false });
  }
  if (metric.color) {
    icon.style.fill = metric.color;
    textElem.style.fill = metric.color;
  }
  textElem.text = '--';
  textElem.style.fill = metric.color ? metric.color : activity.textFill ? activity.textFill : 'white';
  textElem.style.fontSize = metric.fontSize ? metric.fontSize : 50;
  metric.active               = activity.active;
  metric.changeColor          = activity.changeColor;
  metric.changeFormat         = activity.changeFormat;
  metric.iconFill             = activity.iconFill;
  metric.initialized          = activity.initialized
  metric.name                 = activity.name;
  metric.onClick              = activity.onClick;
  metric.refreshActivityColor = activity.refreshActivityColor
  metric.switchToNext         = activity.switchToNext;
  metric.saveSettings         = activity.saveSettings;
  metric.textFill             = activity.textFill;
  metric.update               = activity.update;
  textElem.onclick = () => {
    if (settings.getData('lockUI')) { return; }
    metric.onClick(metric);
  }
}
function initActivity ( { metric , asked } ) { if ( ! asked ) { const savedData = settings . getData ( ` ${ metric . metricNumber } ` ) ; if ( savedData ) { metric . activity = savedData . activity ? savedData . activity : metric . activity ; metric . format = savedData . format ? savedData . format : metric . format ; metric . color = savedData . color ? savedData . color : metric . color ; } } metric . activity = permissions . getNextAllowedActivity ( metric . activity ) ; const activity = activities [ metric . activity ] ; const textElem = document . getElementById ( ` ${ metric . metricNumber } ` ) const icon = document . getElementById ( ` ${ metric . metricNumber } ` ) ; if ( activity . icon ) { icon . style . visibility = 'visible' ; icon . style . opacity = 1 ; textElem . x = layout . getTextX ( { icon : true } ) ; icon . href = activity . icon ; icon . style . fill = activity . iconFill ? activity . iconFill : 'white' ; icon . x = layout . getIconX ( ) ; icon . y = layout . getIconY ( { metricNumber : metric . metricNumber } ) ; } else { icon . style . visibility = 'hidden' ; textElem . x = layout . getTextX ( { icon : false } ) ; } if ( metric . color ) { icon . style . fill = metric . color ; textElem . style . fill = metric . color ; } textElem . text = '--' ; textElem . style . fill = metric . color ? metric . color : activity . textFill ? activity . textFill : 'white' ; textElem . style . fontSize = metric . fontSize ? metric . fontSize : 50 ; metric . active = activity . active ; metric . changeColor = activity . changeColor ; metric . changeFormat = activity . changeFormat ; metric . iconFill = activity . iconFill ; metric . initialized = activity . initialized metric . name = activity . name ; metric . onClick = activity . onClick ; metric . refreshActivityColor = activity . refreshActivityColor metric . switchToNext = activity . switchToNext ; metric . saveSettings = activity . saveSettings ; metric . textFill = activity . textFill ; metric . update = activity . update ; textElem . onclick = ( ) => { if ( settings . getData ( 'lockUI' ) ) { return ; } metric . onClick ( metric ) ; } }
Init new activity to display on the watch
 @param {Object} metric - info line displayed
 @param {Boolean} asked - the user asked for this changes; to distinguish from init
Init new activity to display on the watch @param { Object } metric - info line displayed @param { Boolean } asked - the user asked for this changes ; to distinguish from init
// Permission check // NOTE: Object.assign is NOT available :(