1
- import { snabbdomBundle as V } from "snabbdom/snabbdom.bundle" ;
2
- import { _ } from "../utils/language" ;
3
- import * as helper from "../utils/helper" ;
4
- import { LinkInfo } from "../config_default" ;
5
- import { Link as LinkData } from "../utils/node" ;
1
+ import { classModule , eventListenersModule , h , init , propsModule , styleModule } from "snabbdom" ;
2
+ import { _ } from "../utils/language.js" ;
3
+ import * as helper from "../utils/helper.js" ;
4
+ import { LinkInfo } from "../config_default.js" ;
5
+ import { Link as LinkData } from "../utils/node.js" ;
6
+
7
+ const patch = init ( [ classModule , propsModule , styleModule , eventListenersModule ] ) ;
6
8
7
9
function showStatImg ( images : HTMLElement [ ] , linkInfo : LinkInfo , link : LinkData , time : string ) {
8
10
let subst : ReplaceMapping = {
@@ -19,8 +21,8 @@ function showStatImg(images: HTMLElement[], linkInfo: LinkInfo, link: LinkData,
19
21
"{LOCALE}" : _ . locale ( ) ,
20
22
} ;
21
23
22
- images . push ( V . h ( "h4" , helper . listReplace ( linkInfo . name , subst ) ) ) ;
23
- images . push ( helper . showStat ( V , linkInfo , subst ) ) ;
24
+ images . push ( h ( "h4" , helper . listReplace ( linkInfo . name , subst ) ) as unknown as HTMLElement ) ;
25
+ images . push ( helper . showStat ( linkInfo , subst ) ) ;
24
26
}
25
27
26
28
export const Link = function ( el : HTMLElement , linkData : LinkData [ ] , linkScale : ( t : any ) => any ) {
@@ -42,20 +44,20 @@ export const Link = function (el: HTMLElement, linkData: LinkData[], linkScale:
42
44
let img = [ ] ;
43
45
let time = linkData [ 0 ] . target . lastseen . format ( "DDMMYYYYHmmss" ) ;
44
46
45
- header = V . patch (
47
+ header = patch (
46
48
header ,
47
- V . h (
49
+ h (
48
50
"div" ,
49
- V . h ( "h2" , [
50
- V . h (
51
+ h ( "h2" , [
52
+ h (
51
53
"a" ,
52
54
{
53
55
props : { href : router . generateLink ( { node : linkData [ 0 ] . source . node_id } ) } ,
54
56
} ,
55
57
linkData [ 0 ] . source . hostname ,
56
58
) ,
57
- V . h ( "span" , " - " ) ,
58
- V . h (
59
+ h ( "span" , " - " ) ,
60
+ h (
59
61
"a" ,
60
62
{
61
63
props : { href : router . generateLink ( { node : linkData [ 0 ] . target . node_id } ) } ,
@@ -64,26 +66,24 @@ export const Link = function (el: HTMLElement, linkData: LinkData[], linkScale:
64
66
) ,
65
67
] ) ,
66
68
) ,
67
- ) ;
69
+ ) as unknown as HTMLDivElement ;
68
70
69
71
helper . attributeEntry (
70
- V ,
71
72
children ,
72
73
"node.hardware" ,
73
74
( linkData [ 0 ] . source . model ? linkData [ 0 ] . source . model + " – " : "" ) +
74
75
( linkData [ 0 ] . target . model ? linkData [ 0 ] . target . model : "" ) ,
75
76
) ;
76
- helper . attributeEntry ( V , children , "node.distance" , helper . showDistance ( linkData [ 0 ] ) ) ;
77
+ helper . attributeEntry ( children , "node.distance" , helper . showDistance ( linkData [ 0 ] ) ) ;
77
78
78
79
linkData . forEach ( function ( link ) {
79
80
children . push (
80
- V . h ( "tr" , { props : { className : "header" } } , [ V . h ( "th" , _ . t ( "node.connectionType" ) ) , V . h ( "th" , link . type ) ] ) ,
81
+ h ( "tr" , { props : { className : "header" } } , [ h ( "th" , _ . t ( "node.connectionType" ) ) , h ( "th" , link . type ) ] ) ,
81
82
) ;
82
83
helper . attributeEntry (
83
- V ,
84
84
children ,
85
85
"node.tq" ,
86
- V . h (
86
+ h (
87
87
"span" ,
88
88
{ style : { color : linkScale ( ( link . source_tq + link . target_tq ) / 2 ) } } ,
89
89
helper . showTq ( link . source_tq ) + " - " + helper . showTq ( link . target_tq ) ,
@@ -103,10 +103,10 @@ export const Link = function (el: HTMLElement, linkData: LinkData[], linkScale:
103
103
} ) ;
104
104
}
105
105
106
- let elNew = V . h ( "table" , children ) ;
107
- let pTable = ( table = V . patch ( table , elNew ) ) ;
108
- pTable . elm . classList . add ( "attributes" ) ;
109
- images = V . patch ( images , V . h ( "div" , img ) ) ;
106
+ let elNew = h ( "table" , children ) ;
107
+ let pTable = patch ( table , elNew ) ;
108
+ ( pTable . elm as unknown as HTMLElement ) . classList . add ( "attributes" ) ;
109
+ images = patch ( images , h ( "div" , img ) ) as unknown as HTMLDivElement ;
110
110
} ;
111
111
112
112
self . setData = function setData ( data : { links : LinkData [ ] } ) {
0 commit comments