making the difference between pc to mobile - javascript

I have a website with a lot of javascript code in it.
Now of curse the CSS was edited so the website would look good on mobile too.
About js what should I do? Should I just leave everything on the mouse events and keyboard events or should I detect if a mobile device is using the website and then make another file of js just for mobile with the same actions, maybe in the sane file?
I would appreciate any help with that.

For js it will work hopefully on mobile devices just like it did on your Desktop, you just need to ask yourself if you're using new js code that may no be supported by older browser like for example if you are using promises to make http request then maybe some old phones having old browser will not behave properly (to check if what you are using is supported check this out https://caniuse.com)
Let's say you're using something that is not supported, you can (most of the time) use a polyfill from the internet to make sure the code you write is always working fine.

Related

Minimizing apps via nodejs || plain js

I'm currently working on personal automation project and I want to add 'minimize app' feature.
For example: When I click button, I want to minimize the current browser. I already have window.close(); but this will close the app definitly. I found things like window.minimalize(); or window.minimize();, but none of them worked for me. So is there a way to minimize app?
Edited: It does not have to be only client-side JS, it can be used as terminal based nodejs app. Ex: I type minimize Google Chrome, and it will minimize it.
One Google search for how to minimize browser gives the following result:
There is no way to minimize the browser window within javascript. No, there isn't. However, depending on what you're doing and which browsers you're targeting, you could play around with the blur and focus events of the window to achieve similar effect.
Alternatively, if such control is required, you could always port your code to Electron.js or Neutrino.js, which were made to let you create desktop applications using JavaScript.
Maybe if you post some code and give us a train of thought to follow, we could work something out.

Barcode Scanning Via Mobile Browser?

I am looking at trying to scan barcodes from a mobile device.
I been doing some research and I having hard time finding JavaScript libraries that can do this.
I see these projects
zxing
This seems to be no longer in development and just bugs fixes are done?
QuaggaJS
This one, I am not sure if it is development either anymore as changelog is from 2017
quagga2
This seems to be a fork of the one above? So this might be the better choice to go with vs the 2?
What I am trying to achieve is this. I want to go on an andriod device (think phone, maybe tablet), load up chrome or firefox, go to my site click a button and load up the devices camera and scan a bar code (mostly EAN-8/13).
I want to do the same thing on apple devices (iphone and ipad), load up safari (not sure if they got chrome and Firefox on these devices. I don't own apple), click a button and load up their devices cameras and scan a bar code.
I think this is possible in all the libraries I listed above, but I am still unclear if this is possible on apple devices? I read somewhere that before ios 14 it would not be possible?
I am open to other libaries, I can use Jquery, vanilla javascript and I think angular (but I think it is version 3).
Just been doing this same research myself. All of those open source ones you listed seem to be either dead or have performance/reliability issues. Looks like only the commercial versions are really viable at the moment:
Dynamsoft - https://www.dynamsoft.com/store/dynamsoft-barcode-reader/
Scanbot - https://scanbot.io/products/barcode-software/web-barcode-scanner/
There are also two different mobile apps that are viable. These are web apps that just display a browser view and make a barcode scanning function from the app itself available on the page:
https://berrywing.com/scan-to-web-app/
https://www.mochasoft.dk/iphone_barcode2.htm
The second one has a more capable JS API of the two.
UPDATE: I went with that last option from Mochasoft. Turned out quite well.

Is there a lightweight library I can use to ask users to download a modern browser?

I'm building a site that relies heavily on several HTML5 features. I do not want to develop a separate version of the site for IE6-8. Instead, when those users visit, I'd like a nice-looking modal to pop up to politely suggest that they visit the site with a modern browser like Chrome or Firefox. Is there an existing library that will do this for me?
Ideally, modern browsers would only have to download the browser detection code; the code powering the modal would be loaded asynchronously only when needed.
Try this: http://www.ie6countdown.com/join-us.aspx
Use Modernizr. Instead of checking what browser they use, you can check for the exact feature that you need and display an alert if the current browser does not support it. Additionally, Modernizr also includes the YepNope library which lets you conditionally load resources that you need (like the modal you mentioned)
Investigate Chrome Frame as well.
The rule is to detect browser capabilities, not individual browsers. As pradeek mentioned, modernizr does an excellent job of this.
It looks like this will do the trick: https://github.com/viamarte/modernweb

Can I reasonably assume mobile browsers with JavaScript also support jQuery?

I realise that this question may be almost impossible to answer definitively, but:
Is it reasonable to assume that mobile browser with JavaScript can also cope with jQuery? We're talking relatively basic jQuery such as click events and Ajax.
I'm writing a mobile HTML app. It involves slippy maps so anyone who wants to use it has to have JavaScript.
I'd much prefer to use jQuery for the rest of the coding if possible, but can I reasonably say to the client "any phone with JavaScript should support basic jQuery"?
I know about jQuery mobile, but I'm specifically talking about phones that aren't advanced enough to handle jQuery mobile, but do have JavaScript.
Thanks!
Yes.
jQuery is not a language. It is a library written in JavaScript, and therefore if you can run JavaScript reasonably well, you should be able to run jQuery without any problems.
With that being said, nothing compares to actual testing. Periodically check that your code works across multiple platforms (not only on different phones, but different web browsers as well).
javascript is javascript. You can always use jQuery.support to detect features. You should test on the browsers you want to support anyway.
The answer is simple: yes.
JQuery, and especially its most basic features, is designed to be cross browser. If the mobile browser has reasonable javascript support, JQuery should not be an issue.
For fallbacks on features you aren't sure whether or not are supported, you can use jquery.Support or Modernizr
It should run okay on most... don't expect much from explorer pocket.
Although jQuery functions across these
browsers, IRL many of the cool
effects that jQuery makes simple won't
be seen on a mobile browser, because
the interface is so different. There
is (almost) no concept of mousedown,
mouseup, or hover; click and focus
behave differently, screensize is
different vs effective window size,
animations are slow, etc. The
challenge in mobile browsers is mostly
in the interface design. The main
advantage IMO is AJAX-loaded content,
for speed and low data/bandwidth
usage.
In short: yes.
HOWEVER, if you're only doing Ajax and other little things, you'll see a significant speed gain just using vanilla JS. But I do realize this can be somewhat of a pain. There are lighter-weight packages out there, like xui.
Honestly, I'd consider programming separate sites for mobile Safari (iOS and Android), and other lower-powered devices that don't run WebKit.
To iterate again: jQuery.mobile is NOT a replacement for jQuery, but rather framework that builds on jQuery, much like jQuery-ui does. This would be an even larger footprint and bootstrap time.
You can check http://jquerymobile.com/ - maybe it is what you should use on your pages instead of "regular" jquery.
Yes but you will better off using jQuery Mobile in case you are developing for mobile devices. It's optimized for them.
Check out jQuery mobile, as well as this very informative slideshare which describes the scope and difficulty of the problem you're facing.

Firefox XUL toolbar with javascript to IE?

I have developed a Firefox toolbar in XUL, which uses javascript to manipulate the DOM.
I'd like to export this to IE.
I know that IE doesn't support XUL, but wonder:
(1) is there an easy way to use the existing javascript code for the IE toolbar as well?
(2) is there a IE installer that easily creates all necessary registry values for creating a toolbar?
I'd be grateful for any help. If anyone can point me to a sample IE toolbar code, with several buttons, drop-down menus and perhaps even a search box, that'll make things much easier as well.
Thanks!
Try AmpleSDK by using this you may port your toolbar to ie
Writing an IE toolbar requires C++, the Windows API and Microsoft COM. If you have the paid version of Visual Studio then you can also use ATL to simplify some of the work.
You won't be able to re-use your JavaScript code. Unless perhaps JavaScript code for manipulating the DOM of the currently loaded webpage.
This article is what got me started:
http://msdn.microsoft.com/en-us/library/bb776819.aspx
I found this to be a helpful sample.
I want to warn you though that creating an IE toolbar can be quite painful. If you are serious then I recommend that you learn and understand the basics of COM and ActiveX first. (I did not do this and spent many hours messing around getting nowhere.)
An alternative option would to embed XULRunner in IE. It would allow you to port most of your code. I have never tried this myself though.
Well the company www.softomate.com is focused on porting existing FF plugins to IE and other browsers. We were able to port my existing Security related plugin to IE and Safari with them.

Categories

Resources