Your IP : 52.15.99.234


Current Path : /usr/local/mgr5/skins/dragon/
Upload File :
Current File : //usr/local/mgr5/skins/dragon/extform.xsl

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mgr="http://ispsystem.com/xslplugin" exclude-result-prefixes="mgr">
  <xsl:import href="extfunc.xsl"></xsl:import>
  <xsl:output method="html" encoding="UTF-8" indent="no"></xsl:output>
  <xsl:variable name="theme" select="/doc/@theme"></xsl:variable>
  <xsl:variable name="appearance" select="/doc/@appearance"></xsl:variable>
  <xsl:variable name="binary" select="/doc/@binary"></xsl:variable>
  <xsl:variable name="elid" select="/doc/elid"></xsl:variable>
  <xsl:variable name="plid" select="/doc/plid"></xsl:variable>
  <xsl:variable name="logo" select="/doc/@logo"></xsl:variable>
  <xsl:variable name="host" select="/doc/@host"></xsl:variable>
  <xsl:variable name="hostname" select="/doc/user/@hostname"></xsl:variable>
  <xsl:variable name="localdir" select="/doc/@localdir"></xsl:variable>
  <xsl:variable name="metadata" select="/doc/metadata"></xsl:variable>
  <xsl:variable name="msg" select="/doc/messages"></xsl:variable>
  <xsl:variable name="themepath">
    <xsl:value-of select="concat($theme, $localdir)"></xsl:value-of>
  </xsl:variable>
  <xsl:variable name="logopath">
    <xsl:choose>
      <xsl:when test="not($appearance) or $appearance = '' or not($logo = 'logo-ispmgr.svg')">
        <xsl:value-of select="concat($themepath, 'login-', $logo)"></xsl:value-of>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="concat($themepath, $appearance, '_login-', $logo)"></xsl:value-of>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="backgroundpath">
    <xsl:choose>
      <xsl:when test="not($appearance) or $appearance = ''">
        <xsl:value-of select="concat($themepath, 'background-', $product, '.svg')"></xsl:value-of>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="concat($themepath, $appearance, '_background-', $product, '.svg')"></xsl:value-of>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="product" select="'ispmgr'"></xsl:variable>
  <xsl:key name="msg" match="/doc/messages/msg" use="@name"></xsl:key>
  <xsl:key name="ifhide" match="//if" use="@hide"></xsl:key>
  <xsl:key name="elsehide" match="//else" use="@hide"></xsl:key>

  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="/doc/ok and /doc/ok/@type = 'url'">
        <script>
          location = '<xsl:value-of select="/doc/ok" disable-output-escaping="yes" />';
        </script>
      </xsl:when>
      <xsl:when test="/doc/ok and /doc/ok/@type = 'form'">
        <script>
          location = '<xsl:value-of select="concat(/doc/@host, $binary, '?', /doc/ok)" disable-output-escaping="yes"/>';
        </script>
      </xsl:when>
      <xsl:when test="/doc/tparams/sfrom = 'ajax' or contains(/doc/tparams/redirect, 'sfrom=ajax')">
        {
        "ok" : "true",
        "reload" : "true"
        }
      </xsl:when>
      <xsl:otherwise>
        <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html></xsl:text>
        <html>
          <head>
            <meta name="viewport" content="width=device-width, user-scalable=no"/>
            <script>
              let colorScheme = localStorage.getItem('isp_color_scheme');

              if (!colorScheme) {
                colorScheme = 'light';
                localStorage.setItem('isp_color_scheme', colorScheme);
              } else if (colorScheme === 'auto') {
                if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
                  colorScheme = 'dark';
                } else {
                  colorScheme = 'light';
                }
              }

              document.documentElement.setAttribute('data-color-scheme', colorScheme);
            </script>
            <script>
              var pageInfo = (function() {
                var binary = "<xsl:value-of select="$binary"/>";
                var favicon = "<xsl:value-of select="/doc/@favicon"/>";
                var func = "<xsl:value-of select="/doc/@func"/>";
                var localDir = "<xsl:value-of select="/doc/@localdir"/>";
                var userName = "<xsl:value-of select="/doc/user/@name"/>";
                var level = "<xsl:value-of select="/doc/user/@level"/>";
                var hostName = "<xsl:value-of select="$hostname"/>";
                var host = "<xsl:value-of select="$host"/>";
                var theme = "<xsl:value-of select="$theme"/>";
                var user = "<xsl:value-of select="/doc/user/@name"/>";
                var duplicate = "<xsl:value-of select="$msg/msg[@name='msg_duplicate']"/>";
                var pwgencharacters = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
                var pwgenlen = "8";
                var pwstrength = 2;
                var messages = {
                  "empty" : "<xsl:value-of select="$msg/msg[@name='msg_empty']"/>",
                  "validChangeVal" : "<xsl:value-of select="key('msg','msg_valuechangedbyvalidator')"/>"
                };
                var total = "<xsl:value-of select="$msg/msg[@name='msg_total']"/>";
                var selected = "<xsl:value-of select="$msg/msg[@name='msg_selected']"/>";
                var confirm = "<xsl:value-of select="$msg/msg[@name='msg_confirm']"/>";
                var baseUrl = "<xsl:value-of select="concat(/doc/@host, /doc/@binary)"/>";
                var calendar = {
                  "m0" : "<xsl:value-of select="$msg/msg[@name='msg_m0']"/>",
                  "m1" : "<xsl:value-of select="$msg/msg[@name='msg_m1']"/>",
                  "m2" : "<xsl:value-of select="$msg/msg[@name='msg_m2']"/>",
                  "m3" : "<xsl:value-of select="$msg/msg[@name='msg_m3']"/>",
                  "m4" : "<xsl:value-of select="$msg/msg[@name='msg_m4']"/>",
                  "m5" : "<xsl:value-of select="$msg/msg[@name='msg_m5']"/>",
                  "m6" : "<xsl:value-of select="$msg/msg[@name='msg_m6']"/>",
                  "m7" : "<xsl:value-of select="$msg/msg[@name='msg_m7']"/>",
                  "m8" : "<xsl:value-of select="$msg/msg[@name='msg_m8']"/>",
                  "m9" : "<xsl:value-of select="$msg/msg[@name='msg_m9']"/>",
                  "m10" : "<xsl:value-of select="$msg/msg[@name='msg_m10']"/>",
                  "m11" : "<xsl:value-of select="$msg/msg[@name='msg_m11']"/>",
                  "ms0" : "<xsl:value-of select="$msg/msg[@name='msg_ms0']"/>",
                  "ms1" : "<xsl:value-of select="$msg/msg[@name='msg_ms1']"/>",
                  "ms2" : "<xsl:value-of select="$msg/msg[@name='msg_ms2']"/>",
                  "ms3" : "<xsl:value-of select="$msg/msg[@name='msg_ms3']"/>",
                  "ms4" : "<xsl:value-of select="$msg/msg[@name='msg_ms4']"/>",
                  "ms5" : "<xsl:value-of select="$msg/msg[@name='msg_ms5']"/>",
                  "ms6" : "<xsl:value-of select="$msg/msg[@name='msg_ms6']"/>",
                  "ms7" : "<xsl:value-of select="$msg/msg[@name='msg_ms7']"/>",
                  "ms8" : "<xsl:value-of select="$msg/msg[@name='msg_ms8']"/>",
                  "ms9" : "<xsl:value-of select="$msg/msg[@name='msg_ms9']"/>",
                  "ms10" : "<xsl:value-of select="$msg/msg[@name='msg_ms10']"/>",
                  "ms11" : "<xsl:value-of select="$msg/msg[@name='msg_ms11']"/>",
                  "w0" : "<xsl:value-of select="$msg/msg[@name='msg_w0']"/>",
                  "w1" : "<xsl:value-of select="$msg/msg[@name='msg_w1']"/>",
                  "w2" : "<xsl:value-of select="$msg/msg[@name='msg_w2']"/>",
                  "w3" : "<xsl:value-of select="$msg/msg[@name='msg_w3']"/>",
                  "w4" : "<xsl:value-of select="$msg/msg[@name='msg_w4']"/>",
                  "w5" : "<xsl:value-of select="$msg/msg[@name='msg_w5']"/>",
                  "w6" : "<xsl:value-of select="$msg/msg[@name='msg_w6']"/>",
                  "today" : "<xsl:value-of select="$msg/msg[@name='msg_today']"/>"
                };
                var product = binary.toString().replace(/(.*\/)/g,"");
                var elid = "<xsl:value-of select="$elid"/>";
                var plid = "<xsl:value-of select="$plid"/>";
                <xsl:choose>
                  <xsl:when test="/doc/error">
                    var error = {
                      object: `<xsl:value-of select="/doc/error/@object"/>`,
                      msg: `<xsl:value-of select="/doc/error/msg"/>`,
                    };
                  </xsl:when>
                  <xsl:otherwise>
                    var error = undefined;
                  </xsl:otherwise>
                </xsl:choose>
                var tparams = {
                  <xsl:for-each select="/doc/tparams/*">
                    <xsl:variable name="escapedValue">
                      <xsl:call-template name="escape">
                        <xsl:with-param name="input" select="."></xsl:with-param>
                      </xsl:call-template>
                    </xsl:variable>
                    <xsl:variable name="escapedKey">
                      <xsl:call-template name="escapeBacktick">
                        <xsl:with-param name="input" select="name(.)"/>
                      </xsl:call-template>
                    </xsl:variable>

                    [`<xsl:value-of select ="$escapedKey"/>`]: "<xsl:value-of select="$escapedValue"/>",
                  </xsl:for-each>
                };

                return {
                  binary : binary,
                  favicon : favicon,
                  func : func,
                  localDir : localDir,
                  userName: userName,
                  level : level,
                  hostName : hostName,
                  host : host,
                  theme : theme,
                  user : user,
                  duplicate : duplicate,
                  pwgencharacters : pwgencharacters,
                  pwgenlen : pwgenlen,
                  pwstrength : pwstrength,
                  messages : messages,
                  total : total,
                  selected : selected,
                  confirm : confirm,
                  baseUrl : baseUrl,
                  url : host + binary,
                  calendar : calendar,
                  product : product,
                  elid : elid,
                  plid : plid,
                  extform: true,
                  error: error,
                  tparams: tparams,
                }
              }());

              var ispPrefetchObject = {
                listeners: [],
                result: undefined,
                fetch() {
                  if (ispPrefetchObject.result) {
                    ispPrefetchObject.listeners.forEach(callback =>
                      callback(result.doc),
                    );
                    return;
                  }

                  const queryParams = {
                    ...pageInfo.tparams,
                    theme: 'dragon',
                    out: 'xjson',
                  };
                  const queryParamsString = Object
                    .entries(queryParams)
                    .map(([k, v]) => v ? `${k}=${encodeURIComponent(v)}` : '')
                    .filter(Boolean)
                    .join('&amp;');

                  fetch(`${pageInfo.url}?${queryParamsString}`, {
                    method: 'GET',
                  })
                    .then(result => result.json())
                    .then(result => {
                      ispPrefetchObject.result = result.doc;
                      ispPrefetchObject.listeners.forEach(callback =>
                        callback(result.doc),
                      );
                    })
                    .catch(error => console.error(error));
                },
              };
              <xsl:if test="/doc/@func = 'register.activate' or /doc/@func = 'profile.activate'">
                ispPrefetchObject.result = {
                  <xsl:call-template name="parse-doc">
                    <xsl:with-param name="node" select="/doc"></xsl:with-param>
                  </xsl:call-template>
                }
              </xsl:if>
              ispPrefetchObject.fetch();
            </script>

            <xsl:if test="$metadata/jscript">
              <script type="text/javascript">
                <xsl:for-each select="$metadata/jscript"><xsl:value-of select="."></xsl:value-of></xsl:for-each>
              </script>
            </xsl:if>

            <title>
              <xsl:value-of select="$msg/msg[@name = 'title']"></xsl:value-of>
            </title>

            <xsl:if test="/doc/@host">
              <base href="{/doc/@host}"/>
            </xsl:if>

            <link rel="shortcut icon" href="{/doc/@theme}{$localdir}{/doc/@favicon}" type="image/x-icon"/>
            <xsl:value-of select="/doc/addon/head/text()" disable-output-escaping="yes"></xsl:value-of>
          <link rel="stylesheet" href="/manimg/dragon/extform/styles-EXJ4XH7W.css"/></head>
          <body class="isp-fullscreen-body">
            <!-- @TODO i.ablov remove all old xsl logic, use angular app instead -->
            <isp-root></isp-root>
            <xsl:value-of select="/doc/addon/body/text()" disable-output-escaping="yes"></xsl:value-of>
          <link rel="modulepreload" href="/manimg/dragon/extform/chunk-Y7IE5WBV.js"/><script src="/manimg/dragon/extform/polyfills-EONH2QZO.js" type="module"></script><script src="/manimg/dragon/extform/main-QHUIIEB4.js" type="module"></script></body>
        </html>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="apply-attributes">
    <xsl:param name="node"></xsl:param>
    <xsl:for-each select="$node/@*">
      <xsl:variable name="nodeName" select="name(.)"></xsl:variable>
      <xsl:variable name="nodeValue">
        <xsl:call-template name="replace">
          <xsl:with-param name="input" select="."></xsl:with-param>
          <xsl:with-param name="from" select="'&lt;'"></xsl:with-param>
          <xsl:with-param name="to" select="'&amp;lt;'"></xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
      $<xsl:value-of select="$nodeName"></xsl:value-of>: '<xsl:value-of select="$nodeValue"></xsl:value-of>',
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="parse-form">
    <xsl:param name="node"></xsl:param>
    <xsl:call-template name="apply-attributes">
      <xsl:with-param name="node" select="$node"></xsl:with-param>
    </xsl:call-template>
    <xsl:if test="$node/buttons">
      buttons: {
        button: [
          <xsl:for-each select="$node/buttons/*">
            {
              <xsl:call-template name="apply-attributes">
                <xsl:with-param name="node" select="current()"></xsl:with-param>
              </xsl:call-template>
            },
          </xsl:for-each>
        ],
      },
    </xsl:if>
    <xsl:if test="$node/field">
      field: [
        <xsl:for-each select="$node/field">
          {
            <xsl:call-template name="apply-attributes">
              <xsl:with-param name="node" select="current()"></xsl:with-param>
            </xsl:call-template>

            <xsl:if test="current()/input">
              input: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
            <xsl:if test="current()/select">
              select: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
            <xsl:if test="current()/textdata">
              textdata: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
            <xsl:if test="current()/htmldata">
              htmldata: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
            <xsl:if test="current()/slider">
              slider: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
            <xsl:if test="current()/textarea">
              textarea: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
            <xsl:if test="current()/link">
              link: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
            <xsl:if test="current()/desc">
              desc: [
                <xsl:for-each select="current()/*">
                  {
                    <xsl:call-template name="apply-attributes">
                      <xsl:with-param name="node" select="current()"></xsl:with-param>
                    </xsl:call-template>
                  },
                </xsl:for-each>
              ],
            </xsl:if>
          },
        </xsl:for-each>
      ],
    </xsl:if>
  </xsl:template>

  <xsl:template name="parse-node">
    <xsl:param name="node"></xsl:param>
    <xsl:call-template name="apply-attributes">
      <xsl:with-param name="node" select="$node"></xsl:with-param>
    </xsl:call-template>
    <xsl:for-each select="$node/*">
      <xsl:value-of select="name(.)"></xsl:value-of>: {
        <xsl:call-template name="parse-node">
          <xsl:with-param name="node" select="current()"></xsl:with-param>
        </xsl:call-template>
      },
    </xsl:for-each>
    <xsl:if test="$node/text() != ''">
      $: <xsl:call-template name="escapeNode"><xsl:with-param name="node" select="$node"></xsl:with-param></xsl:call-template>,
    </xsl:if>
  </xsl:template>

  <xsl:template name="parse-doc">
    <xsl:param name="node"></xsl:param>
    <xsl:call-template name="apply-attributes">
      <xsl:with-param name="node" select="$node"></xsl:with-param>
    </xsl:call-template>

    <xsl:for-each select="$node/slist">
      slist: [
        {
          <xsl:call-template name="apply-attributes">
            <xsl:with-param name="node" select="current()"></xsl:with-param>
          </xsl:call-template>
          val: [
            <xsl:for-each select="current()/val">
              {
                <xsl:call-template name="apply-attributes">
                  <xsl:with-param name="node" select="current()"></xsl:with-param>
                </xsl:call-template>
                $: <xsl:call-template name="escapeNode"><xsl:with-param name="node" select="current()"></xsl:with-param></xsl:call-template>,
              },
            </xsl:for-each>
          ],
        },
      ],
    </xsl:for-each>

    <xsl:for-each select="$node/*">
      <xsl:variable name="nodeName" select="name(.)"></xsl:variable>
      <xsl:choose>
        <xsl:when test="$nodeName = 'messages'">
          messages: {
            <xsl:call-template name="apply-attributes">
              <xsl:with-param name="node" select="/doc/messages"></xsl:with-param>
            </xsl:call-template>
            msg: {
              <xsl:for-each select="/doc/messages/*">
                <xsl:value-of select="@name"></xsl:value-of>: `<xsl:value-of select="."></xsl:value-of>`,
              </xsl:for-each>
            }
          },
        </xsl:when>
        <xsl:when test="$nodeName = 'metadata'">
          metadata: {
            <xsl:call-template name="apply-attributes">
              <xsl:with-param name="node" select="current()"></xsl:with-param>
            </xsl:call-template>
            form: {
              <xsl:call-template name="parse-form">
                <xsl:with-param name="node" select="current()/form"></xsl:with-param>
              </xsl:call-template>
            }
          },
        </xsl:when>
        <xsl:when test="$nodeName != 'slist'">
          <xsl:value-of select="name(.)"></xsl:value-of>: {
            <xsl:call-template name="parse-node">
              <xsl:with-param name="node" select="current()"></xsl:with-param>
            </xsl:call-template>
          },
        </xsl:when>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="escapeNode">
    <xsl:param name="node"></xsl:param>
    <xsl:variable name="value" select="$node/."></xsl:variable>
    <xsl:variable name="escapedValue">
      <xsl:call-template name="replace">
        <xsl:with-param name="input" select="$value"></xsl:with-param>
        <xsl:with-param name="from" select="'&lt;'"></xsl:with-param>
        <xsl:with-param name="to" select="'&amp;lt;'"></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    `<xsl:value-of select="$escapedValue"></xsl:value-of>`
  </xsl:template>

  <xsl:template name="escape">
    <xsl:param name="input"></xsl:param>
    <xsl:variable name="escape1">
      <xsl:call-template name="replace">
        <xsl:with-param name="input" select="$input"></xsl:with-param>
        <xsl:with-param name="from" select="'>'"></xsl:with-param>
        <xsl:with-param name="to" select="'&amp;gt;'"></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="escape2">
      <xsl:call-template name="replace">
        <xsl:with-param name="input" select="$escape1"></xsl:with-param>
        <xsl:with-param name="from" select="'&lt;'"></xsl:with-param>
        <xsl:with-param name="to" select="'&amp;lt;'"></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="escape3">
      <xsl:call-template name="replace">
        <xsl:with-param name="input" select="$escape2"></xsl:with-param>
        <xsl:with-param name="from" select="'&quot;'"></xsl:with-param>
        <xsl:with-param name="to" select="'\x22'"></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="$escape3"></xsl:value-of>
  </xsl:template>

  <xsl:template name="escapeBacktick">
    <xsl:param name="input"></xsl:param>
    <xsl:variable name="escapedNoBackTick">
      <xsl:call-template name="replace">
        <xsl:with-param name="input" select="$input"></xsl:with-param>
        <xsl:with-param name="from" select="'`'"></xsl:with-param>
        <xsl:with-param name="to" select="'\`'"></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="escapedNoBackTickNoGt">
      <xsl:call-template name="replace">
        <xsl:with-param name="input" select="$escapedNoBackTick"></xsl:with-param>
        <xsl:with-param name="from" select="'>'"></xsl:with-param>
        <xsl:with-param name="to" select="'&amp;gt;'"></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="$escapedNoBackTickNoGt"></xsl:value-of>
  </xsl:template>

  <xsl:template name="replace">
    <xsl:param name="input"></xsl:param>
    <xsl:param name="from"></xsl:param>
    <xsl:param name="to"></xsl:param>
    <xsl:choose>
      <xsl:when test="contains($input, $from)">
        <xsl:value-of select="substring-before($input, $from)"></xsl:value-of>
        <xsl:value-of select="$to"></xsl:value-of>
        <xsl:call-template name="replace">
          <xsl:with-param name="input" select="substring-after($input, $from)"></xsl:with-param>
          <xsl:with-param name="from" select="$from"></xsl:with-param>
          <xsl:with-param name="to" select="$to"></xsl:with-param>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$input"></xsl:value-of>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>