Javascript console object

65 views
Skip to first unread message

Eugene

unread,
Nov 11, 2018, 8:09:33 AM11/11/18
to Epsilon Notes
The Javascript console function proposed by Mikhail Yudin for testing is available through the beta version at https://play.google.com/apps/testing/com.ekartoyev.enotes

(Should appear in Google Play in an hour or so)


The script for testing is

<script>
console.clear()
console.debug('Debug message')
console.log('Log test');
console.warn('Warn test');
console.error('Error test');
console.time('Time');
for(let i=0;i<5;i++)
console.count('Count test');
console.assert(2===3,"2===3");
console.timeEnd('Time');
console.info('Webkit console methods: ', Object.getOwnPropertyNames(console));
console.log(1,2,3);
ENCON.custom("#ffbb0cd0", "Custom color");
console.profile();
</script>

Waiting for your improvement suggestions.

Screenshot_2018-11-11-16-08-12.png

Eugene

unread,
Nov 11, 2018, 8:19:04 AM11/11/18
to Epsilon Notes
Mikhail, the script I used to intercept the console object is your modified script.
ENCON in the object that actually sends the commands to Epsilon Notes for publishing to the Console.

The modified script here - https://pastebin.com/y4qFJq5k

To turn off the console for a file (e.g. when done debugging), use Yaml

---
console:off
...

If you have further comments before the release, I'd be happy to see your participation. ;)

fagc...@gmail.com

unread,
Nov 12, 2018, 5:09:39 AM11/12/18
to Epsilon Notes
Very cool! Nice to see console! Will online later.

воскресенье, 11 ноября 2018 г., 20:19:04 UTC+7 пользователь Eugene написал:

Ruskey 4ilaveg

unread,
Nov 12, 2018, 8:49:25 AM11/12/18
to Epsilon Notes
I still don't know how to use it. If I insert a script into a note that you suggested for testing, I get some text in the console, but it doesn't fit the width in portrait orientation. The landscape console is too low, I only see five lines in it. So instead of a screenshot I put here the text.

Debug message
Log test
Warn test
Error test
Count test: 1
Count test: 2
Count test: 3
Count test: 4
Count test: 5
Assertion failed: 2===3
Time: 6.70ms
Webkit console methods: [
"debug",
"error",
"info",
"log",
"warn",
"dir",
"dirxml",
"table",
"trace",
"group",
"groupCollapsed",
"groupEnd",
"clear",
"count",
"countReset",
"assert",
"profile",
"profileEnd",
"time",
"timeEnd",
"timeStamp",
"context",
"memory"
]
1 2 3
Custom color
console.profile not implemented yet.
jQuery.Deferred exception: Cannot read property 'indexOf' of undefined TypeError: Cannot read property 'indexOf' of undefined
at HTMLAnchorElement.<anonymous> (about:blank:131:68)
at Function.each (file:///android_asset/jquery-3.1.1.min.js:2:2815)
at r.fn.init.each (file:///android_asset/jquery-3.1.1.min.js:2:1003)
at HTMLDocument.<anonymous> (about:blank:131:29)
at j (file:///android_asset/jquery-3.1.1.min.js:2:29948)
at k (file:///android_asset/jquery-3.1.1.min.js:2:30262)
Script error.

I also noticed that in a new note the text in the console remains the same and I need to erase it every time (probably this is normal?).
I think the command "console.time()" does not work correctly. I just save a note with your script unchanged several times and each time the time increases. First 6.30ms, then 11.40ms, then 14.70, etc.
After adding YAML "console: off" no text appears, except, that are brought out by ENCON.custom(). This text is not erased after a new save and the same results are accumulated.

If there is no script in the note, an error message appears in the console about the script that is in Footer in Preferences. This is your old script for marking links leading to the Internet.

<script>$(function(){$('a').each(function(){if($(this).attr("href").indexOf("http")==0){$(this).prepend('🌏 ');}});});</script>

So far, I have not seen any conflicts with the previous functions.
If you have any other tests, write, I will try to check. But more in details please, I don't understand it.

Eugene

unread,
Nov 12, 2018, 9:44:37 AM11/12/18
to Epsilon Notes
Ruskey 4ilaveg,

when you executed programs, you used alert(something); to see the intermediary results in your program.

Normally, people use the console command.

The commands console.log() console.debug() console.info() console.warn() console.error()

all of them do the same thing. The post a message in the console screen, but using different colors.

Eugene

unread,
Nov 12, 2018, 9:47:40 AM11/12/18
to Epsilon Notes

# Testing console command in a javascript

My name is <span id="name"></span>

<script>$(function(){

// This command clears the console
console.clear();

// This command posts a green message to console
console.info("Starting the program");

// This command starts counting time with the timer called "timer"
console.time("timer");

console.info("Timer has started");

var name = 'Eugene';

console.log('The variable name = ', name);

name += ' Kartoyev';

// log posts a white message
console.log('Now the variable name = ', name);

// debug posts a blue message
console.debug('Now I\'m inserting the name to the Html');

$('#name').text('Eugene');

console.info('The program has finished');

console.info("The total execution of the program took:");

// This finishes counting the time
// and tells how much time it took
// to do the above operations
console.timeEnd("timer");

});</script>

DON'T COPY THIS TEXT FROM EMAIL. Email inserts invisible characters. Copy the text from the group or from here - https://pastebin.com/0Gmcia0W

Eugene

unread,
Nov 12, 2018, 9:48:44 AM11/12/18
to Epsilon Notes
If you don't see the ending of a console line, move the console left or right, using fingers.

Eugene

unread,
Nov 12, 2018, 9:50:55 AM11/12/18
to Epsilon Notes
Example
Screenshot_2018-11-12-17-51-30.png
Screenshot_2018-11-12-17-51-38.png

Eugene

unread,
Nov 12, 2018, 9:56:04 AM11/12/18
to Epsilon Notes
You will always see different execution time with the timer because sometimes it takes longer to execute the same program, sometimes shorter, depending on how busy the processor is.

Eugene

unread,
Nov 12, 2018, 10:29:26 AM11/12/18
to Epsilon Notes
In short, you can use console.log(something) in the same way you used alert(something) in the past.


Before you wrote alert('My message'), now use console.log('My message')

and it will not block the main screen.

Console will also be used to report errors, for example, if you try to decrypt a file that was not encrypted, it will tell the error to console instead of the popup message, so a person can copy the error and post it here, if they want to ask a question about the error.

The same thing about compatibility processor, if you write a wrong regex there, it will tell you about the error to the console.

Screenshot_2018-11-12-18-27-31.png
Screenshot_2018-11-12-18-25-17.png

Ruskey 4ilaveg

unread,
Nov 12, 2018, 11:38:13 AM11/12/18
to Epsilon Notes
Thanks for the clarification. All this should be added to the help. If you do not have more tasks for me, I have only one request - add to the settings item allows you to disable the console for all notes. Now it appears everywhere, even in Folder index (why?). Epsilon is a CommonMark editor, script checking is not necessary for everyone and not always. It is better for people who use it to turn on the console for example in YAML or some other way when they need it.

Eugene

unread,
Nov 12, 2018, 1:12:43 PM11/12/18
to Epsilon Notes

It shouldn't. It means you have an error.

Can you re-copy/paste your script from here https://pastebin.com/87e9Kb0k ?

It seems it has some hidden character.

It stopped popping after I re-wrote it by hand.

Eugene

unread,
Nov 12, 2018, 1:56:19 PM11/12/18
to Epsilon Notes
After I copied you script from email, it was ruined by invisible characters. (I have visualised them with the prerender yaml)

Though the script as posted here in the forum doesn't have the invisible characters...

You may have a different problem
Can you tell me what error it says in your console?

Screenshot_2018-11-12-21-52-21.png
Screenshot_2018-11-12-21-53-18.png

Ruskey 4ilaveg

unread,
Nov 12, 2018, 2:48:41 PM11/12/18
to Epsilon Notes
I found the reason for the error message, it is caused by such a bookmark that I have in Footer - <a name="niz"></a>. Now I tried to replace "name" with "id", did not helped. But I need this bookmark, because I use this button - <a href="#niz" class="tobott" style="position: fixed; left:25px; bottom:45px;width:50px;height:50px; border-radius:25px; box-shadow:0 3px 5px rgba(0,0,0,0.5)"></a>. What am I to do?

Eugene

unread,
Nov 12, 2018, 3:15:47 PM11/12/18
to Epsilon Notes
Oh! You see how good the console is!
Now it forces you and me to get rid of any possible errors. ☺

Try replacing the script with this one (I made it a bit more readable):

<script>
$(function() {

function addIcon() {
h = $(this).attr("href");
if (h !== undefined && h.indexOf("http") === 0)
$(this).prepend("🌍 ");
}

$("a").each(addIcon);

});
</script>

Copy it from here: https://pastebin.com/dPysJYW4

Eugene

unread,
Nov 12, 2018, 3:19:02 PM11/12/18
to Epsilon Notes
Correction

<script>
$(function() {

function addIcon() {
var h = $(this).attr("href");
if (h !== undefined && h.indexOf("http") === 0)
$(this).prepend("🌍 ");
}

$("a").each(addIcon);

});
</script>


pastebin - https://pastebin.com/dPysJYW4

Ruskey 4ilaveg

unread,
Nov 12, 2018, 3:22:15 PM11/12/18
to Epsilon Notes
All clean. Only word "console" displayed. 👍
Message has been deleted

Ruskey 4ilaveg

unread,
Aug 30, 2019, 5:57:07 AM8/30/19
to Epsilon Notes
If I add 'console: off' in YAML 'ENCON.custom('someColor', 'someText') open console anyway. It is normally? Please tell me wh it needed?

Eugene

unread,
Aug 30, 2019, 6:55:23 AM8/30/19
to Epsilon Notes
That's an inofficial assistant function for displaying internal bugs. I use it during debugging etc.

Ruskey 4ilaveg

unread,
Aug 30, 2019, 9:40:21 AM8/30/19
to Epsilon Notes
Ok, just in a case, on 4pda appeared your app. Кажызь паламале, цкаты :)
Reply all
Reply to author
Forward
Message has been deleted
0 new messages