Skip to content

Instantly share code, notes, and snippets.

@marshall
Created December 7, 2009 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshall/250660 to your computer and use it in GitHub Desktop.
Save marshall/250660 to your computer and use it in GitHub Desktop.
<html>
<head>
<style>
#square {
background-color: black;
color: white;
font-size: 30pt;
padding: 10px;
width: 350px;
}
#num {
font-size: 30pt;
background-color: black;
color: white;
padding: 10px;
width: 100px;
}
</style>
</head>
<body>
<div id="square">0</div>
<input id="num" type="text"/>
<button id="button" onclick="showSquares()">Show squares</button>
<script>
function showSquares() {
// this would be for Windows
//var php = Titanium.App.appURLToPath("ti://php/php.exe");
// this would be for OSX / Linux
var php = "/usr/bin/php";
var script = Titanium.App.appURLToPath("app://square.php");
var num = document.getElementById("num").value;
var process = Titanium.Process.createProcess([php, script, num]);
process.setOnRead(function(event) {
document.getElementById("square").innerHTML = event.data.toString();
});
process.setOnExit(function() {
document.getElementById("button").disabled = null;
});
process.launch();
document.getElementById("button").disabled = "disabled";
}
</script>
</body>
</html>
<?php
$orig = $argv[1];
$n = $orig;
for ($i = 0; $i < 30; $i++) {
$n *= $orig;
echo "$orig^".($i+2)." = ".$n;
sleep(1);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment