koalyptus / TableFilter

A Javascript library making HTML tables filterable and a bit more :)
https://www.tablefilter.com
MIT License
324 stars 95 forks source link

Doesnt work with html files created in windows #707

Closed Guyver1wales closed 5 years ago

Guyver1wales commented 5 years ago

So I found this script while google searching for a way to make a html table searchable and filterable. I'm a windows server admin and use PowerShell to automate various domain wide tasks. One task I'm currently working on is to pull all certificates from all our domain servers and create a searchable/filterable table so we can search our entire domain for a specific certificate and see how many servers its installed on. All this is fine and I can get the code I want and get it into a complete html document no issues.

My issue is when adding the scripts code to my html output as outlined in the guide. This is what I'm using: `

` I have been tearing my hair out with this all evening and have finally found the issue as I ended up creating two identical files that show as identical in WinMerge. the working file (which is a copy of the Starter.html file with my table copied into it) is showing in winmerge as a file type of: 1252(windows-1252) Unix. My non-working file which wont load the javascipt correctly and allow me to filter my table shows in WinMerge as: 1200(iso-10646-ucs-2 BOM) Win This is the only difference I can find between the two files as they have 100% identical code content. (confirmed with WinMerge) I am creating the html file by running the following in PowerShell and then adding the js script code as outlined in the projects guidance. Get-Service | ConvertTo-Html | Out-File -FilePath 'C:\temp\Services.html'
Guyver1wales commented 5 years ago

I have found a workaround after looking at the documentation for Out-File. I can now get it working if I use Out-File -Encoding ASCII

Get-Service | ConvertTo-Html | Out-File -FilePath 'C:\temp\Services2.html' -Encoding ascii

It would still be interesting to know why this is dependant on the encoding?

koalyptus commented 5 years ago

@Guyver1wales, glad you worked it out. Html markup uses characters < and > to delimit an element, those characters were probably encoded therefore file content wasn't proper html. Just a theory, don't know enough about the techs you are using. TableFilter js lib does not seem to be part of the problem. Cheers

Guyver1wales commented 5 years ago

nothing wrong with the html, that was working perfectly. as I said, WinMerge is showing the code in the html file as being identical. the javascript simply wasn't loading into the page.

For testing I'm just using windows 10 64bit. PowerShell 5.1 and your current latest version.

Steps to replicate:

  1. Download tablefilter and unzip the /tablefilter folder and starter.html to C:\temp so that the javascript filepath is: "C:\temp\tablefilter\tablefilter.js"
  2. double click on starter.html supplied with tablefilter and check it works as expected (it should)
  3. run powershell as admin and run the following command: Get-Service | ConvertTo-Html | Out-File -FilePath 'C:\temp\Services.html'
  4. copy the Githubissues.
  5. Githubissues is a development platform for aggregating issues.