automatic url change in build / testing, added loader image

master
Ondřej Hruška 8 years ago
parent 46d861e0dc
commit 2ffaf1a4af
  1. 2
      esp_meas.pro.user
  2. 4
      html_src/_end.php
  3. 52
      html_src/_start.php
  4. 1330
      html_src/css/app.css
  5. 2
      html_src/css/app.css.map
  6. BIN
      html_src/img/loader.gif
  7. 108
      html_src/js-src/lib/chibi.js
  8. 2
      html_src/js-src/page_status.js
  9. 5
      html_src/js-src/page_waveform.js
  10. 2
      html_src/js-src/page_wifi.js
  11. 8920
      html_src/js/all.js
  12. 2
      html_src/js/all.js.map
  13. 2
      html_src/page_about.php
  14. 3
      html_src/page_status.php
  15. 3
      html_src/page_wifi.php
  16. 23
      html_src/sass/layout/_content.scss
  17. 4
      user/sampling.h

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.6.1, 2016-03-31T02:51:43. --> <!-- Written by QtCreator 3.6.1, 2016-03-31T20:15:31. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

@ -1,4 +1,4 @@
</div> </div><!-- content -->
</div> </div><!-- outer -->
</body> </body>
</html> </html>

@ -1,16 +1,23 @@
<?php <?php
$menu = [ $prod = defined('STDIN');
'home' => [ '/', 'Home' ], $root = $prod ? '' : 'http://192.168.1.13';
'wifi' => [ '/wifi', 'WiFi config' ],
'waveform' => [ '/waveform', 'Waveform' ],
'fft' => [ '/fft', 'FFT' ],
// 'spectrogram' => [ '/spectrogram', 'Spectrogram' ],
// 'transient' => [ '/transient', 'Power-on transient' ],
'about' => [ '/about', 'About' ],
];
$appname = 'Current analyzer'; $menu = [
'home' => [ $prod ? '/' : '/page_status.php', 'Home' ],
'wifi' => [ $prod ? '/wifi' : '/page_wifi.php', 'WiFi config' ],
'waveform' => [ $prod ? '/waveform' : '/page_waveform.php', 'Waveform' ],
'fft' => [ $prod ? '/fft' : '/page_fft.php', 'FFT' ],
// 'spectrogram' => [ '/spectrogram', 'Spectrogram' ],
// 'transient' => [ '/transient', 'Power-on transient' ],
'about' => [ $prod ? '/about' : '/page_about.php', 'About' ],
];
$appname = 'Current Analyser';
function e($s) {
return htmlspecialchars($s, ENT_HTML5|ENT_QUOTES);
}
?><!doctype html> ?><!doctype html>
<html> <html>
@ -19,32 +26,29 @@ $appname = 'Current analyzer';
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?= htmlspecialchars($menu[$page][1]) ?> - <?= htmlspecialchars($appname) ?></title> <title><?= e($menu[$page][1]) ?> - <?= e($appname) ?></title>
<link href="/css/app.css" rel="stylesheet"> <link href="/css/app.css" rel="stylesheet">
<?php if(false): ?>
<!-- IE8 support (not tested) -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<?php endif; ?>
<script src="/js/all.js"></script> <script src="/js/all.js"></script>
<script>
// server root (or URL) - used for local development with remote AJAX calls
// (this needs CORS working on the target - which I added to esp-httpd)
var _root = <?= json_encode($root) ?>;
</script>
</head> </head>
<body class="page-<?=$page?>"> <body class="page-<?=$page?>">
<div id="outer"> <div id="outer">
<nav id="menu"> <nav id="menu">
<div id="brand" onclick="$('#menu').toggleClass('expanded')">Current Analyser</div> <div id="brand" onclick="$('#menu').toggleClass('expanded')"><?= e($appname) ?></div>
<?php <?php
// generate the menu // generate the menu
foreach($menu as $k => $m) { foreach($menu as $k => $m) {
$sel = ($page == $k) ? ' class="selected"' : ''; $sel = ($page == $k) ? ' class="selected"' : '';
$text = htmlspecialchars($m[1]); $text = e($m[1]);
echo "<a href=\"$m[0]\"$sel>$text</a>"; $url = e($m[0]);
echo "<a href=\"$url\"$sel>$text</a>";
} }
?> ?>
</nav> </nav>
<div id="content"> <div id="content">
<img src="/img/loader.gif" alt="Loading…" id="loader">

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -1,4 +1,6 @@
/*!chibi 3.0.7, Copyright 2012-2016 Kyle Barrow, released under MIT license */ /*!chibi 3.0.7, Copyright 2012-2016 Kyle Barrow, released under MIT license */
// MODIFIED VERSION.
(function () { (function () {
'use strict'; 'use strict';
@ -6,7 +8,6 @@
loadedfn = [], loadedfn = [],
domready = false, domready = false,
pageloaded = false, pageloaded = false,
jsonpcount = 0,
d = document, d = document,
w = window; w = window;
@ -598,103 +599,52 @@
return cb; return cb;
}; };
// Basic XHR 1, no file support. Shakes fist at IE // Basic XHR 1, no file support. Shakes fist at IE
cb.ajax = function (url, method, callback, nocache, nojsonp) { cb.ajax = function (url, method, callback) {
var xhr, var xhr,
query = serializeData(nodes), query = serializeData(nodes),
type = (method) ? method.toUpperCase() : 'GET', type = (method) ? method.toUpperCase() : 'GET',
hostsearch = new RegExp('http[s]?://(.*?)/', 'gi'), timestamp = '_ts=' + (+new Date());
domain = hostsearch.exec(url),
timestamp = '_ts=' + (+new Date()), if (query && (type === 'GET')) {
head = d.getElementsByTagName('head')[0],
jsonpcallback = 'chibi' + (+new Date()) + (jsonpcount += 1),
script;
if (query && (type === 'GET' || type === 'DELETE')) {
url += (url.indexOf('?') === -1) ? '?' + query : '&' + query; url += (url.indexOf('?') === -1) ? '?' + query : '&' + query;
query = null; query = null;
} }
// JSONP if cross domain url xhr = new XMLHttpRequest(); // we dont support IE < 9
if (type === 'GET' && !nojsonp && domain && w.location.host !== domain[1]) {
if (nocache) {
url += (url.indexOf('?') === -1) ? '?' + timestamp : '&' + timestamp;
}
// Replace possible encoded ?
url = url.replace('=%3F', '=?');
// Replace jsonp ? with callback
if (callback && url.indexOf('=?') !== -1) {
url = url.replace('=?', '=' + jsonpcallback);
w[jsonpcallback] = function (data) {
try {
callback(data, 200);
} catch (e) {}
// Tidy up
w[jsonpcallback] = undefined;
};
}
// JSONP
script = document.createElement('script');
script.async = true;
script.src = url;
// Tidy up
script.onload = function () {
head.removeChild(script);
};
head.appendChild(script);
} else {
if (w.XMLHttpRequest) { if (xhr) {
xhr = new XMLHttpRequest(); // prevent caching
} else if (w.ActiveXObject) { url += (url.indexOf('?') === -1) ? '?' + timestamp : '&' + timestamp;
xhr = new ActiveXObject('Microsoft.XMLHTTP'); // IE < 9
}
if (xhr) {
if (nocache) {
url += (url.indexOf('?') === -1) ? '?' + timestamp : '&' + timestamp;
}
// Douglas Crockford: "Synchronous programming is disrespectful and should not be employed in applications which are used by people" // Douglas Crockford: "Synchronous programming is disrespectful and should not be employed in applications which are used by people"
xhr.open(type, url, true); xhr.open(type, url, true);
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
if (callback) { if (callback) {
callback(xhr.responseText, xhr.status); callback(xhr.responseText, xhr.status);
}
} }
};
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
if (type === 'POST' || type === 'PUT') {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
} }
};
xhr.send(query); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
if (type === 'POST' || type === 'PUT') {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
} }
xhr.send(query);
} }
return cb; return cb;
}; };
// Alias to cb.ajax(url, 'get', callback, nocache, nojsonp) // Alias to cb.ajax(url, 'get', callback)
cb.get = function (url, callback, nocache, nojsonp) { cb.get = function (url, callback) {
return cb.ajax(url, 'get', callback, nocache, nojsonp); return cb.ajax(url, 'get', callback);
}; };
// Alias to cb.ajax(url, 'post', callback, nocache) // Alias to cb.ajax(url, 'post', callback)
cb.post = function (url, callback, nocache) { cb.post = function (url, callback) {
return cb.ajax(url, 'post', callback, nocache); return cb.ajax(url, 'post', callback);
}; };
return cb; return cb;

@ -46,7 +46,7 @@ var page_status = (function() {
} }
function requestUpdate() { function requestUpdate() {
$().get('/api/status.json', onUpdate, true, true); $().get(_root+'/api/status.json', onUpdate);
} }
st.init = function() { st.init = function() {

@ -160,14 +160,13 @@ var page_waveform = (function () {
readoutPending = true; readoutPending = true;
//http://192.168.1.13 var url = _root+'/api/{fmt}.json?n={n}&fs={fs}'.format({
var url = '/api/{fmt}.json?n={n}&fs={fs}'.format({
fmt: dataFormat, fmt: dataFormat,
n: $('#count').val(), n: $('#count').val(),
fs: $('#freq').val() fs: $('#freq').val()
}); });
$().get(url, onRxData, true, true); $().get(url, onRxData);
return true; return true;
} }

@ -76,7 +76,7 @@ var page_wifi = (function () {
/** Ask the CGI what APs are visible (async) */ /** Ask the CGI what APs are visible (async) */
function scanAPs() { function scanAPs() {
$().get('http://192.168.1.13/wifi/scan.cgi', onScan, true, true); // no cache, no jsonp $().get(_root+'/wifi/scan.cgi', onScan); // no cache, no jsonp
} }
function rescan(time) { function rescan(time) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -4,7 +4,7 @@
<div class="Box"> <div class="Box">
<img src="/img/cvut.svg" id="logo" class="mq-tablet-min"> <img src="/img/cvut.svg" id="logo" class="mq-tablet-min">
<h2>Current Analyser</h2> <h2><?= e($appname) ?></h2>
<img src="/img/cvut.svg" id="logo2" class="mq-phone"> <img src="/img/cvut.svg" id="logo2" class="mq-phone">

@ -1,5 +1,4 @@
<?php $page = 'home'; <?php $page = 'home'; include "_start.php"; ?>
include "_start.php"; ?>
<h1>System Status</h1> <h1>System Status</h1>

@ -1,5 +1,4 @@
<?php $page = 'wifi'; <?php $page = 'wifi'; include "_start.php"; ?>
include "_start.php"; ?>
<h1>Wireless Setup</h1> <h1>Wireless Setup</h1>

@ -1,12 +1,14 @@
#content { #content {
flex-grow: 1; flex-grow: 1;
position: relative;
overflow-y: auto;
padding: dist(0); padding: dist(0);
@include media($phone) { @include media($phone) {
padding: dist(-1); padding: dist(-1);
} }
overflow-y: auto;
& > * { & > * {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@ -34,3 +36,22 @@
color: $c-form-label-fg; color: $c-form-label-fg;
} }
} }
// Loader wheel in top right corner
#loader {
position: absolute;
right: dist(1);
top: dist(1);
transition: opacity .2s;
opacity: 0;
@include media($phone) {
top: dist(0);
right: dist(0);
}
&.show {
opacity:1;
}
}

@ -5,8 +5,8 @@
#include <httpd.h> #include <httpd.h>
#include "datalink.h" #include "datalink.h"
#define SAMPLING_TMEO 6000 #define SAMPLING_TMEO 10000
#define SAMP_READOUT_TMEO 100 #define SAMP_READOUT_TMEO 500
typedef struct { typedef struct {
uint32_t count; uint32_t count;

Loading…
Cancel
Save