-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.js
158 lines (142 loc) · 4.36 KB
/
project.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// ur api key created on google cloud: https://console.cloud.google.com/apis/credentials
const API_KEY = 'AIzaSyB2FlJwoNn1JKC8hTUkrUY2jGSGYHfNaVY'
// id of ur google spreadsheet: https://docs.google.com/spreadsheets/d/{GET THIS CODE HERE}
const sheets_id = '1vLUSNopvutHwCUDWbN1KaykyqGIFeAqDhlDGOPZDyqQ'
// name of ur worksheet
// quickstart; default content - https://developers.google.com/sheets/api/quickstart/js
const DISCOVERY_DOCS = ['https://sheets.googleapis.com/$discovery/rest?version=v4']
// element where you can to add dynamic content
// project
let project = {
spreadsheetId : sheets_id, // get ur sheets id added above
range : 'project' // get the name of ur worksheet added above
}
// quickstart - https://developers.google.com/sheets/api/quickstart/js
function gapiLoaded() {
gapi.load( 'client', intializeGapiClient ) // default content
}
// quickstart - https://developers.google.com/sheets/api/quickstart/js
async function intializeGapiClient() {
await gapi.client.init( {
apiKey: API_KEY, // get ur api key added above
discoveryDocs: DISCOVERY_DOCS, // default content
} );
// post blog
gapi.client.sheets.spreadsheets.values.get( project ) // get the variable created above
.then( response => mostrar_project( response.result.values )) // get the values of the worksheet
}
const post = document.querySelector('.post-feed')
function mostrar_project(project_lista){
project_lista.shift()
console.log(project_lista)
let post_content = ""
for ( let item of project_lista ) { // get each row
const title = item[0]
const subtitle = item[1]
const description = item[2]
const skills_1 = item[3]
const skills_2 = item[4]
const skills_3 = item[5]
const skills_4 = item[6]
const skills_5 = item[7]
const skills_6 = item[8]
const skills_7 = item[9]
const project_link = item[10]
const github_link = item[11]
const twitter_link = item[12]
const youtube_link = item[13]
const img_file = item[14]
post_content +=
`
<section class="bio-info-1 post-box flex row">
<div class="post flex row">
<div class="left-post">
<a href="${project_link}" target="_blank">
<h2>${title}</h2>
<h3>${subtitle}</h3>
<h4>${description}</h4>
</a>
<ul class="project-skills flex row">
`
if (skills_1 != '-'){
post_content +=
`
<li>${skills_1}</li>
`
}
if (skills_2 != '-'){
post_content +=
`
<li>${skills_2}</li>
`
}
if (skills_3 != '-'){
post_content +=
`
<li>${skills_3}</li>
`
}
if (skills_4 != '-'){
post_content +=
`
<li>${skills_4}</li>
`
}
if (skills_5 != '-'){
post_content +=
`
<li>${skills_5}</li>
`
}
if (skills_6 != '-'){
post_content +=
`
<li>${skills_6}</li>
`
}
if (skills_7 != '-'){
post_content +=
`
<li>${skills_7}</li>
`
}
post_content +=
`
</ul>
`
if (github_link != '-'){
post_content +=
`
<a href="${github_link}" target="_blank">
<i class="fab fa-github" alt="icon for GitHub" aria-hidden="true"></i>
</a>
`
}
if (twitter_link != '-'){
post_content +=
`
<a href="${twitter_link}" target="_blank">
<i class="fab fa-twitter" alt="icon for Twitter" aria-hidden="true"></i>
</a>
`
}
if (youtube_link != '-'){
post_content +=
`
<a href="${youtube_link}" target="_blank">
<i class="fab fa-youtube" alt="icon for YouTube" aria-hidden="true"></i>
</a>
`
}
post_content +=
`
</div>
<div class="right-post">
<img src="img/project/${img_file}" alt="">
</div>
</div>
</section>
`
}
post.innerHTML = post_content // add this html to section .feed-post
}