bef93-runner blogpost
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
require_once (__DIR__ . '/../internals/base.php');
|
||||
|
||||
global $PARAM_CODE;
|
||||
global $PARAM_URL;
|
||||
global $PARAM_INTERACTIVE;
|
||||
global $PARAM_BEFUNGE93RUNNER;
|
||||
|
||||
$code = $PARAM_BEFUNGE93RUNNER['code'];
|
||||
$url = $PARAM_BEFUNGE93RUNNER['url'];
|
||||
$interactive = $PARAM_BEFUNGE93RUNNER['interactive'];
|
||||
$initspeed = $PARAM_BEFUNGE93RUNNER['speed'];
|
||||
$editable = $PARAM_BEFUNGE93RUNNER['editable'];
|
||||
|
||||
function fmtBef($str) {
|
||||
$str = htmlspecialchars($str);
|
||||
@@ -18,25 +22,31 @@ function fmtBef($str) {
|
||||
|
||||
$result = '';
|
||||
|
||||
if ($PARAM_INTERACTIVE) {
|
||||
$result .= '<div class="bce_code b93rnr_base">' . "\n";
|
||||
$result .= ' <div class="bce_code_data b93rnr_data" data-befcode="' . base64_encode($PARAM_CODE) . '">' . fmtBef($PARAM_CODE) . '</div>' . "\n";
|
||||
|
||||
if ($interactive) {
|
||||
$speed_attr = '';
|
||||
if (isset($initspeed) && $initspeed != NULL && $initspeed>0) $speed_attr = ' data-b93rnr_initialspeed="'.$initspeed.'" ';
|
||||
$code_attr = '';
|
||||
$code_attr = 'data-b93rnr_code="' . base64_encode($code) . '"';
|
||||
|
||||
$result .= '<div class="bce_code b93rnr_base" ' . $speed_attr . '>' . "\n";
|
||||
$result .= ' <div class="bce_code_data b93rnr_data" '.$code_attr.'>' . fmtBef($code) . '</div>' . "\n";
|
||||
$result .= ' <textarea class="bce_code_editarea b93rnr_editarea generic_collapsed"></textarea>' . "\n";
|
||||
$result .= ' <div class="bce_code_ctrl">' . "\n";
|
||||
$result .= ' <div class="ctrl_btn_left">' . "\n";
|
||||
$result .= ' <div class="ctrl_btn_group">' . "\n";
|
||||
$result .= ' <div class="ctrl_btn ctrl_btn_ll b93rnr_start">Start</div>' . "\n";
|
||||
$result .= ' <div class="ctrl_btn ctrl_btn_rr b93rnr_speed">3+</div>' . "\n";
|
||||
$result .= ' <div class="ctrl_btn ctrl_btn_rr b93rnr_speed">??</div>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
$result .= ' <div class="ctrl_btn b93rnr_pause ctrl_btn_disabled">Pause</div>' . "\n";
|
||||
$result .= ' <div class="ctrl_btn b93rnr_reset ctrl_btn_disabled">Reset</div>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
if ($PARAM_URL !== '') {
|
||||
$result .= ' <div class="ctrl_btn_right">' . "\n";
|
||||
$result .= ' <a class="ctrl_btn" href="' . $PARAM_URL . '" download target="_blank">Download</a>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
}
|
||||
$result .= ' <div class="ctrl_btn_right">' . "\n";
|
||||
if ($editable && $interactive) $result .= ' <div class="ctrl_btn b93rnr_edit">Edit</div>' . "\n";
|
||||
if ($url !== '') $result .= ' <a class="ctrl_btn" href="' . $url . '" download target="_blank">Download</a>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
$result .= ' <div class="bce_code_out b93rnr_outpanel b93rnr_outpanel_hidden">' . "\n";
|
||||
$result .= ' <div class="bce_code_out b93rnr_outpanel generic_collapsed">' . "\n";
|
||||
$result .= ' <div class="bce_code_out_left">' . "\n";
|
||||
$result .= ' <b>Output:</b>' . "\n";
|
||||
$result .= ' <div class="bce_code_out_text b93rnr_output"></div>' . "\n";
|
||||
@@ -53,13 +63,11 @@ if ($PARAM_INTERACTIVE) {
|
||||
else
|
||||
{
|
||||
$result .= '<div class="bce_code">' . "\n";
|
||||
$result .= ' <div class="bce_code_data">' . fmtBef($PARAM_CODE) . '</div>' . "\n";
|
||||
$result .= ' <div class="bce_code_data">' . fmtBef($code) . '</div>' . "\n";
|
||||
$result .= ' <div class="bce_code_ctrl">' . "\n";
|
||||
if ($PARAM_URL !== '') {
|
||||
$result .= ' <div class="ctrl_btn_right">' . "\n";
|
||||
$result .= ' <a class="ctrl_btn" href="' . $PARAM_URL . '" download target="_blank">Download</a>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
}
|
||||
$result .= ' <div class="ctrl_btn_right">' . "\n";
|
||||
if ($url !== '') $result .= ' <a class="ctrl_btn" href="' . $url . '" download target="_blank">Download</a>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
$result .= ' </div>' . "\n";
|
||||
$result .= '</div>' . "\n";
|
||||
}
|
||||
|
||||
@@ -47,12 +47,18 @@ $max = ceil($max / 20) * 20;
|
||||
|
||||
<b>Solution:</b>
|
||||
<?php
|
||||
global $PARAM_CODE;
|
||||
global $PARAM_URL;
|
||||
$PARAM_CODE = file_get_contents($problem['file_code']);
|
||||
$PARAM_URL = $problem['url_raw'];
|
||||
$PARAM_INTERACTIVE = !$problem['abbreviated'];
|
||||
global $PARAM_BEFUNGE93RUNNER;
|
||||
$PARAM_BEFUNGE93RUNNER =
|
||||
[
|
||||
'code' => file_get_contents($problem['file_code']),
|
||||
'url' => $problem['url_raw'],
|
||||
'interactive' => !$problem['abbreviated'],
|
||||
'speed' => null,
|
||||
'editable' => false,
|
||||
];
|
||||
echo require (__DIR__ . '/../fragments/befunge93_runner.php');
|
||||
|
||||
if ($problem['abbreviated']) echo '<i>This program is too big to display/execute here, click [download] to get the full program. </i><br/>';
|
||||
?>
|
||||
<br/>
|
||||
|
||||
@@ -67,7 +73,7 @@ $max = ceil($max / 20) * 20;
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Execution time</b> (<a href="/programs/view/BefunGen">BefunExec</a>):</td>
|
||||
<td><?php echo $problem['time'] . ' ms <i>(=' . number_format(($problem['steps']/$problem['time'])/1000, 2, '.', '') . ' MHz)</i>'; ?></td>
|
||||
<td><?php echo $problem['time'] . ' ms <i>(=' . (($problem['time']===0) ? '?' : number_format(($problem['steps']/$problem['time'])/1000, 2, '.', '')) . ' MHz)</i>'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Program size:</b></td>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="footerdiv" class="content-responsive">
|
||||
<hr />
|
||||
made with vanilla PHP and MySQL, no frameworks, no bootstrap, no bullshit
|
||||
made with vanilla PHP and MySQL, no frameworks, no bootstrap, no unnecessary javascript
|
||||
</div>
|
||||
Reference in New Issue
Block a user