Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- .jump.striked{text-decoration:line-through;}
- </style>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
- <form>
- Current X: <input name="curX" value="<?=@$_REQUEST["curX"]?>"><br/>
- Current Z: <input name="curZ" value="<?=@$_REQUEST["curZ"]?>"><br/>
- Dst X: <input name="dstX" value="<?=@$_REQUEST["dstX"]?>"><br/>
- Dst Z: <input name="dstZ" value="<?=@$_REQUEST["dstZ"]?>"><br/>
- <label><input type="checkbox" name="no_hyper" value="1"<?=@$_REQUEST["no_hyper"]?' checked="checked"':''?> /> no Hyperspace</label><br/>
- <input type="submit"/>
- </form>
- <?
- define("MAXWARP",1280);
- define("MAXLONGWARP",128000);
- define("LONGMULT",100);
- $noHyper = @$_REQUEST["no_hyper"]?true:false;
- if (isset($_REQUEST['curX'])){
- $cX = intval($_REQUEST['curX'])?intval($_REQUEST['curX']):0;
- $cZ = intval($_REQUEST['curZ'])?intval($_REQUEST['curZ']):0;
- $X = intval($_REQUEST['dstX'])?intval($_REQUEST['dstX']):0;
- $Z = intval($_REQUEST['dstZ'])?intval($_REQUEST['dstZ']):0;
- $trX="<b>W</b>est";
- if ($X>$cX){
- $trX="<b>E</b>ast";
- }
- $trZ="<b>N</b>orth";
- if ($Z>$cZ){
- $trZ="<b>S</b>outh";
- }
- $dX = abs($X-$cX);
- $dZ = abs($Z-$cZ);
- $jumps = array();
- echo "dX: ".$dX."<br/>";
- echo "dZ: ".$dZ."<br/>";
- while($dX>0){
- if ($dX>MAXWARP){
- if ($noHyper){
- $jumps[] = "Jump ".MAXWARP." to ".$trX;
- $dX-=MAXWARP;
- continue;
- }
- if ($dX>MAXLONGWARP){
- $jumps[] = "Hyperjump ".floor(MAXLONGWARP/LONGMULT)." to ".$trX." (".MAXLONGWARP.")";
- $dX-=MAXLONGWARP;
- continue;
- }
- $jumps[] = "Hyperjump ".floor($dX/LONGMULT)." to ".$trX." (".(floor($dX/LONGMULT)*LONGMULT).")";
- $dX-=floor($dX/LONGMULT)*LONGMULT;
- continue;
- }
- $jumps[] = "Jump ".$dX." to ".$trX;
- $dX-=$dX;
- }
- while($dZ>0){
- if ($dZ>MAXWARP){
- if ($noHyper){
- $jumps[] = "Jump ".MAXWARP." to ".$trZ;
- $dZ-=MAXWARP;
- continue;
- }
- if ($dZ>MAXLONGWARP){
- $jumps[] = "Hyperjump ".floor(MAXLONGWARP/LONGMULT)." to ".$trZ." (".MAXLONGWARP.")";
- $dZ-=MAXLONGWARP;
- continue;
- }
- $jumps[] = "Hyperjump ".floor($dZ/LONGMULT)." to ".$trZ." (".(floor($dZ/LONGMULT)*LONGMULT).")";
- $dZ-=floor($dZ/LONGMULT)*LONGMULT;
- continue;
- }
- $jumps[] = "Jump ".$dZ." to ".$trZ;
- $dZ-=$dZ;
- }
- ?><div style="font-size:22px;"><?
- foreach ($jumps as $jump){
- echo '<div class="strikeable"><label><input type="checkbox" class="strikeonchange" /><span class="jump">'.$jump."</span></label></div>";
- }
- ?></div><?
- }?>
- <script>
- $(function(){
- $('.strikeonchange').change(function(){
- if (this.checked){
- $(this).parent().find('.jump').addClass('striked');
- } else {
- $(this).parent().find('.jump').removeClass('striked');
- }
- });
- })
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement