How can I search for a specific fiddle in my JSFiddle? - jsfiddle

I really like JSFiddle, and I used it a lot.
At this moment, I have about 80 fiddles that I created/forked in my JSFiddle dashboard. I have to go through 8 pages to look for a specific fiddle using my eyes to scan through each title.
I might be doable since I only have 80 fiddles, but what if I have 500 or 2000 fiddles by next year ? That will take me forever to scan though each title with my eyes. I'm seeking a better way to deal with this.
Is there a way to search for a specific fiddle without having to go through all the pagination and scan through each title ?
Any tips on that will be much appreciated.

I had the same problem as you so I've created a fiddle to search in my list of fiddles :)
http://jsfiddle.net/panzerkunst/77fgau53/show/
It uses the JSFiddle API to get back your list of fiddles
$.ajax(
{
url: "http://jsfiddle.net/api/user/"+this.username+"/demo/list.json",
data: {
limit:this.limit
},
dataType: "JSONP",
jsonp: "jsoncallback",
type: "GET"
}
)
.done(this.dataReceived.bind(this))
.fail(this.errorHappened.bind(this))
.always(this.resetControls.bind(this));
and then the list is filtered based on the keyword you provide.
dataReceived: function(data){
var query = this.query;
var filtered = _.filter(data.list, function(item){if(item.title.contains(query) || item.description.contains(query)){ return item}});
[...]
}
Hope this helps !
Nicolas
UPDATE: to make it work with your fiddles, you have to change the username passed to the .initialize() method. http://jsfiddle.net/panzerkunst/77fgau53/

Not sure if anyone still ends up here, but I forked Nicolas Bauwens jsfiddle (by panzerkunst) and updated it a bit.
Easily enter any jsfiddle username, then search/filter in either jsfiddle title or text (or leave empty to just show all), and then shows fiddle results in a table with details and clickable links.
https://jsfiddle.net/ElMoonLite/dgfs9aqv/
Should be useable by anyone without the need to install anything.
Core functionality based on:
$.ajax({
url: "https://jsfiddle.net/api/user/" + this.getUsername() + "/demo/list.json",
data: {
limit: 1000
},
dataType: "JSONP",
jsonp: "jsoncallback",
type: "GET"
})
(and then some string matching for search/filter)
More info about the API used:
https://docs.jsfiddle.net/api/displaying-user-fiddles

Related

discord.py Extracting information from api with query parameters

I'm quite new to the aspect of using API with discord.py and I seem to be having issues when it comes to extracting data with query parameters.
My code is as follows:
#command(name="characterID", aliases=["cid"])
async def character_info(self, ctx, characterID):
URL="https://c2s1.op-framework.com/op-framework/character.json"
async with request("GET", URL, headers={}, params=characterID) as response:
if response.status == 200:
data = await response.json()
substring = data["data"]
await ctx.send(f"The CID {characterID} has the following info:\n{substring}")
My goal here is to extract information from a certain character ID but upon running my command I end up with substring = []. I've been reading the documentation and I can't seem to understand what I'm doing wrong. If someone could enlighten me in the right direction it would be much appreciated.
I am provided with the following documentation:
/character.json - > Returns information about a certain character.
Query parameters:
FIELD: characterId TYPE:integer DESCRIPTION: The character id you need information about.
The expected output for substring should be something like this:
[
{
"steamIdentifier": "steam:11000010d322da9",
"firstName": "Kye",
"lastName": "Clancy",
"fullName": "Kye Clancy"
}
]
If my problem is unclear or needs further details as to what I have tried so far feel free to let me know and thank you.

Why is yadcf custom_filter not working?

Fiddle: https://codepen.io/MBaas/pen/rpZZzd
I have a Datatable about newspapers endorsements for presidential candidates that I want to filter on the party - a value that is not contained in the table (I have shortcodes "D" or "R" in the table but would like to use text "Democrat" or "Republican" in the UI).
This may have once worked (I think it did) - but after upgrading to beta 0.9.1 it stopped. Possibly a bug in the beta - or possibly an undetected bug in my code?
My fn:
function myCustomFilterFunction(filterVal,columnVal,rowValues,stateVal)
{
console.log(rowValues);
console.log(filterVal+'/'+columnVal);
if (columnVal === '') { return true;}
return -1 < columnVal.search(filterVal);
}
I had added the log for debugging purposes and it produced this output (excerpt):
["Wisconsin State Journal", "2016", "Clinton", "", "", "", ""]
"D/"
I was surprised to see columnVal being empty. That explained filtering not working, and it being empty can be explained by looking at rowValues. But given that the source-data was defined in JSON as
["Wisconsin State Journal",2016,"Clinton","http:\/\/host.madison.com\/wsj\/opinion\/editorial\/our-endorsement-hillary-clinton-america-must-get-this-right\/article_b526fe64-c2ca-5e3d-807a-0ef4ae23a4d5.html","","","D"]
this is odd. Could it be related to the fact that the column is not visible?
You should make column containing party short code searchable with searchable: true option otherwise your custom filtering function won't work.
For example:
{"searchable":true, "title":"Party (Shortcode)", "visible":true}
See updated example for code and demonstration.

m.request: use URL which contains colons

I have a m.request call like this:
mCmdName = "cn:cmd:list:deselectAll";
m.request({
method : "POST",
url : "/testing/cmd/" + mCmdName,
data: data
});
Now m.request calls
xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data);
and tries to replace all ':[name]' parts with data[name] which results in 'undefined' as data doesn't contain any of the keys. Data is just the data object of the XHR request.
Is there a way to prohibit this default behavior?
Thanks, Stefan
PS: I'm asking here and not in mithril mailing list because I can't post there for incomprehensible reasons. Maybe somebody can give me a hint on this.
Have you tried
encodeURIComponent("cn:cmd:list:deselectAll")
which gives you
cn%3Acmd%3Alist%3AdeselectAll
If necessary you can decode on the server.

fnReloadAjax(url): two requests

I'd like to refresh my table when new item is added. I use such code:
$("#frm_create_user").submit(function() {
var formData = getFormData($("#frm_create_user"));
$.ajax({
type: "POST",
url: getApiUrl("/user"),
dataType: "json",
contentType: 'application/json',
data: JSON.stringify({user:{user_ref: formData.user_ref}}),
}).done(function(r) {
oTable.fnReloadAjax(getApiUrl("/users?sSearch=" + r.user.userid));
});
return false;
});
But for some reason, I can see two requests instead of one.
The first one is correct - http://symfony/app_dev.php/api/users?sSearch=kZoh1s23&_=1394204041433
And the second one is confusing - http://symfony/app_dev.php/api/users?sSearch=kZoh1s23&sEcho=3&iColumns=8&sColumns=&iDisplayStart=0&iDisplayLength=25&mDataProp_0=userid&mDataProp_1=user_ref&mDataProp_2=password&mDataProp_3=vpn_password&mDataProp_4=status_id&mDataProp_5=expire_account&mDataProp_6=created&mDataProp_7=&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&sSearch_6=&bRegex_6=false&bSearchable_6=true&sSearch_7=&bRegex_7=false&bSearchable_7=true&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=false&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true&bSortable_6=true&bSortable_7=true&_=1394204041505
If I remove fnReloadAjax() line, these two requests gone so that it looks like it is caused by fnReloadAjax()
How may I fix it to have only http://symfony/app_dev.php/api/users?sSearch=kZoh1s23&_=1394204041433 requests?
All these confusing parameters are Informations that your server sided script might need to clamp the data that has to be returned to dataTables.
Since I don't know your server sided code, I can only break up what they are good for:
&sEcho=3 //No need to react to this, it's just the result of the last ajax call
&iColumns=8 //Your table has 8 columns
&iDisplayStart=0 //You are on page 1
&iDisplayLength=25 //you want to display up to 25 entrys per page
&mDataProp_0=userid //Your first colum gets the value of [userid]
&mDataProp_1=user_ref //Your first colum gets the value of [user_ref]
&mDataProp_2=password //Your first colum gets the value of [password]
etc...
&sSearch=12345&bRegex=true//Your first column is filtered by userid 12345 and this value should be treated as a regex by your datasource
&sSearch_0=&bRegex_0=false//Your second column is not filtered and should not be treated as a regex by your datasource
etc...
&iSortCol_0=0&sSortDir_0=asc //your first column should be sorted ascending
&iSortingCols=1 //you have one column that is sortable
&bSortable_0=true //Column 0 is sortable
&bSortable_1=false //Column 1 is not sortable
etc..
Your server sided script should react to these values. In case of a mysql datasource it should set up its where clause to the filtering parameters, limit it by pagenumber and items per page, and sort according to the sortinfo.
All this is needed if you want to use the luxury features of datatables like pagination, sorting, individual column filtering, clamping ajax return values to minify serverload when working with thousands of entrys.
If you don't need that, just ignore the additional parameters in your server script and just react to the data you need. But leave them in, you might need them later:-)
Hope this helps

dijit filteringSelect with min length

I can't seem to find a way to require the filtering select input to be of a certain length. I've tried like this:
new dijit.form.FilteringSelect({
'name': 'bla',
'store': jsonRestStore,
'searchAttr': "name",
'pattern': '.{3,}',
'regExp': '.{3,}'
});
but it doesn't change a thing. I want the filtering select to only query the store, if at least 3 characters have been entered. Can't be that exotic a requirement, can it? There are thousands of items behind that store, so querying that with just 1 or 2 characters is slow.
I did a bit more searching and found this post on the dojo mailing list. To summarize, there is no way to native support in the FilteringSelect for it, but it is extremely easy to implement.
// custom min input character count to trigger search
minKeyCount: 3,
// override search method, count the input length
_startSearch: function (/*String*/key) {
if (!key || key.length < this.minKeyCount) {
this.closeDropDown();
return;
}
this.inherited(arguments);
}
Also in the API Docs, there is a searchDelay attribute, which could be helpful in minimizes the number of queries.
searchDelay
Delay in milliseconds between when user types something and we start searching based on that value