Webview Swipe issue - Appcelerator Titanium - appcelerator-mobile

Right now I am using one webview to show data from my aplicationDatadirectory, here everything is working fine, I get content when user click next back respectively. Now what I am doing is in onload of webview I register "touchevent" and "touchmove" in webview's html like this :-
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchstart", function mytouch(){Ti.App.fireEvent("touch", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchmove", function mymove(){Ti.App.fireEvent("move", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
on the basis of this I find swipe event. I get correct html in webview(I can see images). But I am unable to get touchstart and move call. I dont know what is the problem here. I set data in webview using url here.
Now when I set data in webview using html(I used data of my html file(given below) in one var) now I am unable to see images it just shows me one black border(empty) but here my touchstart and touchmove events are firing also my swipe is also working as expected. I am checking this functionality in iPhone.
Can any one find the issue what is going wrong here? Thanks.

I think that this depends on the time when you apply
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchstart", function mytouch(){Ti.App.fireEvent("touch", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchmove", function mymove(){Ti.App.fireEvent("move", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
If you use the html property data is loaded immediately and you can use the code exactly after setting html content. If you use the url (even if it is located locally, which might be difficult for android) then you need to wait a short time until the page is loaded. There is also an event listener for that (web view-event load) but i can't say if that works for local resources but i don't think so.
In this case you should apply your javascript snippet into your html resources (if they are locally) instead of manually adding it using evalJS.
Please note that there is an issue on android that you can't use local images (resources folder) in your webview when you provide the content via html property.

I made it swipe working in iOS(in android it was working).
I did not expect this thing to be a reason but I do not know logic behind it. I was accessing .xhtml files from application data directory and it was working without any issue in android but in iOS it was not.
I just change(rename in my code) .xhtml file to .html and now it is working. :)
Hope this can help someone who is looking for the same.(or just for his interest)
Thanks.

Related

How to change WebBrowser fullscreen video mode?

I have a c++ project with 2 WeBBrowser in a TableLayoutPanel they are set side by side, it's working fine I navigate normal but when I go to specific websites and play a video in fullscreen that sets my whole monitor to fullscreen instead of setting only the WeBBrowser itself, however on other websites that fits perfect in the WeBBrowser. Is there a way to change the way it displays fullscreen? I wanna make it display fullscreen in the WeB​Browser only. I think it has something to do with Web​Browser​Base.​Active​XInstance Property or Web​Browser.​Document Property. Most examples I find on the internet is for the old VB and not related to the fullscreen property.
Here's a similar question:
WebBrowser control video element enter fullscreen
In other examples I've seen a method to extract the element by doing:
HtmlElement^ object = webBrowser1->Document->GetElementById("video");
But I have no idea how to handle that code in order to format that video then set it back to the WeBBrowser with fullscreen mode fixed.
EDIT:
I went further and I could get the <video> element just from a few websites, here's my method:
private: System::Void webBrowser1_DocumentCompleted(System::Object^ sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^ e) {
HtmlElementCollection^ videoElements = webBrowser1->Document->GetElementsByTagName("video");
videoElements[0]->SetAttribute("style", "width: 640px; height: 480px;"); //Not sure if this is a proper way to set an attribute in this element.
}
The problem is that not every website gives you access to <video> tag elements, so for those websites I did the following code to make sure there were indeed no <video> tag elements in the source:
System::Diagnostics::Debug::Write(webBrowser1->DocumentText);
Then I didn't find any <video> tag element in the output, only a few websites provide me that. Why? How to really get and manipulate properly <video> tag elements in c++?
Then I didn't find any tag element in the output, only a few websites provide me that. Why?
Let me make an educated guess. For some of the pages you're referring to, the DOM is built dynamically and asynchronously. Which means, those <video> tags might simply not be there yet.
So, you might need to have some asynchronous polling logic in place that monitors DOM changes, specifically looking for <video> tags.
It might not be possible to come up with a 100% working solution to cover all cases, but have a look at my other post which deals with this problem.

Custom viewpager tabs with custom view, multiple fragment and layouts

I want to make a viewpager which is just like latest facebook application.
and the problem is with tabs.
however i tried to make it, but i need icons with text in tabs and multiple fragments and layouts associated with it.
two issue occurred when i tried to develop.
1. I compromised with my UI, and tried putting static icons in it, but they don't change on selection and they don't even have badge like in facebook application.
2. when i put that code in my application which i have developed in demo app, it shows error and after researching i found that my application don't have an actionbar. so it was giving error after calling getActionBar.
please someone can provide any example or link to that which can help me.
You can refer to the official solution: http://developer.android.com/training/implementing-navigation/lateral.html
Or try this awsome lib: https://github.com/astuetz/PagerSlidingTabStrip

Google charts - Control Wrappers fails on Ajax

I am using google charts to build a graph. Everything is working fine when loaded through browser.
I have different tabs which shows different data on click. I am using ajax to get the data and the graph works fine too, because i use
google.setOnLoadCallback(drawChart(data));
on success.
I am using google.visualization.Dashboard to make use of control wrapper and chart wrapper The control wrapper helps me to get the slider kind of thing which filters within the graph. And this works fine when loaded through browser. However on ajax load i am getting the slider change in values but it doesn't show the slider HTML.
what else need to be passed to achieve this when loaded through ajax ???
Let me know if anything needed !!!
I found the solution, thought it might help someone on this.
The google load initializer i was recalling on every ajax request, wherein this needs to be loaded only once.
google.load("visualization", "1.1", {packages:["controls",'corechart']});
So i used this above the dom ready statement.

Caching data (image, rss) with django

That's my first question in here, I've been looking through old questions, but nothing matched with my problem. Here it is.
I'm creating some site with one main functionality. We want this site to display content of other sites, but in a specific way. User chooses let's say two pages from five and want to see their content. He clicks button 'Display' and goes to next page where he finds let's say view from web cam, and here comes problem.
I want to cache image that is hidden behind the url from which image was downloaded, so after refresh image won't be downloaded again, but browser will get it from cache.
I've been looking through documentation of Django, but nothing seemed to be useful.
I know that I should:
1) create table which stores cache
2) add to settings.py some CACHE_BACKEND = ...
3) use #cache_page(300) before declaration of function which returns content which should be cached,
but... it doesn't seem to work.
I will be greateful if someone tells how to solve that problem, maybe with some sort of code showing the mechanism.
Cheers,
Chris.
I think that right way to do this will be to store image somewhere on your server and delete it later with cron or something similar.
Django cache framework wasn't created for the purpose you are trying to use it.

Is it possible to tell if a user has viewed a portion of the page?

As the title says on a website is it possible to tell if a user has viewed a portion of the page?
Will moving that portion to a separate iframe work? then if they scroll to the bottom, issue a get request for a small image file..forgot the name of the technique..
Update: It is called Web Bug..A Web bug is an object that is embedded in a web page or e-mail and is usually invisible to the user but allows checking that a user has viewed the page or e-mail. One common use is in e-mail tracking. Alternative names are Web beacon, tracking bug, tracking pixel, pixel tag, 1×1 gif, and clear gif.
If you are talking about to check if the user has actually viewed some part of the page you would need to install a web camera and track his eye-movement.
If you are talking about detecting how far the user has scrolled down the page, you can use Javascript to detect this in the OnScroll event. You can then fire some ajax to the server if you need to record this.
I'm not sure this would be ethical - but technically if you use javascript, you could detect the mouseover event of each paragraph tag in the document, and then AJAX that information back to the server. As the user scrolls down the page, they're likely to mouse over the paragraphs, and then you know at least approximately where they've read to.
Not reliably, no.
Simple example: I middle-click on a link, which opens it in a new background tab. I then decide against it, and close the tab without ever looking at it. Any JavaScript trick is going to report that I viewed everything above the fold.
More complicated example: A newbie user doesn't have the browser window maximised, and a portion of the browser window is off-screen. Any JavaScript trick is going to report as if the entire viewport is being viewed, so even restricting your query to only the cases where scrolling occurs will not help.
Unless you require a user action of some kind, all you will be able to tell is that they downloaded some portion, not that they actually looked at it.
Sure. Put that content inside a div, then in your html, with some javascript, capture the onmouseover event and do your work there. If they've put their mouse over something, it's a pretty safe bet that they've seen it, I'd say...
Hope this helps.