add imgping to on-off shortcode
now if a image can be downloadet the service stateis on else off
This commit is contained in:
parent
1ace323411
commit
6c9a2fe2e0
@ -1,8 +1,26 @@
|
||||
{{ $mode := .Get 0 }}
|
||||
{{ $mode := .Get 0 }}{{ $opt := .Get 1 }}
|
||||
|
||||
{{ $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" )}}
|
||||
|
||||
{{ if eq $mode "on" }}
|
||||
<img src="{{ .Page.Site.BaseURL }}img/on-off/switch-on-icon_smal.png" alt="On">
|
||||
<img src="{{ $img_on }}" alt="On">
|
||||
{{ else if eq $mode "off"}}
|
||||
<img src="{{ .Page.Site.BaseURL }}img/on-off/switch-off-icon_smal.png" alt="Off">
|
||||
<img src="{{ $img_off }}" alt="Off">
|
||||
{{ else if eq $mode "imgping" }}
|
||||
{{ with $opt }}
|
||||
{{ $id := md5 $opt }}
|
||||
<img id={{ $id }} src="{{ $img_off }}" alt="Off">
|
||||
<script language="JavaScript">
|
||||
var imgping = new Image();
|
||||
imgping.src = '{{ $opt }}';
|
||||
if(imgping.height>0){
|
||||
document.getElementById("{{ $id }}").outerHTML ='<img src="{{ $img_on }}" alt="On">';
|
||||
}
|
||||
</script>
|
||||
{{ else }}
|
||||
Ned URL to image
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
???
|
||||
{{end}}
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user