Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Forum [code] sections: green comments and scrollbars


  • Please log in to reply
180 replies to this topic
Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
In response to your question: If something easy-to-apply comes out of this, I'd appreciate a bottom-line summary of exactly what it does and whether it would be a good change for everyone (i.e. not something that would please 60% of users but annoy the other 40%).

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

i.e. not something that would please 60% of users but annoy the other 40%

Chris, there is absolutely no dileama about this, don't spawn false issue.
If smb thinks code folding isn't good idea it is his problem.
If 40% ppl think code folding isn't good idea it is their problem.
Or should we talk about Britny Spears again ?


PS:

It is good idea to supply javascripts in bookmarklet form. That way, we can test imediately without having to go to configuration of particular browser.
Posted Image

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Sorry; I meant that I hadn't read or fully understood the recent posts in the topic. When the time comes, please just spell it out for me.

This isn't a separate/false issue. It's simply that I won't implement things that have a good chance of doing more harm than good, or that have marginal net benefit.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

I'd appreciate a bottom-line summary of exactly what it does

I'll work on that later, in the mean time you can take a look at the example I made.

It is good idea to supply javascripts in bookmarklet form.

Bookmarklets have length limits, something like 2kb in Gecko but as small as 255 bytes in other browsers. Also try modifying a compressed one-line version of my script, it's quite difficult as I'm sure you'll agree.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

It's simply that I won't implement things that have a good chance of doing more harm than good, or have marginal net benefit.

This is not one of them.
Or all editor developers fuked up, implementing code folding for marginal benefit.

Now you will probably say that AHK is basicly for non programers, but lets skip this for now and make the Titan feels good for his job.


Titan, good work.
Now, just make the bookmarklet (so, I don't agree, provide both) and Opera support and I will let you kill me once in World of Worcraft. 8)
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
I downloaded your zip.

It doesn't work in Opera 8 and 9.
It works in IE, but I expected code folding not little edits.

One little misstake I noticed. If the code block is smaller then your def value it will be extended with empty space
Posted Image

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I ran it. Assuming it changes all code sections into scrollable boxes, I think a server-side solution would better than a client-side one (assuming it involves minor changes to the relevant phpBB templates). Also, some users have said that they simply don't like the scrollable boxes (I forget the reasons, but the posts were recent). So if this would unconditionally change it for all users, it's probably best to make it optional somehow.

Thanks.

majkinetor!
  • Guests
  • Last active:
  • Joined: --
The summery is good idea

Posibly by allowing Code to have [code="This script does this and this"] but any other solution will be fine.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

Also try modifying a compressed one-line version of my script, it's quite difficult as I'm sure you'll agree.

Keep your original script and use an automated way to make it a bookmarklet: Bookmarklet Builder
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor!
  • Guests
  • Last active:
  • Joined: --
I left him to realise that himself as a homework practice :)

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

It doesn't work in Opera 8 and 9.

Strange, doesn't Opera support W3C Level 2 DOM? I'm not familiar with Opera quirks but I think it might have something to do with event bubbling, I'll look into it later.

It works in IE, but I expected code folding not little edits.

They're not little edits, they're just div containers with a predefined height. I believe it's what Chris wanted anyway, "I like the idea of a scrollable text area, but only as a new/additional option (not to replace code sections)." It works in Firefox too by the way.

One little misstake I noticed. If the code block is smaller then your def value it will be extended with empty space

Thanks, this can be fixed with a check against d.style.height < s prior to the change.

Assuming it changes all code sections into scrollable boxes

Double-click the code sections in IE :)

I think a server-side solution would better than a client-side one

Depends how you go about it. If you simply wanted to wrap code content and add another css style I would agree. If however you want to add extra functionality like reading cookies to prevent code collapsing, toggle styles, copy code to the clipboard and fix the print layout you'll have to use javascript.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


majkinetor!
  • Guests
  • Last active:
  • Joined: --
This is what I would like to see:


Isense_HandleSelection( pSel )
{	
	global
	local params, cmnd, p

	;remove spaces and tabs from the start of the selection
	ISense_TrimLeft( pSel )

	;get the command and parameters
	p := ISense_GetNextDelimiter( pSel, ",,," . A_Space)
	if p = 0
		cmnd := pSel                          

[color=red]	...     [/color]                                                                      [color=red] MORE >>>[/color]

Then after expansion:
Isense_HandleSelection( pSel )
{	
	global
	local params, cmnd, p

	;remove spaces and tabs from the start of the selection
	ISense_TrimLeft( pSel )

	;get the command and parameters
	p := ISense_GetNextDelimiter( pSel, ",,," . A_Space)
	if p = 0
		cmnd := pSel
	else 
	{		
		StringMid, cmnd, pSel, 1, p-1
		if (p)
			StringMid, params, pSel, p+1
	}
	
	ISense_FindMatches( cmnd )
	if ISense_lastMatch =
		params = 

	;Rise info or tooltip mode and set internal variables they use before that.
	ISense_monitor := true
	if params = 
	{
		ISense_lastWord := cmnd
		if ISense_lastMatch != 
			Info_Show(ISense_lastMatch)
	}
	else {	
		ISense_selection := cmnd
		ISense_lastWord := params
		ISense_ESetParamMode()
		Tooltip_Show(-1, ISense_GetCurrentParam( params ))
	}
                                                                                   [color=red]MORE <<<[/color]
}


polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
I intended to have something like that by double-clicking anywhere in the code area and scrolling. Currently the former part only works in IE and expands all code blocks. This shouldn't happen if I register 'set' as the dblclick handler but that does nothing for some reason, new (codeblock()).set does not work either.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


foom
  • Members
  • 386 posts
  • Last active: Jul 04 2007 04:53 PM
  • Joined: 19 Apr 2006
Titan here is a function that i used to add doubleclick handlers to the Code: text above the codeboxes for my user.js highlighter

function addOnOffHandler(){
	var i, c;
    var e = (document.getElementsByTagName("BODY")[0].getElementsByTagName("B"));
	for(i = 0; i < e.length; i++) if(e[i].text == "Code:") {
        e[i].addEventListener(
    	'click',
            function(event){
                if(event.target.innerText == "Code: ON"){
                    //put what ever you do to unfold the box here
                    event.target.innerText = "Code: OFF";
                }
                else{
                    //put what ever you do to fold the box here
                    event.target.innerText = "Code: ON";
                }
            },false
	    );
	    e[i].innerText = "Code: ON";
    }
}
Hope u can use it to make it work with opera.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Thanks but I already tried W3C/Microsoft's event registration handlers and neither work. Besides, I want to reference codeblock.set, any ideas?

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit