Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25483
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Images and pdf in a div |
| Date | 2014-07-20 12:42 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <2221038.iVyETpmlb9@PointedEars.de> (permalink) |
| References | (1 earlier) <lqdl2u$45o$1@solani.org> <lqds4k$iad$1@dont-email.me> <XnsA36FA164733A9eejj99@194.109.133.133> <lqe6fa$sid$1@dont-email.me> <m_CdnTCZ5NKWzlbOnZ2dnUVZ_tGdnZ2d@westnet.com.au> |
Andrew Poulos wrote:
> How about changing the code to something like:
>
> var AcrobatInfo = (function() {
Not a constructor; by convention, the name should start lowercase.
Preferably, you would put it in a private namespace, like “ap.acrobatInfo”.
Creating a user-defined object that would retrieve the information about all
plugins, and then would allow to retrieve information for a specific plugin,
is indicated.
> var isInstalled = false,
> vern = null;
>
> function findPlugin(nme) {
> var p;
> for (key in navigator.plugins) {
Do not use the for-in statement with host objects and array-like objects;
their properties may not be enumerable, not in a defined order or have
enumerable properties that you do not want to iterate over (like “refresh”);
use the “for” statement instead. Exception: Array instances known to
encapsulate a sparse array; in that case for-in is more efficient, and you
can filter and sort the properties later, if necessary.
You have not declared “key”; this code will throw a ReferenceError exception
in strict mode.
> […]
> (function() {
> var plugin;
>
> if (typeof window.ActiveXObject != "undefined") {
Check the “ActiveXObject” property of the global object instead.
> // AcroPDF.PDF is used by version 7 and later
> // PDF.PdfCtrl is used by version 6 and earlier
You should use multi-line comments for documentation instead, in order to be
able to tell them apart from deactivating comments easily.
> try {
> plugin = new ActiveXObject("AcroPDF.PDF");
> isInstalled = true;
> } catch(e) {}
> try {
> plugin = new ActiveXObject("PDF.PdfCtrl");
> isInstalled = true;
> } catch(e) {}
You should nest those try-catch blocks, leaving at most one empty “catch”
block.
“isInstalled” is superfluous because you can test against the value of
“plugin” instead, which would be either not “null” or not “undefined” if
successful, depending on how you initialize it.
> })();
> […]
> })();
I suggest you always use the same indentation for opening and closing
delimiters.
And “}())” instead in order to make clear what makes up the right-hand side
expression. This will also become handy in editors like Vim or Eclipse JSDT
with Vrapper plugin, where, which I discovered yesterday, you can type “vi)”
to select everything between the outer parentheses, for refactoring.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 00:31 +0200
Re: Images and pdf in a div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-07-19 13:34 +0200
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 15:34 +0200
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-19 15:51 +0200
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-19 18:30 +0200
Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-20 15:23 +1000
Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-20 12:42 +0200
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-20 20:07 +0200
Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-21 14:10 +1000
Re: Images and pdf in a div danca <cyberdanny@tiscalinet.it> - 2014-07-21 14:19 +0200
Re: Images and pdf in a div Andrew Poulos <ap_prog@hotmail.com> - 2014-07-21 08:14 +1000
Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-21 02:00 +0200
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-21 07:15 +0200
Re: Images and pdf in a div Osmo Saarikumpu <osmo@weppipakki.com> - 2014-07-24 18:26 +0300
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-24 17:48 +0200
Re: Images and pdf in a div Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-24 22:32 +0100
Re: Images and pdf in a div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-24 23:58 +0200
Re: Images and pdf in a div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-07-24 18:40 +0200
Re: Images and pdf in a div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-25 12:31 +0200
Re: Images and pdf in a div John Harris <niam@jghnorth.org.uk.invalid> - 2014-07-25 15:52 +0100
csiph-web