Tablesorter: filtering by multiple, but not all, columns - tablesorter

I'm using tablesorter with an external filter. (ctrl-F 'filter_external') on the linked page. From the docs:
These external inputs have one requirement, they must have a
data-column="#", where the # targets the column (zero-based index),
pointing to a specific column to search.
<input class="search" type="search" data-column="0" placeholder="Search first column">
If you want to search all columns, using the updated "any match"
method, set the data column value to "all":
<input class="search" type="search" data-column="all" placeholder="Search entire table">
What I'd like is to apply my external filter to a collection of columns (more than one, less than all). Ideally, the html could look something like this:
<input class="search" type="search" data-column="0,1" placeholder="Search first two columns">
or this:
<input class="search" type="search" data-column="0" data-column="1" placeholder="Search first two columns">
(Is the second one even valid html?)
I've been up and down the tablesorter docs and I haven't had any luck applying the sort that I want. One workaround that I attempted was to present a single input to the user and have it write to hidden inputs which were bound to their respective columns:
<input class="search" type="search" placeholder="Search first two columns">
// javascript populates the hidden inputs as the user types in the visible one
<input class="search" type="search" data-column="0" style="display: none;">
<input class="search" type="search" data-column="1" style="display: none;">
This 'works', except that it now 'AND's the filtering from each individual filter, so that BOTH columns have to match the search term for the row to remain visible rather than EITHER column matching the search term for the row to remain visible. The data-column="all" option 'OR's the searches - this is what I want.

That's a great suggestion!
I just added the ability to include multiple columns in an external search input. This change is currently only available within the working branch of the repository
With this change, you can include a range, or multiple columns separated by commas (demo):
<input type="search" class="search" data-column="0-1,3,5-7,9">
Note:
This input behaves the same as an input with data-column="all" in that "range", "notMatch" and "operators" searches are ignored.
If multiple inputs exist, the last search will override all previous searches.
All spaces in the data-column attribute are ignored.

Related

importXML xpath to google sheets returns #N/A

Under the following span class I am looking to extract the number (416) 123-1234. This number is written after data-number or at the end of the span.
<span class="_Xbe _ZWk kno-fv"> ## The Unique ID is _Xbe _ZWk kno-fv
<a class="fl r-idASUKPhOV34" href="#" data-number="+14161231234" data-pstn-
-call-url="" title="Call via Hangouts" jsaction="r.oVdbr2mIpA8"
data-rtid="idASUKPhOV34" jsl="$t t-6xg4lalHw8M;$x 0;" data-ved="0ahUKEwiDtKTG-snZAhUDzIMKHcntCfAQkAgImAEoADAU">(416) 123-1234</a></span>
The problem comes from the XPATH, I am not specifying the right xpath, I tried to copy xpath from the source code and it returned #N/A. My best guess is the following xpath with importxml, though it still returns #N/A.
=IMPORTXML("https://www.google.com/search?q="&A10,"//span[#class='_Xbe _ZWk kno-fv']/a/#href")
How can I write XPATH to extract the number in either form?

Retrieve contents of a tag using XPath in Google Sheets, but *not* the contents of nested/child tags

I'm trying to retrieve one portion of a <h1> tag using the Google Sheets IMPORTXML function. The funtion below gets everything within the <h1>, but I only want the text starting at Lenovo..... and ending at Silver. I do not want the Item #... that is in the nested <span>.
Is there a way to get the <h1>, but ignore the nexted span?
Working Function
=IMPORTXML("https://www.officedepot.com/a/products/"&A2,"//div[#id='skuHeading']/h1[#class='semi_bold fn']")
Structure
<div id="skuHeading" data-auid="productDetail_text_skuDescription">
<h1 itemprop="name" class="semi_bold fn">
Office DepotĀ® Brand White Copy Paper, Letter Paper Size, 20 Lb, 500 Sheets Per Ream, Case Of 10 Reams
<small class="item_sku" data-auid="productDetail_text_sku">
<span itemprop="sku">
Item # 273646
</span>
</small>
</h1>
</div>

UI Bootstrap typeahead sorting

I'm using the excellent 'typeahead' control from angular-ui-bootstrap (http://angular-ui.github.io/bootstrap/#/typeahead). My HTML looks like this:
<input type="text" ng-model="selected"
typeahead="location.name for location in cities
| filter:$viewValue
| limitTo:8" class="form-control"
placeholder="City" ng-model="citysearch">
My problem is how alternatives are sorted. I would like alternatives starting with the typed text to appear on top, but instead other alternatives which merely contain the typed text (sometimes) appear first. For example, consider the following available cities.
New York
London
Los Angeles
Washington
Stockholm
If I type 'S' I would expect Stockholm to appear first, but instead Los Angeles And Washington are first. (Probably because they come before Stockholm in the original array.)
Can I somehow configure this behavior in the typeahead control?
Thanks,
Daniel

Ruby pluck second number from this scraped HTML (wombat)

Here's a section of HTML I'm trying to pull some info from:
<div class="pagination">
<p>
<span>Showing</span>
1-30
of 3744
<span>results</span>
</p>
</div>
I just want to store 3744 from the bit I pull (everything inside the <p>), but I'm having a hard time since the of 3744 doesn't have any CSS styling and I don't understand XPaths at all :)
<span>Showing</span>1-30\nof 3744<span>results</span>
How would you parse the above string to only retrieve the total number of results?
As long as it always looks the same you could also use #scan to get just the last number.
str = '<div class="pagination">
<p>
<span>Showing</span>
1-30
of 3744
<span>results</span>
</p>
</div>'
str.scan(/\d+/).pop.to_i
#=> 3744
Update Explanation of how it works
The scan will pull an Array of all the numbers e.g. ["1","30","3744"] then it will pop the last element from the Array "3744" and then convert that to an integer 3744.
Please note that if the number you want is not the last element in the Array then this will not work as you want e.g.
str = '<div class="pagination">
<p>
<span>Showing</span>
1-30
of 3744
<span>results 14</span>
</p>
</div>'
str.scan(/\d+/).pop.to_i
#=> 14
As you can see since I added the number 14 to the results span this is now the last number in the Array and your results are off. So you could modify it to something like this:
str.gsub(/\s+/,'').scan(/\d+-\d+of(\d+)/).flatten.pop.to_i
#=> 3744
What this will do is remove all spaces with gsub then look for a pattern that equates to something along the lines of #{1,}-#{1,}of#{1,} and capture the last group #=> [["3744"]] then flatten the Array #=> ["3744"] then pop and convert to Integer. This seems like a better solution as it will make sure to match the "of ####" section everytime.
Use regexp look example Rubular:
<span>\w+<\/span>\d\-\d+\\[a-z]+\s(\d+)<span>\w+<\/span>
Match groups:
3744

Parsing text content in ColdFusion

I am attempting to parse text from a <cfoutput query="...">. I am interested in finding the number of times every word in the text is displayed. For example:
"My name is Bob and I like to Bob".
should result in
Bob - 2
Name - 1
etc, etc, etc.
I take my <cfoutput> from a twitter RSS feed. Here is my code:
<blink>
<cfset feedurl="http://twitter.com/statuses/user_timeline/47847839.rss" />
<cftry>
<cffeed source="#feedurl#" properties="feedmeta" query="feeditems" />
<cfcatch></cfcatch>
</cftry>
<ol>
<cfoutput query="feeditems">
#content# #id# <br><br>
</cfoutput>
</ol>
</blink>
I output a pretty great ordered list, but I can't figure out for the life of me how to parse the content and list how many times each word is used.
Thanks for any help you can provide, I am new to these forums!
You can find a solution here:
http://www.coldfusionjedi.com/index.cfm/2007/8/2/Counting-Word-Instances-in-a-String
Basically, split the string up using regex and then loop over the results. There are some darn good comments here as well.

Resources