module.exports = {
  name: 'Convert Variable',
  section: 'Variable Things',

  subtitle (data) {
    const info = ['Number (Int)', 'Number (Float)', 'String', 'Uppercased String', 'Lowercased String']
    return `Conversion Type: ${info[parseInt(data.conversion)]}`
  },

  variableStorage (data, varType) {
    const type = parseInt(data.storage2)
    const prse2 = parseInt(data.conversion)
    const info2 = ['Number', 'Number', 'String', 'String', 'String']
    if (type !== varType) return
    return ([data.varName2, info2[prse2]])
  },

  fields: ['storage', 'varName', 'conversion', 'storage2', 'varName2'],

  html (isEvent, data) {
    return `
<div>
  <div style="float: left; width: 35%;">
    Source Variable:<br>
    <select id="storage" class="round" onchange="glob.refreshVariableList(this)">
      ${data.variables[1]}
    </select>
  </div>
  <div id="varNameContainer" style="float: right; width: 60%;">
    Variable Name:<br>
    <input id="varName" class="round" type="text" list="variableList">
  </div>
</div><br><br><br>
<div>
  <div style="padding-top: 8px; width: 35%;">
    Conversion Type:<br>
    <select id="conversion" class="round">
      <option value="0" selected>Number (Int)</option>
      <option value="1">Number (Float)</option>
      <option value="2">String</option>
      <option value="3">Uppercased String</option>
      <option value="4">Lowercased String</option>
    </select>
  </div>
</div><br>
<div>
  <div style="float: left; width: 35%;">
    Store In:<br>
    <select id="storage2" class="round">
      ${data.variables[1]}
    </select>
  </div>
  <div id="varNameContainer2" style="float: right; width: 60%;">
    Variable Name:<br>
    <input id="varName2" class="round" type="text"><br>
  </div>
</div>
<style>
  /* My Embed CSS code */
  .embed {
    position: relative;
  }
  .embedinfo {
    background: rgba(46,48,54,.45) fixed;
    border: 1px solid hsla(0,0%,80%,.3);
    padding: 10px;
    margin:0 4px 0 7px;
    border-radius: 0 3px 3px 0;
  }
  embedleftline {
    background-color: #eee;
    width: 4px;
    border-radius: 3px 0 0 3px;
    border: 0;
    height: 100%;
    margin-left: 4px;
    position: absolute;
  }
  span {
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
  }
  span.embed-auth {
    color: rgb(255, 255, 255);

  }
  span.embed-desc {
    color: rgb(128, 128, 128);
  }
</style>`
  },

  init () {
    const { glob, document } = this
    glob.refreshVariableList(document.getElementById('storage'))
  },

  action (cache) {
    const data = cache.actions[cache.index]

    const storage = parseInt(data.storage)
    const varName = this.evalMessage(data.varName, cache)
    const variable = this.getVariable(storage, varName, cache)
    const conversion = parseInt(data.conversion)

    let result

    switch (conversion) {
      case 0:
        result = parseInt(variable)
        break
      case 1:
        result = parseFloat(variable)
        break
      case 2:
        result = variable.toString()
        break
      case 3:
        result = variable.toString().toUpperCase()
        break
      case 4:
        result = variable.toString().toLowerCase()
        break
      default:
        break
    }

    if (result !== undefined) {
      const storage2 = parseInt(data.storage2)
      const varName2 = this.evalMessage(data.varName2, cache)
      this.storeValue(result, storage2, varName2, cache)
    }
    this.callNextAction(cache)
  },

  mod () {}
}

@@ -114,24 +114,32 @@
 = %5B'Number (
+Parsing 
 Int)', 'Numb
@@ -138,24 +138,32 @@
 ', 'Number (
+Parsing 
 Float)', 'St
@@ -205,24 +205,58 @@
 ased String'
+, 'Number (Int)', 'Number (Float)'
 %5D%0A    return
@@ -356,93 +356,8 @@
 ) %7B%0A
-    const type = parseInt(data.storage2)%0A    const prse2 = parseInt(data.conversion)%0A
     
@@ -423,22 +423,61 @@
 ing'
-%5D%0A    if (type
+, 'Number', 'Number'%5D%0A    if (parseInt(data.storage2)
  !==
@@ -532,12 +532,32 @@
 o2%5Bp
+a
 rse
-2
+Int(data.conversion)
 %5D%5D)%0A
@@ -1220,24 +1220,32 @@
 ted%3ENumber (
+Parsing 
 Int)%3C/option
@@ -1274,24 +1274,32 @@
 %221%22%3ENumber (
+Parsing 
 Float)%3C/opti
@@ -1440,24 +1440,118 @@
 ng%3C/option%3E%0A
+      %3Coption value=%225%22%3ENumber (Int)%3C/option%3E%0A      %3Coption value=%226%22%3ENumber (Float)%3C/option%3E%0A
     %3C/select
@@ -3326,24 +3326,158 @@
       break%0A
+      case 5:%0A        result = parseInt(Number(variable))%0A        break%0A      case 6:%0A        result = Number(variable)%0A        break%0A
       defaul

Add options for strict conversion in Convert Variable (#718)