Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <h1>Wealth</h1>
<hr/>
<label for="amount_home">Cash at Home</label>
<input id="amount_home" step="any" type="number" onchange="calculate()"/>


<label for="amount_bank">Bank Account Balance</label>
<input id="amount_bank" step="any" type="number" onchange="calculate()"/>

<label for="amount_shares">Cash value of Stocks and Equities</label>
<input id="amount_shares" step="any" type="number" onchange="calculate()"/>

<label for="amount_merchandise">Profits &amp; Inventory</label>
<input id="amount_merchandise" step="any" type="number" onchange="calculate()"/>


<label for="amount_gold">Gold &amp; Silver</label>
<input id="amount_gold" step="any" type="number" onchange="calculate()"/>


<label for="">Investment Property</label>
<input id="amount_property" step="any" type="number" onchange="calculate()">

<label for="">Any Other Income</label>
<input id="amount_other" step="any" type="number" onchange="calculate()">


<h1>Deductions</h1>
<hr/>

<label for="">Debts</label>
<input id="amount_debts" step="any" type="number" onchange="calculate()">

<label for="">Expenses</label>
<input id="amount_expenses" step="any" type="number" onchange="calculate()">


<h1>Totals</h1>
<hr/>

<label for="">Amount Eligible For Zakat</label>
<input id="amount_eligable" type="text" readonly="readonly" onchange="calculate()">

<label for="">Your Zakat Total (2.5% of Eligible Amount)</strong></label>
<input id="amount_zakat" type="text" readonly="readonly">

<button id="donate_button" type="button" aria-label="Donate" data-amount="50" data-formId="2426" style="padding: 12px 35px; font-size: 18px; border-radius: 3px; margin: 10px auto; background-color: #f3a800; color: #f8f17f; border: none; outline: none; cursor: pointer; display: block">Donate Now</button>               

              
            
!

CSS

              
                label {
  font-weight: 100;
  font-size: 12px;
}

input, label {
  display: block;
  padding: 4px;
}

input {
  margin-bottom: 10px;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
}
              
            
!

JS

              
                //helper function for getting 
function getValue(id) {
  var value = document.getElementById(id).value;
  if (value == "" || isNaN(value)) {
    return 0;
  } else {
    return parseFloat(value);
  }
}

function calculate() {

  // The price of about 3oz of gold
  var amt_nisab = 5301; 
  var amt_home = getValue("amount_home");
  var amt_bank = getValue("amount_bank");
  var amt_shares = getValue("amount_shares");
  var amt_merchandise = getValue("amount_merchandise");
  var amt_gold = getValue("amount_gold");
  var amt_property = getValue("amount_property");
  var amt_other = getValue("amount_other");
  var amt_debts = getValue("amount_debts");
  var amt_expenses = getValue("amount_expenses");
  
  // The sum of all of your different assets that you've had for the last
  // lunar year
  var amt_assets_gross = amt_home + amt_bank + amt_shares + amt_merchandise + amt_gold + amt_property + amt_other;
  
  // Gross assets minus the liabilities you have. Again these are typically
  // immediate liabilities. Not the totality of a large loan like a mortgage
  var amt_assets_net = amt_assets_gross - amt_debts - amt_expenses; 
  var amt_eligable = 0; 

  // If this net amount is bigger than the nisab, then it's eligible
  // to have Zakat assessed against it
  if (amt_assets_net > amt_nisab ); {
    amt_eligable = Math.ceil(amt_assets_net);
  }

  // Zakat is 2.5% of ones eligible wealth if it above 
  // Nisab
  var amt_zakat = Math.ceil(amt_eligable * .025);

  var formatter = new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'USD',
  });

  // Write the values back for the user
  document.getElementById("amount_eligable").value = formatter.format(amt_eligable);
  document.getElementById("amount_zakat").value = formatter.format(amt_zakat);

  // If the user is eligible to contribute Zakat, set up a Funraise donation
  // button with their Zakat amount. Else, just ask them for a $50 one time donation
  if(amt_zakat > 0) {
    document.getElementById("donate_button").innerText = formatter.format(amt_zakat) + ' Zakat';
    document.getElementById("donate_button").dataset.amount = amt_zakat;
  } else {
    document.getElementById("donate_button").text = 'Donate Now';
    document.getElementById("donate_button").dataset.amount = 50;
  }

}

// All of your typical Funraise giving form setup stuff below
(function(f,u,n,r,a,i,s,e){var data={window:window,document:document,tag:"script",data:"funraise",orgId:f,uri:u,common:n,client:r,script:a};var scripts;var funraiseScript;data.window[data.data]=data.window[data.data]||[];if(data.window[data.data].scriptIsLoading||data.window[data.data].scriptIsLoaded)return;data.window[data.data].loading=true;data.window[data.data].push("init",data);scripts=data.document.getElementsByTagName(data.tag)[0];funraiseScript=data.document.createElement(data.tag);funraiseScript.async=true;funraiseScript.src=data.uri+data.common+data.script+"?orgId="+data.orgId;scripts.parentNode.insertBefore(funraiseScript,scripts)})('1e78fec4-8fd0-4a3e-b82b-866c29012531','https://assets-dev.funraise.io','/widget/common/2.0','/widget/client','/inject-form.js');

window.funraise.push('create', { form: 2426 });
              
            
!
999px

Console