-
Notifications
You must be signed in to change notification settings - Fork 80
/
index.js
62 lines (54 loc) · 1.89 KB
/
index.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
import $ from 'jquery'
import Swal from 'sweetalert2'
import { ProjectList } from './components/project_list'
require('../styles/index.scss')
$(() => {
initHomeProjects()
const $oauthGreeting = $('.js-oauth-greeting')
showOauthPopup(
$oauthGreeting.data('path-oauth-first-login'),
$oauthGreeting.data('trans-info'),
$oauthGreeting.data('trans-title'),
$oauthGreeting.data('trans-ok')
)
})
function initHomeProjects () {
const $homeProjects = $('#home-projects')
$('.project-list', $homeProjects).each(function () {
const category = $(this).data('category')
const property = $(this).data('property')
const theme = $(this).data('theme')
const flavor = $(this).data('flavor')
const baseUrl = $(this).data('base-url')
let url = baseUrl + '/api/projects?category=' + category
if (flavor !== 'pocketcode' || category === 'example') {
// Only the pocketcode flavor shows projects from all flavors!
// Other flavors must only show projects from their flavor.
url += '&flavor=' + flavor
}
const list = new ProjectList(this, category, url, property, theme)
$(this).data('list', list)
})
}
function showOauthPopup (firstOauthLoginUrl, informationText, title, okTranslation) {
$.get(firstOauthLoginUrl, function (data) {
if (data.first_login === true) {
const shown = localStorage.getItem('oauthSignIn')
if (shown == null) {
localStorage.setItem('oauthSignIn', '1')
Swal.fire({
title: title,
html: informationText,
showCancelButton: false,
allowOutsideClick: false,
confirmButtonText: okTranslation,
icon: 'info',
customClass: {
confirmButton: 'btn btn-primary'
},
buttonsStyling: false
})
}
}
})
}