1
1
function loadCollections ( ) {
2
2
chrome . storage . local . get ( [ 'kerificTerms' ] , function ( result ) {
3
3
let domString = '' ;
4
+ let domStringMarkdown = '' ;
4
5
5
6
if ( result . kerificTerms === undefined ) {
6
7
domString = '<p>No terms found</p>' ;
8
+ domStringMarkdown = '<p>No terms found</p>' ;
7
9
} else {
8
10
const terms = result . kerificTerms . terms ;
9
11
for ( let i = 0 ; i < terms . length ; i ++ ) {
@@ -26,12 +28,34 @@ function loadCollections() {
26
28
This definition comes from: ${ terms [ i ] . organisation }
27
29
</p>
28
30
</div>
31
+ </div>
32
+ ` ;
29
33
34
+ domStringMarkdown += `
35
+ <div class="card mb-5">
36
+ <div class="card-header">
37
+ <h2>${ terms [ i ] . term } </h2>
38
+ </div>
39
+ <div class="card-body">
40
+ <p class="card-text">
41
+ ${ terms [ i ] . definition }
42
+ </p>
43
+ </div>
44
+ <div class="card-footer">
45
+ <p class="card-text">
46
+ This definition comes from: ${ terms [ i ] . organisation }
47
+ </p>
48
+ </div>
30
49
</div>
31
50
` ;
32
51
}
52
+
53
+ domString += `
54
+ <h2>In Markdown-format:</h2>
55
+ <div id="markdown-container"></div>` ;
33
56
}
34
57
document . getElementById ( 'container-collection' ) . innerHTML = domString ;
58
+ document . getElementById ( 'container-collection-for-markdown' ) . innerHTML = domStringMarkdown ;
35
59
36
60
var removeButtons = document . querySelectorAll ( '.remove-button' ) ;
37
61
console . log ( 'removeButtons: ' , removeButtons ) ;
@@ -44,6 +68,22 @@ function loadCollections() {
44
68
} ) ;
45
69
} ) ;
46
70
}
71
+
72
+ const turndownService = new TurndownService ( )
73
+ const markdown = turndownService . turndown ( document . getElementById ( 'container-collection-for-markdown' ) )
74
+ // console.log('markdown: ', markdown);
75
+
76
+ const markdownContainer = document . getElementById ( 'markdown-container' ) ;
77
+ markdownContainer . innerHTML = `
78
+ <textarea rows="50" cols="33" class="form-control" id="markdown" rows="3">${ markdown } </textarea>
79
+ ` ;
80
+
81
+ markdownContainer . addEventListener ( 'click' , function ( e ) {
82
+ console . log ( e . target ) ;
83
+ e . target . select ( ) ;
84
+ } ) ;
85
+ // markdownContainer.select();
86
+
47
87
} ) ;
48
88
49
89
chrome . storage . local . get ( [ 'role' ] , function ( result ) {
0 commit comments