Last active
November 9, 2018 15:51
-
-
Save turnbuga/7f2f3d5934191260726f534fb85f7eb3 to your computer and use it in GitHub Desktop.
Colorado Flag Status Embed - See Example in the footer of larimer.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- Built by Jim Vogl / larimer.org --> | |
<style type="text/css"> | |
.flag-status { color: #fff; } | |
.flag-status .flag-icon { | |
vertical-align: middle; | |
margin-right: 10px; | |
width: 30px; | |
height: auto; | |
} | |
.flag-icon2 { margin-left: 10px; } | |
</style> | |
</head> | |
<body> | |
<?php | |
$flagPath = 'https://www.colorado.gov/governor/api/flag-status-api.json'; | |
$flagPath = 'https://apps.larimer.org/api/flagstatus/flag-status-api.json'; | |
//$flagPath = '/data/flagstatus/flag-status-api.json'; | |
//$data=file_get_contents($_SERVER["DOCUMENT_ROOT"].$flagPath); | |
$ch=curl_init(); | |
$timeout=5; | |
curl_setopt($ch, CURLOPT_URL, $flagPath); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json')); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
if(!empty($data)) { | |
$flagJson = json_decode($data); | |
$us = $flagJson[0]-> field_flag_status; | |
if($us=="H") { $us="Half"; } else { $us="Full"; } | |
$usTitle = $flagJson[0]-> title; | |
// $usBody = $flagJson[0]-> body; | |
$usBody = ""; | |
$usLink = $flagJson[0]->path; | |
if($usLink) { $usLink="<a href='$usLink' target='_blank' class='btn btn-xs btn-white' style='margin-bottom: 5px'><i class='fa fa-info-circle'></i> More info</a> "; } | |
$co = $flagJson[1]-> field_flag_status; | |
if($co=="H") { $co="Half"; } else { $co="Full"; } | |
$coTitle = $flagJson[1]-> title; | |
// $coBody = $flagJson[1]-> body; | |
$coBody = ""; | |
$coLink = $flagJson[1]->path; | |
if($coLink) { $coLink=" <a href='$coLink' target='_blank' style='margin-bottom: 5px' class='btn btn-xs btn-white'><i class='fa fa-info-circle'></i> More Info</a>"; } | |
$subscribe = " <a class='no-icon btn btn-xs btn-white' target='_blank' href='https://www.colorado.gov/governor/flag-status'><i class='fa fa-info-circle'></i> Subscribe to updates</a>"; | |
echo '<div class="flag-status">'; | |
echo '<img class="flag-icon" alt="US Flag" src="https://www.colorado.gov/governor/sites/default/files/styles/medium/public/us-flag-l.png"'; | |
echo ' data-toggle="popover" data-placement="top" data-html="true" title="US Flags at '.$us.' Staff" data-content="'.$usBody.$usLink.$subscribe.'"'; | |
echo '>'; | |
echo '<span class="flag-status-txt">'.$us.'</span>'; | |
echo '<img class="flag-icon flag-icon2" alt="Colorado Flag" src="https://www.colorado.gov/governor/sites/default/files/styles/medium/public/co-flag-l.png"'; | |
echo ' data-toggle="popover" data-placement="top" data-html="true" title="CO Flags at '.$co.' Staff" data-content="'.$coBody.$coLink.$subscribe.'"'; | |
echo '>'; | |
echo '<span class="flag-status-txt">'.$us.'</span>'; | |
echo '</div>'; | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment