-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpageIndex.js
80 lines (57 loc) · 2.56 KB
/
pageIndex.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
const locationSplitIndex = location.href.split('/');
const validUrls = [
'https://developer.amazon.com/alexa/console/ask#/skills',
'https://developer.amazon.com/alexa/console/ask'];
const localesMap = {
'English (IN)': 'en_IN',
'English (AU)': 'en_AU',
'English (US)': 'en_US',
'English (CA)': 'en_CA',
'English (UK)': 'en_GB',
'German (DE)': 'de_DE',
'Portuguese (BR)': 'pt_BR',
'French (CA)': 'fr_CA',
'French (FR)': 'fr_FR',
'Spanish (MX)': 'es_MX',
'Spanish (ES)': 'es_ES',
'Spanish (US)': 'es_US',
'Italian (IT)': 'it_IT',
'Japanese (JP)': 'jp_JP',
'Hindi (IN)': 'hi_IN',
};
// index page (skills list)
if (validUrls.includes(location.href)) {
$(document).ready(function () {
addLinkToTest();
let linkToTestInitialized = false;
$("body").on('DOMSubtreeModified', "#tenant-content", function() {
const skills = $('.astro-table-body tr.astro-table-row').length;
// wait until the skill table is fully loaded
if (skills > 0 && linkToTestInitialized === false) {
linkToTestInitialized = true;
$('tr.astro-table-row').each(function(item) {
const linkToEdit = $(this).find('a[data-qa-hook="skill-list-page-build-link"]').first();
// link to simulator
if (linkToEdit.length > 0) {
let testHref = linkToEdit.attr('href');
testHref = testHref.replace('/build/custom/', '/test/');
testHref = testHref.replace('/dashboard', '');
linkToEdit.parent().after($('<span><a href="'+ testHref + '">Test</a></span>'));
const dashboardHref = linkToEdit.attr('href');
const locales = $(this).find('.astro-row.skill-list-page__column').first().text().trim();
$(this).find('.astro-row.skill-list-page__column').first().html('');
locales.split(',').forEach((item) => {
if (localesMap[item.trim()]) {
let linkDashboard = dashboardHref.replace(/\/([\w]{2})_([\w]{2})\//gi, '/' + localesMap[item.trim()] + '/');
let html = '<a href="'+linkDashboard+'">' + item + '</a>';
$(this).find('.astro-row.skill-list-page__column').first().append(html)
}
});
}
})
}
});
});
function addLinkToTest() {
}
}