Browse Source

Epesi.init as constructor

experimental
Paweł Jedwabny 4 years ago
parent
commit
4e01c57020
3 changed files with 19 additions and 21 deletions
  1. +1
    -1
      init_js.php
  2. +16
    -16
      src/epesi.js
  3. +2
    -4
      src/index.js

+ 1
- 1
init_js.php View File

@@ -35,4 +35,4 @@ if($client_id-5>=0) {
}
session_commit();

?>Epesi.init(<?php print($client_id); ?>,'<?php print(rtrim(str_replace('\\','/',dirname($_SERVER['PHP_SELF'])),'/').'/process.php'); ?>','<?php print(http_build_query($_GET));?>');
?>window.Epesi = new EpesiClass(<?php print($client_id); ?>,'<?php print(rtrim(str_replace('\\','/',dirname($_SERVER['PHP_SELF'])),'/').'/process.php'); ?>','<?php print(http_build_query($_GET));?>');

+ 16
- 16
src/epesi.js View File

@@ -20,22 +20,7 @@ class Epesi {
indicator = 'epesiStatus';
indicator_text = 'epesiStatusText';


updateIndicator = () => {
document.getElementById(this.indicator).style.display = this.procOn ? '' : 'none';
if (!this.procOn) document.getElementById('main_content').style.display = '';
};

updateIndicatorText = (text) => {
document.getElementById(this.indicator_text).innerHTML = text;
document.getElementById(this.indicator_text).innerHTML = text;
};

history_add = (id) => {
window.history.pushState({history_id: id}, '');
};

init = (client_id, process_file_path, params = '') => {
constructor(client_id, process_file_path, params = '') {
this.client_id=client_id;
this.process_file=process_file_path;

@@ -51,6 +36,21 @@ class Epesi {
this.request(params,0);

window.addEventListener('popstate', ({state: {history_id}}) => this.request('', history_id));
window._chj = this.href;
};

updateIndicator = () => {
document.getElementById(this.indicator).style.display = this.procOn ? '' : 'none';
if (!this.procOn) document.getElementById('main_content').style.display = '';
};

updateIndicatorText = (text) => {
document.getElementById(this.indicator_text).innerHTML = text;
document.getElementById(this.indicator_text).innerHTML = text;
};

history_add = (id) => {
window.history.pushState({history_id: id}, '');
};

request = async (url, history) => {


+ 2
- 4
src/index.js View File

@@ -19,6 +19,7 @@ import 'font-awesome/css/font-awesome.css';
window.Chart = Chart;

import Epesi from './epesi';
window.EpesiClass = Epesi;

window.focus_by_id = (idd) => {
let xx = document.getElementById(idd);
@@ -53,7 +54,4 @@ window.is_visible = function (element) {
return is_visible(element.parentNode);
}
return true;
};

window.Epesi = new Epesi();
window._chj = window.Epesi.href;
};

Loading…
Cancel
Save