linkus.js
fileIt should export a linkus
object that is an instance of EventTarget
with the following methods:
Also linkus
object is expected to dispatch the following custom events:
init()
showTwin(links, id)
This function (method) is to be used for side effects only. It should show the link list presenting the given links
array between two nodes, considering the point of view based on the id
of the current node. List items should have the class corresponding to their direction (outgoing
or incoming
). Outgoing links should be shown first.
See the graphus.getLinksById(id)
method for the expected shape of the links
array.
showMany(links)
This function (method) is to be used for side effects only. It should show the link list presenting the given links
array in unrelated
mode. All list items should have outgoing
class.
See the graphus.getLinks()
method for the expected shape of the links
array.
geListedLinks()
This function (method) should return an array of links that are currently shown in the right panel. Expected shape of result is:
[ 0 or more elements like the one below
{
from: positive integer,
to: different positive integer,
},
]
updateLink(from, to, description)
This function (method) should update the description of the link with the given from
and to
ids on the page. It should be called for side effects only.
removeLink(from, to)
This function (method) should remove the link with the given from
and to
ids from the list on the page. It should be called for side effects only.
gotolinktrigger
This event should be dispatched when the “Go to link” button is clicked next to a specific link in unrelated
mode. It should carry the event.detail.id
property with the following data:
{
from: positive integer,
to: different positive integer,
}
editlinktrigger
This event should be dispatched when the “Edit link” button is clicked next to a specific link. It should carry the event.detail.id
property with the following data:
{
from: positive integer,
to: different positive integer,
}
deletelinktrigger
This event should be dispatched when the “Delete link” button is clicked next to a specific link. It should carry such link detail as id
property with the following data:
{
from: positive integer,
to: different positive integer,
}