ui.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. function getAllData(){
  2. $( "#data" ).empty();
  3. var url_string = window.location.href
  4. var url = new URL(url_string);
  5. if(!url.searchParams.has("display")){
  6. var urlarray = ["aktivieren","aktivierenPrio","stornieren","moveTop","moveX","move","move2","edit"]
  7. }else{
  8. var urlparams = url.searchParams.get("display").replace("/","");
  9. var urlarray = urlparams.split(",");
  10. }
  11. if(url.searchParams.has("menu")){
  12. console.log("MENU");
  13. menuentries = url.searchParams.get("menu").split(",")
  14. $( "#data" ).append("<a class='ontop'href='" + menuentries[1] + "' target='_blank'>" + menuentries[0] +"</a>" );
  15. }
  16. $.ajax({
  17. type: "GET",
  18. url: 'data.db',
  19. async: false,
  20. success: function(ret) {
  21. if(!$(ret.data).length == 0){
  22. container = document.getElementById("data");
  23. entry = document.createElement("div");
  24. tablehead = "<table><tbody id='tablecontent'><tr>";
  25. urlarray.forEach(function(element) { tablehead += "<th></th>" });
  26. if(ret.data[0].hasOwnProperty('pkvalue')){
  27. tablehead += "<th class='primarykey'>Primary Key</th>";
  28. }
  29. var joinkey = urlarray.length;
  30. for (var i = 0; i < Object.keys(JSON.parse(ret.data[0].alldata)).length; i++) {
  31. tablehead += "<th class='editable'>" + Object.keys(JSON.parse(ret.data[0].alldata))[i]
  32. if(url.searchParams.has("showfilter")){
  33. tablehead += '<br><input styl="width: 100%;" type="text" id="searchtable' + ++joinkey +'" onkeyup="searchtable(' + joinkey + ')" placeholder="Search for ' + Object.keys(JSON.parse(ret.data[0].alldata))[i] + '" name="' +Object.keys(JSON.parse(ret.data[0].alldata))[i] + '">'
  34. }
  35. tablehead += '</th>'
  36. }
  37. tablehead += "</tr></tbody></table>";
  38. $(entry).html(tablehead);
  39. $(container).append(entry);
  40. container = document.getElementById("tablecontent");
  41. entry = document.createElement("tr");
  42. $(entry).attr("id","AddEntry");
  43. $(entry).attr("class","tableentryAdd");
  44. tableedit = "<td class='addEntry'><a onclick='addEntry()' href='#'>Add</a></td>"
  45. urlarray.forEach(function(element) { });
  46. for (var i = 1; i < urlarray.length; i++) { //start at 1 as add is already set
  47. tableedit += "<td></td>"
  48. }
  49. if(ret.data[0].hasOwnProperty('pkvalue')){
  50. tableedit += "<td class='editableprimarykey'>Primary Key</td>";
  51. }
  52. tableedit += "<td class='editable'>" + Object.keys(JSON.parse(ret.data[0].alldata)).join("</td><td class='editable'>") + "</td>"
  53. $(entry).append(tableedit);
  54. $("#tablecontent").append(entry);
  55. $.each(ret.data, function(i, item) {
  56. setSingleData(item, urlarray, i, url);
  57. });
  58. }
  59. }
  60. });
  61. if(url.searchParams.has("searchkey")){
  62. var searchkey = url.searchParams.get("searchkey").replace("/","");
  63. $('[name="' + searchkey +'"]').val(url.searchParams.get("searchterm").replace("/",""));
  64. $('[name="' + searchkey +'"]').keyup();
  65. }
  66. if(url.searchParams.has("sendListBack")){
  67. $('body').append('<a onclick="collectdata2sendBack()" href="#">Sende Liste</a>');
  68. }
  69. /*
  70. //Single move
  71. if(urlarray.includes("move")){
  72. $( "#data" ).prepend('<a id="storesortedtablebutton" onclick="storesortedtable()" hidden href="#">Store Table</a>');
  73. $( "#tablecontent" ).sortable({
  74. handle: '.handle',
  75. change: function (event, ui) {
  76. $( "#storesortedtablebutton" ).show();
  77. }
  78. });
  79. }*/
  80. if(urlarray.includes("move") || urlarray.includes("move")){
  81. $( "#data" ).prepend('<a id="storesortedtablebutton" onclick="storesortedtable()" hidden href="#">Store Table</a>');
  82. }
  83. //move single or multiple items (buttonpress)
  84. if(urlarray.includes("move")){
  85. new Sortable(tablecontent, {
  86. handle: '.handle',
  87. multiDrag: true, // Enable multi-drag
  88. selectedClass: 'sortable-selected', // The class applied to the selected items
  89. fallbackTolerance: 3, // So that we can select items on mobile
  90. animation: 150,
  91. avoidImplicitDeselect: false,
  92. onSelect: function(/**Event*/evt) {
  93. $( 'tr[ grouping="' + $(evt.item).attr("grouping") + '"]' ).each(function( index ) {
  94. console.log( index + ":select " + $( this ).text() );
  95. Sortable.utils.select($(this)[0]);
  96. });
  97. },
  98. onDeselect: function(/**Event*/evt) {
  99. $( 'tr[ grouping="' + $(evt.item).attr("grouping") + '"]' ).each(function( index ) {
  100. console.log( index + ":deselect " + $( this ).text() );
  101. Sortable.utils.deselect($(this)[0]);
  102. });
  103. },
  104. onEnd: function (/**Event*/evt) { //deselect all on end
  105. $( 'tr' ).each(function( index ) {
  106. console.log( index + ": " + $( this ).text() );
  107. Sortable.utils.deselect($(this)[0]);
  108. });
  109. },
  110. onSort: function (/**Event*/evt) { //on any change show store table button
  111. $( "#storesortedtablebutton" ).show();
  112. }
  113. });
  114. }
  115. if(urlarray.includes("move2")){
  116. new Sortable(tablecontent, {
  117. handle: '.handle2',
  118. multiDrag: true, // Enable multi-drag
  119. selectedClass: 'sortable-selected', // The class applied to the selected items
  120. fallbackTolerance: 3, // So that we can select items on mobile
  121. animation: 150,
  122. avoidImplicitDeselect: false,
  123. onSelect: function(/**Event*/evt) {
  124. $( 'tr[ grouping2="' + $(evt.item).attr("grouping2") + '"]' ).each(function( index ) {
  125. console.log( index + ": " + $( this ).text() );
  126. Sortable.utils.select($(this)[0]);
  127. });
  128. },
  129. onDeselect: function(/**Event*/evt) {
  130. $( 'tr[ grouping2="' + $(evt.item).attr("grouping2") + '"]' ).each(function( index ) {
  131. console.log( index + ": " + $( this ).text() );
  132. Sortable.utils.deselect($(this)[0]);
  133. });
  134. },
  135. onEnd: function (/**Event*/evt) { //deselect all on end
  136. $( 'tr' ).each(function( index ) {
  137. console.log( index + ": " + $( this ).text() );
  138. Sortable.utils.deselect($(this)[0]);
  139. });
  140. },
  141. onSort: function (/**Event*/evt) { //on any change show store table button
  142. $( "#storesortedtablebutton" ).show();
  143. }
  144. });
  145. }
  146. /*
  147. $( "#tablecontent" ).sortable({
  148. multiDrag: true, // Enable the plugin
  149. selectedClass: "sortable-selected", // Class name for selected item
  150. multiDragKey: null, // Key that must be down for items to be selected
  151. avoidImplicitDeselect: true, // true - if you don't want to deselect items on outside click
  152. // Called when an item is selected
  153. onSelect: function(/**Event*/ /*evt) {
  154. evt.item // The selected item
  155. console.log(evt.item);
  156. },
  157. // Called when an item is deselected
  158. onDeselect: function(/**Event*/ /*evt) {
  159. evt.item // The deselected item
  160. }
  161. });
  162. }
  163. */
  164. //$( "#tablecontent" ).on( "sortstart", function( event, ui ) {console.log("start" + ui.item.html())} );
  165. }
  166. function collectdata2sendBack(){
  167. console.log("sending");
  168. var sendback = [];
  169. $('[name="pkvalues"]:visible').each(function(){
  170. sendback.push($(this).html());
  171. });
  172. sendDataElementBack(sendback)
  173. }
  174. function searchtable(key) {
  175. // Declare variables
  176. var input, filter, table, tr, td, i, txtValue;
  177. input = document.getElementById("searchtable" +key);
  178. filter = input.value.toUpperCase();
  179. table = document.getElementById("tablecontent");
  180. tr = table.getElementsByTagName("tr");
  181. // Loop through all table rows, and hide those who don't match the search query
  182. for (i = 0; i < tr.length; i++) {
  183. td = tr[i].getElementsByTagName("td")[key];
  184. if (td) {
  185. txtValue = td.textContent || td.innerText;
  186. if (txtValue.toUpperCase().indexOf(filter) > -1) {
  187. tr[i].style.display = "";
  188. } else {
  189. tr[i].style.display = "none";
  190. }
  191. }
  192. }
  193. }
  194. function sortTable(n) {
  195. var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
  196. table = document.getElementById("tablecontent");
  197. switching = true;
  198. // Set the sorting direction to ascending:
  199. dir = "asc";
  200. /* Make a loop that will continue until
  201. no switching has been done: */
  202. while (switching) {
  203. // Start by saying: no switching is done:
  204. switching = false;
  205. rows = table.rows;
  206. /* Loop through all table rows (except the
  207. first, which contains table headers): */
  208. for (i = 1; i < (rows.length - 1); i++) {
  209. // Start by saying there should be no switching:
  210. shouldSwitch = false;
  211. /* Get the two elements you want to compare,
  212. one from current row and one from the next: */
  213. x = rows[i].getElementsByTagName("TD")[n];
  214. y = rows[i + 1].getElementsByTagName("TD")[n];
  215. /* Check if the two rows should switch place,
  216. based on the direction, asc or desc: */
  217. if (dir == "asc") {
  218. if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
  219. // If so, mark as a switch and break the loop:
  220. shouldSwitch = true;
  221. break;
  222. }
  223. } else if (dir == "desc") {
  224. if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
  225. // If so, mark as a switch and break the loop:
  226. shouldSwitch = true;
  227. break;
  228. }
  229. }
  230. }
  231. if (shouldSwitch) {
  232. /* If a switch has been marked, make the switch
  233. and mark that a switch has been done: */
  234. rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
  235. switching = true;
  236. // Each time a switch is done, increase this count by 1:
  237. switchcount ++;
  238. } else {
  239. /* If no switching has been done AND the direction is "asc",
  240. set the direction to "desc" and run the while loop again. */
  241. if (switchcount == 0 && dir == "asc") {
  242. dir = "desc";
  243. switching = true;
  244. }
  245. }
  246. }
  247. }
  248. function deleteDataElement(dataelement){
  249. console.log("Löschen")
  250. console.log(dataelement)
  251. $.ajax({
  252. type: "DELETE",
  253. url: location.protocol + '//' + location.host + location.pathname,
  254. contentType: "application/json",
  255. headers: {"content-id": "deleteByID"},
  256. data: JSON.stringify(dataelement),
  257. success: function(ret) {
  258. getAllData();
  259. }
  260. });
  261. }
  262. //if used in frames send row to frames
  263. function sendDataElementBack(dataelement, type){
  264. parent.sendJson(window.name,{ type: type, dataelement: dataelement })
  265. //deleteDataElement(dataelement.__orderID__)
  266. }
  267. //retrieves ID´s in current order and sends back 2 server
  268. //security, in case an id got removed it is not retrieved, in case an id got added it will still be added
  269. //server does the following: looks for ID and sets the order to the current order we sent,
  270. //in case the id is not found nothing happens (entry was removed during sorting by someone else)
  271. //in case another ID is in the db that was added while we sort, the id will remain (maybe at different position)
  272. function storesortedtable(){
  273. var alldata = [];
  274. alldata.entry = entry;
  275. $( ".tableentry" ).each(function( index ) {
  276. alldata.push($( this ).attr("id"));
  277. });
  278. $.LoadingOverlay("show");
  279. $.ajax({
  280. type: "PUT",
  281. url: location.protocol + '//' + location.host + location.pathname,
  282. headers: {"content-id": "storesortedtable"},
  283. contentType: "application/json",
  284. data: JSON.stringify(alldata),
  285. success: function(ret) {
  286. $.LoadingOverlay("hide");
  287. getAllData();
  288. }
  289. });
  290. }
  291. function move(from, to){
  292. $.ajax({
  293. type: "PUT",
  294. url: location.protocol + '//' + location.host + location.pathname,
  295. headers: {"content-id": "move"},
  296. contentType: "application/json",
  297. data: JSON.stringify({"From": from, "To": to}),
  298. success: function(ret) {
  299. getAllData();
  300. }
  301. });
  302. }
  303. function setSingleData(singleData, urlarray, i = -1, url = ""){
  304. container = document.getElementById("tablecontent");
  305. entry = document.createElement("tr");
  306. $(entry).attr("id",singleData.__orderID__);
  307. $(entry).attr("class","tableentry");
  308. if(urlarray.includes("move")){
  309. if(url.searchParams.has("group1column")){
  310. $(entry).attr("grouping","Grp1" + JSON.parse(singleData.alldata)[url.searchParams.get("group1column").replace("/","")]);
  311. }
  312. }
  313. if(urlarray.includes("move2")){
  314. if(url.searchParams.has("group2column1") & url.searchParams.has("group2column2")){
  315. $(entry).attr("grouping2","Grp2" + JSON.parse(singleData.alldata)[url.searchParams.get("group2column1").replace("/","")]+ "_" + JSON.parse(singleData.alldata)[url.searchParams.get("group2column2").replace("/","")]);
  316. }
  317. }
  318. /*
  319. if(urlarray.includes("move")){
  320. $(entry).attr("draggable","true");
  321. $(entry).attr("ondragstart","start()");
  322. $(entry).attr("ondragover","dragover()");
  323. }
  324. */
  325. if(url.searchParams.has("colorize")){
  326. if(i == 0){
  327. var tableheader = url.searchParams.has("colorize") ? url.searchParams.get("colorize").replace("/","") : "";
  328. var colorizestart = url.searchParams.has("colorize2") ? url.searchParams.get("colorizestart").replace("/","") : "";
  329. var colorizecol = url.searchParams.has("colorize2") ? url.searchParams.get("colorizecol").replace("/","") : "";
  330. var table2header = url.searchParams.has("colorize2") ? url.searchParams.get("colorize2").replace("/","") : "";
  331. var colorize2start = url.searchParams.has("colorize2start") ? url.searchParams.get("colorize2start").replace("/","") : "";
  332. var colorize2col = url.searchParams.has("colorize2col") ? url.searchParams.get("colorize2col").replace("/","") : "";
  333. if(JSON.parse(singleData.alldata).hasOwnProperty(tableheader)){
  334. if(JSON.parse(singleData.alldata)[tableheader].startsWith(colorizestart)){
  335. $(entry).attr("style","background-color: #" + colorizecol);
  336. }
  337. }
  338. if(JSON.parse(singleData.alldata).hasOwnProperty(table2header)){
  339. if(JSON.parse(singleData.alldata)[table2header].startsWith(colorize2start)){
  340. $(entry).attr("style","background-color: #" + colorize2col);
  341. }
  342. }
  343. }
  344. }
  345. tableentry = "";
  346. if(urlarray.includes("aktivieren")){
  347. tableentry += "<td><a onclick='sendDataElementBack(" + JSON.stringify(singleData) +", \"normal\")' href='#'>Aktivieren</a></td>"
  348. }
  349. if(urlarray.includes("aktivierenPrio")){
  350. tableentry += "<td><a onclick='sendDataElementBack(" + JSON.stringify(singleData) +", \"prio\")' href='#'>Aktivieren Prio</a></td>"
  351. }
  352. if(urlarray.includes("stornieren")){
  353. tableentry += "<td><a onclick='deleteDataElement(" + singleData.__orderID__ +")' href='#'>Stornieren</a></td>"
  354. }
  355. if(urlarray.includes("moveTop")){
  356. tableentry += "<td><a onclick='move(" + singleData.__orderID__ +",0)' href='#'>MoveTop</a></td>"
  357. }
  358. if(urlarray.includes("moveX")){
  359. tableentry += "<td><a onclick='move(" + singleData.__orderID__ +",7)' href='#'>MovetoX</a></td>"
  360. }
  361. if(urlarray.includes("move")){
  362. var name = "⇅";
  363. if(url.searchParams.has("group1name")){
  364. name = url.searchParams.get("group1name").replace("/","")
  365. }
  366. tableentry += '<td class="handle"><a href="#">' + name +'</a></td>'
  367. }
  368. if(urlarray.includes("move2")){
  369. var name = "⇅";
  370. if(url.searchParams.has("group2name")){
  371. name = url.searchParams.get("group2name").replace("/","")
  372. }
  373. tableentry += '<td class="handle2"><a href="#">' + name + '</a></td>'
  374. }
  375. url.searchParams.get("menu")
  376. if(urlarray.includes("edit")){
  377. tableentry += "<td class='edit'><a onclick='edit(" + singleData.__orderID__ +")' href='#'>Edit</a></td>"
  378. }
  379. if(singleData.hasOwnProperty('pkvalue')){
  380. tableentry += "<td name='pkvalues'>" + singleData.pkvalue + "</td>";
  381. }
  382. tableentry += "<td class='editable'>" + Object.values(JSON.parse(singleData.alldata)).join("</td><td class='editable'>") + "</td>"
  383. $(entry).html(tableentry);
  384. //$(entry).hide().fadeIn(2000);
  385. $("#tablecontent tr:last").before(entry);
  386. }
  387. function getUpdateData(id){
  388. //Json aufbauen
  389. var i = 0;
  390. var obj = {};
  391. $("#tablecontent th[class='editable'").each(function( index ) {
  392. curname = $( this ).html();
  393. curvalue = $("#" + id + " .editable:eq(" + i + ") input").val();
  394. if(isNaN(curvalue)){
  395. obj[curname] = curvalue;
  396. }else{
  397. obj[curname] = parseInt(curvalue, 10);
  398. }
  399. ++i;
  400. });
  401. console.log("TEST" + JSON.stringify(obj));
  402. update(id, obj)
  403. }
  404. function update(id, obj){
  405. $.ajax({
  406. type: "PUT",
  407. url: location.protocol + '//' + location.host + location.pathname,
  408. headers: {"content-id": "update"},
  409. contentType: "application/json",
  410. data: JSON.stringify({"ID": id, "alldata": obj}),
  411. success: function(ret) {
  412. getAllData();
  413. }
  414. });
  415. }
  416. function edit(id){
  417. console.log("#" + id + " .editable");
  418. $("#" + id + " .edit").each(function( index ) {
  419. $( this ).html("<a onclick='getUpdateData(" + id +")' href='#'>Update</a>");
  420. });
  421. $("#" + id + " .editable").each(function( index ) {
  422. if(isNaN($( this ).text())){
  423. $( this ).html("<input type='text' value='" + $( this ).text() +"'>");
  424. }else{
  425. $( this ).html("<input type='number' value='" + $( this ).text() +"'>");
  426. }
  427. });
  428. }
  429. function addEntry() {
  430. $("#AddEntry .addEntry").each(function( index ) {
  431. $( this ).html("<a onclick='getNewData(\"AddEntry\")' href='#'>Add</a>");
  432. });
  433. $("#AddEntry .editableprimarykey").each(function( index ) {
  434. $( this ).html("<input type='text' value='" + $( this ).text() +"'>");
  435. });
  436. $("#AddEntry .editable").each(function( index ) {
  437. $( this ).html("<input type='text' value='" + $( this ).text() +"'>");
  438. });
  439. }
  440. function getNewData(id){
  441. //Json aufbauen
  442. var i = 0;
  443. var obj = {};
  444. $("#tablecontent th[class='editable'").each(function( index ) {
  445. curname = $( this ).html();
  446. curvalue = $("#" + id + " .editable:eq(" + i + ") input").val();
  447. if(isNaN(curvalue)){
  448. obj[curname] = curvalue;
  449. }else{
  450. obj[curname] = parseInt(curvalue, 10);
  451. }
  452. ++i;
  453. });
  454. pk = $("#" + id + " .editableprimarykey input").val()
  455. obj = {alldata: obj, pkvalue: pk}
  456. addNewData(id, obj)
  457. }
  458. function addNewData(id, obj){
  459. $.ajax({
  460. type: "POST",
  461. url: location.protocol + '//' + location.host + location.pathname,
  462. headers: {"content-id": "directADD"},
  463. contentType: "application/json",
  464. data: JSON.stringify(obj),
  465. success: function(ret) {
  466. getAllData();
  467. }
  468. });
  469. }
  470. function openlink(menuitem){
  471. var menu = { name: menuitem };
  472. $.ajax({
  473. type: "PUT",
  474. url: window.name,
  475. contentType: "application/json",
  476. data: JSON.stringify(menu),
  477. success: function (data) {
  478. }
  479. });
  480. }
  481. function showDocument() {
  482. $.ajax({
  483. type: "GET",
  484. url: location.protocol + '//' + location.host + location.pathname + 'style.url',
  485. success: function(ret) {
  486. $('head link.custom').attr('href',ret);
  487. }
  488. });
  489. /*
  490. $.ajax({
  491. type: "GET",
  492. url: 'info.json',
  493. success: function(ret) {
  494. makeGrid(ret.x_amount, ret.y_amount);
  495. //set name
  496. document.title = ret.document_name;
  497. $.ajax({
  498. type: "GET",
  499. url: 'frames.json',
  500. success: function(ret2) {
  501. for (i of ret2.data) {
  502. makeFrame(i.lx,i.ly,i.rx,i.ry, i.url, i.callback, i.default, i.showbutton, i.style);
  503. }
  504. }
  505. });
  506. },
  507. error: function() {
  508. reason = '';
  509. clearDocument();
  510. }
  511. });*/
  512. }
  513. function clearDocument() {
  514. console.log('rrrr');
  515. $('#languages').addClass('hidden');
  516. $('#nope').removeClass('hidden');
  517. $('#control .added').remove();
  518. $('#content .added').remove();
  519. $('#reason').text(reason);
  520. }
  521. function init() {
  522. es = new EventSource('sse/');
  523. es.onopen = function() {
  524. getAllData();
  525. // load
  526. };
  527. es.onmessage = function(e) {
  528. console.log("Got SSE");
  529. if (e.data == 'new') {
  530. reason = '';
  531. showDocument();
  532. }
  533. if (e.data == 'reset') {
  534. reason = '';
  535. showDocument();
  536. }
  537. else{
  538. if(e.data == "update"){
  539. alert("update")
  540. }
  541. if(e.data != "keepalive" && e.data != "started"){
  542. try {
  543. var prdata = JSON.parse(e.data)
  544. //alert("LastIf" + prdata.seriennummer)
  545. setSingleData(prdata);
  546. }
  547. catch (e) {
  548. }
  549. }
  550. }
  551. };
  552. es.onerror = function() {
  553. es.close();
  554. reason = 'Server down.';
  555. clearDocument();
  556. setTimeout(init, 10000);
  557. };
  558. }
  559. $(document).ready(function() {
  560. init();
  561. });