Ajax + qtranslate - ajax

Hi I ran into the same problem as Rik had here
The answer given was that he had to "Search in code for link request "ajax.php". Replace "ajax.php" with ajax.php/?lang='.qtrans_getLanguage()" "
My question is this (I know it might sound stupid, I suck at this stuff), what code does this answer refer to and where do I find it? I've searched all php files in the qtranslate and ajax plugins but cannot find where it is.

It depends on which WP ajax-plugin you have a problem with. In case "Category-Post AJAX Tree" I had to replace
$localize = array ('ajaxurl' => admin_url('admin-ajax.php'),
with
$localize = array ('ajaxurl' => admin_url('admin-ajax.php?lang='.qtrans_getLanguage()),
in cat-post-tree-ajax.php and to replace
var url = CatPostAjax.ajaxurl + '?action=myajax-submit&category=' + id; // compose url
with
var url = CatPostAjax.ajaxurl + '&action=myajax-submit&category=' + id; // compose url
in cat-post-tree-ajax.js. Please tell us what plugin you mean so we'll be able to help.

Related

socket.io send an object to a html table

I am a real newbie - I was given a leg up to create something and it is using socket.io. I'm trying to fiddle around the edges, learning odd things as I go now. But have hit a wall in a really early stage of my project. It May well be too deep ... but just in the case asking here gives me an answer I can make sense of - here goes:
I have essentially three files working together. server.js, client.js, and index.ejs (which is my html file). I have a series of stuff happening in a "room" and now I want to display the values (next I will want to do more with them, but for now display) of an object in a html table.
server.js
... it creates the information of interest (uses a database call that currently works) and then:
io.to(roomId).emit('room-location-update', result.rows);
client.js
... receives data. My console.log has it all there. Then I assign a variable to hold it for use in the html:
socket.on("room-location-update", (data_information) => {
console.log(data_information);
//I think I need code in here?
var wp = data_information;
}
index.ejs
... fails to show anything. I have a table constructed to use the variable from client.js in a series of table cells essentially all constructed as:
<td id=wp.name><td id=wp.radius>
but nothing is displayed. the .name and .radius attributes are valid in the database when data_information is first created.
why nothing displayed? Google searches imply (to me) that this is basic stuff and should work. So clearly I am missing something basic (?) Any ideas what?
sorry, I don't actually know what you are talking about with edits. Apologies if I have done something wrong - I am a genuine newbie.
In the end I gave up on doing it in the ejs file and created a big string containing the html table codes and substituting in values where I wanted them in the client.js. And just popped that into the ejs file. No idea if this is efficient or not but it works, so hooray.
truncated code snippet of what worked for me (in client.js):
var $table = "<table border='1'>"
$table += "<thead><tr><th>Player</th><th>Location</th></tr></thead><tbody>"
for (var i = 0; i < display_information.length; i++) {
$table += '<tr><td>' + display_information[i].id + '</td>'
$table += '<td>' + display_information[i].name + '</td>'
}
$table += "</tr></tbody></table>"
$('#displayinfo').empty().append($table);
and then in my index.ejs is: <pre><span id="displayinfo"></span></pre>

TextBox1.Text string on end of a link

I wanted to make an application that checks if a link was blocked on steam.
I used the linkfilter page. (https://steamcommunity.com/linkfilter/?url=)
I tried doing it like this:
WebBrowser1.Url = https://steamcommunity.com/linkfilter/?url=(TextBox1.Text)
But I got two errors. Is there a way to do this?
Did you try setting your string values as actual strings?:
WebBrowser1.Url = new Uri("https://steamcommunity.com/linkfilter/?url=" + TextBox1.Text);
or:
WebBrowser1.Url = new Uri(string.Format("https://steamcommunity.com/linkfilter/?url={0}", TextBox1.Text));

CodeIgniter Pagination with number in the middle of the query string

I searched the whole day for any solution but did not found any.
I have the same problem as this guy here: Codeigniter Pagination having page number in the middle of url but the "uri_segment" param doesn't work.
My Urls look like:
localhost/controller/0/some/filter/here/
The Pagination returns teh correct link for the next and 2. page.
But once I go there, I get a wrong link back to the first site.
I did something like this:
/*Paginartion Config*/
$pagconfig['base_url'] = base_url($this->uri->segment(1).'/0/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$this->uri->segment(5).'/'.$this->uri->segment(6).'/'.$this->uri->segment(7).'/'.$this->uri->segment(8));
$pagconfig['total_rows'] = $ress->num_rows;
$pagconfig['per_page'] = 10;
$pagconfig['uri_segment'] = 2;
$pagconfig['prefix'] = '/'.$this->uri->segment(1).'/';
$pagconfig['suffix'] = '/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$this->uri->segment(5).'/'.$this->uri->segment(6).'/'.$this->uri->segment(7).'/'.$this->uri->segment(8);
Also I just tried using the current_url() as base_url config param and of course I also just tried to use uri_segment = 2 without using pre- and sufix.
It never worked properly.
Routes look like this:
$route['map/(:num)/(:any)'] = 'map/index/$1/$2';
$route['map/(:num)/(:any)/(:any)'] = 'map/index/$1/$2/$3';
$route['map/(:num)/(:any)/(:any)/(:any)'] = 'map/index/$1/$2/$3/$4';
$route['karte/(:num)/(:any)'] = 'map/index/$1/$2';
$route['karte/(:num)/(:any)/(:any)'] = 'map/index/$1/$2/$3';
$route['karte/(:num)/(:any)/(:any)/(:any)'] = 'map/index/$1/$2/$3/$4';
As you can see I use two kind of routes, translates for google.
The routes and Controller also work!
If I type in by hand I get the correct paginated site content:
For Example: localhost/controller/10/some/filter/here returns every row beginning with 11 (it skips first 10 as it should).
Very important is that the number always appears even on the first page where it is 0 - as you can see above.
It would be so great to get any help in that one...
Best Regards

Windows Phone 7 WebBrowserTask problem

I'm trying to open this url using a WebBrowserTask in WP7, and it doesn't work (I get a custom error on our website), but when I type it in by hand, it works fine. Any ideas?
It also works perfectly fine in Google Chrome and IE7.
This is the url:
http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae
And this is my code:
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae";
WebBrowserTask browser = new WebBrowserTask();
browser.URL = url;
browser.Show();
Thanks!
EDIT:
Without any of the solutions below, this code works fine:
WebBrowserTask browser = new WebBrowserTask();
browser.URL = "http://www.youtube.com/results?search_query=Windows+Phone+7&aq=f";
browser.Show();
I don't understand what is different?
There is a bug with the SDK. In URL that contains &, you need to escape it.
For example:
... Uri.EscapeDataString("&") + "ShowTime=8:00p"
This is most likely because your query string parameters are not URL-encoded. Modern web browsers will attempt to compensate when you paste that into the address bar because it's hard to URL-encode in your head. But when you're using an API, you should really URL-encode those pieces yourself.
Use the Uri.EscapeDataString method to encode each part of the query string individually. For example.
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx" +
"?ShowDate=" + Uri.EscapeDataString("12/15/10") +
"&ShowTime=" + Uri.EscapeDataString("8:00p") +
"&Uid=" + Uri.EscapeDataString("54918a0d-1beb-4552-bdc8-2d474e3ea5ae");
The following code worked for me:
s = "www.. "; //url
s = Uri.EscapeUriString(s);
task.URL = HttpUtility.UrlEncode(s);
You're URI needs to be escaped indeed. As simpler way I think is :
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae";
WebBrowserTask browser = new WebBrowserTask();
browser.URL = Uri.EscapeUriString(url);
browser.Show();

How can I search for a text and fill/click on a link with Selenium?

Here's the deal:
Is there a way to search for an input name or type witch is not precise and fill it?
For example, I want to fill any input with the name email with my email, but I maybe have some inputs named email-123, emailemail, emails etc... Is there a way to do something like * email * ?
And how can I click on a link verifying some text that could be on the link, or above the link, or close, or at class etc ?
ps: I'm using selenium ide with firefox
You can use Xpath to find it with something like //input[contains(#name,'email'). If you have multiple instances like that on the page it will be worth moving your test to your favourite programming language and then doing
emailInstances = sel.get_xpath_count("//input[contains(#name,'email')]")
for i in range(int(emailInstances)):
sel.type("//input[contains(#name,'email')]["+ i + 1 +"]","email#address.tld")
Xpath works well and the solution above is good. If you are trying to test old verions of IE you could also use JavaScript injection. I find it is very fast, although can be a bit trickier to debug. I didn't actually check if the below works but hopefully it gives you an idea of what you can do:
String javaScript = "_sl_enterEmailStr = function(parentObj,str) { "+
" var allTags = parentObj.getElementsByTagName('input'); "+
" for (var i = 0; i < allTags.length; ++i) { "+
" var tag = allTags[i]; "+
" if (tag.name && tag.type && tag.type === 'text' "+
" && tag.name.match(/email/)) { "+
" tag.value = str; "+
" } "+
" } "+
"}; "+
"_sl_enterEmailStr(this.browserbot.getCurrentWindow().document "+
" ,'myemail#mydomain.org'); ";
mySelenium.getEval(javaScript);
I find JavaScript injection with regular expressions allows me to do great things to dynamic input fields. Note you can use findElement() to be more specific about where you look for tags.
Regarding clicking a link and getting text, those are simple click() and getText() operations that can be done given the proper locator. I would check out the selenium API. for example, here is the link to the Java one for 1.0b2.

Resources