Welcome to mirror list, hosted at ThFree Co, Russian Federation.

footer_scripts.js « js « assets - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ee9aa69f276cd1903081817e73c376064f7db38a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
function historyApiBack() {
  window.history && window.history.back();
}
function redirectToIframesView() {
  if (
    window.inPopUp ||
    parent.frames.length ||
    stateObj.reload === 'other' ||
    stateObj.in_test !== '0'
  ) {
    return false;
  }
  var redirect_to,
    subject = location.pathname
      .replace(stateObj.subfolder, '')
      .replace('/src/views/', '')
      .replace('.php', '');

  if (subject === '/redirect/server') {
    subject = '/servers';
  }
  redirect_to = `${stateObj.subfolder}/${subject}${location.search}`;
  var redirection_msg =
    'location subject ' + subject + ' will redirect_to ' + redirect_to;
  return redirect_to;
}
function addBehaviorToTopLinks(amIDetailFrame) {
  const parentHandle =
      amIDetailFrame && window.parent.document.querySelector('#detail'),
    toplink_logout =
      amIDetailFrame &&
      (parentHandle.contentDocument || document).querySelector(
        '#toplink_logout'
      );

  parentHandle &&
    [
      ...(parentHandle.contentDocument || document).querySelectorAll(
        '.toplink a.toplink_popup'
      ),
    ].forEach((element) => {
      let href = element.href;
      element.addEventListener('click', (e) => {
        e.preventDefault();
        window
          .open(
            `${href}`,
            `sqledit:${stateObj.server}`,
            'toolbar=no,width=750,height=520,resizable=yes,scrollbars=yes'
          )
          .focus();
      });
      element.setAttribute('rel', href);

      element.href = 'javascript:void(this.click())'; // eslint-disable-line
    });
  toplink_logout &&
    toplink_logout.addEventListener('click', (e) => {
      e.preventDefault();
      if (confirm(stateObj.strconfdropcred)) {
        window.location.href = e.target.href;
      }
    });

  return;
}
if (
  !window.inPopUp &&
  stateObj.reload !== 'other' &&
  !parent.frames.length &&
  stateObj.in_test === '0'
) {
  redirectToIframesView();
}
let {
  frames: { browser },
} = window.parent;
if (browser && browser.jsTree && stateObj.reload) {
  browser.jsTree.jstree('refresh');
}

$.ready
  .then(() => {
    let amIDetailFrame = document.body.classList.contains('detailbody');
    // Need to open popup from parent document

    let redirect_to = redirectToIframesView();
    if (redirect_to === false) {
      return addBehaviorToTopLinks(amIDetailFrame);
    }
    window.location.replace(redirect_to);
  })
  .then(() => {
    if (window.parent.frames.length === 0) {
      return;
    }
    window.parent.document.title = window.document.title;

    /* beautify preserve:start */
    stateObj.realurl = location.href.replace(location.origin, '');
    //path will only be defined inside a route

    /* beautify preserve:end */
    stateObj.newurl =
      stateObj.subfolder +
      stateObj.realurl
        .replace(stateObj.subfolder, '')
        .replace('src/views/', '')
        .replace('.php', '');
    stateObj.parenturl = window.parent.location.href.replace(
      window.parent.location.origin,
      ''
    );
    return;
  })
  .then(() => {
    if (window.location.href.indexOf('servers?action=logout') !== -1) {
      window.setTimeout(function () {
        window.parent.location.replace(`${stateObj.subfolder}/servers`);
      }, 3000);
    } else if (
      stateObj.method === 'GET' &&
      stateObj.newurl !== stateObj.parenturl
    ) {
      //console.log('will pushState', stateObj);
      window.parent.history.pushState(
        stateObj,
        document.title,
        stateObj.newurl
      );
    }
  })
  .then(() => {
    if (jQuery.fn) {
      if (jQuery.fn.select2) {
        jQuery('.select2').select2();
      }
      if (jQuery.fn.DataTable) {
        $('.will_be_datatable').DataTable({
          pageLength: 100,
        });
      }
    }
    if (typeof hljs !== 'undefined') {
      $('pre code.hljs').each(function (i, block) {
        hljs.highlightBlock(block);
      });
    }
    return;
  })
  .catch((err) => {
    console.error(err);
  });