topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday May 22, 2024, 10:55 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ProCompSys [ switch to compact view ]

Pages: [1]
1
Thank you for the warm welcome! To both of you. :-)
I'm still quite overwhelmed, especially as my contribution was just a q'n'd quick shot from the hip without any claim to clean style whatsoever.
It would make me very happy to see an approach to my "remember and restore explorer-windows"-idea.
Thanks and greetings!

2
I'm new to DC and besides an up to now unanswered "IDEA" I think this was my first reply to a question.
At this moment I was actually still in a phase of trying to figure out what that "180 credits" means in RL.
Working in a full-time position, I just didn't have the time yet to figure it out... except for that help-page "What are DonationCredits?".
Just from skimming over the text, I got the impression that this would represent real money.
Though I'm still not quite sure about it and still expect a catch to it, I do come to the conclusion that the amount is exceptional.
Being used to some standard discussion-boards, I kinda feel a little uncomfortable with the turnout and suspect there might as well be a typo on the part of @OptimalDesigns.
If so, please let me know!
Best Regards!

3
It is up and working!  Thanks for all your help, Phil

Check your donation account for 180 'credits'
-OptimalDesigns (July 12, 2023, 11:42 AM)

Pleased I could help.
Thanks a lot!

4
[...]
I have several <tables> on one webpage, so your general <scripts> and <styles> don't work as stated.
-OptimalDesigns (July 11, 2023, 12:31 PM)

When using different tables, you can restrict your button design to only this table by giving your table an id like
<table id="table01" ... >
and then assigning your css to only that table by
<STYLE TYPE="text/css">
  #table01 button.btn1 {border: 1px solid red;}
</STYLE>
In this example, red borders are only applied to button-tags, that have the class "btn1",
and only if that button in within an element, that hat the ID "table01".
So buttons within other tables are not affected by that css-definition.


My buttons colors are set as:
<style>
.btn1 {background-color: #4CAF50;} /* Green */
.btn2 {background-color: #008CBA;} /* Blue */
</style>
Which may explain why no lightgray came thru, true?

-OptimalDesigns (July 11, 2023, 12:31 PM)
True.
Try removing the background-style and the browser's standard display for buttons should be applied.

5
Looks like this:

screenshot.002.png


I added another line with filename(s) "def".
To avoid errors when clicking, the filenames have to exist, of course. At least as dummy-files.

Code like this:



Code: HTML5 [Select]
  1.    <head>
  2.       <STYLE TYPE="text/css">
  3.          td {
  4.             padding:10px;
  5.          }
  6.          
  7.          .button {
  8.             padding: 6px 16px;
  9.             border: 1px solid green;
  10.             border-radius: 0 8px 8px;
  11.             box-shadow: 0 lpx 5px gray;
  12.             color: white;
  13.             text-shadow: 0 -1px 1px #333;
  14.             font-size: 20px;
  15.             line-height: 30px;
  16.             background: #5a9900 linear-gradient(#8db243, #5a9900);
  17.          }
  18.          
  19.          .button:disabled {
  20.             background: #808080 linear-gradient(#C0C0C0, #808080);
  21.          }
  22.          
  23.       </style>
  24.    
  25.       <script type="text/javascript">
  26.          function dNdB(whichOne) {
  27.             // read VALUE-attribute to get filetype
  28.             fileType=document.getElementById(whichOne).value;
  29.            
  30.             // read TITLE of parent-node (TR) to get filename (without extension)
  31.             fileName=document.getElementById(whichOne).parentNode.parentNode.getAttribute("title");
  32.            
  33.             // creating fileUrl from fileName + "." + fileType
  34.             fileUrl=fileName + "." + fileType;
  35.            
  36.             // for testing purposes
  37.             // alert(fileUrl);
  38.            
  39.             // open new tab/window to download the file
  40.             window.open(fileUrl,"_blank");
  41.            
  42.             // disable the button that was clicked
  43.             document.getElementById(whichOne).setAttribute("disabled", "");
  44.          }
  45.       </script>
  46.    
  47.    </head>
  48.  
  49.    <body>
  50.  
  51.       <table border="1">
  52.          <tr class="topic" title="abc">
  53.             <td>
  54.                Descript 1 [abc]
  55.             </td>
  56.             <td>
  57.                <button id="btn1-1" class="button btn1" value="ppt" onClick="dNdB(this.id);">PPT</button>
  58.             </td>
  59.             <td>
  60.                <button id="btn2-1" class="button btn2" value="pdf" onClick="dNdB(this.id);">PDF</button>
  61.             </td>
  62.             <td>
  63.                <button id="btn3-1" class="button btn3" value="doc" onClick="dNdB(this.id);">DOC</button>
  64.             </td>
  65.          </tr>
  66.          <tr class="topic" title="def">
  67.             <td>
  68.                Descript 2 [def]
  69.             </td>
  70.             <td>
  71.                <button id="btn1-2" class="button btn1" value="ppt" onClick="dNdB(this.id);">PPT</button>
  72.             </td>
  73.             <td>
  74.                <button id="btn2-2" class="button btn2" value="pdf" onClick="dNdB(this.id);">PDF</button>
  75.             </td>
  76.             <td>
  77.                <button id="btn3-2" class="button btn3" value="doc" onClick="dNdB(this.id);">DOC</button>
  78.             </td>
  79.          </tr>
  80.       </table>
  81.  
  82. </body>
  83.  
  84. </html>

6
After a little thinking and re-reading, I now think I understand what you mean by putting filename in TR and filetype in TD/BUTTON:
The filename stays identical whithin a row, just the fileformat changes over the columns, right?
Would be possible, but... this appears a little too much 'over the top' of compressing code and avoiding redundancy.
I could try to make it work... shouldn't be much of a deal... but... really?  :-\

7
It kinda worked.  Here is a list of things needing some work on:
1. It opened the file, but no saved download file.  Anyway for both?
-OptimalDesigns (July 11, 2023, 09:31 AM)
What (kind of) file?
As mentioned before, it depends on the browser how to handle the file... PDFs might be opened right away within the browser as "PDF preview". If all else fails, try a zipped version of the file to download. In my case a "Save as..." dialogue-window was opened by the browser in the first place.

2. How to change background-color to lightgray for 'this.id' button?
-OptimalDesigns (July 11, 2023, 09:31 AM)
The button design ist determined by the browser, if no special format is defined.
But you can change the appearance using CSS-code.
Though in my case, the button WAS changed to light grey (see screenshot).

screenshot.001.png

Dealing with CSS (cascading style-sheets) is not really complicated, but if you're completely new to that matter it might need some work on the basics to it.
See updated source-code below.
I put some CSS-code for the buttons in the HEAD-section,
referencing the BUTTON-class via the .button-section (mind the dot at the beginning!) as such (i.e. for all buttons),
and another class called  .btn1 that only applies to the first button, as the second one has the class "btn2" (all taken from your original template).
If you're not familiar with CSS - at least with the basics - this might not be the best time to go for it, if you need fast results with your button-page... you might get lost in the middle of nowhere. ;-)




<html>
   <head>
      <STYLE TYPE="text/css">
         td {
            padding:10px;
         }
         
         .button {
            padding: 6px 16px;
            border: 1px solid green;
            border-radius: 0 8px 8px;
            box-shadow: 0 lpx 5px gray;
            color: white;
            text-shadow: 0 -1px 1px #333;
            font-size: 20px;
            line-height: 30px;
         }
         
         .btn1 {
            background: #5a9900 linear-gradient(#8db243, #5a9900);
         }
         
         .btn1:disabled {
            background: #808080 linear-gradient(#C0C0C0, #808080);
         }
         
         .btn2 {
            background: #5a3300 linear-gradient(#8db243, #5a3300);
         }
         
      </style>
   
      <script type="text/javascript">
         function dNdB(whichOne) {
            // read VALUE-attribute to get link to file
            fileUrl=document.getElementById(whichOne).value;
           
            // open new tab/window to download the file
            window.open(fileUrl,'_blank');
           
            // disable the button that was clicked
            document.getElementById(whichOne).setAttribute("disabled", "");
         }
      </script>
   
   </head>

   <body>

      <table border="1">
         <tr class="topic">
            <td>
               Descript 1
            </td>
            <td>
               <!-- <a href="abc.ppt" download></a> -->
               <button id="btn1-1" class="button btn1" value="abc.ppt" onClick="dNdB(this.id);">PPT</button>
            </td>
            <td>
               <!-- <a href="abc.pdf" download></a> -->
               <button id="btn2-1" class="button btn2" value="abc.pdf" onClick="dNdB(this.id);">PDF</button>
            </td>
         </tr>
      </table>

</body>

</html>




3. Any way to put 'onClick="dwldAndDisableButton(this.id);" ' cmd in <table> cmd?  This takes up a lot of room and is redundant.  Presently there are 20+ rows of these and more may be coming.  Plus, another type of filetype may be added; giving another column of buttons.
-OptimalDesigns (July 11, 2023, 09:31 AM)
Uhm... no, I don't think so.
It's actually no big difference to a standard A-HREF-tag. There you would have to put in the URL anyway. This is not more or less redundant than the  'onClick="dwldAndDisableButton(this.id);" '.
And I guess, there's more redundancy in all the TR- and TD-tags of a TABLE anyway. ;-)

You only have one TABLE, but 20+ ... 40+ ... buttons. How would you distinguish the URLs?
You can of course rename the function "dwldAndDisableButton()" to something shorter... like "dNdB()" or even just "x()". But from the view of a programmer, always try to name your variables and function to something intuitive and self-explaining, so you don't get lost in your code if you want to change it in two years, when you have to work yourself through understanding your own code.

You could though put all the URLs into the HEAD/SCRIPT-section, where your function is.
You could put all the URLs there in variables like
   URL01=abc.ppt
   URL02=abc.pdf
   URL03=...
and so on.
Then you could call your function within your "onClick" by
   onClick="dNdB(this.id,'URL01')"
But I see no point in this, as on the one hand it doesn't really make your code shorter (as you now have to pass two arguments to your function, one to tell the button-ID to change the button-style and one to define the URL), and on the other hand you produce "overhead" in the function itself, because every time you call the function, all your URL-variables have to be initialized of which you only need one.
Imagine a page with 500 buttons, thus 500 URL-variables in your function. Every time you click a button, all 500 URL-variables are parsed, and then you select one of them... no very performant.
Just tell the function what URL you want in the first place.



4. Any way to save filename in <tr> and pass it on to <button> cmd.s as it is redundant too.  Will need to merge filename & filetype in <button> cmd.
-OptimalDesigns (July 11, 2023, 09:31 AM)
Filename in TR? From the original template, there's 2 button in a table-row (TR) with different URLs.
So there would have to be two URLs in one TR-tag that would have to be distinguished from one another.
Does not appear plausible to me.
You could put the URL in the table-data (TD = table-cell), as there is one button per TD, but what's the use? The amount of code stays the same if I move the URL from the BUTTON-tag to the TD-tag.
Same with TR... just cumulating two URLs from the buttons to two URLs in the TR surrounding it.
Just needs some additional JS-code to get from 'this.id' (i.e. the button) to the parent-element 'TD' and/or the parent-element of that, the 'TR'.

Don't get me wrong, there are ways of optimizing this and maybe making the code a little more compact, but that would need a database-system with PHP or ASP or similar. And I guess we're FAR away from that point where you want to setup a PHP-server or something like that.




8
Hi,
my five cent to this topic:

First, delete those A-Tags, just keep the BUTTON-Tags.
Then add a VALUE-Attribute to the BUTTON-Tags that keep the URL of the file you want to download.
In the OnClick-attribute, we start a small JavaScript that is nested in the HEAD-section of the HTML-file.
The script does 2 things:
1. it opens a new browser-tab (on older browsers a new window) and directs it to the file to download
2. it sets a new attribute to the button called "disabled". This does exactly what it sounds like... it disables the button ;-)

You can probably replace
window.open(fileUrl,'_blank');
with
window.open(fileUrl,'');
to not open the download in a new tab/window.
But please test with PDF-files, as current browsers tend to open PDFs within the browser... you might end up having to click the back-button to get back to your page. In that case you might have to stick to the "open in new tab" version.

<html>
   <head>
      <STYLE TYPE="text/css">
         td {
            padding:10px;
         }
      </style>
   
      <script type="text/javascript">
         function dwldAndDisableButton(whichOne) {
            // read VALUE-attribute to get link to file
            fileUrl=document.getElementById(whichOne).value;
           
            // open new tab/window to download the file
            window.open(fileUrl,'_blank');
           
            // disable the button that was clicked
            document.getElementById(whichOne).setAttribute("disabled", "");
         }
      </script>
   
   </head>

   <body>

      <table border="1">
         <tr class="topic">
            <td>
               Descript 1
            </td>
            <td>
               <!-- <a href="abc.ppt" download></a> -->
               <button id="btn1-1" class="button btn1" value="abc.ppt" onClick="dwldAndDisableButton(this.id);">PPT</button>
            </td>
            <td>
               <!-- <a href="abc.pdf" download></a> -->
               <button id="btn2-1" class="button btn2" value="abc.pdf" onClick="dwldAndDisableButton(this.id);">PDF</button>
            </td>
         </tr>
      </table>

</body>

</html>


First, we define a function named "dwldAndDisableButton" that does the magic.
In the OnClick-attribute of the button(s) we call this function with a parameter... "this.id"... it tells the function which button was pressed by specifying THIS element of the page (that was clicked = the clicked button) and the individual ID, so that the function knows exactly where to look for the URL that needs to be downloaded.

The function then uses "getElementById" to find the clicked element within the page and reads the content of the VALUE-attribute, that - in our case - contains the needed URL.
It then opens a new tab/window with that URL... resulting in a download.

Finally, the function uses "getElementById" again, to add the attribute DISABLED to the button.

Done.

9
Dear Coders,
for a long time I've been missing and searching for a little helper-tool to remember my opened Explorer-windows, so it can restore them after a reboot or Explorer-crash.
For simple reboots, Windows is usually able to restore those windows after next logon, but if the explorer-process crashes before reboot (or in the middle of the session), those opened windows are usually gone.

Usually - and I guess I'm not the only one - I have around 5 to 15 explorer-windows opened I'm working with. Files, projects, tools... Some of them are mostly always the same windows/paths, others change every now and then with changing projects etc.
And a crashing explorer.exe - be it in the middle of my work or after Windows tells me to NOW do a reboot after updates etc. - usually kills the Windows-feature to "restore explorer-windows after reboot".

For some time I tried to keep track with a text-file, where I kept my paths of opened explorer-windows, but keeping it up manually is quite a pain in the neck.
Also tried putting shortcuts on my desktop... that's actually what they're intended for, right? But it's just not quite what I have in mind, as I have to maintain them manually as well.

A nice tool I use on a quite regular basis is "Rexplorer". It kills the explorer-process and restarts it, but other than what you can do manually with taskmanager (kill, then manually start again), it remembers which explorer-windows were open and it restores them. Nice!
So there obviously has to be a way to detect and remember a list of opened windows.

In addition I've been using a little piece of software ("DesktopOK") for a long time, that remembers the icon-layout on my desktop. With two screens and somewhat around 50 links, files and folders on my desktop, it's quite nice to have this little helper in the systemtray, that keeps track of the last few desktop-layouts / icon-arrangements and can restore them with one mouse-click. It can even automatically "save before reboot/shutdown" and automatically "restore saved profile on logon".

Now that's what I really need for opened explorer-windows!
It just sits in the tray, keeps a list of the paths of opened explorer-windows, remembers the last changes (at least, when I tell it to do so, nice if it also checks and saves automatically like every 30 minute sor so),
and if I feel the need, I just klick the tray-icon, it shows me a list of the last saved "profiles" and I can select one to restore and re-open those explorer-windows with their saved paths... either after an explorer-crash or after a reboot.

That would really be bliss!
Anyone else thinks, this might be a nice idea and/or feels the need for something like this?

Pages: [1]