123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- function getAllData(){
-
- $.ajax({
- type: "GET",
- url: 'data.db',
- success: function(ret) {
- $.each(ret.data, function(i, item) {
- setSingleData(item);
- });
- }
- });
- }
- function setSingleData(singleData){
- //remove data
- $( "#" + singleData.seriennummer ).remove();
-
- container = document.getElementById(singleData.activity);
- entry = document.createElement("div");
- $(entry).attr("id",singleData.seriennummer);
- $(entry).html("<span>Code: " + singleData.produktcode + "</span><span> SN: " + singleData.seriennummer + "</span>");
- container.appendChild(entry);
- }
- function showDocument() {
-
- $.ajax({
- type: "GET",
- url: 'style.url',
- success: function(ret) {
- $('head link.custom').attr('href',ret);
- }
- });
- /*
- $.ajax({
- type: "GET",
- url: 'info.json',
- success: function(ret) {
- makeGrid(ret.x_amount, ret.y_amount);
- //set name
- document.title = ret.document_name;
- $.ajax({
- type: "GET",
- url: 'frames.json',
- success: function(ret2) {
- for (i of ret2.data) {
- makeFrame(i.lx,i.ly,i.rx,i.ry, i.url, i.callback, i.default, i.showbutton, i.style);
- }
- }
- });
- },
- error: function() {
- reason = '';
- clearDocument();
- }
- });*/
- }
- function clearDocument() {
- console.log('rrrr');
- $('#languages').addClass('hidden');
- $('#nope').removeClass('hidden');
- $('#control .added').remove();
- $('#content .added').remove();
- $('#reason').text(reason);
- }
- function init() {
- es = new EventSource('sse/');
- es.onopen = function() {
- getAllData();
- // load
- };
- es.onmessage = function(e) {
- console.log("Got SSE");
- if (e.data == 'new') {
- reason = '';
- showDocument();
- }
- if (e.data == 'reset') {
- reason = '';
- showDocument();
- }
- else{
- if(e.data == "update"){
- alert("update")
- }
- if(e.data != "keepalive" && e.data != "started"){
- try {
- var prdata = JSON.parse(e.data)
- //alert("LastIf" + prdata.seriennummer)
- setSingleData(prdata);
- }
- catch (e) {
- }
- }
- }
- };
- es.onerror = function() {
- reason = 'Server down.';
- clearDocument();
- setTimeout(init, 10000);
- };
- }
- $(document).ready(function() {
- init();
- });
|