modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-06-26 18:14:20 +04:00
parent 70e9c4d268
commit f3af19406b
2 changed files with 42 additions and 21 deletions

View File

@ -15,22 +15,40 @@ class showmorePlugin extends BasePlugin {
/** @var string classe du panneau caché par défaut */
const INVITE_CONTENT = "En savoir plus...";
const PANEL_CLASS = "showmore-panel";
function __construct(?array $params=null) {
$this->containerClass = $params["container_class"] ?? static::CONTAINER_CLASS;
$this->inviteClass = $params["invite_class"] ?? self::INVITE_CLASS;
$this->inviteContent = $params["invite_content"] ?? self::INVITE_CONTENT;
$this->panelClass = $params["panel_class"] ?? self::PANEL_CLASS;
$this->onShow = $params["on_show"] ?? null;
}
protected string $containerClass;
protected string $inviteClass, $inviteContent;
protected string $panelClass;
protected ?string $onShow;
function startc(): array {
return v::sdiv(["class" => self::CONTAINER_CLASS]);
return v::sdiv(["class" => $this->containerClass]);
}
function invite($vs=null): array {
if ($vs === null) $vs = self::INVITE_CONTENT;
$vs ??= $this->inviteContent;
return v::a([
"class" => self::INVITE_CLASS,
"class" => $this->inviteClass,
"href" => "#",
$vs,
]);
}
function startp(): array {
return v::sdiv(["class" => [self::PANEL_CLASS, "hidden"]]);
return v::sdiv([
"class" => [$this->panelClass, "hidden"],
]);
}
function endp(): array {
@ -76,7 +94,10 @@ jQuery.noConflict()(function($) {
$(".<?=self::INVITE_CLASS?>").click(function() {
let $this = $(this);
$this.addClass("hidden");
$this.closest(".<?=self::CONTAINER_CLASS?>").find(".<?=self::PANEL_CLASS?>").removeClass("hidden");
let $container = $this.closest(".<?=self::CONTAINER_CLASS?>");
let $panel = $container.find(".<?=self::PANEL_CLASS?>");
$panel.removeClass("hidden");
<?=$this->onShow?>
return false;
});
});

View File

@ -107,8 +107,8 @@ class RunFile {
}
}
function haveWorked(int $serial, ?int &$currentSerial=null): bool {
$data = $this->read();
function haveWorked(int $serial, ?int &$currentSerial=null, ?array $data=null): bool {
$data ??= $this->read();
$currentSerial = $data["serial"];
return $serial !== $currentSerial;
}
@ -122,7 +122,7 @@ class RunFile {
}
function warnIfLocked(?array $data=null): bool {
if ($data === null) $data = $this->read();
$data ??= $this->read();
if ($data["locked"]) {
msg::warning("$data[name]: possède le verrou depuis $data[date_lock]");
return true;
@ -172,22 +172,22 @@ class RunFile {
}
/** tester si l'application a déjà été démarrée au moins une fois */
function wasStarted(): bool {
$data = $this->read();
function wasStarted(?array $data=null): bool {
$data ??= $this->read();
return $data["date_start"] !== null;
}
/** tester si l'application est démarrée et non arrêtée */
function isStarted(?array &$data=null): bool {
$data = $this->read();
function isStarted(?array $data=null): bool {
$data ??= $this->read();
return $data["date_start"] !== null && $data["date_stop"] === null;
}
/**
* vérifier si l'application marquée comme démarrée tourne réellement
*/
function isRunning(?array &$data=null): bool {
$data = $this->read();
function isRunning(?array $data=null): bool {
$data ??= $this->read();
if ($data["date_start"] === null) return false;
if ($data["date_stop"] !== null) return false;
if (!posix_kill($data["pid"], 0)) {
@ -216,14 +216,14 @@ class RunFile {
}
/** tester si l'application est déjà été stoppée au moins une fois */
function wasStopped(): bool {
$data = $this->read();
function wasStopped(?array $data=null): bool {
$data ??= $this->read();
return $data["date_stop"] !== null;
}
/** tester si l'application a été démarrée puis arrêtée */
function isStopped(?array &$data=null): bool {
$data = $this->read();
function isStopped(?array $data=null): bool {
$data ??= $this->read();
return $data["date_start"] !== null && $data["date_stop"] !== null;
}
@ -250,8 +250,8 @@ class RunFile {
return false;
}
$done = true;
if (!$updateDone) return null;
return ["is_done" => $done];
if ($updateDone) return ["is_done" => $done];
else return null;
});
return $done;
}