Skip to content

Commit

Permalink
all data in and basic styling
Browse files Browse the repository at this point in the history
  • Loading branch information
VinnyTheLegend committed Nov 25, 2023
1 parent 9654ec2 commit ab8c0d8
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
23 changes: 23 additions & 0 deletions sql-fetch/characters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sqlFetch
import (
"encoding/json"
"fmt"
"time"
)

type Character struct {
Expand All @@ -13,6 +14,7 @@ type Character struct {
Gang Gang
Vehicles []Vehicle
MDTData MDTData
Age int
}

type CharInfo struct {
Expand Down Expand Up @@ -56,7 +58,23 @@ type Gang struct {
IsBoss bool `json:"isboss"`
}

func CalculateAge(birthdayString string) (int, error) {
birthday, err := time.Parse("01/02/2006", birthdayString)
if err != nil {
return 0, err
}

currentDate := time.Now()
// Calculate the difference in years
age := currentDate.Year() - birthday.Year()

// Check if the birthday for this year has occurred or not
if currentDate.YearDay() < birthday.YearDay() {
age--
}

return age, nil
}

func allCharacters() ([]Character, error) {

Expand Down Expand Up @@ -100,6 +118,11 @@ func allCharacters() ([]Character, error) {
character.Gang.Label = "None"
}

character.Age, err = CalculateAge(character.CharInfo.Birthday)
if err != nil {
fmt.Println("Error:", err)
}

characters = append(characters, character)
}
if err := rows.Err(); err != nil {
Expand Down
54 changes: 54 additions & 0 deletions static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ body {
padding: 0;
margin: 0;
}

/* width */
::-webkit-scrollbar {
width: 10px;
}


/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
}

/* outer */
#list-filter {
background-color: var(--secondary-bg-color);
Expand Down Expand Up @@ -197,4 +215,40 @@ body {

#cid>h3 {
margin: 0;
}

.profile-vehicle-list > ul {
list-style: none;
margin: 0;
padding: 0;
margin-top: 2.5px;
}

.profile-vehicle-list > ul > li {
border: var(--accent-color) 3px solid;
border-radius: 10px;
background-color: var(--secondary-bg-color);
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
}

.veh-name {
padding-left: 5px;
padding-right: 5px;
font-weight: bolder;
}

.veh-info {
text-align: right;
}

.veh-info>span {
border-radius: 10px;
background-color: var(--accent-color);
padding: 3px;
margin-left: 5px;
text-wrap: nowrap;
}
4 changes: 2 additions & 2 deletions templates/character.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ <h3>{{.CitizenID}}</h3>
<span>Phone Number:</span>
</div>
<div>
<span id="age">age</span><br>
<span id="gender">{{.CharInfo.Gender}}</span><br>
<span id="age">{{.Age}} y/o</span><br>
<span id="gender">{{if .CharInfo.Gender}}Female{{else}}Male{{end}}</span><br>
<div id="phone-number"><span>{{.CharInfo.PhoneNumber}}</span></div>
</div>
</div>
Expand Down

0 comments on commit ab8c0d8

Please sign in to comment.