MoI discussion forum
MoI discussion forum

Full Version: Adding "Info" button and documentaion for a node.

From: bemfarmer
4 Oct 2019   [#1]
The Sweep node was modified by Karsten to have a right click on the Sweep node bring up the "info" menu button for the Sweep.html documentation file.

The "Docupath" is already defined by Karsten in a recent version of basicFunctions.js.

LineWeb.js node file was used as an example of how to modify one node, to get the "Info" menu selection, for the node documentation, by right clicking on the node.

After the two lines in LineWeb.js:
LineWeb.title = "LineWeb";
LineWeb.desc = "LineWeb";
It is necessary to modify the Node code by adding the following: (Comment lines are not needed.)

// Start: New code for Info menu and LineWeb.html link.
LineWeb.prototype.getExtraMenuOptions = function ()
{
var that = this;
return [
{content: lang.getTranslation("Info"), callback: function () {
moi.UI.createDialog(docupath+"LineWeb.html");
}}
];
};
// End: New code for Info menu and LineWeb.html link.

(This section of the Sweep node code is a little more elaborate because it has two additional extra menu options.)

Now it is necessary to create LineWeb.html documentation, similar to Sweep.html, and place the LineWeb.html file in the EN folder of %appdate% /nodeeditor/nodes/extensions/Documentation/EN folder. (or Mac equivalent folder)
For other language, use the appropriate folder...(?)

Notepad++ with the "Preview HTML" plugin was used to modify the Sweep.html file, renamed LineWeb.html.
https://moi3d.com/forum/index.php?webtag=MOI&msg=9517.2

(Closing nodeeditor does not close the popup html window, but the window does have an X close button.)

- Brian

(My LineWeb.html file is just a rough draft, so far., but its window pops up just fine when the Info menu item is selected.)

So all of the nodes would have to be modified, quite a bit of copy and edit work, but pretty repetitive.
Also .html documentation files would need to be written for each node. Quite a lot more work.
From: Frenchy Pilou (PILOU)
4 Oct 2019   [#2]
As I started by hasard the extension part by the Sweep Node for my Elephant repository i had believed that all nodes were documented like this! :)
From: bemfarmer
4 Oct 2019   [#3] In reply to [#2]
Hi Pilou,
Your hard work doing documentation should make popup info documentation much easier.
Your documentation will be superior, due to your many examples, IMHO :-)
- Brian

I suppose the popup documentation will be fairly basic, without examples?
Then there is the translation work...

Maybe a master programmer could devise an easier method?
From: bemfarmer
4 Oct 2019   [#4]
Karsten's basicFunctions.js apparently implements lang.LANGUAGE for adding another language to the Info button.

Currently, line 4 of lang.js in %APPDATA%\nodeeditor\core\lang.js must be changed to (for example) FR, in order for a nodes Info selection to use the French version of the
Info *.html file. (The MoI Option button change to French is not recognized by Info selection.)
To change language to French "FR", use MoI Option button.

New .html documentation information:
So to add Sweep.html documentation for another language, say French, add another folder alongside EN, called FR, path:
%APPDATE%\nodeeditor\nodes\extensions\Documentation\FR (or equivalent Math path.)
After translating Sweep.html, to say SweepFR.html, place SweepFR.html into the FR directory.

The above is tested, and subject to editing :-) EDIT, SOMETHING IS WRONG...Line 4 of lang.js currently needs to be edited, for example to "FR" for French Info .html to work. See Below

- Brian

(As has been explained in other posts, %APPDATA% refers to the users appdata folder and path. My version on windows 10 is here: C:\Users\orcha\AppData\Roaming\Moi )
Mac version is a similar, but a little different.
From: Frenchy Pilou (PILOU)
4 Oct 2019   [#5] In reply to [#4]
I will test that when the Construct2 will be finished because there here the French translation of the Fillet's Info! ;)

http://moiscript.weebly.com/construct2-f.html
From: bemfarmer
5 Oct 2019   [#6] In reply to [#4]
Finally got the French version of Info documentation to work.
I used Planar from the Construct2 as an example.

Lesson 1, Create (or translate), a French version of Planar.html, and place the file in the FR folder under the nodeeditor Documentation folder.
Do NOT change the name Planar.html.

Lesson 2, (I could be mistaken, but:) Apparently Karsten's code does not utilize the MoI Option button language version.
So changing "EN" to "FR" in line 4 of lang.js was used to enable Info to access French version of Planar.html in the FR directory.

???This should be corrected by modifying the prototype.getExtraMenuOptions code??? to recognize the MoI language being used as per the Option button language version selection. (Somehow, I do not know how.)

- Brian
(My French Planar.html file was just titled as a pretend translation.)
From: Frenchy Pilou (PILOU)
5 Oct 2019   [#7] In reply to [#6]
Post it ...for I a take a look to the translation of the text! If existing... :)
From: bemfarmer
5 Oct 2019   [#8] In reply to [#7]
Here is the document file for planar.html

The "How it works" section was carefully considered, and should be correct, or nearly correct :-)

I did not attempt any translation, just changed the title to Planar pretend French version, to be able to tell which file Info button was displaying,
due to the bug/inability of Info button to recognize the MoI Option button language selection.
Info button is limited to only recognizing "EN" or "FR" in the nodeeditor lang.js file, line 4, in order for the correct language version of .html to display.
This manual editing of "EN" to "FR" should not be required.

- Brian

Notepad++ can show two different view versions of an .html file.

Attachments:
Planar.html


From: Frenchy Pilou (PILOU)
5 Oct 2019   [#9]
Planar Info works fine...in English :)

In general just rename / double the folder "EN" in Folder "Fr" is not sufficient and of course the file HTML?

Keep the good work...
From: Frenchy Pilou (PILOU)
5 Oct 2019   [#10]
Here the file with French translation (i just make that)
http://moiscript.weebly.com/uploads/3/9/3/8/3938813/planar.html

Accents are possible not acceptable so just reload in your text editor and change the ANSI / UTF and resave...

(i tested on my web browers that works fine - accents are not good as preview with the system of loading for send...so normally no problem from the node Edtor if you succeess to call it :)


From: bemfarmer
6 Oct 2019   [#11]
Excellent Pilou.

Further investigation of the Info documentation, in particular the Info code for all of the nodes of construct2.js brings up the following:

Firstly,
The lang.js file should have translations for "Intro", "single rail", "two rail", and "normal".
"Normal" is already translated in the lang.js file, so the getExtraMenuOptions code for normal node in construct2.js, could have "Normal" with capitalized N.
Maybe "single rail" and "two rail" should be capitalized in getExtraMenuOptions code for sweep node in construct2.js?
If additional Info .html files are developed for the other nodes with Extra Menu Options, those selections should also be translated in the lang.js file.

Secondly,
Currently, the getExtraMenuOptions only access the language code of lang.js line 4, default value "EN" unless "EN is manually edited to say "FR".
The proper access should be by the MoI Option language setting. So some minor modification of the getExtraMenuOptions code is needed.

The last 7 lines of lang.js yield the language code such as EN, RU, FR, for MoI's Option languages setting of for example English, Russian, French.
I do not understand the code very well.
Perhaps some knowledgeable person could make an adjustment to the getExtraMenuOptions code of Karsten, so that the proper nodeeditor Info Documentation subdirectory
such as EN folder, RU folder, or FR folder, containing the various *.html files is used when using the Info button.
I'm not sure if the proper label is lang, language, LANGUAGE, lng, l, or ?. Also there are .XXX methods.

- Brian

ps Are there any other nodeeditor language translations such as SP Spanish?
From: Frenchy Pilou (PILOU)
6 Oct 2019   [#12] In reply to [#11]
There is no Ru in the Moi itself! ;)



Maybe there is special one by Max ?

And for have a node editor in a special language you must edit the dictionnary of it!
+ some codes pages...if i have good memory ...i made that a long time ago...all new nodes are not yet translated!

It's that i done for the French version! :) (not updated i am waiting the V 4 ! ;)

It's for that i make for the moment only principally the Not Native Nodes in English! :)
From: bemfarmer
6 Oct 2019   [#13] In reply to [#12]
So, For example, adding RussianStrings.txt to the MoI ui folder would add Russian to the Options button. (?)
Guess there has not been much interest... Maybe Max would provide RussianStrings.txt for MoI, if someone requested?

- Brian
From: bemfarmer
19 Oct 2019   [#14] In reply to [#4]
At this time, the node info button is NOT working for the light color scheme.

I thing that basicFunctions.js ( I think Karsten wrote it?), applies to index.html, but NOT to index.html?scheme=Light?
The path to basicFunctions.js is %APPDATA\nodeeditor\node\extensions\libs\

Still puzzled,
- Brian
From: bemfarmer
22 Oct 2019   [#15] In reply to [#14]
So using the Info menu with light version was solved by Karsten back in March.
I forgot, and also lost the correction after my SSD failure a month or 2 ago.

https://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1398

- Brian

So I made Karstens modification to basicFunctions.js so that the Info *.html box will appear in Light version of nodeeditor.
(commented out older code.)
(Backup of basicFunctions.js saved as basicFunctions.BAK, NOT basicFunctionsOld.js.)
From: bemfarmer
25 Oct 2019   [#16]
Updating the Info *.html file for a node is not working.
The old *.html Info file keeps coming up in nodeeditor, even if the file is deleted.
It was working just fine a day ago... I only made a few minor changes...
Maybe a cache need clearing?

- Brian

Reboot of computer did not help.
Closing MoI4beta did not help.
From: bemfarmer
25 Oct 2019   [#17] In reply to [#16]
So if an old info *.html gets Stuck with the corresponding node, Press Alt+New on the nodeeditor screen to clear the old info .html file.

This must be some kind of correctable bug in the info code in a node?
Closing a node should sever its tye to its info *.node?

- Brian

Is there a superior way to code the info files than with .html?