Skip to content

Commit

Permalink
version 0.4.0
Browse files Browse the repository at this point in the history
Added expanded descriptions when you click a parcel.
  • Loading branch information
fireshaper authored Aug 24, 2020
1 parent 9ffe0b2 commit 71185b0
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 31 deletions.
97 changes: 77 additions & 20 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
/*Get an API Token from my.trackinghive.com and put it here */
$bearerToken = '';

$version = "0.3";
$version = "0.4";

//echo "Setting alertMessage to ' '<br />";
$alertMessage = "";

$comment = "No title";

$now = new DateTime();
Expand All @@ -26,6 +29,10 @@

//----- Functions -----//



//-- PHP Stuff --//

function deleteParcel($_id, $bearerToken){
$ch = curl_init();

Expand All @@ -47,7 +54,9 @@ function deleteParcel($_id, $bearerToken){

$json = json_decode($response, true);
if ($json['meta']['code'] == 200) {
//echo '<font color="red">Package removed!</font><br /><br />';
$alertMessage = "Removed";
//echo $alertMessage;
}

return $alertMessage;
Expand Down Expand Up @@ -146,7 +155,9 @@ function addSubscription ($_id, $bearerToken) {
if ($json->meta->code == 200) {
$_id = $json->data->_id;

//echo '<font color="green">Package added!</font><br /><br />';
$alertMessage = "Added";
//echo $alertMessage;
//addSubscription($_id, $bearerToken);
} else if ($json->meta->code == 400) {
echo '<font color="red">Could not add package.</font><br /><br />';
Expand All @@ -161,6 +172,8 @@ function addSubscription ($_id, $bearerToken) {
<div class="main">

<?php
//echo $alertMessage;

if ($alertMessage == "Added") { ?>
<div class="alert" id="alert-added">
<font color="green">Package added!</font>
Expand Down Expand Up @@ -251,7 +264,7 @@ function addSubscription ($_id, $bearerToken) {
$json = json_decode($response, false);

//print_r($json);

try {
foreach ($json->data as $mydata) {
$custom_fields = explode(':', $mydata->custom_fields);
$comment = $custom_fields[1];
Expand All @@ -268,7 +281,7 @@ function addSubscription ($_id, $bearerToken) {
$expectedDelivery = "Expected Delivery Today";
}
else {
$expectedDelivery = "Expected Delivery is " . date("m/d/y", strtotime($expTS));
$expectedDelivery = "Expected Delivery is " . date("l, m/d/y", strtotime($expTS));
}

$scheduled = true;
Expand Down Expand Up @@ -335,23 +348,6 @@ function addSubscription ($_id, $bearerToken) {
$carrier = $carriers->title;
}
}

/*
switch ($carrier_slug){
case 'usps':
$carrier = 'USPS';
break;
case 'ups':
$carrier = 'UPS';
break;
case 'fedex':
$carrier = 'FedEx';
break;
case 'dhl':
$carrier = 'DHL';
break;
}
*/

$trackingNum = $mydata->tracking_number;

Expand Down Expand Up @@ -470,10 +466,39 @@ function addSubscription ($_id, $bearerToken) {
</form>
</div>
</div>
<div class="media-click-text">
Click to Expand
</div>
<div class="media-track">
<ul class="fa-ul">
<?php

$count = 0;
foreach (array_reverse($mydata->trackings->checkpoints) as $checkpoint) {
$cTS = $checkpoint->checkpoint_time;
$checkpointTime = date("m-d-Y H:i:s", strtotime($cTS));

if ($count == 0){
echo '<li><span class="fa-il"><i class="fa fa-circle"></i></span><b> ' . $checkpointTime . " " . $checkpoint->location . " " . $checkpoint->message . "</b></li>";
echo '<li>&nbsp;<span class="fa-il"><i class="fas fa-long-arrow-alt-up"></i></span>';
} else if ($count == count($mydata->trackings->checkpoints)-1){
echo '<li><span class="fa-il"><i class="far fa-circle"></i></span> ' . $checkpointTime . " " . $checkpoint->location . " " . $checkpoint->message . "</li>";
} else {
echo '<li><span class="fa-il"><i class="far fa-circle"></i></span> ' . $checkpointTime . " " . $checkpoint->location . " " . $checkpoint->message . "</li>";
echo '<li>&nbsp;<span class="fa-il"><i class="fas fa-long-arrow-alt-up"></i></span>';
}
$count++;
}
?>
</ul>
</div>
</div>
</div>
</div>
<?php }
}catch (Exception $e) {
echo "Error getting parcels:" . $e;
}
}catch (Exception $e){
echo "Error getting parcels:" . $e;
}
Expand All @@ -490,6 +515,38 @@ function addSubscription ($_id, $bearerToken) {
</div>
</div>
</div>

<script type="text/javascript">
$(".media").click(function() {

if ($(this).nextAll( ".media-track" ).css("display") == "block") {
$(this).nextAll( ".media-click-text" ).text('Click to Expand');
} else {
$(this).nextAll( ".media-click-text" ).text('Click to Close');
}

$(this).nextAll( ".media-track" ).slideToggle(100, function() {
return $(this).nextAll( ".media-track" ).is(":visible");
});

});

$(".media-click-text").click(function() {

var link = $(this);
if ($(this).next( ".media-track" ).css("display") == "block") {
link.text('Click to Expand');
} else {
link.text('Click to Close');
}

$(this).nextAll( ".media-track" ).slideToggle(100, function() {
return $(this).nextAll( ".media-track" ).is(":visible");
});

});
</script>

</body>
</html>

51 changes: 40 additions & 11 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ a {
width: 1075px;
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px;
box-sizing: border-box;
}

.content {
margin-left: -15px;
margin-left: -30px;
margin-right: -15px;
box-sizing: border-box;
}
Expand Down Expand Up @@ -82,13 +80,13 @@ a {
.package-container {
position: relative;
min-height: 100%;
margin-top: 10px;
padding: 20px;
margin-bottom: 10px;
background: #fff;
box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.2);
border-radius: 2px;
box-sizing: border-box;
overflow: auto;
}

.logo-view {
Expand All @@ -111,10 +109,8 @@ a {
.parcel-item {
padding-top: 10px;
padding-bottom: 15px;
min-height: 150px;
border-top: 1px solid #ddd;
min-height: 170px;
box-sizing: border-box;

}

.row {
Expand All @@ -126,19 +122,22 @@ a {
.media-box {
padding-left: 15px;
padding-right: 25px;
width: 100%;
width: 985px;
float: left;
position: relative;
border-top: 1px solid #ddd;
}

.media {
padding-top: 10px;
padding-left: 15px;
padding-right: 25px;
width: 83.33333333%;
float: left;
position: relative;
min-height: 1px;
box-sizing: border-box;
cursor: pointer;
}

.media-right {
Expand All @@ -156,9 +155,25 @@ a {
display: table-cell;
vertical-align: top;
box-sizing: border-box;
}

.media-click-text {
position: relative;
float: left;
max-width: 100%;
padding-left: 45%;
padding-bottom: 10px;
color: #9e9e9e;
cursor: pointer;
}

.media-track {
display: none;
float: left;
width: 100%;
}


.info {
display: block;
margin-top: 4px;
Expand Down Expand Up @@ -282,6 +297,8 @@ input[type=button], input[type=submit] {
.info-middle {
box-sizing: border-box;
padding-top: 3px;
display: flex;
flex-direction: column;
}

.loc {
Expand Down Expand Up @@ -351,6 +368,7 @@ input[type=button], input[type=submit] {
text-overflow: ellipsis;
white-space: nowrap;
box-sizing: border-box;
min-height: 20px;
}

.last-update {
Expand Down Expand Up @@ -436,7 +454,7 @@ a {

.content {
box-sizing: border-box;

margin: 0px;
}

.package-view {
Expand Down Expand Up @@ -508,13 +526,13 @@ a {

.parcels {
padding: 2px;
overflow: auto;
}

.parcel-item {
padding-top: 10px;
padding-bottom: 15px;
min-height: 150px;
border-top: 1px solid #ddd;
min-height: 160px;
box-sizing: border-box;

}
Expand All @@ -533,6 +551,7 @@ a {
position: relative;
display: flex;
flex-direction: column;
min-height: 150.5px;
}

.media {
Expand All @@ -545,6 +564,15 @@ a {
width: auto;
}

.media-click-text {
padding-left: 30%;
}

.media-track {
font-size: 12px;
width: 90%;
}

.media-right {
padding: 0 5px;
float: left;
Expand Down Expand Up @@ -754,6 +782,7 @@ a {
white-space: nowrap;
box-sizing: border-box;
padding-left: 10px;
min-height: 20px;
}

.last-update {
Expand Down

0 comments on commit 71185b0

Please sign in to comment.