Jump to content

smus

Members
  • Content Count

    165
  • Joined

  • Last visited

Everything posted by smus

  1. Server settings, try absolute address
  2. For the default value, you should simply add value="yourdefaultvalue" to your input tag. What do you want to display "LHS,RHS" in your code, when datalist is set to "initial or awlays"?
  3. var pageBreak = document.getElementById("pageBreak") All var declarations must be inside the function
  4. vmars316, not working at all or with errors? Looks like collectedTextareas variable was not initialized
  5. Thanks very much for the idea! Used this function for sorting the array: function arraysort(s) length = ubound(s) for i = 0 to length for j = 0 to length if s(i)<s(j) then t = s(i) s(i) = s(j) s(j) = t end if next next arraysort = s end function
  6. You mean I place them in an array, sort the elements as I want and display them in that order? That makes sense. Because now it only iterates through the folders and prints it out as it was returned from the file system.
  7. <%@LANGUAGE="VBSCRIPT"%> <% Option Explicit On Error Resume Next ' this section is optional - it just denies anonymous access ' If Request.ServerVariables("LOGON_USER")="" Then ' Response.Status = "401 Access Denied" 'End If ' declare variables Dim objFSO, objFolder Dim objCollection, objItem Dim strPhysicalPath, strTitle, strServerName Dim strPath, strTemp Dim strName, strFile, strExt, strAttr Dim intSizeB, intSizeK, intAttr, dtmDate ' declare constants Const vbReadOnly = 1 Const vbHidden = 2 Const vbSystem = 4 Const vbVolume = 8 Const vbDirectory = 16 Const vbArchive = 32 Const vbAlias = 64 Const vbCompressed = 128 ' don't cache the page Response.AddHeader "Pragma", "No-Cache" Response.CacheControl = "Private" ' get the current folder URL path strTemp = Mid(Request.ServerVariables("URL"),2) strPath = "" Do While Instr(strTemp,"/") strPath = strPath & Left(strTemp,Instr(strTemp,"/")) strTemp = Mid(strTemp,Instr(strTemp,"/")+1) Loop strPath = "/" & strPath ' build the page title ' strServerName = UCase(Request.ServerVariables("SERVER_NAME")) strTitle = "sitelist" ' create the file system objects strPhysicalPath = Server.MapPath(strPath) Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPhysicalPath) %> <html> <head> <title>The list of websites available</title> <base target="blank"> <style> BODY {background: hsl(24, 100%, 70%); } a {text-decoration:none;} a:hover {color:darkred;font-weight:600;} a:active {text-decoration:none;} </style> </head> <body class="w3-container"> <br> <h2 align="center"><%=strTitle%></h2> <div align="center"><center> <table border="0" cellspacing="0" cellpadding="2" style="BACKGROUND: #000000; width:70%"> <!-- <tr> <th align="left">Name</th> <th align="left">Bytes</th> <th align="left">KB</th> <th align="left">Attributes</th> <th align="left">Ext</th> <th align="left">Type</th> <th align="left">Date</th> <th align="left">Time</th> </tr> --> <% '''''''''''''''''''''''''''''''''''''''' ' output the folder list '''''''''''''''''''''''''''''''''''''''' Set objCollection = objFolder.SubFolders For Each objItem in objCollection strName = objItem.Name strAttr = MakeAttr(objItem.Attributes) dtmDate = CDate(objItem.DateLastModified) %> <tr> <td align="center" style="background: hsl(60, 100%, 75%);COLOR: #000000;font-family:courier;font-size:20px;"><a class="link hvr-underline-from-center" href="<%=strName%>"><%=strName%></a></td> <!-- <td align="right">N/A</td> <td align="right">N/A</td> <td align="left"><tt><%=strAttr%></tt></td> <td align="left"><b><DIR></b></td> <td align="left"><b>Directory</b></td> <td align="left"><%=FormatDateTime(dtmDate,vbShortDate)%></td> <td align="left"><%=FormatDateTime(dtmDate,vbLongTime)%></td> --> </tr> <% Next %> <!-- <% '''''''''''''''''''''''''''''''''''''''' ' output the file list '''''''''''''''''''''''''''''''''''''''' Set objCollection = objFolder.Files For Each objItem in objCollection strName = objItem.Name strFile = Server.HTMLEncode(Lcase(strName)) intSizeB = objItem.Size intSizeK = Int((intSizeB/1024) + .5) If intSizeK = 0 Then intSizeK = 1 strAttr = MakeAttr(objItem.Attributes) strName = Ucase(objItem.ShortName) If Instr(strName,".") Then strExt = Right(strName,Len(strName)-Instr(strName,".")) Else strExt = "" dtmDate = CDate(objItem.DateLastModified) %> <tr> <td align="left"><a href="<%=strFile%>"><%=strFile%></a></td> <td align="right"><%=FormatNumber(intSizeB,0)%></td> <td align="right"><%=intSizeK%>K</td> <td align="left"><tt><%=strAttr%></tt></td> <td align="left"><%=strExt%></td> <td align="left"><%=objItem.Type%></td> <td align="left"><%=FormatDateTime(dtmDate,vbShortDate)%></td> <td align="left"><%=FormatDateTime(dtmDate,vbLongTime)%></td> </tr> <% Next %> --> </table> </center></div> <br><br> </body> </html> <% Set objFSO = Nothing Set objFolder = Nothing ' this adds the IIf() function to VBScript Function IIf(i,j,k) If i Then IIf = j Else IIf = k End Function ' this function creates a string from the file atttributes Function MakeAttr(intAttr) MakeAttr = MakeAttr & IIf(intAttr And vbArchive,"A","-") MakeAttr = MakeAttr & IIf(intAttr And vbSystem,"S","-") MakeAttr = MakeAttr & IIf(intAttr And vbHidden,"H","-") MakeAttr = MakeAttr & IIf(intAttr And vbReadOnly,"R","-") End Function %> I am using the code above (in a separate index.asp file) to list all the subfolders in a current folder. It works under IIS and displays the names of all the subfolders (as a hyperlinks to browse to a subfolder). It always sorted them alphabetically (a - z), but now (after folders restoration) it started to add new folders to the bottom of the list, regardless of their name. I've already tried many things: restarted IIS, changed folders attributes etc., but it is the same, however, it works properly on the external webhosting service. What can be wrong? IIS settings? I've changed the file system when I was restoring those folders and files, from NTFS to exFAT, might that be the probable reason?
  8. I am not really into Linux shell system, but if you don't want to use PHP, other server side languages might be the alternative
  9. Try using Server side JavaScript (node.js)
  10. smus

    Table Sort

    Solved it! I was unattentive to include the additional <span> tag inside <td></td> (for the styles). It sorts normally without it, or with it if we use innerText instead of innerHTML
  11. smus

    Table Sort

    <!-- the table header --> <table class='i´╗┐ndextable' align='center'><th onclick='sortTable(this.parentNode.parentNode,0)'>Subject</th><th onclick='sortTable(this.parentNode.parentNode,1)'>Questions</th><th>Edit</th> <!-- the javascript function --> <script> function sortTable(t,n) { var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0, intx, inty; table = t;//document.getElementsByClassName("indextable")[0]; switching = true; // Set the sorting direction to ascending: dir = "asc"; /* Make a loop that will continue until no switching has been done: */ while (switching) { // Start by saying: no switching is done: switching = false; rows = table.rows; /* Loop through all table rows (except the first, which contains table headers): */ for (i = 1; i < (rows.length - 1); i++) { // Start by saying there should be no switching: shouldSwitch = false; /* Get the two elements you want to compare, one from current row and one from the next: */ x = rows.getElementsByTagName("TD")[n]; y = rows[i + 1].getElementsByTagName("TD")[n]; /* Check if the two rows should switch place, based on the direction, asc or desc: */ if (dir == "asc") { if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { // If so, mark as a switch and break the loop: shouldSwitch = true; break; } } else if (dir == "desc") { if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { // If so, mark as a switch and break the loop: shouldSwitch = true; break; } } } </script>
  12. smus

    Table Sort

    What I am doing is that I am only adding the condition. If it is the second row of the table (n==1), convert the x.innerHTML to an integer value using parseInt or Number. It does not react onclick, but the first row keeps on sorting the values out.
  13. smus

    Table Sort

    Here's the code: <!-- the table header --> <table class='indextable' align='center'><th onclick='sortTable(this.parentNode.parentNode,0)'>Subject</th><th onclick='sortTable(this.parentNode.parentNode,1)'>Questions</th><th>Edit</th> <!-- the javascript function --> <script> function sortTable(t,n) { var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0, intx, inty; table = t;//document.getElementsByClassName("indextable")[0]; switching = true; // Set the sorting direction to ascending: dir = "asc"; /* Make a loop that will continue until no switching has been done: */ while (switching) { // Start by saying: no switching is done: switching = false; rows = table.rows; /* Loop through all table rows (except the first, which contains table headers): */ for (i = 1; i < (rows.length - 1); i++) { // Start by saying there should be no switching: shouldSwitch = false; /* Get the two elements you want to compare, one from current row and one from the next: */ x = rows.getElementsByTagName("TD")[n]; y = rows[i + 1].getElementsByTagName("TD")[n]; /* Check if the two rows should switch place, based on the direction, asc or desc: */ if (dir == "asc") { if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { // If so, mark as a switch and break the loop: shouldSwitch = true; break; } } else if (dir == "desc") { if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { // If so, mark as a switch and break the loop: shouldSwitch = true; break; } } } </script>
  14. smus

    Table Sort

    ? It continues sorting the column with numbers as if it's text, despite the conversion (text to number)
  15. smus

    Table Sort

    Hi, I need your hint. I am using table sort from this w3schools example: https://www.w3schools.com/howto/howto_js_sort_table.asp There is a table with 2 columns, the first contains text data, the second - numbers. I want the second one to be sorted as integers, but it doesn't work when I convert a string to number like this: if(n === 1){x = parseInt(x.innerHTML)} or number(x.innerHTML) n is the column id starting from zero
  16. justsomeguy is right, if you have complex data, better to store it in a database, server-side or client-side. Even HTML5 (using JS) has a way to store data called webstorage. Choose the way that suits you best
  17. Can you explain what you want?
  18. <input type="text" onkeyup="thenameofthefunction()"> <input type="text" onclick="thenameofthefunction()">
  19. smus

    Web Workers

    HTML Web Workers are using JavaScript code to run. Why Web Workers need to be used only under a server then? I tried launching .html file separately and they don't work.
  20. smus

    Object's key names

    Yeah, true, same info is on StackOverflow: different implementatoins of recursive approach. Strange that ES6 doesn't have a built-in function or method for it. Object.hasOwnProperty is only for the upper-level keys which makes it useless for structured objects.
  21. const data = { level1: { level2: { level3: 'some data' } } }; Is there a way to get the names of all the keys (at any level) in that object without using a recursion? (level1, level2, level3)
  22. smus

    Hex to ASCII

    Yeah, I agree. It's pretty straightforward
  23. But it's fast! Have any of you tried AkelPad? I like it. It is simple, fast and if you need any of that options as highlighting, they are represented as plug-ins, so you can switch them on.
  24. <button onclick="someFunction()">button</button> Have you added the quotes? The function starts on the page load?
×
×
  • Create New...