Posts

Showing posts from January, 2015

Struggling to fit a rejected PhoneGap project (app) into XCode

So at some point in December last year, I got a rather nice "Happy new year" message on my Google chat. The following is an extract from that message, A zillion thanks for posting the Swift with html5 frameworks. I have really been struggling to get a rejected PhoneGap project into XCode, and using your Framework made it possible.  Thanks a million and Happy New Year to you!   The framework the message was referring to was this Github project  that I created last year, I have described this project in more detail in this post . So long story short, being new to iOS development, I had/have a burning desire to build an HTML5 project for iOS devices. My goal has/was to build a hybrid project like the way I have described in my blog post and I wanted to make use of the Ionic framework . When I started developing the project, I had some issues getting the project to the point where I wanted it to be, simply because I did not know enough about iOS. Eventually I did get to ...

Passing parameters into a Swift method and modifying their values

So for people who have read my blog or who know me, they would probably know that I am a Java developer in my day job(full-time contract) and coding Swift is something that I do in my spare time. So there is one thing that I do every now and again in Java and that is something like this public void modifyCollection(List<String> collection) { collection.add("one"); collection.add("two"); collection.add("three"); } and the method is invoked as follows List<String> testCollection = new ArrayList<String>(); modifyCollection(testCollection); So after the line  modifyCollection(testCollection); the testCollection will have strings one , two and three. Now let us trying something similar in Swift func modifyCollection(collection:[String]) { collection.append("one") collection.append("two") collection.append("three") } var strArray:[String] = [String]() modifyCollection(strArray)...

Java servlet to work as a proxy for html2canvas

So I wrote about how I used the html2canvas to solve one of the problems at work in this post . Now have a read of the  documentation  for html2canvas, and focus on the bit about same origin content. So in summary, if the web page you are trying to capture the screenshot of, contains an image that comes from a different domain, that image wont be in the screenshot that you just captured with the library. So the only way to ensure cross origin content is included in the screenshot is via a proxy. Now the author of html2canvas, has provided proxies, for Python  and Node.js , but they are not of use to me as I was using the html2canvas in a Java project. So I had to write my own little Java servlet to get the job done. So it was a very simple servlet and I was just surprised that there wasn't a Java based proxy out there. Anyway so the servlet that I had to write to work as a proxy was something similar to what I have shared in this Github repo . I am sure you realise t...

Capturing the screenshot of a web-page from your web app (using html2Canvas)

A few months ago, I had to add a feature to this web app at work that would enable the users to get a screenshot of the page they are on. When I was given this problem to solve, I thought surely someone must have solved this problem? so I started looking for a library that would help me achieve this. After a bit of searching I came across the html2canvas library which is awesome and it really does get the job done. I am not going to get into details about how the html2canvas library works, I think it's documentation does a good job of it. Anyway my javascript code to capture the screenshot was something like this. function getScreenshot(callbackFunc){ var content = document.querySelectorAll("divToCapture")[0]; setTimeout(function(){screenCap();},0); function screenCap(){ html2canvas(content, { onrendered: function(canvas) { callbackFunc(canvas.toDataURL()); } }); } } So the above function is pr...