Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h4>In this demo, it helps you to understand how to create a cluase and provide a comment to user.</h4>
<!--Part 1: create buy me a cofffe config  -->
<h4>Buy me a coffee</h4>
<fieldset style="width:40%">
  <legend>Buy me a coffee - config</legend>
  <label for="address">Your address:</label>
  <input type="text" id="address" name="address" value="0x70aE85A2fF6030366F512DbcD60Be3828139b498"><br><br>
  <label for="amount">Amount:</label>
  <input type="number" id="amount" name="amount" value="100">VET / cup<br><br>
  <label for="message">Message:</label>
 <textarea id="message" name="message">Thanks for supporting my apllication 😊</textarea><br><br>
  <input type="submit" value="Save config" onclick="saveConfig()"></input>
 </fieldset>
</form>
<br>
<!--Part2: a button which embed in article/application ...etcs -->
<div id="supportDiv" style="display:none">
<h3>Support</h3> 
  <label>Buy me a coffee</label>
  <input type="radio" checked name="cups" id="one" value="1">1 Cup</input>
  <input type="radio"  name="cups" id="two" value="2">2 Cups</input>
  <input type="radio"  name="cups"id="three" value="3">3 Cups</input>
<input onclick="signTx()" type="submit" value="Buy"></input>
</div>
<pre id="result"></pre>
              
            
!

CSS

              
                
              
            
!

JS

              
                const vendor = new Connex.Vendor("test");
var configDetails = ""

function saveConfig() {
  configDetails = {
    to: document.getElementById("address").value,
    value: parseInt(document.getElementById("amount").value), 
    data: "0x",
    message: document.getElementById("message").value
  };

  alert("Config saved,Please click BUY to continue");
  
document.getElementById("supportDiv").style.display="inline-block"
}

function signTx() {
  var cups = 1;
  const cupsRadio = document.getElementsByName("cups");
  
  for (var i = 0; i < cupsRadio.length; i++) {
    if (cupsRadio[i].checked) {
      cups = cupsRadio[i].value;
    }
  }
  vendor
    .sign("tx", [
      {
        to: configDetails.to,
        value: configDetails.value * 1e18 * cups,
        data: configDetails.data,
        // Click cluase to view comment
        comment: "support " + configDetails.value*cups +" VET"
      }
    ])
    .comment(configDetails.message)
    // .accepted(() => alert("accepted"))
    .request()
    .then((r) => document.getElementById("result").innerText=JSON.stringify(r,null,4))
    .catch((e) => console.log("error:" + e.message));
}

              
            
!
999px

Console