Remove duplicated code

This commit is contained in:
Andrew Z
2019-09-21 21:09:12 -04:00
parent 9abe0b66c8
commit 64dc296cce
@@ -85,17 +85,17 @@ if (isset($_POST['contName'])) {
if (!is_dir($userTmplDir)) mkdir($userTmplDir, 0777, true);
if ($Name) {
$filename = sprintf('%s/my-%s.xml', $userTmplDir, $Name);
if ( is_file($filename) ) {
$oldXML = simplexml_load_file($filename);
if ($oldXML->Icon != $_POST['contIcon']) {
if (! strpos($Repository,":")) {
$Repository .= ":latest";
}
$iconPath = $DockerTemplates->getIcon($Repository);
@unlink("$docroot/$iconPath");
@unlink("{$dockerManPaths['images']}/".basename($iconPath));
}
}
if ( is_file($filename) ) {
$oldXML = simplexml_load_file($filename);
if ($oldXML->Icon != $_POST['contIcon']) {
if (! strpos($Repository,":")) {
$Repository .= ":latest";
}
$iconPath = $DockerTemplates->getIcon($Repository);
@unlink("$docroot/$iconPath");
@unlink("{$dockerManPaths['images']}/".basename($iconPath));
}
}
file_put_contents($filename, $postXML);
}
// Run dry
@@ -148,14 +148,7 @@ if (isset($_POST['contName'])) {
}
if ($startContainer) $cmd = str_replace('/docker create ', '/docker run -d ', $cmd);
execCommand($cmd);
if ( $newIcon ) {
if (! strpos($Repository,":")) {
$Repository .= ":latest";
}
$iconPath = $DockerTemplates->getIcon($Repository);
@unlink("$docroot/$iconPath");
@unlink("{$dockerManPaths['images']}/".basename($iconPath));
}
echo '<div style="text-align:center"><button type="button" onclick="done()">Done</button></div><br>';
goto END;
}
@@ -390,11 +383,11 @@ button[type=button]{margin:0 20px 0 0}
}
return newConfig.prop('outerHTML');
}
function escapeQuote(string) {
return string.replace(new RegExp('"','g'),"&quot;");
}
function makeAllocations(container,current) {
var html = [];
for (var i=0,ct; ct=container[i]; i++) {