afr / post_nossa

// ==UserScript==
// @name         post_nossa
// @namespace    http://tampermonkey.net/
// @version      4.1
// @description  try to take over the world!
// @author       afr
// @include      /https:\/{2}nossa.telkom.co.id\/maximo\/ui\/\?event=loadapp&value=incident&uisessionid=\d+&csrftoken=\S+/
// @include      /https:\/{2}nossa.telkom.co.id\/maximo\/ui\/\?event=loadapp&value=incident&uniqueid=\d+&uisessionid=\d+&csrftoken=\S+/
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_xmlhttpRequest
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @icon         https://www.google.com/s2/favicons?domain=co.id
// @copyright    2021
// @license      MIT
// @updateURL    https://openuserjs.org/meta/afr/post_nossa.meta.js
// ==/UserScript==

(function () {
  'use strict';
  // waitForKeyEements
  /*--- waitForKeyElements():  A utility function, for Greasemonkey scripts,
    that detects and handles AJAXed content.

    Usage example:

        waitForKeyElements (
            "div.comments"
            , commentCallbackFunction
        );

        //--- Page-specific function to do what we want when the node is found.
        function commentCallbackFunction (jNode) {
            jNode.text ("This comment changed by waitForKeyElements().");
        }

    IMPORTANT: This function requires your script to have loaded jQuery.
*/
  function waitForKeyElements(
    selectorTxt,
    /* Required: The jQuery selector string that
                        specifies the desired element(s).
                    */
    actionFunction,
    /* Required: The code to run when elements are
                           found. It is passed a jNode to the matched
                           element.
                       */
    bWaitOnce,
    /* Optional: If false, will continue to scan for
                      new elements even after the first match is
                      found.
                  */
    iframeSelector
    /* Optional: If set, identifies the iframe to
                          search.
                      */
  ) {
    var targetNodes, btargetsFound;

    if (typeof iframeSelector == "undefined")
      targetNodes = $(selectorTxt);
    else
      targetNodes = $(iframeSelector).contents()
      .find(selectorTxt);

    if (targetNodes && targetNodes.length > 0) {
      btargetsFound = true;
      /*--- Found target node(s).  Go through each and act if they
            are new.
        */
      targetNodes.each(function () {
        var jThis = $(this);
        var alreadyFound = jThis.data('alreadyFound') || false;

        if (!alreadyFound) {
          //--- Call the payload function.
          var cancelFound = actionFunction(jThis);
          if (cancelFound)
            btargetsFound = false;
          else
            jThis.data('alreadyFound', true);
        }
      });
    }
    else {
      btargetsFound = false;
    }

    //--- Get the timer-control variable for this selector.
    var controlObj = waitForKeyElements.controlObj || {};
    var controlKey = selectorTxt.replace(/[^\w]/g, "_");
    var timeControl = controlObj[controlKey];

    //--- Now set or clear the timer as appropriate.
    if (btargetsFound && bWaitOnce && timeControl) {
      //--- The only condition where we need to clear the timer.
      clearInterval(timeControl);
      delete controlObj[controlKey]
    }
    else {
      //--- Set a timer, if needed.
      if (!timeControl) {
        timeControl = setInterval(function () {
            waitForKeyElements(selectorTxt,
              actionFunction,
              bWaitOnce,
              iframeSelector
            );
          },
          300
        );
        controlObj[controlKey] = timeControl;
      }
    }
    waitForKeyElements.controlObj = controlObj;
  }

  //'use strict';
  const version = "4.1"

  $('document').ready(() => {
    // post with alt+1
    var map = []
    onkeydown = onkeyup = function (e) {
      e = e || Event
      map[e.key] = e.type === 'keydown'
      if (map['Alt'] && map['1']) {
        function getDatek() {
          let hl = document.querySelectorAll('label')[2].innerText
          let metroPatt = /([A-Z]+-[A-Z]+|[A-Z]+\d+[A-Z]+|[A-Z]+|[A-Z]+\d+)-D\d+-([A-Z]+-[A-Z]+|[A-Z]+)/g
          let gponPatt = /GPON\d+-D\d+-[A-Z]+-(\d+[A-Z]+|\d+)/g
          if (hl.match(metroPatt) === null && hl.match(gponPatt) === null) {
            return ''
          }
          else if (hl.match(gponPatt) === null) {
            return hl.match(metroPatt)
          }
          else {
            return hl.match(gponPatt)
          }
        }

        let patt = /[A-Z]{3}\d{3}/g
        let datek = getDatek()

        const ticketId = document.querySelectorAll('label')[1].innerText
        const ticketHL = document.querySelectorAll('label')[2].innerText
        const dateOpen = document.querySelectorAll('input')[7].value
        const remedy = document.querySelectorAll('input')[71].value
        const impact = document.querySelectorAll('textarea')[2].value

        let ticket = {
          ticketId: ticketId,
          ticketHL: ticketHL,
          dateOpen: dateOpen,
          remedy: remedy,
          impact: impact,
          datek: datek,
          version: version
        }

        const details = {
          method: 'POST',
          url: 'https://autofill-2u8b.onrender.com/addlist',
          // url: 'http://localhost:3000/addlist',
          headers: {
            "Content-Type": "application/json"
          },
          data: JSON.stringify(ticket),
          onerror: ((err) => {
            console.log(err.responseText)
            console.log(err.statusText)
          }),
          onload: ((res) => {
            console.log(res.status)
            console.log(res.responseText)
            if (res.status === 200) {
              let notification = $('#notify')
              notification.slideDown(200)
              setTimeout(() => {
                notification.slideUp(200)
              }, 500)
            }

          })

        }
        if (impact.length !== 0) {
          GM_xmlhttpRequest(details)
        }
        else {
          console.log('Impacted Site cannot be empty')
        }

      }
      else if (map['Alt'] && map['2']) {
        console.log('PUT')

        const ticketId = document.querySelectorAll("input")[4].value
        const ticketHL = document.querySelectorAll('input')[5].value
        const actualSolution = document.querySelectorAll("input")[7].value
        const incidentDomain = document.getElementById('inputDom').value
        const RFO_details = document.querySelectorAll("iframe")[0].contentDocument.querySelector("#dijitEditorBody").innerText
        const dateClosed = document.querySelector('table.dsc1.mc.modal').querySelectorAll('div')[68].innerText

        //update for closing
        let ticket = {
          ticketId: ticketId,
          ticketHL: ticketHL,
          actualSolution: actualSolution,
          incidentDomain: incidentDomain,
          RFO_details: RFO_details,
          dateClosed: dateClosed,
          version: version
        }
        const details = {
          method: 'PUT',
          url: 'https://autofill-2u8b.onrender.com/list',
          // url: 'http://localhost:3000/list',
          headers: {
            "Content-Type": "application/json"
          },
          data: JSON.stringify(ticket),
          onerror: ((err) => {
            console.log(err.responseText)
            console.log(err.statusText)
          }),
          onload: ((res) => {
            console.log(res.status)
            let notification = $('#putNotify')
            if (res.status === 200) {
              notification.slideDown(200)
              setTimeout(() => {
                notification.slideUp(200)
              }, 500)
            }
          })
        }
        GM_xmlhttpRequest(details)
      }
      else if (map['Alt'] && map['3']) {
        let impact = document.querySelectorAll('iframe')[1].contentDocument.querySelectorAll('body')[0].innerText.toUpperCase().match(/[A-Z]{3}\d{3}/ig) //document.querySelectorAll('iframe')[1].contentDocument.querySelectorAll('div')[0].innerText.toUpperCase().match(/[A-Z]{3}\d{3}/ig) //document.querySelectorAll('iframe')[1].contentWindow.document.querySelectorAll('div')[0].innerText.match(/[A-Z]{3}\d{3}/ig)
        impact = [...new Set(impact)]
        let setImpact = `Jumlah Site:${impact.length}
2G:${impact.length}NE
3G:${impact.length}NE
4G:${impact.length}NE
Detail Site:
${impact}`
        navigator.clipboard.writeText(setImpact) //copy to clipboard
      }
    }
  })

  function notify(jNode) {
    jNode.before('<img id="notify" src="https://media1.giphy.com/media/1xp0KDHzTY5GlDEpuL/giphy.gif?cid=ecf05e47i8j3sf6y4tr7vmxrmc2j4ujekfwplazmsue4hyeb&rid=giphy.gif&ct=s" />')
    let notification = $('#notify')
    notification.css({
      'display': 'block',
      'margin-left': 'auto',
      'margin-right': 'auto',
      'width': '50%',
      'width': '50px',
      'height': '50px'
    })
    notification.hide()
  }

  function putNotify(jNode) {
    jNode.after('<img id="putNotify" src="https://media1.giphy.com/media/1xp0KDHzTY5GlDEpuL/giphy.gif?cid=ecf05e47i8j3sf6y4tr7vmxrmc2j4ujekfwplazmsue4hyeb&rid=giphy.gif&ct=s" />')
    let notification = $('#putNotify')
    notification.css({
      'display': 'block',
      'margin-left': 'auto',
      'margin-right': 'auto',
      'width': '50%',
      'width': '50px',
      'height': '50px'
    })
    notification.hide()
  }

  function putInputJamu(jNode) {

    //create input
    const atts = {
      id: 'inputDom',
      type: 'text',
      list: 'domain',
      class: 'fld text',
      style: 'width:286px !important;',
    }

    const input = document.createElement('input')

    function setAttributes(el, attrs) {
      for (var key in attrs) {
        el.setAttribute(key, attrs[key])
      }
    }

    setAttributes(input, atts)

    //render to dom
    document.querySelectorAll('img')[38].after(input)

    //create datalist
    //const optionsList = ["TELKOM-CATUDAYA OLTREMOTE-KABELCATUAN", "TELKOM-CATUDAYA OLTREMOTE-METERPLNRUSAK", "TELKOM-CATUDAYA OLTREMOTE-PLNMATI", "TELKOM-CATUDAYA OLTREMOTE-PULSAPLNHABIS", "TELKOM-CATUDAYA OLTREMOTE-RECTIFIEROLT", "TELKOM-CATUDAYA STO-GENSETSTO", "TELKOM-CATUDAYA STO-METERPLNRUSAK", "TELKOM-CATUDAYA STO-PLNSTOMATI", "TELKOM-CATUDAYA STO-PULSAPLNHABIS", "TELKOM-CATUDAYA STO-RECTIFIERSTORUSAK", "TELKOM-DWDM-HANG", "TELKOM-DWDM-HILANG", "TELKOM-DWDM-KONFIGURASI", "TELKOM-DWDM-MODUL", "TELKOM-DWDM-SFP", "TELKOM-DWDM-SOFTWARE", "TELKOM-FO CORE/BACKBONE-BENDING", "TELKOM-FO CORE/BACKBONE-DEGRADED/BAD", "TELKOM-FO CORE/BACKBONE-GANGGUNHEWAN", "TELKOM-FO CORE/BACKBONE-JOINCLOSURE", "TELKOM-FO CORE/BACKBONE-PIHAK-3NONPROJECT", "TELKOM-FO CORE/BACKBONE-PIHAK-3PROJECT", "TELKOM-FO CORE/BACKBONE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO CORE/BACKBONE-VANDALISME", "TELKOM-FO CORE OLT-METRO-BENDING", "TELKOM-FO CORE OLT-METRO-DEGRADED/BAD", "TELKOM-FO CORE OLT-METRO-GANGGUNHEWAN", "TELKOM-FO CORE OLT-METRO-JOINCLOSURE", "TELKOM-FO CORE OLT-METRO-PIHAK-3NONPROJECT", "TELKOM-FO CORE OLT-METRO-PIHAK-3PROJECT", "TELKOM-FO CORE OLT-METRO-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO CORE OLT-METRO-VANDALISME", "TELKOM-FO DISTRIBUSI-BENDING", "TELKOM-FO DISTRIBUSI-DEGRADED/BAD", "TELKOM-FO DISTRIBUSI-GANGGUNHEWAN", "TELKOM-FO DISTRIBUSI-JOINCLOSURE", "TELKOM-FO DISTRIBUSI-PIHAK-3NONPROJECT", "TELKOM-FO DISTRIBUSI-PIHAK-3PROJECT", "TELKOM-FO DISTRIBUSI-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO DISTRIBUSI-VANDALISME", "TELKOM-FO DROPCORE-BENDING", "TELKOM-FO DROPCORE-DEGRADED/BAD", "TELKOM-FO DROPCORE-GANGGUNHEWAN", "TELKOM-FO DROPCORE-JOINCLOSURE", "TELKOM-FO DROPCORE-PIHAK-3NONPROJECT", "TELKOM-FO DROPCORE-PIHAK-3PROJECT", "TELKOM-FO DROPCORE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO DROPCORE-VANDALISME", "TELKOM-FO FEEDER-BENDING", "TELKOM-FO FEEDER-DEGRADED/BAD", "TELKOM-FO FEEDER-GANGGUNHEWAN", "TELKOM-FO FEEDER-JOINCLOSURE", "TELKOM-FO FEEDER-PIHAK-3NONPROJECT", "TELKOM-FO FEEDER-PIHAK-3PROJECT", "TELKOM-FO FEEDER-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO FEEDER-VANDALISME", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-BENDING", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-DEGRADED/BAD", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-GANGGUNHEWAN", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-PIHAK-3NONPROJECT", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-PIHAK-3PROJECT", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-VANDALISME", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-BENDING", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-DEGRADED/BAD", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-GANGGUNHEWAN", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-PIHAK-3NONPROJECT", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-PIHAK-3PROJECT", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-VANDALISME", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-BENDING", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-DEGRADED/BAD", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-GANGGUNHEWAN", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-PIHAK-3NONPROJECT", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-PIHAK-3PROJECT", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-VANDALISME", "TELKOM-FO PATCHCORE GPON-ODF-BENDING", "TELKOM-FO PATCHCORE GPON-ODF-DEGRADED/BAD", "TELKOM-FO PATCHCORE GPON-ODF-GANGGUNHEWAN", "TELKOM-FO PATCHCORE GPON-ODF-PIHAK-3NONPROJECT", "TELKOM-FO PATCHCORE GPON-ODF-PIHAK-3PROJECT", "TELKOM-FO PATCHCORE GPON-ODF-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO PATCHCORE GPON-ODF-VANDALISME", "TELKOM-FO PATCHCORE ME-GPON-BENDING", "TELKOM-FO PATCHCORE ME-GPON-DEGRADED/BAD", "TELKOM-FO PATCHCORE ME-GPON-GANGGUNHEWAN", "TELKOM-FO PATCHCORE ME-GPON-PIHAK-3NONPROJECT", "TELKOM-FO PATCHCORE ME-GPON-PIHAK-3PROJECT", "TELKOM-FO PATCHCORE ME-GPON-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO PATCHCORE ME-GPON-VANDALISME", "TELKOM-FO PATCHCORE TOBTS-BENDING", "TELKOM-FO PATCHCORE TOBTS-DEGRADED/BAD", "TELKOM-FO PATCHCORE TOBTS-GANGGUNHEWAN", "TELKOM-FO PATCHCORE TOBTS-PIHAK-3NONPROJECT", "TELKOM-FO PATCHCORE TOBTS-PIHAK-3PROJECT", "TELKOM-FO PATCHCORE TOBTS-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO PATCHCORE TOBTS-VANDALISME", "TELKOM-FO PERTENG-CUT", "TELKOM-FO PRB-CUT", "TELKOM-FO PRT-CUT", "TELKOM-FORCEMAJOR-BANJIR", "TELKOM-FORCEMAJOR-LONGSOR", "TELKOM-FORCEMAJOR-PETIR", "TELKOM-FO SKKL-PUTUS", "TELKOM-GPON OLT-HANG", "TELKOM-GPON OLT-KONFIGURASI", "TELKOM-GPON OLT-MODUL", "TELKOM-GPON OLT-SFP", "TELKOM-GPON OLT-SOFTWARE", "TELKOM-GPON OLT-TERTABRAK", "TELKOM-GPON ONT-HANG", "TELKOM-GPON ONT-HILANG", "TELKOM-GPON ONT-KONFIGURASI", "TELKOM-GPON ONT-MODUL", "TELKOM-GPON ONT-SFP", "TELKOM-GPON ONT-SOFTWARE", "TELKOM-L2-SWTCH-HILANG", "TELKOM-L2-SWTCH-KONFIGURASI", "TELKOM-L2-SWTCH-MODUL", "TELKOM-METRO-HANG", "TELKOM-METRO-HILANG", "TELKOM-METRO-KONFIGURASI", "TELKOM-METRO-MODUL", "TELKOM-METRO-SFP", "TELKOM-METRO-SOFTWARE", "TELKOM-ODC-ODCBADPORT", "TELKOM-ODC-ODCBOCOR", "TELKOM-ODC-ODCGANGGUANHEWAN", "TELKOM-ODC-ODCTERTABRAK", "TELKOM-ODF-ODFBADPORT", "TELKOM-ODF-ODFBOCOR", "TELKOM-ODF-ODFGANGGUANHEWAN", "TELKOM-ODF-ODFTERTABRAK", "TELKOM-ODP-ODPBADPORT", "TELKOM-ODP-ODPBOCOR", "TELKOM-ODP-ODPGANGGUANHEWAN", "TELKOM-QUALITYFO AKSES-LOWCAPACITY", "TELKOM-QUALITYFO AKSES-TXRXRENDAH/REDAMANTINGGI", "TELKOM-QUALITYFO BACKBONE-LOWCAPACITY", "TELKOM-QUALITYFO BACKBONE-TXRXRENDAH/REDAMANTINGGI", "TELKOM-QUALITYRADIOIP-LOWCAPACITY", "TELKOM-QUALITYRADIOIP-RSLFLIKER/RENDAH", "TELKOM-QUALITYRADIOLH-LOWCAPACITY", "TELKOM-QUALITYRADIOLH-RSLFLIKER/RENDAH", "TELKOM-RADIOIP-ANTENNA", "TELKOM-RADIOIP-COAXIAL", "TELKOM-RADIOIP-FANIDU", "TELKOM-RADIOIP-IDUSET", "TELKOM-RADIOIP-INTERFRENCE", "TELKOM-RADIOIP-ISR/SEGELBALMON", "TELKOM-RADIOIP-KONEKTORCOAXIAL", "TELKOM-RADIOIP-LINKOBSTACLE", "TELKOM-RADIOIP-MODULIDU", "TELKOM-RADIOIP-MODULPOWERIDU", "TELKOM-RADIOIP-ODU", "TELKOM-RADIOLH-ANTENNA", "TELKOM-RADIOLH-COAXIAL", "TELKOM-RADIOLH-FANIDU", "TELKOM-RADIOLH-IDUSET", "TELKOM-RADIOLH-INTERFRENCE", "TELKOM-RADIOLH-ISR/SEGELBALMON", "TELKOM-RADIOLH-KONEKTORCOAXIAL", "TELKOM-RADIOLH-LINKOBSTACLE", "TELKOM-RADIOLH-MODULIDU", "TELKOM-RADIOLH-MODULPOWERIDU", "TELKOM-RADIOLH-ODU", "TELKOM-ROUTER-HANG", "TELKOM-ROUTER-HILANG", "TELKOM-ROUTER-KONFIGURASI", "TELKOM-ROUTER-MODUL", "TELKOM-ROUTER-SFP", "TELKOM-ROUTER-SOFTWARE", "TELKOM-SATELIT-PUTUS", "TELKOMSEL-CATUDAYA SITE-PLNMATI", "TELKOMSEL-FO -PUTUS FO  TSEL", "TELKOMSEL-GROUNDING-HILANG PUTUS/TIDAK ADA", "TELKOMSEL-IKGSITE-NO IKG", "TELKOMSEL-ISP(NE,DLL)-ISP PUTUS", "TELKOMSEL-KONTRAKTENANT-NO KONTRAK", "TELKOMSEL-LANBTS-PUTUS LAN", "TELKOMSEL-PENDINGINRUANGAN-MATI AC", "TELKOM-SHELTER-BOCOR", "TELKOM-STM64 MODUL", "TELKOM-STM64 HANG", "TELKOM- STM64 SFP", "TELKOM-ODP KONEKTOR", "TELKOM- ODC-KONEKTOR ", "TELKOM- OTB ", "TELKOM-OTB KONEKTOR", "TELKOM- FO ME TO OTB SITE", "TELKOM- FO ME TO IDU-GANGGUAN HEWAN", "TELKOM- PATCHCORE ME TO IDU BENDING", "TELKOM- PATCHCORE ME TO IDU GANGGUANHEWAN", "TELKOM-FORCEMAJOR-HUJANBADAI", "TELKOM-FORCEMAJOR-KEBAKARAN", "TELKOM-RADIOIP-MODUL/PERANGKAT HANG", "TELKOM-RADIOIP-MISSED CONFIG"]
    const optionsList = ["TELKOM-CATUDAYA OLTREMOTE-KABELCATUAN", "TELKOM-CATUDAYA OLTREMOTE-METERPLNRUSAK", "TELKOM-CATUDAYA OLTREMOTE-PLNMATI", "TELKOM-CATUDAYA OLTREMOTE-PULSAPLNHABIS", "TELKOM-CATUDAYA OLTREMOTE-RECTIFIEROLT", "TELKOM-CATUDAYA STO-GENSETSTO", "TELKOM-CATUDAYA STO-METERPLNRUSAK", "TELKOM-CATUDAYA STO-PLNSTOMATI", "TELKOM-CATUDAYA STO-PULSAPLNHABIS", "TELKOM-CATUDAYA STO-RECTIFIERSTORUSAK", "TELKOM-DWDM-HANG", "TELKOM-DWDM-HILANG", "TELKOM-DWDM-KONFIGURASI", "TELKOM-DWDM-MODUL", "TELKOM-DWDM-SFP", "TELKOM-DWDM-SOFTWARE", "TELKOM-FO CORE/BACKBONE-BENDING", "TELKOM-FO CORE/BACKBONE-DEGRADED/BAD", "TELKOM-FO CORE/BACKBONE-GANGGUNHEWAN", "TELKOM-FO CORE/BACKBONE-JOINCLOSURE", "TELKOM-FO CORE/BACKBONE-PIHAK-3NONPROJECT", "TELKOM-FO CORE/BACKBONE-PIHAK-3PROJECT", "TELKOM-FO CORE/BACKBONE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO CORE/BACKBONE-VANDALISME", "TELKOM-FO CORE OLT-METRO-BENDING", "TELKOM-FO CORE OLT-METRO-DEGRADED/BAD", "TELKOM-FO CORE OLT-METRO-GANGGUNHEWAN", "TELKOM-FO CORE OLT-METRO-JOINCLOSURE", "TELKOM-FO CORE OLT-METRO-PIHAK-3NONPROJECT", "TELKOM-FO CORE OLT-METRO-PIHAK-3PROJECT", "TELKOM-FO CORE OLT-METRO-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO CORE OLT-METRO-VANDALISME", "TELKOM-FO DISTRIBUSI-BENDING", "TELKOM-FO DISTRIBUSI-DEGRADED/BAD", "TELKOM-FO DISTRIBUSI-GANGGUNHEWAN", "TELKOM-FO DISTRIBUSI-JOINCLOSURE", "TELKOM-FO DISTRIBUSI-PIHAK-3NONPROJECT", "TELKOM-FO DISTRIBUSI-PIHAK-3PROJECT", "TELKOM-FO DISTRIBUSI-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO DISTRIBUSI-VANDALISME", "TELKOM-FO DROPCORE-BENDING", "TELKOM-FO DROPCORE-DEGRADED/BAD", "TELKOM-FO DROPCORE-GANGGUNHEWAN", "TELKOM-FO DROPCORE-JOINCLOSURE", "TELKOM-FO DROPCORE-PIHAK-3NONPROJECT", "TELKOM-FO DROPCORE-PIHAK-3PROJECT", "TELKOM-FO DROPCORE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO DROPCORE-VANDALISME", "TELKOM-FO FEEDER-BENDING", "TELKOM-FO FEEDER-DEGRADED/BAD", "TELKOM-FO FEEDER-GANGGUNHEWAN", "TELKOM-FO FEEDER-JOINCLOSURE", "TELKOM-FO FEEDER-PIHAK-3NONPROJECT", "TELKOM-FO FEEDER-PIHAK-3PROJECT", "TELKOM-FO FEEDER-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO FEEDER-VANDALISME", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-BENDING", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-DEGRADED/BAD", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-GANGGUNHEWAN", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-PIHAK-3NONPROJECT", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-PIHAK-3PROJECT", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO LINK-KE2 DISTRIBUSIPREMIUMSITE-VANDALISME", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-BENDING", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-DEGRADED/BAD", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-GANGGUNHEWAN", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-PIHAK-3NONPROJECT", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-PIHAK-3PROJECT", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO LINK-KE2 DROPCOREPREMIUMSITE-VANDALISME", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-BENDING", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-DEGRADED/BAD", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-GANGGUNHEWAN", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-PIHAK-3NONPROJECT", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-PIHAK-3PROJECT", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO LINK-KE2 FEEDERPREMIUMSITE-VANDALISME", "TELKOM-FO PATCHCORE GPON-ODF-BENDING", "TELKOM-FO PATCHCORE GPON-ODF-DEGRADED/BAD", "TELKOM-FO PATCHCORE GPON-ODF-GANGGUNHEWAN", "TELKOM-FO PATCHCORE GPON-ODF-PIHAK-3NONPROJECT", "TELKOM-FO PATCHCORE GPON-ODF-PIHAK-3PROJECT", "TELKOM-FO PATCHCORE GPON-ODF-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO PATCHCORE GPON-ODF-VANDALISME", "TELKOM-FO PATCHCORE ME-GPON-BENDING", "TELKOM-FO PATCHCORE ME-GPON-DEGRADED/BAD", "TELKOM-FO PATCHCORE ME-GPON-GANGGUNHEWAN", "TELKOM-FO PATCHCORE ME-GPON-PIHAK-3NONPROJECT", "TELKOM-FO PATCHCORE ME-GPON-PIHAK-3PROJECT", "TELKOM-FO PATCHCORE ME-GPON-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO PATCHCORE ME-GPON-VANDALISME", "TELKOM-FO PATCHCORE TOBTS-BENDING", "TELKOM-FO PATCHCORE TOBTS-DEGRADED/BAD", "TELKOM-FO PATCHCORE TOBTS-GANGGUNHEWAN", "TELKOM-FO PATCHCORE TOBTS-PIHAK-3NONPROJECT", "TELKOM-FO PATCHCORE TOBTS-PIHAK-3PROJECT", "TELKOM-FO PATCHCORE TOBTS-TERTABRAK/TARIKKENDARAAN", "TELKOM-FO PATCHCORE TOBTS-VANDALISME", "TELKOM-FO PERTENG-CUT", "TELKOM-FO PRB-CUT", "TELKOM-FO PRT-CUT", "TELKOM-FORCEMAJOR-BANJIR", "TELKOM-FORCEMAJOR-LONGSOR", "TELKOM-FORCEMAJOR-PETIR", "TELKOM-FO SKKL-PUTUS", "TELKOM-GPON OLT-HANG", "TELKOM-GPON OLT-KONFIGURASI", "TELKOM-GPON OLT-MODUL", "TELKOM-GPON OLT-SFP", "TELKOM-GPON OLT-SOFTWARE", "TELKOM-GPON OLT-TERTABRAK", "TELKOM-GPON ONT-HANG", "TELKOM-GPON ONT-HILANG", "TELKOM-GPON ONT-KONFIGURASI", "TELKOM-GPON ONT-MODUL", "TELKOM-GPON ONT-SFP", "TELKOM-GPON ONT-SOFTWARE", "TELKOM-L2-SWTCH-HILANG", "TELKOM-L2-SWTCH-KONFIGURASI", "TELKOM-L2-SWTCH-MODUL", "TELKOM-METRO-HANG", "TELKOM-METRO-HILANG", "TELKOM-METRO-KONFIGURASI", "TELKOM-METRO-MODUL", "TELKOM-METRO-SFP", "TELKOM-METRO-SOFTWARE", "TELKOM-ODC-ODCBADPORT", "TELKOM-ODC-ODCBOCOR", "TELKOM-ODC-ODCGANGGUANHEWAN", "TELKOM-ODC-ODCTERTABRAK", "TELKOM-ODF-ODFBADPORT", "TELKOM-ODF-ODFBOCOR", "TELKOM-ODF-ODFGANGGUANHEWAN", "TELKOM-ODF-ODFTERTABRAK", "TELKOM-ODP-ODPBADPORT", "TELKOM-ODP-ODPBOCOR", "TELKOM-ODP-ODPGANGGUANHEWAN", "TELKOM-QUALITYFO AKSES-LOWCAPACITY", "TELKOM-QUALITYFO AKSES-TXRXRENDAH/REDAMANTINGGI", "TELKOM-QUALITYFO BACKBONE-LOWCAPACITY", "TELKOM-QUALITYFO BACKBONE-TXRXRENDAH/REDAMANTINGGI", "TELKOM-QUALITYRADIOIP-LOWCAPACITY", "TELKOM-QUALITYRADIOIP-RSLFLIKER/RENDAH", "TELKOM-QUALITYRADIOLH-LOWCAPACITY", "TELKOM-QUALITYRADIOLH-RSLFLIKER/RENDAH", "TELKOM-RADIOIP-ANTENNA", "TELKOM-RADIOIP-COAXIAL", "TELKOM-RADIOIP-FANIDU", "TELKOM-RADIOIP-IDUSET", "TELKOM-RADIOIP-INTERFRENCE", "TELKOM-RADIOIP-ISR/SEGELBALMON", "TELKOM-RADIOIP-KONEKTORCOAXIAL", "TELKOM-RADIOIP-LINKOBSTACLE", "TELKOM-RADIOIP-MODULIDU", "TELKOM-RADIOIP-MODULPOWERIDU", "TELKOM-RADIOIP-ODU", "TELKOM-RADIOLH-ANTENNA", "TELKOM-RADIOLH-COAXIAL", "TELKOM-RADIOLH-FANIDU", "TELKOM-RADIOLH-IDUSET", "TELKOM-RADIOLH-INTERFRENCE", "TELKOM-RADIOLH-ISR/SEGELBALMON", "TELKOM-RADIOLH-KONEKTORCOAXIAL", "TELKOM-RADIOLH-LINKOBSTACLE", "TELKOM-RADIOLH-MODULIDU", "TELKOM-RADIOLH-MODULPOWERIDU", "TELKOM-RADIOLH-ODU", "TELKOM-ROUTER-HANG", "TELKOM-ROUTER-HILANG", "TELKOM-ROUTER-KONFIGURASI", "TELKOM-ROUTER-MODUL", "TELKOM-ROUTER-SFP", "TELKOM-ROUTER-SOFTWARE", "TELKOM-SATELIT-PUTUS", "TELKOMSEL-CATUDAYA SITE-PLNMATI", "TELKOMSEL-FO -PUTUS FO TSEL", "TELKOMSEL-GROUNDING-HILANG PUTUS/TIDAK ADA", "TELKOMSEL-IKGSITE-NO IKG", "TELKOMSEL-ISP(NE,DLL)-ISP PUTUS", "TELKOMSEL-KONTRAKTENANT-NO KONTRAK", "TELKOMSEL-LANBTS-PUTUS LAN", "TELKOMSEL-PENDINGINRUANGAN-MATI AC", "TELKOM-RADIOIP- SHELTER BOCOR", "TELKOM-STM64 MODUL", "TELKOM-STM64 HANG", "TELKOM- STM64 SFP", "TELKOM-ODP KONEKTOR", "TELKOM- ODC-KONEKTOR", "TELKOM- OTB", "TELKOM-OTB KONEKTOR", "TELKOM- FO ME TO OTB SITE", "TELKOM- FO ME TO IDU-GANGGUAN HEWAN", "TELKOM- PATCHCORE ME TO IDU BENDING", "TELKOM- PATCHCORE ME TO IDU GANGGUANHEWAN", "TELKOM-FORCEMAJOR-HUJANBADAI", "TELKOM-FORCEMAJOR-KEBAKARAN", "TELKOM-RADIOIP-MODUL/PERANGKAT HANG", "TELKOM-RADIOIP-MISSED CONFIG", "TELKOM-CANCEL TIKET", "TELKOM-NO-CRA-ACTIVITY", "TELKOM-CRA ACTIVITY"]

    function fillDataList() {
      const container = document.getElementById('inputDom')
      const dataList = document.createElement('datalist')
      dataList.id = 'domain'

      for (var i = 0; i < optionsList.length; i++) {
        const option = document.createElement('option')
        option.value = optionsList[i]
        dataList.appendChild(option)
      }

      container.appendChild(dataList)
    }
    fillDataList()

    $('#inputDom').change(() => {
      const val = document.getElementById('inputDom').value
      const ticket = document.querySelectorAll('input')[4].value

      //create
      const data = {
        ticketId: ticket,
        IncidentDomain: val
      }
      sessionStorage.setItem(ticket, JSON.stringify(data))
      console.log(data)
    })

    function setIncidentDomain() {
      const ticket = document.querySelectorAll('input')[4].value
      const input = document.getElementById('inputDom')
      const ex = JSON.parse(sessionStorage.getItem(ticket))

      if (ex === null) {
        input.value = ''
      }
      else {
        input.value = ex.IncidentDomain
      }
      console.log(ex)

    }
    setIncidentDomain()

  }

  waitForKeyElements('table#mx79', notify)
  waitForKeyElements('h1[title="View History"]', putNotify)
  waitForKeyElements('a[title="Actual Resolution"][class="text tablabelon on "]', putInputJamu)
})();