From a7a6ae4be87ee9178905ab784d84a4c0a8303f9b Mon Sep 17 00:00:00 2001 From: fulup Date: Sun, 23 Jul 2017 01:23:37 +0200 Subject: Added TLV->DBscale into HAL control 1st Working version of HAL ctl-get with TLV Cleanup HTML5 test pages WIP Only --- htdocs/AFB-websock.js | 7 +++-- htdocs/AudioBinding.css | 7 +++++ htdocs/AudioBinding.js | 74 ++++++++++++++++++++++++++++++++++++------------- htdocs/alsa-core.html | 68 +++++++++++++++++++++++++-------------------- htdocs/alsa-hal.html | 31 ++++++++++++++------- htdocs/audio-logic.html | 26 ++--------------- 6 files changed, 128 insertions(+), 85 deletions(-) create mode 100644 htdocs/AudioBinding.css (limited to 'htdocs') diff --git a/htdocs/AFB-websock.js b/htdocs/AFB-websock.js index e77ec89..ff9fa60 100644 --- a/htdocs/AFB-websock.js +++ b/htdocs/AFB-websock.js @@ -1,7 +1,10 @@ +var urlws; +var urlhttp; + AFB = function(base, initialtoken){ -var urlws = "ws://"+window.location.host+"/"+base; -var urlhttp = "http://"+window.location.host+"/"+base; +urlws = "ws://"+window.location.host+"/"+base; +urlhttp = "http://"+window.location.host+"/"+base; /*********************************************/ /**** ****/ diff --git a/htdocs/AudioBinding.css b/htdocs/AudioBinding.css new file mode 100644 index 0000000..1052aa7 --- /dev/null +++ b/htdocs/AudioBinding.css @@ -0,0 +1,7 @@ +pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; } +.string { color: green; } +.number { color: darkorange; } +.boolean { color: blue; } +.null { color: magenta; } +.key { color: red; } + diff --git a/htdocs/AudioBinding.js b/htdocs/AudioBinding.js index 7105b20..e000a70 100644 --- a/htdocs/AudioBinding.js +++ b/htdocs/AudioBinding.js @@ -1,8 +1,30 @@ var afb = new AFB("api", "mysecret"); var ws; - var halapi="HALNotSelected"; + var sndcard="HALNotSelected"; var evtidx=0; + function syntaxHighlight(json) { + if (typeof json !== 'string') { + json = JSON.stringify(json, undefined, 2); + } + json = json.replace(/&/g, '&').replace(//g, '>'); + return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { + var cls = 'number'; + if (/^"/.test(match)) { + if (/:$/.test(match)) { + cls = 'key'; + } else { + cls = 'string'; + } + } else if (/true|false/.test(match)) { + cls = 'boolean'; + } else if (/null/.test(match)) { + cls = 'null'; + } + return '' + match + ''; + }); + } + function getParameterByName(name, url) { if (!url) { url = window.location.href; @@ -25,8 +47,8 @@ var sndname=getParameterByName("sndname"); if (!sndname) sndname="PCH"; - var quiet=getParameterByName("quiet"); - if (!quiet) quiet="99"; + var mode=getParameterByName("mode"); + if (!mode) mode="99"; @@ -54,12 +76,12 @@ function replyok(obj) { console.log("replyok:" + JSON.stringify(obj)); - document.getElementById("output").innerHTML = "OK: "+JSON.stringify(obj); + document.getElementById("output").innerHTML = "OK: "+ syntaxHighlight(obj); } function replyerr(obj) { console.log("replyerr:" + JSON.stringify(obj)); - document.getElementById("output").innerHTML = "ERROR: "+JSON.stringify(obj); + document.getElementById("output").innerHTML = "ERROR: "+ syntaxHighlight(obj); } function gotevent(obj) { @@ -78,7 +100,8 @@ // On button click from HTML page function callbinder(api, verb, query) { console.log ("subscribe api="+api+" verb="+verb+" query=" +query); - document.getElementById("question").innerHTML = "apicall: " + api+"/"+verb +" ("+ JSON.stringify(query)+")"; + var question = urlws +"/" +api +"/" +verb + "?query=" + JSON.stringify(query); + document.getElementById("question").innerHTML = syntaxHighlight(question); ws.call(api+"/"+verb, query).then(replyok, replyerr); } @@ -89,27 +112,38 @@ // onlick update selected HAL api selectobj.onclick=function(){ - halapi= this.value; - console.log ("New Default HAL=" + halapi); + sndcard= this.value; + console.log ("Default Selection=" + sndcard); }; function gotit (result) { - // display response as for normal onclick action - replyok(result); - var response=result.response; + // display response as for normal onclick action + replyok(result); + var response=result.response; - // fulfill select with avaliable active HAL - for (idx=0; idx - Hello world test + + Alsa Low Level Simple Test + + + + references -
    -
  1. http://localhost:1234/alsa-core.html?devid=hw:xx
  2. -
  3. amixer -D hw:PCH controls
  4. -
- - -

Hello world test

- + +

+ Selected SndCard + + + API Verbosity +
+ +
    -
  1. getinfo: List Sound Cards -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. +
  8. +
  9. +
  10. +

  11. -
  12. -
  13. -
  14. -
  15. -
  16. +
  17. +
  18. +
  19. +
  20. +

  21. -
  22. -
  23. -
  24. -
  25. +
  26. +
  27. +
  28. +

  29. -
  30. +

  31. -
  32. +

diff --git a/htdocs/alsa-hal.html b/htdocs/alsa-hal.html index ce48ff3..7a8655c 100644 --- a/htdocs/alsa-hal.html +++ b/htdocs/alsa-hal.html @@ -1,7 +1,7 @@ Basic Audio Hardware Abstraction Layer Test - + @@ -9,29 +9,40 @@ - references -

Simple AlsaHAL tests



Selected HAL + + API Verbosity +

    -
  1. -
  2. -
  3. -
  4. +
  5. +
  6. +
  7. +
  8. +
    +
  9. +
  10. +
  11. +

diff --git a/htdocs/audio-logic.html b/htdocs/audio-logic.html index 79ab114..c31282a 100644 --- a/htdocs/audio-logic.html +++ b/htdocs/audio-logic.html @@ -1,29 +1,9 @@ - Hello world test + High Level API Simple Test Page - - -

Hello world test

- -
-
    -
  1. -
    -
  2. -
  3. -
  4. -
  5. -
    -
  6. -
  7. -
    -
  8. + -
    - +ToBeDone \ No newline at end of file -- cgit 1.2.3-korg