From 93d0d6223ce0d63e1f8e7a810d8bb860a3fbb574 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 21 Sep 2015 16:59:52 +0200 Subject: [PATCH] template strings woohoo --- app/browser/js/app/parser.js | 12 ++-- app/browser/js/app/utils.js | 32 +++++---- app/browser/js/app/widgets.js | 128 +++++++++++++++++----------------- app/main/config.json | 3 +- 4 files changed, 89 insertions(+), 86 deletions(-) diff --git a/app/browser/js/app/parser.js b/app/browser/js/app/parser.js index 69161b22..ee77c2a9 100644 --- a/app/browser/js/app/parser.js +++ b/app/browser/js/app/parser.js @@ -37,7 +37,7 @@ parsetabs = function(tabs,parent,sub){ label= tabData.label||tabData.id - navtabs.append('
  • '+label+'
  • ') + navtabs.append(`
  • ${label}
  • `) var tabContent = $('
    ').addClass('tab').attr('id',id) @@ -71,11 +71,11 @@ parsewidgets = function(widgets,parent) { widgetData.path = path - var widgetContainer = $('\ -
    \ -
    '+label+'
    \ -
    \ - ') + var widgetContainer = $(` +
    +
    ${label}
    +
    + `) if (widgetData.label===false) widgetContainer.addClass('nolabel') diff --git a/app/browser/js/app/utils.js b/app/browser/js/app/utils.js index c9759f36..00d891dc 100644 --- a/app/browser/js/app/utils.js +++ b/app/browser/js/app/utils.js @@ -74,7 +74,7 @@ openSession = function(path){ icon = function(i) { - return '' + return `` } createMenu = function(template) { @@ -95,7 +95,7 @@ createMenu = function(template) { html if (!item.html) { - html = $(''+label+'') + html = $(`${label}`) } else { html = $(item.html) } @@ -115,13 +115,13 @@ createMenu = function(template) { createPopup = function(title,content) { - var popup = $('\ - '), + var popup = $(` + `), closer = popup.find('.popup-title .closer') closer.click(function(){ @@ -159,13 +159,15 @@ configPanel = function(){ $.each(config,function(i) { - var item = $('
    \ - \ -

    '+config[i].info+'

    \ -
    ') + var item = $(` +
    + +

    ${config[i].info}

    +
    + `) - var input = $('') + var input = $(``) input.change(function(){ var v = input.val().trim().replace(/[\s]+/,' ') @@ -185,7 +187,7 @@ configPanel = function(){ }) - var submit = $(''+icon('save')+' Save') + var submit = $(`${icon('save')} Save`) form.append(submit) diff --git a/app/browser/js/app/widgets.js b/app/browser/js/app/widgets.js index 9a4b4e8e..b3374e43 100644 --- a/app/browser/js/app/widgets.js +++ b/app/browser/js/app/widgets.js @@ -2,10 +2,10 @@ createWidget= {} createWidget.strip = function(widgetData,container) { - var widget = $('\ -
    \ -
    \ - ') + var widget = $(` +
    +
    + `) if (widgetData.horizontal) { container.addClass('horizontal') } @@ -17,11 +17,11 @@ createWidget.strip = function(widgetData,container) { createWidget.led = function(widgetData) { - var widget = $('\ -
    \ -
    \ -
    \ - '), + var widget = $(` +
    +
    +
    + `), led = widget.find('span'), range = widgetData.range || {min:0,max:1} @@ -41,11 +41,11 @@ createWidget.toggle = createWidget.button = function(widgetData) { widgetData.on = widgetData.on || 1 widgetData.off = widgetData.off || 0 - var widget = $('\ -
    \ -
    \ + var widget = $(` +
    +
    \ - '), + `), led = widget.find('.light') @@ -89,10 +89,10 @@ createWidget.toggle = createWidget.button = function(widgetData) { createWidget.switch = function(widgetData) { - var widget = $('\ -
    \ -
    \ - ') + var widget = $(` +
    +
    + `) for (v in widgetData.values) { widget.append('
    '+widgetData.values[v]+'
    ') @@ -130,17 +130,17 @@ createWidget.switch = function(widgetData) { createWidget.xy = function(widgetData) { - var widget = $('\ -
    \ -
    \ -
    \ -
    \ -
    \ - \ - \ -
    \ -
    \ - '), + var widget = $(` +
    +
    +
    +
    +
    + + +
    +
    + `), handle = widget.find('.handle'), pad = widget.find('.xy'), value = {x:widget.find('.x'),y:widget.find('.y')}, @@ -249,19 +249,19 @@ createWidget.xy = function(widgetData) { createWidget.rgb = function(widgetData) { - var widget = $('\ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ - \ - \ -
    \ -
    '), + var widget = $(` +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    `), rgbHandle = widget.find('.rgb .handle'), hueHandle = widget.find('.hue .handle'), pad = widget.find('.xy'), @@ -449,17 +449,17 @@ createWidget.rgb = function(widgetData) { createWidget.fader = function(widgetData,container){ - var widget = $('\ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ - \ -
    \ - '), + var widget = $(` +
    +
    +
    +
    +
    +
    +
    + +
    + `), handle = widget.find('.handle'), fader = widget.find('.fader'), pips = widget.find('.pips'), @@ -602,18 +602,18 @@ createWidget.fader = function(widgetData,container){ createWidget.knob = function(widgetData) { - var widget = $('\ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ -
    \ - \ -
    \ - '), + var widget = $(` +
    +
    +
    +
    +
    +
    +
    +
    + +
    + `), knob = widget.find('.knob'), input = widget.find('input'), range = widgetData.range || {min:0,max:1}, diff --git a/app/main/config.json b/app/main/config.json index 54cb8658..946f5212 100644 --- a/app/main/config.json +++ b/app/main/config.json @@ -1,6 +1,7 @@ { "sessionPath": "/home/bordun/oscwork/oschtmlgui/sessions/", "recentSessions": [ - "/home/bordun/oscwork/oschtmlgui/sessions/sebkhachott.js" + "/home/bordun/oscwork/oschtmlgui/sessions/sebkhachott.js", + "/home/bordun/oscwork/oschtmlgui/sessions/demo.js" ] } \ No newline at end of file