XHTML + JavaScript

  • Beitrags-Autor:
  • Beitrags-Kategorie:Sonstiges
<script>//<![CDATA[
console.log("js...");
//]]></script>

window.myTool = {
  abcdInstalled: [],
  install: function(initCommaList = [], initValue = -1) {
    // configure elemets...
    // [HTML5] data-abcd="def123"
    // [XHTML] xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" | pt:data-abcd="def123"
    const elements = document.querySelectorAll('[data-abcd]');
    for (let i = 0; i < elements.length; i++) {
      const e = elements[i];
      const abcd = e.getAttribute('data-abcd');
      if (!this.abcdInstalled.includes(abcd)) {
        this.abcdInstalled.push(abcd);
      }
    }
  }
}
<h:head>
  <script src="/js/myTool.js"></script>
</h:head>
<h:body>
  <script>
    window.myTool.install(["#{bean.commaList}"], "#{bean.value}");
  </script>
</h:body>