Wednesday, January 4, 2012

Back button hack for webapps built on a single HTML page.

   At the outset, let me start with some background of why anyone would like to do this stuff of virtually making back button work for a webapp wherein a single HTML file you have many sections[modelled as pages in app].
The theory for this goes as follows. If you are developing a web app/widget for mobile using HTML, CSS and Javascript and you want to put all the app logic and navigation in a single HTML page, but still would like to have many pages in your app and from anypage in app on pressing browser back, you want to goto its previous page[previous page of app and not of browser] this solution will be a beacon for you.

The procedure goes as follows:
- Have each section tag [a new addition in HTML5] that will be a page in your app.
- At any given Instance, all other div's will be hidden other than the one you want to see.
// Javascript code to Hide all divs and Show one of them


hide_all(){
for(i=0;i<document.getElementsByTagName("section").length;i++)
   document.getElementsByTagName("section")[i].style.display = "none";
}


show_one(secNo){
   document.getElementsByTagName("section")[secNo].style.display = "none";
}


Hence, at any given instance of time if you want display the 3rd section(page) in your app, using above 2 functions:


hide_all();
show_one();
- Using above logic, you can simulate multiple pages in a single HTML file.
- Now comes a scenario when you are in some page and when you press browser back, you want to go to the previous section.
- For this, there are 2 ways of doing things. First way is to use window.onpopstate/pushstate (will not work in some desktop browsers and even many mobile phone browsers) so, the other way is to hack the browser, fake it by doing a URL rewriting for every page/section of the app.
- URL rewriting is a logical solution and has no dependencies as in window.onpopstate.
- explanation is given below:
Consider my base URL is http://noddycha.com/trial.html
URL rewriting can be done using the Javascript code - window.location.href = "#" + pageNavname;
where, pageNavname will be id of the section you want to goto. if i have declared pageNavname="chatPage"; by using above code, my URL will be http://noddycha.com/trial.html#pageNavname. But, you will remain on the same page.
- similarly have as many number of pageNavname as those of your sections. 
- Rewrite URL as specified above for every navigation.
- But when you come back to a URL on pressing back, you need to hide all other sections and show the section as in the end of URL after "#".
- To do this, you need to do something as below:


// Check if there is a change in URL using onhashchange.
window.onhashchange = reNewApp;


and in reNewApp you need to do something as below:



function reNewApp()
{
switch(getpageNavName())
{
case ' homepage ': hide_all(); show_one("homepage");break;
case ' prechatform ': hide_all(); show_one("prechatform");break;
case ' chatpage ': hide_all(); show_one("chatpage");break;
case 'nav_feedbackPageLive': hide_all(); show_one("feedbackpagelive");break;
default: hide_all(); show_one("homepage");break;
}
}


To get the app page to be displayed or section id to be displayed, look at the code below:


// You get the PageName/section name from the URL by parsing URL of the window as below:
function getpageNavName()
{
hide_all();
var navURL = document.location.href;
var URLlength = navURL.length;
var startPos = navURL.search("#");
if(startPos)
{
return pageNavName = navURL.substr(startPos+1,URLlength);
}
}



Finally, you will end up in a app where in a single HTML page will have multiple pages and back button of browser will not take you out of app(HTML page), but will take you to previous section.


You can see a working demo @ http://samplewac.freeiz.com/247ilabs/

Cheers,
noddyCha

Saturday, November 5, 2011

The Android Mania .. Android Vs iPhone


Recent data indicates that 44% of all smartphones purchased in the third quarter of 2010 are operating on Google's Android powered operating system. As the smartphone market is growing, so is the search engine turned software producer's stake, proving that the unreachable iPhone sales may just be able to be reached. The following article will discuss why the Android system is outperforming iOS and what factors limit the iOS from competing.




This data initially sounds mind boggling, considering that the iPhone 4 is one of the hottest devices on the market. The trick to this data is that Google is now offering its software platform to a wide variety of devices, such as the ever so popular Droid.While iOS only makes up 21% of the market share, they have done so by proprietarily installing this platform only on their highly acclaimed iPhone line of smartphone products. When compared to the over 20+ devices that run the android operating system, the results now seem more understandable.Secondly, the iPhone 4 is currently only offered by AT and T in the US.



In January 2011, Verizon will be launching their edition of the iPhone 4. One of the most common complaints about the iPhone 4 is not the device itself, rather it is the carrier that provides the service. From dropped calls, to iPhone monopolies, AT and T has managed to create a rather unhappy customer base. So much so that many Verizon customers will not make the switch even though they want the device. Apple will likely see a whole new market unfold with the release of the iPhone 4 to Verizon and possibly other carriers.Finally, as Apple continues their virtual domination in every category they enter, they are not concerned about their platform being shared amongst others. Apple carries a sense of superiority that drives customers into their stores, regardless the economic climate.



The Story of Happy Days of My Life .. Part 1

         It all began on September 3rd 2007, a rainy evening with chilling typical belgaum cold and i'm fully drenched in rain! The event was supposed to begin @ 5:00PM, but because of some reasons it got delayed by an Hour and started at 6:00PM. Thinking what this event was? .. Hmm.. It was the freshman welcome function for 2007 Batch in GIT,Belgaum. i.e My First Day at GIT. I felt too Tiny that day. Around 700 freshers  had gathered in college Auditorium with their parents, to attend the function. I hardly new anyone in GIT at that moment and was roaming all alone in the campus :( I was completely tensed and at the same time was very much excited as i was about to begin a new phase of my life. Jumping from a metro city Bangalore to a city like Belgaum was a big change for me. New people, language, food, weather, friends, place.. It was all in all a new start. And as in calendar, my official engineering life began on 4th September 2007.

        And finally, my first official day in engineering was here and my first class was supposed to be Workshop Lab! But in a hurry i went and sat in Physics Lab .. He.. He.. After an Hour in Physcis Lab i got to know that i was supposed to attend Workshop Lab with some other Batch!! Later it took me 15mins to figure out where actually this workshop lab was in GIT. So, in all i was late to my first class of my engineering life by 1 hour, 15mins. After my first class, some seniors from mech dept caught hold of me and started to rag me.. some questions they asked me were, "Introduce Yourself", "Tell tables of 1","Do a Cat Walk" !!  Sounds Funny now, But that day i had a busy and speedy first day. I had earned 3 to 4 friends on my first day and that was the only takeover from that day. Actually, it was a busy beginning for me. From morning 8 to eve 7 i used to be in college and later used to come back to room and sleep. started feeling that i'm becoming busy. My division i.e 1st sem 'E' div was a gr8 place to be as a fresher. It was a diverse class, You would get people of all kinds and types of lifestyle and places in karnataka and was yet united. Loved this class. days started rolling in my first sem. day by day friends happened and at the same time syllabus was seeming infinite :) Feels like there was no fun at all in my first sem.The only 3 things that i did regularly in 1st sem are - Reading Books, Attending classes and Taking suggestions from seniors.

         And after 5 slow moving months of college, 1st sem exam occured. It was like as if i'm attending the most toughest exams of my life. Had very hard ass burning days during my first sem exams. But somehow i managed to do well and score well in 1st sem. Then it was the most awaited vacation! Which i spent in Bangalore to its core.. After we gathered back in Feb 2008, the feeling was a bit different than before. everyone looked confident in college as they were 6 months old engg students now. This sem started with some fun as we wer taken to Rakascope dam as a activity of chemistry lab. This was the beginning of jolly days of my engg life. Second sem was very cool and easy sem. I spent most of my time on watching hit english movies like Terminator, Lords of the rings, iRobot, Resident Evil etc.. Had a easy life. Academically i started Gaining confidence. People of belgaum were a lot lot supportive in making me set with this place. A mild and Fast and Bindass 2nd sem. CAD and Chemistry created mystery in my life for 2nd sem.

         One of the Greatest of my achievements in 2nd sem was that my technical paper got selected in a national level Paper presentation competition in Paanchajanya 2008 conducted by IEEE,GIT. I had submitted a paper on "Genetically Modified Organisms", which i had prepared by taking utmost effort and search in google. Second sem exams were nearing and i had a handfull of friends and ample time around to get going with aaram life. this sem brought me a lot of Do's and Dont's of life. Second sem exam was a cake walk for me as i loved most of the subjects in this sem. At last i was going to complete 1st year engg.
The feeling in myself doubled up as i had completed 1 year of engg life. I was in full confusion asto what i'm learning and is this what the thing called engineering. I opted to CSE as i had a lot of interest and passion towards it, but in 1st year engg i had learnt all subjects other than CSE .. I wondered many times "Am i in a wrong place." But later i came to know from seniors that this confusion is what that signifies the completion of first year engg. I mean, nothing is clear as its whole .. college, course, branch, events in college. Everything used to appear unknown and fiery in 1st year. Placement, Projects, Fests were completely unknown for me. All that i remember about 1st year is Classes, Attendance, Assignments, IA's etc.. Finally this year was done with a lot of unanswered questions in my mind. Later , with a hope of light ahead i looked forward for 2nd year...


To Be Continued...

Wednesday, September 14, 2011

HeartFelt Tribute to one of the Best Engineer ever born on this Planet.

           This is a blog post written by me on September 15th, i.e The day when we celebrate "Engineers Day" in India. Please take some time from your busy schedule to read about this great personality and Thank him for all the great things he has done to the Human Community.


          This happened some years ago in the United States of America. Some Indians stood at the foot of a seventy-five-foot ladder in a factory. They were visiting important factories in the States to study their  working. Officers of the factory were with them, explaining how the factory worked In one part Of the factory, the officer said "If you want to see how this machine works you will have to climb to the top,"
The leader of the Indians was "Very well, let us climb," he said. That meant that they had to climb up the seventy-five-foot ladder, past four stories. The others were very much surprised. He was the oldest of them all; most of them trembled at the thought of climbing up the steel ladder. The old gentleman briskly stepped towards the ladder, and started to climb. Many of the others stayed back. A few followed as a matter of duty, but some of them soon gave it up. The old gentleman reached the top, completed the inspection and briskly climbed down. Only three others completed the feat. It was always so with the gentleman - anything he undertook he did systematically and very well. No difficulty, any danger could keep him back.The old gentleman went up the ladder!

He was Doctor Sri M. Visvesvaraya -or, Sir M.V., as he was popularly known.



He lead a very simple life. He was a strict vegetarian and a teetotaler. Some of the positions he held were
  1. Assistant Engineer, Bombay Government Service[in 1884]
  2. Chief Engineer, Hyderabad State [he served only for 7 months starting April 15, 1909]
  3. Chief Engineer in Mysore State [Nov 15, 1909]. He was also Secretary to the Railways.
  4. President of Education and Industrial Development committees in Mysore State
  5. Dewan of Mysore. [for six years starting 1912]
  6. Chairman, Bhadravati Iron Works
  7. Member of the Governing Council of the Indian Institute of Science, Bangalore
  8. Member of the Governing Council of Tata Iron and Steel Company [TISCO]
  9. Member of Back Bay enquiry committee, London
  10. Member of a committee constituted in 1917 to make recommendations regarding the future of Indian States.
To name few of the many things he was responsible for:
  1. Architect of the Krishnarajasagara dam - or KRS or Brindavan gardens.  One of the biggest dams in India which irrigates a hundred and twenty thousand acres of land.
  2. Bhadravati Iron and Steel Works - as its Chairman he rescued it from becoming extinct.
  3. Mysore Sandal Oil Factory and the Mysore soap factory
  4. Mysore University - Sir M.V.'s question was "If Australia and Canada could have universities of their own for less than a million population, cannot Mysore with a population of not less that 60 lakhs have a University of its own?"
  5. State Bank of Mysore (it was first named The Bank of Mysore)
  6. Public libraries in Mysore and Bangalore
  7. Encouraging girls to attend school.
  8. Mysore Chamber of Commerce
  9. Kannada Sahitya Parishad or the Kannada Literary Academy
  10. Sri Jayachamarajendra Occupational Institute, Bangalore - funded by the ENTIRE money [Rs 2 lacs] he earned from rescuing Bhadravati Iron Works
Some of the honours and laurels conferred on Sir M.V.,
 
1904Honorary Membership of London Institution of Civil Engineers for an unbroken period of 50 years
1906"Kaisar-i-Hind" in recognition of his services
1911C.I.E. (Companion of the Indian Empire) at the Delhi Darbar
1915K.C.I.E. (Knight Commander of the Order of the Indian Empire)
1921D.Sc. - Calcutta University
1931LLD - Bombay University
1937D.Litt - Benaras Hindu University
1943Elected as an Honorary Life Member of the Institution of Engineers (India)
1944D.Sc. - Allahabad University
1948Doctorate - LLD., Mysore University
1953D.Litt - Andhra University
1953Awarded the Honorary Fellowship of the Institute of Town Planners, India
1955Conferred ' BHARATHA RATNA'(The gem of India), the highest dinstiction of the country
1958'Durga Prasad Khaitan Memorial Gold Medal' by the Royal Asiatic Society Council of Bengal
1959Fellowship of the Indian Institute of Science, Bangalore


Bank Balance

Sir MV maintained an account with Bank of Mysore, which is now State Bank of Mysore. Sir MV had Rs 990 on March 27, 1918, which increased to Rs 11,487 on March 3, 1919. His account had thrice attracted interests of Rs 14, Rs 66 and Rs 117 during this period. An entry in the passbook on Nov 18, 1918 reveals he got Rs 13,486 transferred to this current account from a fixed deposit account.


This great man, this worker of miracles, this Bhagiratha of Karnataka, this Bharata Ratna (the Gem of India) was Sri M.V. The man who gave even one of these would deserve admiration and gratitude.But all these were the gifts of one man - and he gave these to his country about fifty-five years ago, when it was still not free and when few people here cared to study science. Hats Off to you sir. We are blessed to be born in a country where you lived for 101 years.


source and courtesy : karnataka.com, freeindia.org, wikipedia.




Tuesday, September 13, 2011

Core differences between a Scripting and a Programming Language.

         In this era of computers, where there are a handfull of programming and scripting languages, Its really important to know basic differences between programming and scripting languages. This is a post where i would like to discuss on some of the myths about scripting Language and how it differs from any programming language that we use. Aim of this post is to make the reader familiar about the potential differences between, How, Why, When and What about the above mentioned 2 strata of Languages.


         To make the reader familiar with a wide spectra of languages avail, here is a list of different kinds of languages :




            -----Programming----- 
             |                                |
  Scripting(JS/VBS)   Compiling(C++/VB) 




The Last 2 links above makes u more familiar with basic definitions of these respective languages. Hence, In brief it can be just said that - "A Scripting Language is a Programming Language that is not compiled regularly!!". The differences b/w these languages in the respective criteria is discussed as follows:


1. Syntax : Both seem to have in common is Sequence (the order of your code), Selection (If and Select/Switch type statements), and Iteration (Loops)...so the line is very blurry in terms of syntax of both languages.


2. Compilation : The classic definition is it is a program if it is compiled and it is a script if it is interpreted. If you can open the interpreted file in Notepad and it's readable then it's a script.  If the compiled file when opened in a notepad is a bunch of  weirdy boxy characters everywhere, it's probably a program that compiles itself in a compiler.


3. Flexibility : This is a core difference where Scripting Language highlights itself, Essentially it comes down to ease and flexibility of change. Scripts change quickly and easily whereas programs require more effort.


4. Weak and strong typing : Weak typing allows a value of one type to be treated as another, for example treating a string as a number. Strong typing prevents the above. An attempt to perform an operation on the wrong type of value raises an error. An alternative definition for "weakly typed" refers to scripting languages, such as Perl and JavaScript, which permit a large number of implicit type conversions. Thus it can be said as most of the scripting are weakly typed and Programming languages are strongly typed.



5. Light-weight-ness : Its always upheld and assumed that scripting languages are very lightweight and robust as compared with programming languages. Because, the code is not compiled the overhead for compilation is reduced in scripting languages. 




Conclusion : 
                   In reality, though there is no prominent change in programming structure and pattern between both, the working, execution and practical usability between these two languages differs a lot. Scripting Languages are used in applications where logical programming is much important than system resource / system programming. Some of the most important examples of scripting languages usage are : Javascript, PHP, VBScript, Perl, Python etc.. Though there are many exceptions where even scripting languages are compiled, In general terms the defn goes conventionally. I hope this post makes u guyz familiar with what it means to script and program?

Thursday, August 25, 2011

This is what India needs to be a super power in 2020.!! .. Entrepreneurship ..

Dedication and Attitude to be a Entrepreneur is just that lacks in the youngsters like us. To be frank enough i feel why cant we, when suhas was able to do wen he was 16????


Proud to say - "I am Anna Hazare!! " |||| Know more..


Who is Anna Hazare?


He once contemplated suicide and even wrote a two-page essay on why he wanted to end his life. Anna Hazare was not driven to such a pass by circumstances. He wanted to live no more because he was frustrated with life and wanted an answer to the purpose of human existence.


The story goes that one day at the New Delhi Railway Station, he chanced upon a book on Swami Vivekananda. Drawn by Vivekananda's photograph, he is quoted as saying that he read the book and found his answer - that the motive of his life lay in service to his fellow humans.


Today, Anna Hazare is the face of India's fight against corruption. He has taken that fight to the corridors of power and challenged the government at the highest level. People, the common man and well-known personalities alike, are supporting him in the hundreds swelling to the thousands.


For Anna Hazare, it is another battle. And he has fought quite a few, Including some as a soldier for 15 years in Indian Army. He enlisted after the 1962 Indo-China war when the government exhorted young men to join the Army.


In 1978, he took voluntary retirement from the 9th Maratha Battalion and returned home to Ralegaon Siddhi, a village in Maharashtra's drought-prone Ahmadnagar. He was 39 years old.


He found farmers back home struggling for survival and their suffering would prompt him to pioneer rainwater conservation that put his little hamlet on the international map as a model village.


The villagers revere him. Thakaram Raut, a school teacher in Ralegaon Siddhi says, "Thanks to Anna's agitations, we got a school, we got electricity, we got development schemes for farmers.''


Anna Hazare's fight against corruption began here. He fought first against corruption that was blocking growth in rural India. His organization - the Bhrashtachar Virodhi Jan Andolan (People's movement against Corruption). His tool of protest - hunger strikes. And his prime target - politicians.


Maharashtra stalwarts like Sharad Pawar and Bal Thackeray have often called his style of agitation nothing short of "blackmail".
 
But his weapon is potent. In 1995-96, he forced the Sena-BJP government in Maharashtra to drop two corrupt Cabinet Ministers. In 2003, he forced the Congress-Nationalist Congress Party (NCP) state government to set up an investigation against four ministers. In April this year, four days of fasting brought thousands of people out in support of his crusade against corruption. They also made the government realise it could not be dismissive about Anna Hazare and his mass appeal.  
 
His relationship with the UPA government continues to be uneasy. The truce of April was short-lived. An exercise to set up a joint committee made up of equal numbers of government representatives and civil society activists, including Anna Hazare came to naught when the two sides failed to agree and drafted two different Lok Pal Bills. The government has brought its version in Parliament and Team Anna is livid. 
 
The Gandhian is soldiering on. From one battle to another in his war against corruption. He fought from the front to have Right to Information (RTI) implemented. He is now fighting for the implementation of the Jan Lokpal Bill, the anti-corruption bill drafted by his team of crusaders.


This year, more than 30 years after Anna Hazare started his crusade, as the 74-year-old plans a second hunger strike in Delhi against large-scale corruption at the national level. Nothing really has changed except the scale of his battle.