File examples/wsdemo.c changed (mode: 100644) (index 8078778..517fc1f) |
... |
... |
static void load1(struct Conn *C) |
215 |
215 |
const char *u = |
const char *u = |
216 |
216 |
"window.wsdemo.load1_update = function(id, slots, width, space, load) {\n" |
"window.wsdemo.load1_update = function(id, slots, width, space, load) {\n" |
217 |
217 |
" var svgns = \"http://www.w3.org/2000/svg\";\n" |
" var svgns = \"http://www.w3.org/2000/svg\";\n" |
218 |
|
"" |
|
|
218 |
|
"\n" |
219 |
219 |
" var d = document.getElementById('load1_container');\n" |
" var d = document.getElementById('load1_container');\n" |
220 |
220 |
" d.setAttribute('width', slots);\n" |
" d.setAttribute('width', slots);\n" |
221 |
|
"" |
|
|
221 |
|
"\n" |
222 |
222 |
" d = document.getElementById(id);\n" |
" d = document.getElementById(id);\n" |
223 |
|
"" |
|
|
223 |
|
"\n" |
224 |
224 |
" // Removing first rects if we have too many\n" |
" // Removing first rects if we have too many\n" |
225 |
225 |
" while (d.children.length >= slots)\n" |
" while (d.children.length >= slots)\n" |
226 |
226 |
" d.removeChild(d.children[0]);\n" |
" d.removeChild(d.children[0]);\n" |
227 |
|
"" |
|
|
227 |
|
"\n" |
228 |
228 |
" // Creating a new rectangle\n" |
" // Creating a new rectangle\n" |
229 |
229 |
" var rect = document.createElementNS(svgns, 'rect');\n" |
" var rect = document.createElementNS(svgns, 'rect');\n" |
230 |
230 |
" rect.setAttributeNS(null, 'y', 90 - load);\n" |
" rect.setAttributeNS(null, 'y', 90 - load);\n" |
|
... |
... |
static void load1(struct Conn *C) |
232 |
232 |
" rect.setAttributeNS(null, 'width', width - space);\n" |
" rect.setAttributeNS(null, 'width', width - space);\n" |
233 |
233 |
" rect.setAttributeNS(null, 'fill', 'red');\n" |
" rect.setAttributeNS(null, 'fill', 'red');\n" |
234 |
234 |
" d.appendChild(rect);\n" |
" d.appendChild(rect);\n" |
235 |
|
"" |
|
|
235 |
|
"\n" |
236 |
236 |
" // Set correct positions\n" |
" // Set correct positions\n" |
237 |
237 |
" len = d.children.length;\n" |
" len = d.children.length;\n" |
238 |
238 |
" for (i = 0; i < len; i++) {\n" |
" for (i = 0; i < len; i++) {\n" |
239 |
239 |
" d.children[i].setAttributeNS(null, 'x', slots - len + i);\n" |
" d.children[i].setAttributeNS(null, 'x', slots - len + i);\n" |
240 |
240 |
" }\n" |
" }\n" |
241 |
|
"" |
|
|
241 |
|
"\n" |
242 |
242 |
" // Set text\n" |
" // Set text\n" |
243 |
243 |
" var div = document.getElementById(id + '_text');\n" |
" var div = document.getElementById(id + '_text');\n" |
244 |
244 |
" div.innerHTML = 'Load: ' + load;\n" |
" div.innerHTML = 'Load: ' + load;\n" |
|
... |
... |
static void band1(struct Conn *C) |
279 |
279 |
const char *u = |
const char *u = |
280 |
280 |
"window.wsdemo.band1_update = function (slots, up, down) {\n" |
"window.wsdemo.band1_update = function (slots, up, down) {\n" |
281 |
281 |
" var svgns = 'http://www.w3.org/2000/svg';\n" |
" var svgns = 'http://www.w3.org/2000/svg';\n" |
282 |
|
"" |
|
|
282 |
|
"\n" |
283 |
283 |
" var d = document.getElementById('band1_container');\n" |
" var d = document.getElementById('band1_container');\n" |
284 |
284 |
" d.setAttribute('width', slots);\n" |
" d.setAttribute('width', slots);\n" |
285 |
|
"" |
|
|
285 |
|
"\n" |
286 |
286 |
" d = document.getElementById('band1_line');\n" |
" d = document.getElementById('band1_line');\n" |
287 |
287 |
" d.setAttribute('x2', slots);\n" |
" d.setAttribute('x2', slots);\n" |
288 |
|
"" |
|
|
288 |
|
"\n" |
289 |
289 |
" d = document.getElementById('band1_text_up');\n" |
" d = document.getElementById('band1_text_up');\n" |
290 |
290 |
" d.innerHTML = 'Up: ' + up + 'mbit/s';\n" |
" d.innerHTML = 'Up: ' + up + 'mbit/s';\n" |
291 |
|
"" |
|
|
291 |
|
"\n" |
292 |
292 |
" d = document.getElementById('band1_text_down');\n" |
" d = document.getElementById('band1_text_down');\n" |
293 |
293 |
" d.innerHTML = 'Down: ' + down + 'mbit/s';\n" |
" d.innerHTML = 'Down: ' + down + 'mbit/s';\n" |
294 |
|
"" |
|
|
294 |
|
"\n" |
295 |
295 |
" d = document.getElementById('band1');\n" |
" d = document.getElementById('band1');\n" |
296 |
296 |
" while (d.children.length >= 2 * (slots - 1)) {\n" |
" while (d.children.length >= 2 * (slots - 1)) {\n" |
297 |
297 |
" d.removeChild(d.children[0]);\n" |
" d.removeChild(d.children[0]);\n" |
298 |
298 |
" d.removeChild(d.children[0]);\n" |
" d.removeChild(d.children[0]);\n" |
299 |
299 |
" }\n" |
" }\n" |
300 |
|
"" |
|
|
300 |
|
"\n" |
301 |
301 |
" // Creating new lines\n" |
" // Creating new lines\n" |
302 |
302 |
" for (j = 0; j < 2; j++) {\n" |
" for (j = 0; j < 2; j++) {\n" |
303 |
303 |
" var line = document.createElementNS(svgns, 'line');\n" |
" var line = document.createElementNS(svgns, 'line');\n" |
|
... |
... |
static void band1(struct Conn *C) |
311 |
311 |
" line.setAttributeNS(null, 'stroke', color);\n" |
" line.setAttributeNS(null, 'stroke', color);\n" |
312 |
312 |
" d.appendChild(line);\n" |
" d.appendChild(line);\n" |
313 |
313 |
" }\n" |
" }\n" |
314 |
|
"" |
|
|
314 |
|
"\n" |
315 |
315 |
" // Set correct positions\n" |
" // Set correct positions\n" |
316 |
316 |
" len = d.children.length;\n" |
" len = d.children.length;\n" |
317 |
317 |
" for (i = 0; i < len; i += 2) {\n" |
" for (i = 0; i < len; i += 2) {\n" |
|
... |
... |
static void arc1(struct Conn *C) |
361 |
361 |
" // compute sum\n" |
" // compute sum\n" |
362 |
362 |
" var sum = 0;\n" |
" var sum = 0;\n" |
363 |
363 |
" var i;\n" |
" var i;\n" |
364 |
|
"" |
|
|
364 |
|
"\n" |
365 |
365 |
" for (i = 0; i < a.length; i++)\n" |
" for (i = 0; i < a.length; i++)\n" |
366 |
366 |
" sum += a[i].value;\n" |
" sum += a[i].value;\n" |
367 |
|
"" |
|
|
367 |
|
"\n" |
368 |
368 |
" var d = document.getElementById('arc1');\n" |
" var d = document.getElementById('arc1');\n" |
369 |
369 |
" var t = document.getElementById('arc1_text');\n" |
" var t = document.getElementById('arc1_text');\n" |
370 |
|
"" |
|
|
370 |
|
"\n" |
371 |
371 |
" // TODO: we must respect first point to allow user to position the elements!\n" |
" // TODO: we must respect first point to allow user to position the elements!\n" |
372 |
372 |
" var last_x = 10; var last_y = 50; var last_angle = Math.PI;\n" |
" var last_x = 10; var last_y = 50; var last_angle = Math.PI;\n" |
373 |
373 |
" for (i = 0; i < a.length; i++) {\n" |
" for (i = 0; i < a.length; i++) {\n" |
374 |
374 |
" var m = d.children[i].pathSegList[0];\n" |
" var m = d.children[i].pathSegList[0];\n" |
375 |
375 |
" m.x = last_x; m.y = last_y;\n" |
" m.x = last_x; m.y = last_y;\n" |
376 |
|
"" |
|
|
376 |
|
"\n" |
377 |
377 |
" var c = d.children[i].pathSegList[1];\n" |
" var c = d.children[i].pathSegList[1];\n" |
378 |
378 |
" angle = a[i].value * 2 * Math.PI / sum;\n" |
" angle = a[i].value * 2 * Math.PI / sum;\n" |
379 |
379 |
" if (angle > Math.PI) {\n" |
" if (angle > Math.PI) {\n" |
|
... |
... |
static void bar1(struct Conn *C) |
435 |
435 |
"window.wsdemo.bar1_update = function(a, width, depth) {\n" |
"window.wsdemo.bar1_update = function(a, width, depth) {\n" |
436 |
436 |
" var svgns = \"http://www.w3.org/2000/svg\";\n" |
" var svgns = \"http://www.w3.org/2000/svg\";\n" |
437 |
437 |
" var i, bbox, space = width - a.length;\n" |
" var i, bbox, space = width - a.length;\n" |
438 |
|
"" |
|
|
438 |
|
"\n" |
439 |
439 |
" var d = document.getElementById('bar1');\n" |
" var d = document.getElementById('bar1');\n" |
440 |
440 |
" var t = document.getElementById('bar1_text');\n" |
" var t = document.getElementById('bar1_text');\n" |
441 |
441 |
" var tv = document.getElementById('bar1_values');\n" |
" var tv = document.getElementById('bar1_values');\n" |
442 |
|
"" |
|
|
442 |
|
"\n" |
443 |
443 |
" var last_x = (100 - a.length * width - (a.length - 1) * space) / 2;\n" |
" var last_x = (100 - a.length * width - (a.length - 1) * space) / 2;\n" |
444 |
444 |
" for (i = 0; i < a.length; i++) {\n" |
" for (i = 0; i < a.length; i++) {\n" |
445 |
445 |
" if (d.children[i] == null) {\n" |
" if (d.children[i] == null) {\n" |
|
... |
... |
static void bar1(struct Conn *C) |
448 |
448 |
" path.setAttribute('stroke-width', '0.1');\n" |
" path.setAttribute('stroke-width', '0.1');\n" |
449 |
449 |
" path.setAttribute('d', 'M0 0');\n" |
" path.setAttribute('d', 'M0 0');\n" |
450 |
450 |
" d.appendChild(path);\n" |
" d.appendChild(path);\n" |
451 |
|
"" |
|
|
451 |
|
"\n" |
452 |
452 |
" var text = document.createElementNS(svgns, 'text');\n" |
" var text = document.createElementNS(svgns, 'text');\n" |
453 |
453 |
" text.setAttribute('y', 90);\n" |
" text.setAttribute('y', 90);\n" |
454 |
454 |
" text.setAttribute('font-size', 3);\n" |
" text.setAttribute('font-size', 3);\n" |
455 |
455 |
" t.appendChild(text);\n" |
" t.appendChild(text);\n" |
456 |
|
"" |
|
|
456 |
|
"\n" |
457 |
457 |
" text = document.createElementNS(svgns, 'text');\n" |
" text = document.createElementNS(svgns, 'text');\n" |
458 |
458 |
" text.setAttribute('y', 94);\n" |
" text.setAttribute('y', 94);\n" |
459 |
459 |
" text.setAttribute('font-size', 3);\n" |
" text.setAttribute('font-size', 3);\n" |
460 |
460 |
" text.setAttribute('fill', '#000');\n" |
" text.setAttribute('fill', '#000');\n" |
461 |
461 |
" tv.appendChild(text);\n" |
" tv.appendChild(text);\n" |
462 |
462 |
" }\n" |
" }\n" |
463 |
|
"" |
|
|
463 |
|
"\n" |
464 |
464 |
" var v = a[i].value;\n" |
" var v = a[i].value;\n" |
465 |
465 |
" var center = last_x + width / 2;\n" |
" var center = last_x + width / 2;\n" |
466 |
|
"" |
|
|
466 |
|
"\n" |
467 |
467 |
" var m = d.children[i];\n" |
" var m = d.children[i];\n" |
468 |
468 |
" m.setAttribute('fill', a[i].color);\n" |
" m.setAttribute('fill', a[i].color);\n" |
469 |
469 |
" m.setAttribute('d',\n" |
" m.setAttribute('d',\n" |
|
... |
... |
static void bar1(struct Conn *C) |
471 |
471 |
" + ' v' + v + ' h-' + width + ' v-' + v + ' z'\n" |
" + ' v' + v + ' h-' + width + ' v-' + v + ' z'\n" |
472 |
472 |
" + ' l' + depth + ',-' + depth + ' v' + v + ' l-' + depth + ',' + depth + ' z'\n" |
" + ' l' + depth + ',-' + depth + ' v' + v + ' l-' + depth + ',' + depth + ' z'\n" |
473 |
473 |
" + ' h-' + width + ' l' + depth + ',-' + depth + ' h' + width + ' z');\n" |
" + ' h-' + width + ' l' + depth + ',-' + depth + ' h' + width + ' z');\n" |
474 |
|
"" |
|
|
474 |
|
"\n" |
475 |
475 |
" t.children[i].setAttribute('fill', a[i].color);\n" |
" t.children[i].setAttribute('fill', a[i].color);\n" |
476 |
476 |
" t.children[i].innerHTML = a[i].name;\n" |
" t.children[i].innerHTML = a[i].name;\n" |
477 |
477 |
" bbox = t.children[i].getBBox();\n" |
" bbox = t.children[i].getBBox();\n" |
478 |
478 |
" t.children[i].setAttribute('x', center - bbox.width / 2);\n" |
" t.children[i].setAttribute('x', center - bbox.width / 2);\n" |
479 |
|
"" |
|
|
479 |
|
"\n" |
480 |
480 |
" tv.children[i].innerHTML = v;\n" |
" tv.children[i].innerHTML = v;\n" |
481 |
481 |
" bbox = tv.children[i].getBBox();\n" |
" bbox = tv.children[i].getBBox();\n" |
482 |
482 |
" tv.children[i].setAttribute('x', center - bbox.width / 2);\n" |
" tv.children[i].setAttribute('x', center - bbox.width / 2);\n" |
483 |
|
"" |
|
|
483 |
|
"\n" |
484 |
484 |
" last_x += width + space;\n" |
" last_x += width + space;\n" |
485 |
485 |
" }\n" |
" }\n" |
486 |
486 |
" while (d.children[i] != null) {\n" |
" while (d.children[i] != null) {\n" |
|
... |
... |
static void cyl1(struct Conn *C) |
533 |
533 |
" var ctx = canvas.getContext('2d');\n" |
" var ctx = canvas.getContext('2d');\n" |
534 |
534 |
" ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);\n" |
" ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);\n" |
535 |
535 |
" ctx.lineWidth = 1;\n" |
" ctx.lineWidth = 1;\n" |
536 |
|
"" |
|
|
536 |
|
"\n" |
537 |
537 |
" // draw big rectangle\n" |
" // draw big rectangle\n" |
538 |
538 |
" ctx.beginPath();\n" |
" ctx.beginPath();\n" |
539 |
539 |
" ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height);\n" |
" ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height);\n" |
540 |
540 |
" ctx.stroke();\n" |
" ctx.stroke();\n" |
541 |
|
"" |
|
|
541 |
|
"\n" |
542 |
542 |
" // draw some lines\n" |
" // draw some lines\n" |
543 |
543 |
" for (i = 0; i < 100; i += 10) {\n" |
" for (i = 0; i < 100; i += 10) {\n" |
544 |
544 |
" ctx.beginPath();\n" |
" ctx.beginPath();\n" |
|
... |
... |
static void cyl1(struct Conn *C) |
546 |
546 |
" ctx.lineTo(100, 99.5 - i);\n" |
" ctx.lineTo(100, 99.5 - i);\n" |
547 |
547 |
" ctx.stroke();\n" |
" ctx.stroke();\n" |
548 |
548 |
" }\n" |
" }\n" |
549 |
|
"" |
|
|
549 |
|
"\n" |
550 |
550 |
" ctx.save();\n" |
" ctx.save();\n" |
551 |
551 |
" ctx.shadowColor = '#444';\n" |
" ctx.shadowColor = '#444';\n" |
552 |
552 |
" ctx.shadowBlur = 2;\n" |
" ctx.shadowBlur = 2;\n" |
|
... |
... |
static void cyl1(struct Conn *C) |
560 |
560 |
" g.addColorStop(0.5, colors[i].m);\n" |
" g.addColorStop(0.5, colors[i].m);\n" |
561 |
561 |
" g.addColorStop(1, colors[i].s);\n" |
" g.addColorStop(1, colors[i].s);\n" |
562 |
562 |
" ctx.fillStyle = g;\n" |
" ctx.fillStyle = g;\n" |
563 |
|
"" |
|
|
563 |
|
"\n" |
564 |
564 |
" ctx.fillRect(last_x, 99 - a[i], 10, a[i]);\n" |
" ctx.fillRect(last_x, 99 - a[i], 10, a[i]);\n" |
565 |
565 |
" last_x += 15;\n" |
" last_x += 15;\n" |
566 |
566 |
" }\n" |
" }\n" |
|
... |
... |
static void pie1(struct Conn *C) |
610 |
610 |
" var sum = 0;\n" |
" var sum = 0;\n" |
611 |
611 |
" for (i = 0; i < a.length; i++)\n" |
" for (i = 0; i < a.length; i++)\n" |
612 |
612 |
" sum += a[i].value;\n" |
" sum += a[i].value;\n" |
613 |
|
"" |
|
|
613 |
|
"\n" |
614 |
614 |
" var canvas = document.getElementById('pie1');\n" |
" var canvas = document.getElementById('pie1');\n" |
615 |
615 |
" var ctx = canvas.getContext('2d');\n" |
" var ctx = canvas.getContext('2d');\n" |
616 |
616 |
" ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);\n" |
" ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);\n" |
617 |
|
"" |
|
|
617 |
|
"\n" |
618 |
618 |
" ctx.shadowColor = '#444';\n" |
" ctx.shadowColor = '#444';\n" |
619 |
619 |
" ctx.shadowBlur = 3;\n" |
" ctx.shadowBlur = 3;\n" |
620 |
620 |
" ctx.shadowOffsetX = 2;\n" |
" ctx.shadowOffsetX = 2;\n" |
|
... |
... |
static void pie1(struct Conn *C) |
631 |
631 |
" ctx.fill();\n" |
" ctx.fill();\n" |
632 |
632 |
" ctx.strokeStyle = '#444';\n" |
" ctx.strokeStyle = '#444';\n" |
633 |
633 |
" ctx.stroke();\n" |
" ctx.stroke();\n" |
634 |
|
"" |
|
|
634 |
|
"\n" |
635 |
635 |
" last_angle += angle;\n" |
" last_angle += angle;\n" |
636 |
636 |
" }\n" |
" }\n" |
637 |
637 |
"}"; |
"}"; |
|
... |
... |
static void trigger(struct Conn *C) |
675 |
675 |
// Here goes some init stuff |
// Here goes some init stuff |
676 |
676 |
const char *code = |
const char *code = |
677 |
677 |
"window.wsdemo = [];\n" |
"window.wsdemo = [];\n" |
678 |
|
"" |
|
|
678 |
|
"\n" |
679 |
679 |
"window.wsdemo.button = function(a) {\n" |
"window.wsdemo.button = function(a) {\n" |
680 |
680 |
" var data = {\n" |
" var data = {\n" |
681 |
681 |
" op: 'button',\n" |
" op: 'button',\n" |
|
... |
... |
static void trigger(struct Conn *C) |
683 |
683 |
" };\n" |
" };\n" |
684 |
684 |
" ws.send(JSON.stringify(data));\n" |
" ws.send(JSON.stringify(data));\n" |
685 |
685 |
"}\n" |
"}\n" |
686 |
|
"" |
|
|
686 |
|
"\n" |
687 |
687 |
"window.wsdemo.my_resize = function(e) {\n" |
"window.wsdemo.my_resize = function(e) {\n" |
688 |
688 |
" var data = {\n" |
" var data = {\n" |
689 |
689 |
" op: 'resize',\n" |
" op: 'resize',\n" |
|
... |
... |
static void trigger(struct Conn *C) |
692 |
692 |
" };\n" |
" };\n" |
693 |
693 |
" ws.send(JSON.stringify(data));\n" |
" ws.send(JSON.stringify(data));\n" |
694 |
694 |
"}\n" |
"}\n" |
|
695 |
|
"\n" |
|
696 |
|
"window.wsdemo.source = function(name) {\n" |
|
697 |
|
" var t;\n" |
|
698 |
|
" var d = document.getElementById(name + '_source');\n" |
|
699 |
|
" if (d.innerHTML == '' || d.innerHTML == '<pre></pre>')\n" |
|
700 |
|
" t = window.wsdemo[name + '_update'].toString();\n" |
|
701 |
|
" else\n" |
|
702 |
|
" t = '';\n" |
|
703 |
|
" d.innerHTML = '<pre>' + t + '</pre>';\n" |
|
704 |
|
"}\n" |
695 |
705 |
"window.addEventListener('resize', window.wsdemo.my_resize, true);\n" |
"window.addEventListener('resize', window.wsdemo.my_resize, true);\n" |
696 |
706 |
"window.wsdemo.my_resize();\n"; |
"window.wsdemo.my_resize();\n"; |
697 |
707 |
push_code(C, code); |
push_code(C, code); |
|
... |
... |
static void trigger(struct Conn *C) |
721 |
731 |
|
|
722 |
732 |
static const char main_screen[] = |
static const char main_screen[] = |
723 |
733 |
"<div class=\"gem\" width=\"120px\">\n" |
"<div class=\"gem\" width=\"120px\">\n" |
724 |
|
"Progress bar 1 (div)\n" |
|
|
734 |
|
"Progress bar 1 (div)</br />\n" |
725 |
735 |
"<div style=\"margin: 3px; height: 10px; width: 100px; background-color: #eeeeee; border: 1px solid\">\n" |
"<div style=\"margin: 3px; height: 10px; width: 100px; background-color: #eeeeee; border: 1px solid\">\n" |
726 |
736 |
" <div id=\"per1\" style=\"height: 10px; width: 0px; background-color: red\"></div>\n" |
" <div id=\"per1\" style=\"height: 10px; width: 0px; background-color: red\"></div>\n" |
727 |
737 |
"</div>\n" |
"</div>\n" |
728 |
|
"</div>\n\n" |
|
729 |
|
"" |
|
|
738 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('per1');\" value=\"Source\" />\n" |
|
739 |
|
"<div class=\"source\" id=\"per1_source\"></div>\n" |
|
740 |
|
"</div>\n" |
|
741 |
|
"\n" |
730 |
742 |
"<div class=\"gem\" width=\"120px\">\n" |
"<div class=\"gem\" width=\"120px\">\n" |
731 |
|
"Progress bar 2 (SVG)\n" |
|
|
743 |
|
"Progress bar 2 (SVG)<br />\n" |
732 |
744 |
"<svg height=\"20\" width=\"110\" style=\"border: 1px solid black\">\n" |
"<svg height=\"20\" width=\"110\" style=\"border: 1px solid black\">\n" |
733 |
745 |
" <defs>\n" |
" <defs>\n" |
734 |
746 |
" <linearGradient id=\"per2_gra1\" gradientTransform=\"rotate(90)\">\n" |
" <linearGradient id=\"per2_gra1\" gradientTransform=\"rotate(90)\">\n" |
|
... |
... |
static const char main_screen[] = |
737 |
749 |
" <stop offset=\"95%\" stop-color=\"#f60\" />\n" |
" <stop offset=\"95%\" stop-color=\"#f60\" />\n" |
738 |
750 |
" </linearGradient>\n" |
" </linearGradient>\n" |
739 |
751 |
" </defs>\n" |
" </defs>\n" |
740 |
|
" <rect id=\"per2\" x=\"5\" y=\"5\" width=\"0\" height=\"10\" fill=\"url(#per2_gra1)\"/>\n" |
|
741 |
|
" <rect x=\"5\" y=\"5\" width=\"100\" height=\"10\" style=\"fill:transparent; stroke-width:.1; stroke:black\"/>\n" |
|
742 |
|
"</svg>\n" |
|
743 |
|
"</div>\n\n" |
|
744 |
|
"" |
|
|
752 |
|
" <rect id=\"per2\" x=\"5\" y=\"5\" width=\"0\" height=\"10\" fill=\"url(#per2_gra1)\" />\n" |
|
753 |
|
" <rect x=\"5\" y=\"5\" width=\"100\" height=\"10\" style=\"fill:transparent; stroke-width:.1; stroke:black\" />\n" |
|
754 |
|
"</svg><br />\n" |
|
755 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('per2');\" value=\"Source\" />\n" |
|
756 |
|
"<div class=\"source\" id=\"per2_source\"></div>\n" |
|
757 |
|
"</div>\n" |
|
758 |
|
"\n" |
745 |
759 |
"<div class=\"gem\" width=\"120px\">\n" |
"<div class=\"gem\" width=\"120px\">\n" |
746 |
|
"Server load (SVG)\n" |
|
|
760 |
|
"Server load (SVG)<br />\n" |
747 |
761 |
"<svg id=\"load1_container\" height=\"102\" width=\"102\" style=\"border: 1px solid green\">\n" |
"<svg id=\"load1_container\" height=\"102\" width=\"102\" style=\"border: 1px solid green\">\n" |
748 |
762 |
" <g id=\"load1\"></g>\n" |
" <g id=\"load1\"></g>\n" |
749 |
763 |
" <text id=\"load1_text\" x=\"2\" y=\"99\" style=\"font-size: 10px\">Load here</text>\n" |
" <text id=\"load1_text\" x=\"2\" y=\"99\" style=\"font-size: 10px\">Load here</text>\n" |
750 |
|
"</svg>\n" |
|
|
764 |
|
"</svg><br />\n" |
|
765 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('load1');\" value=\"Source\" />\n" |
|
766 |
|
"<div class=\"source\" id=\"load1_source\"></div>\n" |
751 |
767 |
"<div class=\"note\" width=\"100px\">Note: the width of the SVG is scaled based on" |
"<div class=\"note\" width=\"100px\">Note: the width of the SVG is scaled based on" |
752 |
768 |
" available width, but no more than 100px; previous values are pushed by the server.</div>\n" |
" available width, but no more than 100px; previous values are pushed by the server.</div>\n" |
753 |
|
"</div>\n\n" |
|
754 |
|
"" |
|
|
769 |
|
"</div>\n" |
|
770 |
|
"\n" |
755 |
771 |
"<div class=\"gem\">\n" |
"<div class=\"gem\">\n" |
756 |
|
"Bandwidth (SVG)\n" |
|
|
772 |
|
"Bandwidth (SVG)<br />\n" |
757 |
773 |
"<svg id=\"band1_container\" height=\"102\" width=\"100\" style=\"border: 1px solid green\">\n" |
"<svg id=\"band1_container\" height=\"102\" width=\"100\" style=\"border: 1px solid green\">\n" |
758 |
774 |
" <g id=\"band1\"></g>\n" |
" <g id=\"band1\"></g>\n" |
759 |
|
" <line id=\"band1_line\" x1=\"0\" x2=\"100\" y1=\"50\" y2=\"50\" style=\"stroke: blue\"/>\n" |
|
|
775 |
|
" <line id=\"band1_line\" x1=\"0\" x2=\"100\" y1=\"50\" y2=\"50\" style=\"stroke: blue\" />\n" |
760 |
776 |
" <text id=\"band1_text_up\" x=\"1\" y=\"7\" style=\"font-size: 5pt\"></text>\n" |
" <text id=\"band1_text_up\" x=\"1\" y=\"7\" style=\"font-size: 5pt\"></text>\n" |
761 |
777 |
" <text id=\"band1_text_down\" x=\"1\" y=\"100\" style=\"font-size: 5pt\"></text>\n" |
" <text id=\"band1_text_down\" x=\"1\" y=\"100\" style=\"font-size: 5pt\"></text>\n" |
762 |
|
"</svg>\n" |
|
|
778 |
|
"</svg><br />\n" |
|
779 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('band1');\" value=\"Source\" />\n" |
|
780 |
|
"<div class=\"source\" id=\"band1_source\"></div>\n" |
763 |
781 |
"<div class=\"note\" width=\"200px\">Note: the width of the SVG is" |
"<div class=\"note\" width=\"200px\">Note: the width of the SVG is" |
764 |
782 |
" scaled based on available width, but no more than 200px.</div>\n" |
" scaled based on available width, but no more than 200px.</div>\n" |
765 |
|
"</div>\n\n" |
|
766 |
|
"" |
|
|
783 |
|
"</div>\n" |
|
784 |
|
"\n" |
767 |
785 |
"<div class=\"gem\" width=\"420px\">\n" |
"<div class=\"gem\" width=\"420px\">\n" |
768 |
|
"Arc 1 (SVG arcs + div text)\n" |
|
|
786 |
|
"Arc 1 (SVG arcs + div text)</br />\n" |
769 |
787 |
"<svg height=\"100\" width=\"100\" style=\"border: 1px solid green\">\n" |
"<svg height=\"100\" width=\"100\" style=\"border: 1px solid green\">\n" |
770 |
788 |
"<defs>\n" |
"<defs>\n" |
771 |
789 |
" <filter id=\"ds1\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n" |
" <filter id=\"ds1\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n" |
772 |
790 |
" <feGaussianBlur result=\"blur\" in=\"SourceAlpha\" stdDeviation=\"2\" />\n" |
" <feGaussianBlur result=\"blur\" in=\"SourceAlpha\" stdDeviation=\"2\" />\n" |
773 |
791 |
" </filter>\n" |
" </filter>\n" |
774 |
792 |
"</defs>\n" |
"</defs>\n" |
775 |
|
" <circle r=\"40\" cx=\"50\" cy=\"50\" fill=\"transparent\" stroke=\"black\" stroke-width=\"10\" filter=\"url(#ds1)\"/>\n" |
|
|
793 |
|
" <circle r=\"40\" cx=\"50\" cy=\"50\" fill=\"transparent\" stroke=\"black\" stroke-width=\"10\" filter=\"url(#ds1)\" />\n" |
776 |
794 |
" <g id=\"arc1\">\n" |
" <g id=\"arc1\">\n" |
777 |
|
"" // a r1 r2 angle largeArcFlag sweepFlag dx dy |
|
778 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#f00\" stroke-width=\"10\"/>\n" |
|
779 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#00f\" stroke-width=\"10\"\"/>\n" |
|
780 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#f0f\" stroke-width=\"10\"\"/>\n" |
|
781 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#909\" stroke-width=\"10\"\"/>\n" |
|
782 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#770\" stroke-width=\"10\"\"/>\n" |
|
|
795 |
|
"\n" // a r1 r2 angle largeArcFlag sweepFlag dx dy |
|
796 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#f00\" stroke-width=\"10\" />\n" |
|
797 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#00f\" stroke-width=\"10\"\" />\n" |
|
798 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#f0f\" stroke-width=\"10\"\" />\n" |
|
799 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#909\" stroke-width=\"10\"\" />\n" |
|
800 |
|
" <path d=\"M 10 50 a 40 40 0 0 1 0 0\" fill=\"transparent\" stroke=\"#770\" stroke-width=\"10\"\" />\n" |
783 |
801 |
" </g>\n" |
" </g>\n" |
784 |
802 |
" <g id=\"arc1_text\" style=\"font-size: 4pt\">\n" |
" <g id=\"arc1_text\" style=\"font-size: 4pt\">\n" |
785 |
803 |
" <text x=\"30\" y=\"32\" fill=\"#f00\"></text>\n" |
" <text x=\"30\" y=\"32\" fill=\"#f00\"></text>\n" |
|
... |
... |
static const char main_screen[] = |
788 |
806 |
" <text x=\"30\" y=\"62\" fill=\"#909\"></text>\n" |
" <text x=\"30\" y=\"62\" fill=\"#909\"></text>\n" |
789 |
807 |
" <text x=\"30\" y=\"72\" fill=\"#990\"></text>\n" |
" <text x=\"30\" y=\"72\" fill=\"#990\"></text>\n" |
790 |
808 |
" </g>\n" |
" </g>\n" |
791 |
|
"</svg>\n" |
|
792 |
|
"</div>\n\n" |
|
793 |
|
"" |
|
|
809 |
|
"</svg><br />\n" |
|
810 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('arc1');\" value=\"Source\" />\n" |
|
811 |
|
"<div class=\"source\" id=\"arc1_source\"></div>\n" |
|
812 |
|
"</div>\n" |
|
813 |
|
"\n" |
794 |
814 |
"<div class=\"gem\" width=\"420px\">\n" |
"<div class=\"gem\" width=\"420px\">\n" |
795 |
|
"Bar 1 (SVG lines + SVG text)\n" |
|
|
815 |
|
"Bar 1 (SVG lines + SVG text)<br />\n" |
796 |
816 |
"<svg height=\"100\" width=\"100\" style=\"border: 1px solid green\">\n" |
"<svg height=\"100\" width=\"100\" style=\"border: 1px solid green\">\n" |
797 |
|
" <line x1=\"0\" x2=\"100\" y1=\"85\" y2=\"85\" style=\"stroke: red\"/>\n" |
|
|
817 |
|
" <line x1=\"0\" x2=\"100\" y1=\"85\" y2=\"85\" style=\"stroke: red\" />\n" |
798 |
818 |
" <g id=\"bar1\"></g>\n" |
" <g id=\"bar1\"></g>\n" |
799 |
819 |
" <g id=\"bar1_text\"></g>\n" |
" <g id=\"bar1_text\"></g>\n" |
800 |
820 |
" <g id=\"bar1_values\"></g>\n" |
" <g id=\"bar1_values\"></g>\n" |
801 |
|
"</svg>\n" |
|
802 |
|
"</div>\n\n" |
|
803 |
|
"" |
|
|
821 |
|
"</svg><br />\n" |
|
822 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('bar1');\" value=\"Source\" />\n" |
|
823 |
|
"<div class=\"source\" id=\"bar1_source\"></div>\n" |
|
824 |
|
"</div>\n" |
|
825 |
|
"\n" |
804 |
826 |
"<div class=\"gem\">\n" |
"<div class=\"gem\">\n" |
805 |
|
"Cylinders (canvas, 2D)\n" |
|
|
827 |
|
"Cylinders (canvas, 2D)<br />\n" |
806 |
828 |
"<canvas id=\"cyl1\" width=\"100px\" height=\"100px\">\n" |
"<canvas id=\"cyl1\" width=\"100px\" height=\"100px\">\n" |
807 |
829 |
" Your browser does not support canvas.\n" |
" Your browser does not support canvas.\n" |
808 |
|
"</canvas>\n" |
|
|
830 |
|
"</canvas><br />\n" |
|
831 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('cyl1');\" value=\"Source\" />\n" |
|
832 |
|
"<div class=\"source\" id=\"cyl1_source\"></div>\n" |
809 |
833 |
"</div>\n" |
"</div>\n" |
810 |
|
"" |
|
|
834 |
|
"\n" |
811 |
835 |
"<div class=\"gem\">\n" |
"<div class=\"gem\">\n" |
812 |
|
"Pie (canvas, 2D)\n" |
|
|
836 |
|
"Pie (canvas, 2D)<br />\n" |
813 |
837 |
"<canvas id=\"pie1\" width=\"100px\" height=\"100px\">\n" |
"<canvas id=\"pie1\" width=\"100px\" height=\"100px\">\n" |
814 |
838 |
" Your browser does not support canvas.\n" |
" Your browser does not support canvas.\n" |
815 |
|
"</canvas>\n" |
|
|
839 |
|
"</canvas><br />\n" |
|
840 |
|
"<input type=\"button\" onclick=\"window.wsdemo.source('pie1');\" value=\"Source\" />\n" |
|
841 |
|
"<div class=\"source\" id=\"pie1_source\"></div>\n" |
816 |
842 |
"</div>\n" |
"</div>\n" |
817 |
|
"" |
|
|
843 |
|
"\n" |
818 |
844 |
"<div class=\"gem\">\n" |
"<div class=\"gem\">\n" |
819 |
|
"Buttons\n" |
|
|
845 |
|
"Buttons<br />\n" |
820 |
846 |
"<input type=\"button\" onclick=\"window.wsdemo.button('notify');\"" |
"<input type=\"button\" onclick=\"window.wsdemo.button('notify');\"" |
821 |
847 |
" value=\"trigger notification\" />\n" |
" value=\"trigger notification\" />\n" |
822 |
848 |
"</div>\n"; |
"</div>\n"; |