Fun Calculators – Calculators-Free.com https://calculators-free.com Free Calculators & Free Source Code Sun, 21 Aug 2022 07:20:21 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.21 https://calculators-free.com/wp-content/uploads/2019/11/cropped-fav-32x32.png Fun Calculators – Calculators-Free.com https://calculators-free.com 32 32 Your Weight in SPAM® Calculator https://calculators-free.com/weight-worth-in-spam https://calculators-free.com/weight-worth-in-spam#respond Mon, 11 Nov 2019 08:08:33 +0000 https://calculators-free.com/?p=83 Introduction | Demonstration Calculator | Source Code

How This Calculator Works

Find out how much you’d be worth if you were worth your weight in SPAM®, with this fun calculator.

Just enter your body weight, actual price of SPAM, and press the “calculate” button to find out how much your weight is worth in SPAM. By default, the price of SPAM is $0.00684 per gram ($13.99 for six 12-ounce cans).

Introduction | Demonstration Calculator | Source Code

Demonstration Calculator

Your Weight:

Price of SPAM (in dollars):
per

Introduction | Demonstration Calculator | Source Code

Your Weight in SPAM® Calculator Source Code

This calculator is licensed to you under Creative Commons Attribution 3.0. If you would like to use the source code on your site or create a derivative work from it, you must include the following HTML on the page where the calculator appears. We’re giving you this code for free with a legal license to use it. All you have to do is credit us in the manner we specify.

Required Credit HTML

INSTALLATION

Just cut and paste the Javascript code and HTML form below into your page. If you want to customize the appearance of the form, feel free. Just make sure the input name and form id/name values are not changed.



<script type="text/javascript">
function calcWeightSPAM(){

// GET VALUES FROM FORM, SET VALUE TO ONE IF THE VALUE IN THE FORM IS NOT A NUMBER

var weight = (isNaN(document.wcbubba.weight.value)) ? 1 : document.wcbubba.weight.value;
var price = (isNaN(document.wcbubba.price.value)) ? 1 : document.wcbubba.price.value;
var wis = document.wcbubba.wis.value;
var wospam = document.wcbubba.wospam.value;

if(wis == "pound"){weight = weight / 2.205;}

if(wospam == "ounce"){price = price * 28.3495;}

// DO CALCULATION

var result = parseInt((weight * 1000 * price) * 100) / 100;

var expout = 'Your weight in SPAM® is worth: $' + result;

document.getElementById('totals').innerHTML = expout;

}
</script>

<form name="wcbubba" action="javascript:void();">

Your Weight:<br>
<input name="weight" size="5" type="text" />

<select name="wis" size="1">
<option value="kilogram" selected="selected">kg</option>
<option value="pound">pounds</option>
</select><br><br>

Price of SPAM (in dollars):<br>
<input name="price" size="5" type="text" value="0.00684" /> per 

<select name="wospam" size="1">
<option value="gram" selected="selected">gram</option>
<option value="ounce">ounce</option>
</select>

<input type="submit" value="calculate" onclick="calcWeightSPAM()"></form><br>

<div id="totals" style="padding-top:1em;padding-bottom:2em"></div>

]]>
https://calculators-free.com/weight-worth-in-spam/feed/ 0
Fun Google Compatibility Calculator https://calculators-free.com/fungoogle-compatibility-calculator-8 https://calculators-free.com/fungoogle-compatibility-calculator-8#respond Wed, 26 Dec 2018 04:19:34 +0000 https://calculators-free.com/?p=6 Introduction | Demonstration Calculator | Source Code

How The Google Compatibility Calculator Works

Enter your name and the name of the person you want to be matched with into the appropriate boxes in the calculator, then click “Calculate Our Compatibility”. A client-side JavaScript uses AJAX to query Google for the number of search results that come up for each name at Google. It then uses those numbers to determine a compatibility score.

Please note the calculator doesn’t work properly, since Google changed the API.

 

Introduction | Demonstration Calculator | Source Code

Demonstration Calculator

GOOGLE COMPATIBILITY CALCULATOR

 

Your Name:
Crush’s Name:

Introduction | Demonstration Calculator | Source Code

Fun Google Compatibility Calculator Source Code

 
This calculator is licensed to you under Creative Commons Attribution 3.0. If you would like to use the source code on your site or create a derivative work from it, you must include the following HTML on the page where the calculator appears. We’re giving you this code for free with a legal license to use it. All you have to do is credit us in the manner we specify.

Required Credit HTML

INSTALLATION

Download popucalc.zip. In it you will find the three graphics, PHP script for querying Google via their RESTful search API, an HTML file with the AJAX JavaScript and the search form, plus a README file with further instructions on getting it running.

Here are the two source files if you’d like to examine them.

JavaScript & HTML source code


<script type="text/javascript">

var firstval = "";
var secondval = "";
var firstdone = false;
var seconddone = false;
var offset=3;

function popucalc(){

document.getElementById('calcresults').innerHTML = '<b>Calculating</b><br /><img src="/images/pleasewait.gif">';

var firstname = escape(document.popcalc.firstname.value);
var getURL = 'popucalc.php?SP=' + firstname;
parseName(getURL,'first name');

var secondname = escape(document.popcalc.secondname.value);
getURL = 'popucalc.php?SP=' + secondname;
parseName(getURL,'second name');

}

function parseName(getURL,nameID)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }

//this is the part that processes the incoming data
    xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
        var myresults = xmlHttp.responseText; 
        parseResults(myresults,nameID);
      }
    }

//This is the part that sends it
  xmlHttp.open("get",getURL,true);
  xmlHttp.send(null);
  
  
  }
function parseResults(result,nameID){
  
    if(nameID == 'first name') {
       firstval = (isNaN(parseInt(result))) ? 0 : parseInt(result);
        firstdone = true;
       
          } else if (nameID == "second name"){
          secondval = (isNaN(parseInt(result))) ? 0 : parseInt(result);
          seconddone = true;
          }
 
     if((firstdone)&&(seconddone)) showresults(); 
 }
           
function showresults(){
     
     var topper;
     var bottomer;
     firstdone=false;
     seconddone=false;
     
     if(firstval > secondval){
          bottomer = firstval;
          topper = secondval;
          } else {
          topper = firstval;
          bottomer = secondval;
          }

     var popindex;
          
          if((topper == 0)||(bottomer==0)){
               popindex = 0;
               } else {
 
          var popindex = (topper/bottomer);
          popindex = Math.round(popindex*1000)/1000
               }
               
      var popcover = Math.round(200 - ((popindex * 190) + 10));
      var popamt = Math.round(popindex * 1000)/10;
      
     var resultspot = document.getElementById('calcresults');
     
     var resout = '<b>Matched: ' + popamt + '% </b><br>' + document.popcalc.firstname.value + ' and ' + document.popcalc.secondname.value + '<br>';
     
     resout += '<div style="width:210px;height:45px;padding:5px;border:1pt solid #222;font-size:12px;"><div style="width:100px;float:left;text-align:left">Cool</div><div style="width:100px;float:left;text-align:right">Scorching</div><br style="clear:all">';

     var quoter = "'/images/pcgradient.gif'";

     resout += '<div style="width:200px;height:20px;margin:0px;padding:0px; background:url('+quoter+');text-align:right;"><img src="/images/pcwhite.gif" height=20 width=' + popcover + ' style="margin:0px;padding:opx;border:none;" /></div></div><br /><br />';
     
     resultspot.innerHTML = resout;

   }
  
  
</script>

<div style="border:2px solid #222;margin:5px;padding:5px;width:350px;"><h3>GOOGLE COMPATIBILITY CALCULATOR</H3>
<form name="popcalc" action="javascript:void();">
Your Name: <input size=20 name="firstname" id="firstname" type=text> <br>
Crush's Name: <input size=20 name="secondname" id="secondname" type=text><br>
<input type="submit" value="Calculate Our Compatibility" onClick="popucalc()";>
</form>
<div id="calcresults" style="height:120px;"></div><br />
</div>

 

PHP source code


<?php

$searchphrase = $_REQUEST["SP"];

$searchphrase = str_replace(""","",$searchphrase);
$searchphrase = str_replace("%22","",$searchphrase);

$searchphrase=urlencode($searchphrase);

$booboo = passnum($searchphrase);

echo $booboo;

function passnum($searchphrase){

$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=%22" . $searchphrase . "%22";

// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.mysite.com/index.html");
$body = curl_exec($ch);
curl_close($ch);

// now, process the JSON string
$json = json_decode($body, true);
// now have some fun with the results...

$sam = $json["responseData"]["cursor"]["estimatedResultCount"];

return $sam;
}

?>
]]>
https://calculators-free.com/fungoogle-compatibility-calculator-8/feed/ 0