forked from MycroftAI/mycroft-skills
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meta_editor.html
1369 lines (1159 loc) · 46.2 KB
/
meta_editor.html
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!-- Copyright Mycroft AI, Inc. 2017. All Rights Reserved. -->
<!-- Thanks to https://www.sanwebe.com/2014/08/css-html-forms-designs for the basis of this. -->
<html class="gr__rawgit_com" lang="en">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Mobile Styles */
@media only screen and (max-width: 400px) {
.page {
margin: 0 5% 0 5%;
}
}
/* Tablet Styles */
@media only screen and (min-width: 401px) and (max-width: 960px) {
.page {
margin: 0 10% 0 10%;
}
}
/* Desktop Styles */
@media only screen and (min-width: 961px) {
.pageEdit {
margin: 0 15% 0 15%;
}
}
body {
text-align: left;
font-family: "Roboto";
font-size: 16px;
line-height: 1.5;
color: #2c3e50;
/* margin-right: 2em;
margin-left: 2em; */
}
a {
text-decoration: none;
color: #22a7f0;
}
h1 {
display: block;
text-align: left;
padding: 20px 0px;
/* margin: 0 0; */
color: #22a7f0;
/* font-variant: small-caps; */
font-size: 2.5em;
font-weight: 900;
line-height: 1.2;
}
h2 {
color: #22a7f0;
padding: 10px 0px;
font-size: 1em;
font-variant: small-caps;
/* text-transform: uppercase; */
font-weight: 500;
}
p {
padding: 0px 0px 30px 0px;
}
ol {
list-style: none;
}
i {
display: inline;
color: #6c7a89;
/* padding-right: 10px; */
}
.topnav {
height: 64px;
background-color: #22a7f0;
margin-bottom: 0px;
color: white;
font-weight: 400;
font-size: 18px;
padding: 17px 20px;
}
.logo {
margin-right: 10px;
/* margin-top: 10px; */
}
.instructions {
max-width: 100%;
margin: 0px auto 30px auto;
padding: 30px 50px 50px 50px;
background-color: #c3d8e2 ;
border-radius: 6px;
line-height: 2;
}
.entry-form placeholder {
background-color: #ff0000;
}
.entry-form {
max-width: 100%;
margin: 0px auto;
background: #fff;
border-radius: 6px;
/* padding: 20px; */
/* font-family: Georgia, "Times New Roman", Times, serif; */
}
.entry-form ul {
list-style: none;
padding: 0;
margin: 0;
/* background-color: ff0000; */
}
.entry-form li {
display: block;
padding: 8px 0px 0px 0px;
border: 2px solid #c3d8e2 ;
margin-bottom: 36px;
border-radius: 6px;
/* font-weight: bold; */
}
.entry-form li > label {
display: block;
/* float: left; */
/* margin-top: -19px; */
background: #fff;
/* height: 14px; */
padding: 0px 10px;
color: #22a7f0;
font-size: 16px;
overflow: hidden;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-weight: 500;
}
.entry-form input[type="text"],
.entry-form input[type="date"],
.entry-form input[type="datetime"],
.entry-form input[type="email"],
.entry-form input[type="number"],
.entry-form input[type="search"],
.entry-form input[type="time"],
.entry-form input[type="url"],
.entry-form input[type="password"],
.entry-form textarea,
.entry-form select {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
width: 100%;
display: block;
outline: none;
border: none;
/* height: 25px; */
/* line-height: 25px; */
font-size: 16px;
padding: 12px 10px;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
color: #2c3e50;
}
.entry-form input[type="text"]:focus,
.entry-form input[type="date"]:focus,
.entry-form input[type="datetime"]:focus,
.entry-form input[type="email"]:focus,
.entry-form input[type="number"]:focus,
.entry-form input[type="search"]:focus,
.entry-form input[type="time"]:focus,
.entry-form input[type="url"]:focus,
.entry-form input[type="password"]:focus,
.entry-form textarea:focus,
.entry-form select:focus {
}
.entry-form li > span {
background: #c3d8e2 ;
display: block;
padding: 8px 10px;
/* margin: 0 -9px -9px -9px; */
text-align: left;
color: black;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-size: 13px;
}
.entry-form textarea {
/* This is just Long Description field */
resize: none;
padding: 12px 10px;
/* background-color: ff0000; */
/* color: #ff0000; */
}
.device {
padding-left: 20px;
padding-bottom: 4px;
}
.category {
padding-left: 20px;
padding-bottom: 4px;
}
.first {
padding-top: 8px;
}
#page_README input[type="button"] {
background: #40dbb0;
border: none;
padding: 12px 20px;
/* border-bottom: 3px solid #ff0000; */
border-radius: 3px;
color: #2c3e50;
float:right;
margin-bottom: 5px;
margin-left: 5px;
}
#msgImportedREADME {
color: rebeccapurple;
float: right;
padding-top: 6px;
}
#page_README input[type="button"]:hover {
background: #fd9e66;
cursor: pointer;
color: #2c3e50;
}
#lblREADMENote {
font-size: 75%;
color: #22a7f0;
}
.entry-form .noborder {
border: none;
text-align: center;
margin-bottom: 38px;
margin-top: -8px;
}
.ex[id^="ex_"][name^="ex_"] {
background: #fff;
/* margin: 3px 0 3px 0; */
padding: 12px 10px;
margin-left: 20px;
counter-reset: item;
list-style-type: decimal;
}
.ex::before {
content: "»";
background-color: red;
background: red;
color: red;
}
.author[id^="author_"][name^="author_"] {
background: #fff;
/* margin: 3px 0 3px 0; */
padding: 14px 10px;
/* color: #ff0000; */
/* font-weight: 900; */
}
input::placeholder {
color: #AAAFB2;
/* background-color: red; */
}
textarea::placeholder {
color: #AAAFB2;
}
#custom_sections {
height: 200px;
}
code {
font-family: monospace;
/* display: none; */
}
#rawREADME {
width: 100%;
height: 60vh;
}
#github_preview_frame {
width: 100%;
height: 60vh;
}
.primary_category span {
color: black;
font-weight: 900;
}
tt {
font-family: monospace;
font-size: 0.9em;
font-weight: 700;
}
.card {
/* Add shadows to create the "card" effect */
box-shadow: 2px 4px 8px 2px rgba(0,0,0,0.2);
border-radius: 5px; /* 5px rounded corners */
padding: 2px 16px;
}
.card:hover {
box-shadow: 2px 8px 16px 2px rgba(0,0,0,0.2);
}
.card_content {
height: 100%;
overflow: hidden;
}
.icon {
width: 50px;
height: 50px;
font-size: 50px;
}
/**********************/
/* Small card preview */
/**********************/
#card_small_category {
font-size: 30px;
color: #FD9E66;
}
#card_small_preview {
width: 320px;
height: 260px;
padding: 10px;
position: relative;
}
#title_small {
font-size: 30px;
margin-bottom: 5px;
font-family: 'Roboto Mono',monospace;
font-weight: 700;
font-size: 24px;
text-align: center;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
#utt_small {
background-color: #E4F1FE;
width: 260px;
padding: 5px;
margin-bottom: 15px;
border-radius: 3px;
}
.utt_large {
background-color: #E4F1FE;
padding: 5px;
border-radius: 3px;
}
#card_small_preview input[type="button"] {
border: none;
padding: 12px 20px;
/* border-bottom: 3px solid #ff0000; */
border-radius: 3px;
background: #cccccc;
width: 260px;
position: absolute;
bottom: 20px;
}
/**********************/
/* Large card preview */
/**********************/
#cardb_large_preview {
width: 700px;
min-height: 500px;
padding: 20px;
position: relative;
}
#cardb_large_title {
background: #dddddd;
padding: 10px;
margin: 0;
margin-bottom: 10px;
}
#desc_large {
margin-left: 70px;
}
#cardb_large_preview input[type="button"] {
border: none;
padding: 12px 20px;
/* border-bottom: 3px solid #ff0000; */
border-radius: 3px;
background: #cccccc;
width: 260px;
position: absolute;
bottom: 20px;
right: 20px;
}
#div_fulldesc_large {
margin-top: 15px;
margin-bottom: 50px;
}
#by_large {
position: absolute;
bottom: 20px;
left: 20px;
}
#title_large {
font-size: 30px;
margin-bottom: 5px;
}
/******************/
/* Style the tabs */
/******************/
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Style the buttons that are used to open the tab content */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 1px 8px;
height: 3em;
transition: 0.3s;
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: #ccc;
font-weight: 900;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
xxborder: 1px solid #ccc;
xxborder-top: none;
}
</style>
<head>
<meta http-equiv='Content-Type' content='text/html' ; charset='UTF-8'>
<title>Mycroft Skill Readme Generator</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,500,700,900">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/commonmark@0.28.1/dist/commonmark.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pickr-widget/dist/pickr.min.css"/>
<script src="https://cdn.jsdelivr.net/npm/pickr-widget/dist/pickr.min.js"></script>
<script type="text/javascript">
var colorPicker = null;
//auto expand textarea
function adjust_textarea(h) {
new_height = h.scrollHeight;
if (new_height < 130) {
new_height = 130;
}
h.style.height = "20px";
h.style.height = new_height + "px";
}
///////////////////////////////////////////////////////////////////////////////
// Helpers
function strip(s){
return ( s || '' ).trim();
}
String.prototype.replaceAll = function(search, replace)
{
//if replace is not sent, return original string otherwise it will
//replace search string with 'undefined'.
if (replace === undefined) {
return this.toString();
}
return this.replace(new RegExp('[' + search + ']', 'g'), replace);
};
///////////////////////////////////////////////////////////////////////////////
// README.md -> form
function showREADMEImport() {
document.getElementById("msgImportedREADME").style.display = "block";
}
function hideREADMEImport() {
document.getElementById("msgImportedREADME").style.display = "none";
}
function parseREADME() {
// Take a README and populate the appropriate editor elements
var text = document.getElementById("rawREADME").value;
var sections = extract_sections(text);
// Extract title, short desc and icon
title_info = find_title_info(sections);
document.getElementById("name").value = title_info[0];
document.getElementById("short_desc").value = title_info[1];
if (title_info[2])
document.getElementById("icon").value = title_info[2];
else {
if (title_info[3])
document.getElementById("icon").value = title_info[3];
if (title_info[4])
colorPicker.setColor(title_info[4]);
}
// Extract long desc
document.getElementById("long_desc").value = find_section("About", sections) || find_section("Description", sections);
adjust_textarea(document.getElementById("long_desc"));
// Extract platform
platform = find_section("Supported Devices", sections) || '';
document.getElementById("req_mark1").checked = (platform.indexOf("platform_mark1") != -1);
document.getElementById("req_mark2").checked = (platform.indexOf("platform_mark2") != -1);
document.getElementById("req_picroft").checked = (platform.indexOf("platform_picroft") != -1);
document.getElementById("req_plasmoid").checked = (platform.indexOf("platform_plasmoid") != -1);
checkDevices();
// Warn if platform is not found
leftovers = strip(platform.replace("platform_mark1", "").replace("platform_mark2", "").replace("platform_picroft", "").replace("platform_plasmoid", ""));
if (leftovers.length > 0)
alert("WARNING: Nonstandard platform ("+leftovers+") will be lost.");
// Parse Categories
var categories = find_section("Category", sections) || "";
leftovers = categories;
var categoryEl = document.getElementsByClassName("category_section");
for (var i = 0; i < categoryEl.length; i++) {
id = categoryEl[i].id;
name = id.substring(4); // skip "cat_"
if (categories.indexOf(name) != -1)
{
categoryEl[i].checked = true;
if (categories.indexOf("**"+name+"**") != -1) {
document.getElementById("for_"+id).className = "primary_category";
leftovers = leftovers.replace("**"+name+"**", "");
}
else {
document.getElementById("for_"+id).className = "";
leftovers = leftovers.replace(name, "");
}
} else {
categoryEl[i].checked = false;
document.getElementById("for_"+id).className = "";
}
}
// Warn if category is not found
leftovers = strip(leftovers);
if (leftovers.length > 0)
alert("WARNING: Nonstandard category ("+leftovers+") will be lost.");
// Parse Tags
var tags = (find_section("Tags", sections) || "").split("\n");
var tagParent = document.getElementById("all_tags");
tagParent.innerHTML = '<label for="tag_1">Tags</label>'+
'<input class="tag" type="text" id="tag_1" maxlength="100" placeholder="#Tag 1" onkeyup="addNext(this, \'tag_\')" onchange="validateTag(this)"/>'+
'<span>Tags are single word identifiers, such as #kids, #crypto and are used for searching.</span>';
var elTag = document.getElementById("tag_1");
for (var i = 0; i < tags.length; i++) {
elTag.value = strip(tags[i]);
elTag = addNext(elTag, 'tag_');
}
// Parse Examples
var examples = (find_section("Examples", sections) || "").split("\n");
var exParent = document.getElementById("all_ex");
exParent.innerHTML = '<label for="ex_1">User Phrases: Hey Mycroft...</label>'+
'<input class="ex" type="text" id="ex_1" maxlength="100" placeholder="Phrase 1" onkeyup="addNext(this, \'ex_\')"/>'+
'<span>Provide examples of phrases handled by the Skill after the Wake Word is spoken. The first may be highlighted and should be a prime example.<br/>Ex: "play the news", "set a 10-minute timer"</span>';
var elEx = document.getElementById("ex_1");
for (var i = 0; i < examples.length; i++) {
elEx.value = strip(examples[i].replaceAll('"', "").replaceAll('*', ""));
"".repl
elEx = addNext(elEx, 'ex_');
}
// Parse Credits
var credits = (find_section("Credits", sections) || "").split("\n");
var elCredits = document.getElementById("all_authors");
elCredits.innerHTML = '<label for="author_1">Author(s)</label>'+
'<input class="author" type="text" id="author_1" maxlength="100" placeholder="Author name (@github_handle) 1" onkeyup="addNext(this, \'author_\')"/>'+
'<span>Credits for people or organizations involved (name, email, and/or GitHub @handle).</span>';
var elCredit = document.getElementById("author_1");
for (var i = 0; i < credits.length; i++) {
elCredit.value = strip(credits[i]);
elCredit = addNext(elCredit, 'author_1');
}
// Deal with any custom markdown sections
var elCustom = document.getElementById("custom_sections");
elCustom.value = "";
for (var i=1; i < sections.length; i++)
{
title = sections[i][0];
if (title.indexOf("About") >= 0 || title.indexOf("Examples") >= 0 ||
title.indexOf("Credits") >= 0 || title.indexOf("Tags") >= 0 ||
title.indexOf("Supported Devices") >= 0 ||
title.indexOf("Category") >= 0 || title.indexOf("Tags") >= 0)
continue;
content = sections[1];
if (elCustom.value != "")
elCustom.value += "\n";
elCustom.value += "## "+title + "\n" + sections[i][1];
}
}
function find_section(name, sections)
{
name = name.toLowerCase();
for (var i=0; i < sections.length; i++)
{
section = sections[i];
if (section[0].toLowerCase() == name)
return sections[i][1];
}
return null;
}
function find_title_info(sections)
{
if (sections.length == 0)
return "";
var iTitle = 0; // Old scheme: use first section
for (var i=0; i < sections.length; i++)
{
section = sections[i];
if (section[0].indexOf("<img") != -1)
{
iTitle = i;
break;
}
}
// extract icon info
var icon_parts = sections[iTitle][0].split("'");
var prev = "";
var url = null;
var name = null;
var color = null;
for (var i=0; i < icon_parts.length; i++)
{
var part = strip(icon_parts[i]);
if (prev.endsWith("src="))
url = part;
else if (prev.endsWith("card_color="))
color = part;
prev = part;
}
if (url && (url.startsWith("https://rawgit.luolix.top/FortAwesome/Font-Awesome") ||
url.startsWith("https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/")))
{
name = url.split('/').pop().split(".")[0]
url = null;
}
title = strip(sections[iTitle][0].split("/>").pop());
short_desc = strip(sections[iTitle][1]);
return [title, short_desc, url, name, color];
}
function extract_sections(text)
{
var lines = text.split("\n");
var sections = []
var section_title = "";
var content = "";
for (var i=0; i < lines.length; i++)
{
var line = strip(lines[i]);
if (line.startsWith("# ") || line.startsWith("## "))
{
if (section_title || content)
sections.push([section_title, content]);
section_title = strip(line.substring(2));
content = [];
}
else
{
if (content.length > 0)
content += "\n"+line;
else
content = line;
}
}
if (content != "")
sections.push([section_title, content]);
return sections;
}
///////////////////////////////////////////////////////////////////////////////
// form -> README.md
function generateREADME() {
// Convert the filled-out form to a markdown description (README.md) for
// the mycroft-skill on Github
var elem = document.getElementById("rawREADME");
var elIcon = document.getElementById("icon");
var elName = document.getElementById("name");
var elShortDesc = document.getElementById("short_desc");
var elLongDesc = document.getElementById("long_desc");
var elCustomSections = document.getElementById("custom_sections");
if (elIcon.value.startsWith("http"))
icon_url = elIcon.value;
else
icon_url = "https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/"+elIcon.value+".svg";
markdown = "# <img src='"+icon_url+"' card_color='"+colorPicker.getColor().toHEX().toString()+"' width='50' height='50' style='vertical-align:bottom'/>";
markdown += " " + elName.value + "\n";
markdown += elShortDesc.value + "\n\n";
markdown += "## About\n";
markdown += elLongDesc.value + "\n\n";
markdown += "## Examples\n";
for (var i = 1; ; i++) {
var ex = document.getElementById("ex_" + i);
if (!ex) break;
if (ex.value != "") markdown += '* "' + ex.value + '"\n';
}
markdown += "\n## Credits\n";
for (var i = 1; ; i++) {
var ex = document.getElementById("author_" + i);
if (!ex) break;
if (ex.value != "") markdown += ex.value + "\n";
}
var req_mark1 = document.getElementById("req_mark1").checked;
var req_mark2 = document.getElementById("req_mark2").checked;
var req_picroft = document.getElementById("req_picroft").checked;
var req_plasmoid = document.getElementById("req_plasmoid").checked;
if (req_mark1 || req_mark2 || req_picroft || req_plasmoid) {
markdown += "\n## Supported Devices \n";
if (req_mark1) markdown += "platform_mark1 ";
if (req_mark2) markdown += "platform_mark2 ";
if (req_picroft) markdown += "platform_picroft ";
if (req_plasmoid) markdown += "platform_plasmoid ";
markdown += "\n";
}
var categoryEl = document.getElementsByClassName("category_section");
markdown += "\n## Category\n";
for (var i = 0; i < categoryEl.length; i++) {
if (categoryEl[i].checked)
{
id = categoryEl[i].id;
category = id.substring(4); // skip "cat_"
if (document.getElementById("for_"+id).className.includes("primary_category"))
markdown += "**" + category + "**\n";
else
markdown += category + "\n";
}
}
if (!validateCategories())
markdown +="WARNING: You have no Categories selected. Please ensure your Skill is assigned to at least one Category." + "\n";
var tagEl = document.getElementsByClassName("tag");
markdown += "\n## Tags\n";
for (var i = 1; ; i++) {
var tag = document.getElementById("tag_" + i);
if (!tag)
break;
if (tag.value != "")
markdown += tag.value + "\n";
}
if (elCustomSections.value)
markdown += "\n\n" + elCustomSections.value;
hideREADMEImport();
elem.value = markdown;
}
function addNext(input, id_prefix) {
if (input.value == "")
return null;
inputNext = input.cloneNode(true);
input.onkeyup = "";
// ## <input class="ex" type="text" id="ex_1" maxlength="100" placeholder="example 1"...
num = input.id.substring(id_prefix.length) * 1 + 1;
inputNext.id = id_prefix + num;
inputNext.value = "";
if (input.placeholder) {
placeholder_prefix = input.placeholder.substring(0, input.placeholder.length - (''+(num-1)).length)
inputNext.placeholder = placeholder_prefix + num;
}
// Add after the last
input.parentElement.insertBefore(inputNext, input.nextSibling);
return inputNext;
}
function validateTag(elem)
{
if (elem.value[0] != '#')
elem.value = '#'+elem.value;
elem.value = elem.value.replace(/ /g, "");
}
function validateCategories(){
var categories = document.getElementsByClassName('category_section');
var cCategories = 0;
for (var i = 0; i < categories.length; i++) {
if (categories[i].checked)
return true;
}
return false;
}
function categoryClick(cb) {
var elements = document.getElementsByClassName("category_section");
var checks = 0;
var iChecked = null;
for (var i = 0; i < elements.length; i++) {
if (elements[i].checked) {
checks++;
iChecked = i;
}
// TODO: Remove this logic?
if (elements[i].id === "suggest") {
if (elements[i].value !== "") {
checks++;
}
}
}
if (checks <= 1) {
for (var i = 0; i < elements.length; i++) {
var label = document.getElementById("for_"+elements[i].id);
if (label)
if (i == iChecked)
label.className = "primary_category";
else
label.className = "";
}
}
}
function toTab(evt) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById("page_"+evt.currentTarget.id).style.display = "block";
evt.currentTarget.className += " active";
}
function generatePreviewCard()
{
var elCategory = document.getElementById("card_small_category");
var categoryEl = document.getElementsByClassName("category_section");
var cat = "";
for (var i = 0; i < categoryEl.length; i++) {
if (categoryEl[i].checked)
{
id = categoryEl[i].id;
category = id.substring(4); // skip "cat_"
if (document.getElementById("for_"+id).className.includes("primary_category")) {
cat = category;
break;
}
}
}
document.getElementById("card_small_category").innerText = cat;
var elName = document.getElementById("name");
document.getElementById("title_small").innerText = elName.value;
var elShortDesc = document.getElementById("short_desc");
document.getElementById("desc_small").innerText = elShortDesc.value;
var elUtt0 = document.getElementById("ex_1");
document.getElementById("utt_0_small").innerText = elUtt0.value;
// TODO: Validate icon and color
var elIcon = document.getElementById("icon");
if (elIcon.value.startsWith("http"))
{
document.getElementById("img_icon_small").src = elIcon.value;
document.getElementById("img_icon_small").style.display = "inline";
document.getElementById("icon_small").style.display = "none";
}
else
{
document.getElementById("icon_small").className = "fa-3x fas fa-"+elIcon.value;
document.getElementById("icon_small").style.color= colorPicker.getColor().toHEX().toString();
document.getElementById("img_icon_small").style.display = "none";
document.getElementById("icon_small").style.display = "inline";
}
}
function generatePreviewDetail()
{
var elName = document.getElementById("name");
document.getElementById("title_large").innerText = elName.value;
var elShortDesc = document.getElementById("short_desc");
document.getElementById("desc_large").innerText = elShortDesc.value;
var elLongDesc = document.getElementById("long_desc");
document.getElementById("fulldesc_large").innerText = elLongDesc.value;
// TODO: All authors
var elAuthor = document.getElementById("author_1");
document.getElementById("author_large").innerText = elAuthor.value;
var phrases = "";
for (var i = 1; ; i++) {
var ex = document.getElementById("ex_" + i);
if (!ex) break;