Fixing codeboxes

Discuss issues and requests related with the forum software
gregster
Posts: 2818
Joined: 30 Sep 2013, 06:48

Re: Fixing codeboxes

15 Jan 2019, 21:12

Well, in the Digi theme it doesn't underline - but I personally don't care much, because the cursor changes to pointy hand while hovering.

But something else happened just recently. Clickable built-in functions (from yesterday) were rolled back, it seems:

Code: Select all

Userfunc()	; still clickable, but doesn't help much 

OnMessage(0x112,"WM_SYSCOMMAND")	; not clickable anymore
DllCall("AnimateWindow","UInt",Splash_ID,"Int",1000,"UInt","0x90000")	; not clickable anymore
Yesterday, at some point, all functions were clickable, user and built-in. Built-in functions were correctly linked and user functions were showing a google search. The latter was not really necessary, but it is the only thing that still works at the moment, function-wise, while built-in funcs are not links anymore.
swagfag
Posts: 2851
Joined: 11 Jan 2017, 17:59

Re: Fixing codeboxes

15 Jan 2019, 21:47

only prosilver underlines, and on simplicity they arent clickable at all
gregster
Posts: 2818
Joined: 30 Sep 2013, 06:48

Re: Fixing codeboxes

15 Jan 2019, 23:44

Something else about codeboxes I just discovered:
Inside of spoilers they lack the custom 'Expand View' button... well, this is workable, while not ideal ;)
Spoiler

edit: Also, length() in code boxes points to the wrong page (to https://autohotkey.com/docs/commands/StringLen.htm instead of https://autohotkey.com/docs/objects/Object.htm#Length):

Code: Select all

loop % A_Args.Length()	; points to https://autohotkey.com/docs/commands/StringLen.htm
	msgbox % A_Args[A_index]
Between [docs ] tags it is fine, though.
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

16 Jan 2019, 15:58

Weird, for me everything is clickable in simplicity...
and length in codeboxes link to https://www.google.com/search?q=site:au ... rgs.Length
Yes, true I have not added full support for codeboxes in spolier ctrls...
Alright, I'll look into it later tonight.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
gregster
Posts: 2818
Joined: 30 Sep 2013, 06:48

Re: Fixing codeboxes

16 Jan 2019, 16:03

joedf wrote:
16 Jan 2019, 15:58
and length in codeboxes link to https://www.google.com/search?q=site:au ... rgs.Length
Perhaps differences in themes. In Digi I always get https://autohotkey.com/docs/commands/StringLen.htm
Well, actually it is https://www.autohotkey.com/docs/redirec ... pic=Length which then redirects to https://autohotkey.com/docs/commands/StringLen.htm
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

16 Jan 2019, 22:22

I've added forced underlining code .token:hover{text-decoration:underline !important;} this also causes other tokens to be underlined also... but I guess that okay.

Strange, everything works fine here on Digi with this link: https://www.autohotkey.com/boards/viewt ... 03&style=7
Try it, clear cache etc?

EDIT: got it, some functions were changed to type builtin...
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

16 Jan 2019, 22:59

Updated collapsed codeboxes:

Code: Select all

// Following add Expand/Collapse to [code] tags
// thanks to tmplinshi
// modified by joedf from  https://greasyfork.org/en/scripts/374036-ahk-forum-fix/code

window.expandCode = function (e) {
    var c = e.parentNode.parentNode.getElementsByTagName('code')[0];
	if (c.getAttribute('expanded') == 'true') {
		c.style.height = '200px';
		e.innerHTML = 'Expand View';
		c.setAttribute('expanded','false');
	}
	else {
		//c.style.maxHeight = 'none';
		c.style.height = 'auto';
		e.innerHTML = 'Collapse View';
		c.setAttribute('expanded','true');
	}
}
function expand_code_init() {
	var boxes = document.getElementsByTagName('code');
	var add_expand = false;
	for (var i = 0; i < boxes.length; i++) {
		if (boxes[i].scrollHeight > boxes[i].offsetHeight + 1) {
			add_expand = true;
        	} else if (boxes[i].scrollHeight == 0) { /* possibly inside a spoiler control */
			if (boxes[i].innerHTML.split('\n').length-1 > 17) {
				add_expand = true;
			}
		} else {
			/* leave as is? */
			add_expand = false;
		}

		if (add_expand) {
			var tagP = (boxes[i].parentNode.tagName.toLowerCase() == 'pre' ? boxes[i].parentNode.previousSibling : boxes[i].previousSibling);
            		tagP.innerHTML += ' - <a href="#" onclick="expandCode(this); return false;">Expand View</a>';
           		var c = tagP.parentNode.getElementsByTagName('code')[0];
            		c.setAttribute('expanded','false');
            		c.style.height = '200px';
			c.style.maxHeight = 'unset';
		}
	}
}
expand_code_init();
Updated highlighting links in code:

Code: Select all

// linker to docs for prism.js update
// created 7/01/2019 - updated 16/01/2019
// script by joedf
////////////////////////////////////

var redirectQURL = 'https://www.autohotkey.com/docs/redirect.php?topic=';

// get AHK codeboxes
var cboxes = document.querySelectorAll('code.language-autohotkey');

for(var i=0;i<cboxes.length;i++) {
	ctokens = cboxes[i].getElementsByClassName('token');
	for(var j=0;j<ctokens.length;j++) {
		type = ctokens[j].className.replace('token','').trim().toLowerCase();
		
		// supported types: selector, keyword, constant, operator, and variable
		if (['selector','keyword','constant','operator','function','builtin'].indexOf(type)>-1) {
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML+'">'+ctokens[j].outerHTML+'</a>';
		} else if (type.indexOf('variable')>-1) {
			// same as bove normal rediretor usage but remove the % symbols...
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML.replace(/%/gi,'')+'">'+ctokens[j].outerHTML+'</a>';
		} else if (type.indexOf('important')>-1) {
			// same as bove normal rediretor usage but remove the # symbols...
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML.replace(/#/gi,'')+'">'+ctokens[j].outerHTML+'</a>';
		} else {
			// do nothing? leave as is...
		}
	}
}

/* force the underlined link style */
codelinkstyle = document.createElement('style');
codelinkstyle .innerHTML = "code a:hover{text-decoration:underline !important;}";
document.head.appendChild(codelinkstyle);
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

16 Jan 2019, 23:01

As for length... looks like there's a difference between
https://autohotkey.com/docs/length()
and
https://autohotkey.com/docs/length
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
TAC109
Posts: 346
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Fixing codeboxes

16 Jan 2019, 23:06

Help in code boxes still doesn’t work for me. I use prosilver layout.
On my iPad using default Safari web browser it doesn’t work at all.
On my PC it works only once and then not at all until the PC is reloaded. Here I use IE11.

Before the forum software was 'upgraded' it all used to work fine on both platforms.

Hope you can get to the bottom of this.
Cheers
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
gregster
Posts: 2818
Joined: 30 Sep 2013, 06:48

Re: Fixing codeboxes

17 Jan 2019, 01:25

joedf wrote:
16 Jan 2019, 23:01
As for length... looks like there's a difference between
https://autohotkey.com/docs/length()
and
https://autohotkey.com/docs/length
Yes, okay, but the code boxes seem to use the second, even If i use () behind it - but not a big deal. This is so much better now than directly after the forum software upgrade.
Thank you again for your work on this. I see now underlining and 'Expand view' in spoilers - and built-in functions are working again :clap:
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

17 Jan 2019, 09:51

TAC109 wrote:
16 Jan 2019, 23:06
Help in code boxes still doesn’t work for me. I use prosilver layout.
On my iPad using default Safari web browser it doesn’t work at all.
On my PC it works only once and then not at all until the PC is reloaded. Here I use IE11.

Before the forum software was 'upgraded' it all used to work fine on both platforms.

Hope you can get to the bottom of this.
Cheers
Thanks for reporting this. I was able to reproduce the links not working. I have tested with IE11 and refreshed a few times.
https://www.autohotkey.com/boards/viewt ... 73&style=1
If you try running with the developer tools - console open, do you see any errors?
I get this error for now, which I shall fix when I get home:
SCRIPT438: Object doesn't support property or method 'contains'
highlightsolved.js (11,1)

gregster wrote:
17 Jan 2019, 01:25
joedf wrote:
16 Jan 2019, 23:01
As for length... looks like there's a difference between
https://autohotkey.com/docs/length()
and
https://autohotkey.com/docs/length
Yes, okay, but the code boxes seem to use the second, even If i use () behind it - but not a big deal. This is so much better now than directly after the forum software upgrade.
Thank you again for your work on this. I see now underlining and 'Expand view' in spoilers - and built-in functions are working again :clap:
Okay, it seems like I can use Dllcall() instead of Dllcall too, so I will change builtin function links to have an extra () at the end. Should fix it. I'll try this when I get home.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
TAC109
Posts: 346
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Fixing codeboxes

17 Jan 2019, 16:46

On IE11 I see 'css3114 @font-face failed OpenType embedding permission check. Permission must be installable.' twice when it works the first time. Keyword was underlined with little hand icon. After going back in IE11, hovering over keyword again now has no effect (no underline and no little hand icon).

I also see the 'script438' error.

Nothing happens at all on iPad.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
User avatar
jeeswg
Posts: 6651
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Fixing codeboxes

17 Jan 2019, 20:22

- The url tag used to show the full url, currently it doesn't.
- I've always used the url tag in my posts, so that people can easily copy and paste all the information, with full urls.

- Also, the default quote text has changed:
- Current: 'quote=##### post_id=###### time=########## user_id=##'.
- Original: 'quote=#####'. Thanks.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

17 Jan 2019, 22:38

Ok, IE Bug fix

Code: Select all

// ==UserScript==
// @name        AHK-Forum display solved h3 title
// @namespace   autohotkey.com
// @include     http://autohotkey.com/boards/viewtopic.php*
// @include     https://autohotkey.com/boards/viewtopic.php*
// @version     1
// @grant       none
// @author      joedf
// timestamp 15:11 2016/06/24
// ==/UserScript==
if (document.body.contains(document.getElementsByClassName('icon_solved_post') [0])) {
  //window.onload = function () {
    p = document.getElementsByClassName('postbody');
    n = p.length;
    for (i = 0; i < n; i++) {
      if (p[i].getElementsByTagName('h3')[0].contains(document.getElementsByClassName('icon_solved_post') [0])) {
        p[i].getElementsByTagName('h3')[0].style.display = 'inline';
        m = p[i].getElementsByTagName('div')[0];
        m.style.border = '2px solid lime';
        m.style.padding = '4px';
        m.style.backgroundColor = 'lightgoldenrodyellow';
        break;
      }
    }
  //}
}
Built-in functions fix

Code: Select all

// linker to docs for prism.js update
// created 7/01/2019 - updated 16/01/2019
// script by joedf
////////////////////////////////////

var redirectQURL = 'https://www.autohotkey.com/docs/redirect.php?topic=';

// get AHK codeboxes
var cboxes = document.querySelectorAll('code.language-autohotkey');

for(var i=0;i<cboxes.length;i++) {
	ctokens = cboxes[i].getElementsByClassName('token');
	for(var j=0;j<ctokens.length;j++) {
		type = ctokens[j].className.replace('token','').trim().toLowerCase();
		
		// supported types: selector, keyword, constant, operator, and variable
		if (['selector','keyword','constant','operator','function'].indexOf(type)>-1) {
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML+'">'+ctokens[j].outerHTML+'</a>';
		} else if (type.indexOf('builtin')>-1) {
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML+'()">'+ctokens[j].outerHTML+'</a>';
		} else if (type.indexOf('variable')>-1) {
			// same as bove normal rediretor usage but remove the % symbols...
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML.replace(/%/gi,'')+'">'+ctokens[j].outerHTML+'</a>';
		} else if (type.indexOf('important')>-1) {
			// same as bove normal rediretor usage but remove the # symbols...
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML.replace(/#/gi,'')+'">'+ctokens[j].outerHTML+'</a>';
		} else {
			// do nothing? leave as is...
		}
	}
}

/* force the underlined link style */
codelinkstyle = document.createElement('style');
codelinkstyle .innerHTML = "code a:hover{text-decoration:underline !important;}";
document.head.appendChild(codelinkstyle);
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

17 Jan 2019, 22:40

jeeswg wrote:
17 Jan 2019, 20:22
- The url tag used to show the full url, currently it doesn't.
- I've always used the url tag in my posts, so that people can easily copy and paste all the information, with full urls.

- Also, the default quote text has changed:
- Current: 'quote=##### post_id=###### time=########## user_id=##'.
- Original: 'quote=#####'. Thanks.
Yes, you are correct. Phpbb changed some things... Please open a seperate topic for this. I have too many things in mind. Posting here about this will only confuse me more.
Thanks.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
jeeswg
Posts: 6651
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Fixing codeboxes

17 Jan 2019, 22:50

Sure, will do. (I thought of them as codebox issues, but I can see now they're more like post issues.) Thanks.

Done:
phpBB issues - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=3&t=61130
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
TAC109
Posts: 346
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Fixing codeboxes

19 Jan 2019, 16:55

Some progress on iPad using Safari - some code boxes support help lookup, but others don’t. :crazy:

Not so good with IE11 - help doesn’t work at all now. :think:
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

20 Jan 2019, 21:36

TAC109 wrote:
19 Jan 2019, 16:55
Some progress on iPad using Safari - some code boxes support help lookup, but others don’t. :crazy:

Not so good with IE11 - help doesn’t work at all now. :think:
Thank you for report. Okay there was a little compatibility that was fixed. Now, there are not errors... but, the timing is off. If prism.urls.js runs at the very end, everything is okay on IE11.
But when it loads from cache, the timing is messed up.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
joedf
Posts: 7193
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Fixing codeboxes

20 Jan 2019, 21:58

Okay, should work now. Tested. Updated and hooks on to timing of Prism.js :+1:

Code: Select all

/* PrismJS 1.15.0 -- modified joedf: added patch from nnnik for block-comments https://github.com/PrismJS/prism/pull/1703

// [...]

/* joedf - include prism.urls.js after prism.js load */
(function(){
	if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
		return;
	}
	Prism.RunCount = 0;
	Prism.hooks.add('complete', function(env) {
		Prism.RunCount += 1;
		Prism.RunTotal = document.body.getElementsByTagName('code').length;
		console.log("Prism executed ["+Prism.RunCount+" / "+Prism.RunTotal+"].");
		if (Prism.RunCount >= Prism.RunTotal) {
			console.log("Launching prism.urls.js ...");
			if (document.body.getElementsByTagName('code').length > 0) {
				var prismdocsjs = document.createElement('script');
				prismdocsjs.src="/boards/assets/prism/prism.urls.js";
				document.body.appendChild(prismdocsjs);
			}
		}
	});
})();
prism.urls.js

Code: Select all

// linker to docs for prism.js update
// created 7/01/2019 - updated 20/01/2019
// script by joedf
////////////////////////////////////

var redirectQURL = 'https://www.autohotkey.com/docs/redirect.php?topic=';

// get AHK codeboxes
var cboxes = document.querySelectorAll('code.language-autohotkey');

for(var i=0;i<cboxes.length;i++) {
	ctokens = cboxes[i].getElementsByClassName('token');
	for(var j=0;j<ctokens.length;j++) {
		type = ctokens[j].className.replace('token','').trim().toLowerCase();
		
		// supported types: selector, keyword, constant, operator, and variable
		if (['selector','keyword','constant','operator'].indexOf(type)>-1) {
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML+'">'+ctokens[j].outerHTML+'</a>';
		} else if (['builtin','function'].indexOf(type)>-1) {
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML+'()">'+ctokens[j].outerHTML+'</a>';
		} else if (type.indexOf('variable')>-1) {
			// same as bove normal rediretor usage but remove the % symbols...
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML.replace(/%/gi,'')+'">'+ctokens[j].outerHTML+'</a>';
		} else if (type.indexOf('important')>-1) {
			// same as bove normal rediretor usage but remove the # symbols...
			ctokens[j].outerHTML = '<a href="'+redirectQURL+ctokens[j].innerHTML.replace(/#/gi,'')+'">'+ctokens[j].outerHTML+'</a>';
		} else {
			// do nothing? leave as is...
		}
	}
}

/* force the underlined link style */
codelinkstyle = document.createElement('style');
codelinkstyle .innerHTML = "code a:hover{text-decoration:underline !important;}";
document.head.appendChild(codelinkstyle);
console.log("prism.urls.js executed.");

Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
DRocks
Posts: 460
Joined: 08 May 2018, 10:20

Re: Fixing codeboxes

22 Jan 2019, 06:46

The code box is nicer than before now.. good job!
Thank you

Return to “Forum Issues”

Who is online

Users browsing this forum: No registered users and 6 guests