2019-07-13 22:43:31 +00:00
|
|
|
{{ $mode := .Get 0 }}{{ $opt1 := .Get 1 }}{{ $opt2 := .Get 2 }}
|
2019-07-13 22:30:39 +00:00
|
|
|
|
|
|
|
{{ $img_on := ( printf "%s%s" $.Page.Site.BaseURL "img/on-off/switch-on-icon_smal.png" )}}
|
|
|
|
{{ $img_off := ( printf "%s%s" $.Page.Site.BaseURL "img/on-off/switch-off-icon_smal.png" )}}
|
|
|
|
|
2019-07-13 20:34:21 +00:00
|
|
|
{{ if eq $mode "on" }}
|
2019-07-13 22:30:39 +00:00
|
|
|
<img src="{{ $img_on }}" alt="On">
|
2019-07-13 20:34:21 +00:00
|
|
|
{{ else if eq $mode "off"}}
|
2019-07-13 22:30:39 +00:00
|
|
|
<img src="{{ $img_off }}" alt="Off">
|
|
|
|
{{ else if eq $mode "imgping" }}
|
2019-07-13 22:43:31 +00:00
|
|
|
{{ with $opt1 }}
|
|
|
|
{{ $id := md5 $opt1 }}
|
|
|
|
{{ if eq $opt2 "on" }}
|
|
|
|
<img id={{ $id }} src="{{ $img_on }}" alt="On">
|
|
|
|
{{ else }}
|
|
|
|
<img id={{ $id }} src="{{ $img_off }}" alt="Off">
|
|
|
|
{{ end }}
|
2019-07-13 22:30:39 +00:00
|
|
|
<script language="JavaScript">
|
2019-07-14 01:06:02 +00:00
|
|
|
function exec(){
|
2019-07-14 01:00:19 +00:00
|
|
|
var imgping = new Image();
|
2019-07-14 01:06:02 +00:00
|
|
|
imgping.src = {{ $opt1 }};
|
2019-07-14 01:00:19 +00:00
|
|
|
if(imgping.height>0){
|
2019-07-14 01:06:02 +00:00
|
|
|
document.getElementById({{ $id }}).outerHTML ='<img src="{{ $img_on }}" alt="On">';
|
2019-07-14 01:00:19 +00:00
|
|
|
} else {
|
2019-07-14 01:06:02 +00:00
|
|
|
document.getElementById({{ $id }}).outerHTML ='<img src="{{ $img_off }}" alt="Off">';
|
2019-07-14 01:00:19 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-14 01:06:02 +00:00
|
|
|
exec();
|
2019-07-13 22:30:39 +00:00
|
|
|
</script>
|
|
|
|
{{ else }}
|
2019-07-13 22:43:31 +00:00
|
|
|
imgping [URL to image] [default on/off]
|
2019-07-13 22:30:39 +00:00
|
|
|
{{ end }}
|
2019-07-13 20:34:21 +00:00
|
|
|
{{ else }}
|
|
|
|
???
|
2019-07-13 22:30:39 +00:00
|
|
|
{{ end }}
|