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"?>
<!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>
<data>
<variable>EnvironmentId</variable>

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

@ -1,16 +1,23 @@
<?php
$menu = [
'home' => [ '/', 'Home' ],
'wifi' => [ '/wifi', 'WiFi config' ],
'waveform' => [ '/waveform', 'Waveform' ],
'fft' => [ '/fft', 'FFT' ],
// 'spectrogram' => [ '/spectrogram', 'Spectrogram' ],
// 'transient' => [ '/transient', 'Power-on transient' ],
'about' => [ '/about', 'About' ],
];
$prod = defined('STDIN');
$root = $prod ? '' : 'http://192.168.1.13';
$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>
<html>
@ -19,32 +26,29 @@ $appname = 'Current analyzer';
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<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">
<?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>
// 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>
<body class="page-<?=$page?>">
<div id="outer">
<nav id="menu">
<div id="brand" onclick="$('#menu').toggleClass('expanded')">Current Analyser</div>
<div id="brand" onclick="$('#menu').toggleClass('expanded')"><?= e($appname) ?></div>
<?php
// generate the menu
foreach($menu as $k => $m) {
$sel = ($page == $k) ? ' class="selected"' : '';
$text = htmlspecialchars($m[1]);
echo "<a href=\"$m[0]\"$sel>$text</a>";
$text = e($m[1]);
$url = e($m[0]);
echo "<a href=\"$url\"$sel>$text</a>";
}
?>
</nav>
<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 */
// MODIFIED VERSION.
(function () {
'use strict';
@ -6,7 +8,6 @@
loadedfn = [],
domready = false,
pageloaded = false,
jsonpcount = 0,
d = document,
w = window;
@ -598,103 +599,52 @@
return cb;
};
// 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,
query = serializeData(nodes),
type = (method) ? method.toUpperCase() : 'GET',
hostsearch = new RegExp('http[s]?://(.*?)/', 'gi'),
domain = hostsearch.exec(url),
timestamp = '_ts=' + (+new Date()),
head = d.getElementsByTagName('head')[0],
jsonpcallback = 'chibi' + (+new Date()) + (jsonpcount += 1),
script;
if (query && (type === 'GET' || type === 'DELETE')) {
timestamp = '_ts=' + (+new Date());
if (query && (type === 'GET')) {
url += (url.indexOf('?') === -1) ? '?' + query : '&' + query;
query = null;
}
// JSONP if cross domain url
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 {
xhr = new XMLHttpRequest(); // we dont support IE < 9
if (w.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else if (w.ActiveXObject) {
xhr = new ActiveXObject('Microsoft.XMLHTTP'); // IE < 9
}
if (xhr) {
if (nocache) {
url += (url.indexOf('?') === -1) ? '?' + timestamp : '&' + timestamp;
}
if (xhr) {
// prevent caching
url += (url.indexOf('?') === -1) ? '?' + timestamp : '&' + timestamp;
// Douglas Crockford: "Synchronous programming is disrespectful and should not be employed in applications which are used by people"
xhr.open(type, url, true);
// Douglas Crockford: "Synchronous programming is disrespectful and should not be employed in applications which are used by people"
xhr.open(type, url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (callback) {
callback(xhr.responseText, xhr.status);
}
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (callback) {
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;
};
// Alias to cb.ajax(url, 'get', callback, nocache, nojsonp)
cb.get = function (url, callback, nocache, nojsonp) {
return cb.ajax(url, 'get', callback, nocache, nojsonp);
// Alias to cb.ajax(url, 'get', callback)
cb.get = function (url, callback) {
return cb.ajax(url, 'get', callback);
};
// Alias to cb.ajax(url, 'post', callback, nocache)
cb.post = function (url, callback, nocache) {
return cb.ajax(url, 'post', callback, nocache);
// Alias to cb.ajax(url, 'post', callback)
cb.post = function (url, callback) {
return cb.ajax(url, 'post', callback);
};
return cb;

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

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

@ -76,7 +76,7 @@ var page_wifi = (function () {
/** Ask the CGI what APs are visible (async) */
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) {

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">
<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">

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

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

@ -1,12 +1,14 @@
#content {
flex-grow: 1;
position: relative;
overflow-y: auto;
padding: dist(0);
@include media($phone) {
padding: dist(-1);
}
overflow-y: auto;
& > * {
margin-left: auto;
margin-right: auto;
@ -34,3 +36,22 @@
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 "datalink.h"
#define SAMPLING_TMEO 6000
#define SAMP_READOUT_TMEO 100
#define SAMPLING_TMEO 10000
#define SAMP_READOUT_TMEO 500
typedef struct {
uint32_t count;

Loading…
Cancel
Save