Page 1 of 1
Forum code listings : folding + quick selection
Posted: Fri Mar 03, 2017 7:27 am
by Blue
I would very much appreciate having a button to fold code sections in forum postings.
It would make following discussions a lot easier, especially where participants offer very long code examples; it would as well seriously diminish all the scrollling required to follow topics.
Additionally, having a button to select the code in one shot would be quite practical, especially when the code is lengthy.
Re: Forum code listings : folding + quick selection
Posted: Fri Mar 03, 2017 8:24 am
by davido
@Blue,
I was advised, in answer to a similar question, to use the Prosilver Board Style.
The code section is placed in a small scrollable window with the ability to easily highlight all the code with a single click to Select All.
Re: Forum code listings : folding + quick selection
Posted: Mon Mar 06, 2017 4:42 am
by Blue
Major thanks for that tip, Davido.
I did change the board style and I do love the Select All feature in code boxes.
But i'm surprised. I had no idea that different board styles offered different functionalities.
I thought styles were purely about looks and colours.
But my wishes still stand:
+ a folding function for code sections
+ a select function for code sections in all board styles
Re: Forum code listings : folding + quick selection
Posted: Mon Mar 06, 2017 5:06 am
by skywalk
+1.
I requested this before since subsilverPlus is my preferred skin.
For now I assign this javascript to a bookmark and click it for pages with Code tags.
It's an extra step, but still saves time.
Code: Select all
javascript:var hoch="95px",select="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAMAAABIK2QJAAAAB3RJTUUH2AYGEg8u3H74gAAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAADAFBMVEVFRUWAAAAAgACAgAAAAICAAIAAgIDAwMDA3MCmyvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAACH5BAEHAAEALAAAAAAKAAoAAAMgGDo8+mEQ4mAUosaGG5sEBjJYWQ5ACmAq8AyddWVy+yQAOw==",expandfunc="\n";expandfunc+="function expand_code(img_id)\n",expandfunc+="{\n",expandfunc+=" var node = document.getElementById(img_id);\n",expandfunc+=' node.src = "'+minus+'" ;\n',expandfunc+=" node.onclick = function() { collapse_code(img_id); };\n",expandfunc+=' var node = document.getElementById("c"+img_id);\n',expandfunc+=' node.style.overflow = "visible";\n',expandfunc+=' node.style.height = "100%";\n',expandfunc+="}\n";var collapsefunc="\n";collapsefunc+="function collapse_code(img_id)\n",collapsefunc+="{\n",collapsefunc+=" var node = document.getElementById(img_id);\n",collapsefunc+=' node.src = "'+plus+'" ;\n',collapsefunc+=" node.onclick = function() { expand_code(img_id); };\n",collapsefunc+=' var node = document.getElementById("c"+img_id);\n',collapsefunc+=' node.style.height = "'+hoch+'";\n',collapsefunc+=' node.style.overflow = "scroll";\n',collapsefunc+="}\n";var selectfunc="\n";selectfunc+="function select_code ( img_id )\n",selectfunc+="{\n",selectfunc+=" if ( window.getSelection() && window.getSelection().removeAllRanges() ) {\n",selectfunc+=" window.getSelection().removeAllRanges();\n",selectfunc+=" }\n",selectfunc+=" div_id = img_id - 1000;\n",selectfunc+=' var node = document.getElementById ( "c" + div_id );\n',selectfunc+=" if ( document.createRange() ){;\n",selectfunc+=" range = document.createRange();\n",selectfunc+=" if ( range.selectNode(node) ){;\n",selectfunc+=" range.selectNode(node);\n",selectfunc+=" };\n",selectfunc+=" };\n",selectfunc+=" if ( window.getSelection() && window.getSelection().addRange( range ) ){\n",selectfunc+=" window.getSelection().addRange( range );\n",selectfunc+=" };\n",selectfunc+="}\n";for(var img_id=0,len=document.getElementsByTagName("div").length,script,i=0;len>i;i++)if("codetitle"==document.getElementsByTagName("div")[i].className){var node=document.getElementsByTagName("div")[i],html=node.innerHTML,count=0,code=0;node.innerHTML="<b>Code :</b>",img_id+=1,select_id=img_id+1e3,code=node.nextSibling,code.innerHTML.split("<br>").length-1>=10&&(node.innerHTML+=' <img id="'+img_id+'" src="'+plus+'" onclick="expand_code('+img_id+')" />',code.style.height=hoch,code.style.overflow="scroll"),code.id="c"+img_id,node.innerHTML+=' <img id="'+select_id+'" src="'+select+'" onclick="select_code('+select_id+')" />'}script=document.createElement("script"),script.innerHTML=expandfunc,script.innerHTML+=collapsefunc,script.innerHTML+=selectfunc,document.body.appendChild(script);
Re: Forum code listings : folding + quick selection
Posted: Mon Mar 06, 2017 5:48 am
by Blue
skywalk wrote:[...]I requested this before since subsilverPlus is my preferred skin.
That was my style of choice until tonight as well.
I only changed it, because of the information provided by Davido.
skywalk wrote:[...]I assign this javascript to a bookmark and click it for pages with Code tags.
Seems like a very smart solution.
And I'd like to be smart too !
However, i have no clue how to use that with Chrome (Windows 10 x64).
Any extra information would be appreciated... and much required
Thank you, Skywalk.
Re: Forum code listings : folding + quick selection
Posted: Mon Mar 06, 2017 3:33 pm
by skywalk
Ha, that is the URL of my bookmark in Chrome on Windows 10 x64. Make a bookmark of some site and edit its properties.