Dashboard: added custom case image selection

This commit is contained in:
bergware
2019-05-16 15:43:23 +02:00
parent a7ba07078a
commit b8b5269fbb
+19 -2
View File
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2012-2018, Bergware International.
/* Copyright 2005-2019, Lime Technology
* Copyright 2012-2019, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -27,20 +27,34 @@ if ($_POST['mode']=='get') {
if ($exist) echo file_get_contents("$boot/$file");
exit;
}
if ($_POST['mode']=='file') {
$name = 'case-model.png';
file_put_contents("$boot/$file",$name);
file_put_contents("$boot/$name",base64_decode(str_replace('data:image/png;base64,','',$_POST['data'])));
symlink("$boot/$name","/usr/local/emhttp/webGui/images/$name");
exit;
}
$casemodel = $exist ? file_get_contents("$boot/$file") : '';
?>
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-fonts.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-popup.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/default-cases.css")?>">
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/font-awesome.css")?>">
<style>
div.case-list{float:left;padding:10px;margin-right:10px;margin-bottom:44px;height:72px;width:72px;text-align:center}
div.case-list i{width:auto;max-width:72px;height:72px;font-size:72px;}
div.case-list i.fa{padding-top:16px;margin-bottom:-16px;max-width:48px;font-size:48px;}
div.case-list:hover{color:#f0000c;transform:scale(1.4,1.4);-webkit-transform:scale(1.4,1.4)}
div.case-list:hover .case-name{margin-top:-5px;font-size:1rem}
div.case-name{margin-top:8px;font-family:clear-sans}
</style>
<script src="<?autov('/webGui/javascript/dynamix.js')?>"></script>
<script>
function importFile(file) {
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function(e){$.post('/webGui/include/SelectCase.php',{mode:'file',file:'<?=$file?>',data:e.target.result,csrf_token:'<?=$_GET['csrf']?>'},function(){top.Shadowbox.close();})};
}
function setCase(model) {
$.post('/webGui/include/SelectCase.php',{mode:'set',file:'<?=$file?>',model:model,csrf_token:'<?=$_GET['csrf']?>'},function(){top.Shadowbox.close();});
}
@@ -56,5 +70,8 @@ foreach ($models as $model) {
$select = $name==$casemodel ? 'color:#e68a00' : '';
echo "<a style='text-decoration:none;cursor:pointer;$select' onclick='setCase(\"$name\")'><div class='case-list' id='$name'><i class='$model'></i><div class='case-name'>$name</div></div></a>";
}
$select = substr($casemodel,-4)=='.png' ? 'color:#e68a00' : '';
echo "<a style='text-decoration:none;cursor:pointer;$select' onclick='$(\"input#file\").trigger(\"click\")'><div class='case-list' id='Custom'><i class='fa fa-file-image-o'></i><div class='case-name'>custom image</div></div></a>";
?>
<input type='file' id='file' accept='.png' onchange='importFile(this.files[0])' style='display:none'>
</div>