Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   JSON without AJAX (http://www.velocityreviews.com/forums/t922059-json-without-ajax.html)

VK 12-22-2005 12:08 PM

JSON without AJAX
 
Mission statement:

A mechanics to get text stream into browser from any Web location
without reloading the current page.

1) This mechanics has to support *at the very least* IE 5.5 and higher
and Firefox 1.5 and higher: but it may be completely different from one
browser to another. It is important only to be able to build an
uniformed interface atop of it.

2) This mechanics has to exploit some core features of modern browsers
so it would not be possible to lock it without stopping the browser to
be a browser (like visited links sniffing).

Com'on guys: let's hack sh** out of them! :-)

My initial donation:
1)
<link
id = "JSON"
title="JSON"
rel="alternate appendix"
type="text/plain"
href="data.txt"
charset="iso-8859-1"
hreflang="en-US">

Not even a hack, but seems to way to get the data.txt content

2)
<link
id = "JSON"
title="JSON"
rel="alternate stylesheet"
type="text/css"
href="data.css"
charset="iso-8859-1"
hreflang="en-US">

That would be nearly ideal as style rule declaration is almost
identical to JSON object syntaxes. But unknown attributes are ignored
so:
..data {
key1:value1;
key2:value2;
key3:value3;
}
will result into empty parenthesis
..data {}

Any way to stop it?

3)
IE-only "download" behavior
Not explored plus seems too easy to "upgrade security" if Microsoft
decides to. Still decided to mention.


P.S. If you find some really breathtaking solution conformant to the
requirement 2) above you may want to try to copyright it first before
posting in a public forum. Or you may don't - but needs to be
mentioned.


RobG 12-22-2005 02:33 PM

Re: JSON without AJAX
 
VK wrote:
> Mission statement:
>
> A mechanics to get text stream into browser from any Web location
> without reloading the current page.
>
> 1) This mechanics has to support *at the very least* IE 5.5 and higher
> and Firefox 1.5 and higher: but it may be completely different from one
> browser to another. It is important only to be able to build an
> uniformed interface atop of it.
>
> 2) This mechanics has to exploit some core features of modern browsers
> so it would not be possible to lock it without stopping the browser to
> be a browser (like visited links sniffing).
>
> Com'on guys: let's hack sh** out of them! :-)


No hack required:

<script type="text/javascript" src="json.data"></script>


You can even dynamically load the script files using DOM to add the
script elements.


[...]

>
> P.S. If you find some really breathtaking solution conformant to the
> requirement 2) above you may want to try to copyright it first before
> posting in a public forum.


No need to 'try to copyright it'. Original work is copyright the
moment it is fixed in some medium (in most jurisdictions that observe
copyright).


> Or you may don't - but needs to be
> mentioned.


No, it doesn't.


--
Rob

VK 12-22-2005 02:53 PM

Re: JSON without AJAX
 

RobG wrote:
> No hack required:
> <script type="text/javascript" src="json.data"></script>
> You can even dynamically load the script files using DOM to add the
> script elements.


That was the most obvious one, already discussed in this group.
Drawbacks:
1) Interpreter will try to parse received data right on arrival. For
serialized objects it will create unnecessary overheat plus potential
error stream.
Does
scriptObject.defer = true
help in that?

2) IE supports onreadystatechange for scriptObject.
readyState comes in traditional IE's string notation:
"uninitialized"
"loading"
"loaded"
"interactive"
"complete"
(instead of 0 -4, that was IE's partial compromise for AJAX users).

That would be easy to fix but up to date no other rivals seems to
support onreadystatechange except for XMLHttpRequest (?)

So how to get state update in a nice and reliable way?

> No need to 'try to copyright it'. Original work is copyright the
> moment it is fixed in some medium (in most jurisdictions that observe
> copyright).


Read the already discussed GIF story. At least in the USA if you post
some information in a public media and do not state any copyrights in
such publication, it is assumed that you forward it to the public
domain. Still reversable but easier to say right away "This work is
mine and I want to copyright it as soon as I can". Why make things more
difficult as they should be? ;-)


VK 12-22-2005 02:58 PM

Re: JSON without AJAX
 
> easier to say right away "This work is
> mine and I want to copyright it as soon as I can".


As you may notice * I * personally do not say it anywhere.
But I cannot act for everyone else.


bwucke@gmail.com 12-22-2005 03:06 PM

Re: JSON without AJAX
 
On related note, any way to access/process the data (binary) of an
image? (<img src> or Image() ?)


re: copyright. By law you own copyright to anything you publish unless
you state otherwise. Thing is, you need some kind of proof you're the
original author. Anyone can publish your work and (wrongly) claim
copyright on it, and unless you can prove you created it before they
did, you can do nothing about it even if lawfully it belongs to you.
Doesn't work on patenting, ideas enter public domain and become
unpatentable when published - so nobody can copy your code verbatim
legally but they can use the same ideas.


VK 12-22-2005 03:18 PM

Re: JSON without AJAX
 

bwucke@gmail.com wrote:
> On related note, any way to access/process the data (binary) of an
> image? (<img src> or Image() ?)


>From the disk or from the web?


On Firefox and Netscape you can use undocumented but perfectly
functionning btoa() and atob() methods to convert data to base64 and
back for Web transmission.
IE doesn'r have such methods so they need to be emulated by custom
JavaScript program. Due to some buffer limitations any solution will
get dead slow or even crashes for files approx. > 100Kb

Explicit binary transmission (or reading binary files from disk) is not
allowed in IE: you're getting only the file header.

Noop :-(

> re: copyright. By law you own copyright to anything you publish unless
> you state otherwise. Thing is, you need some kind of proof you're the
> original author. Anyone can publish your work and (wrongly) claim
> copyright on it, and unless you can prove you created it before they
> did, you can do nothing about it even if lawfully it belongs to you.
> Doesn't work on patenting, ideas enter public domain and become
> unpatentable when published - so nobody can copy your code verbatim
> legally but they can use the same ideas.


Good to know to everyone, thanks.


VK 12-22-2005 03:33 PM

Re: JSON without AJAX
 
bwucke@gmail.com wrote:
> On related note, any way to access/process the data (binary) of an
> image? (<img src> or Image() ?)


Thinking over:

What DOM objects ever had or have or will have loadable .location .src
or .href or similar property?

Off my head:
window
frame
document
iframe
link (style)
script
object (HTML) ?
image

Is it all?


bwucke@gmail.com 12-22-2005 06:14 PM

Re: JSON without AJAX
 
> Is it all?
A
APPLET
AREA
BASE
INPUT type=image
META (sometimes contains URLs...)
everything that takes "longdesc".


Thomas 'PointedEars' Lahn 12-22-2005 06:51 PM

Re: JSON without AJAX
 
bwucke@gmail.com wrote:

>> Is it all?

> A
> APPLET
> AREA
> BASE
> INPUT type=image
> META (sometimes contains URLs...)
> everything that takes "longdesc".


He referred to "DOM objects ever had or have or will have
_loadable_ .location .src or .href or similar property",
note the Subject.

If you would have quoted what you are referring to, you
would have known.

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
<URL:http://www.safalra.com/special/googlegroupsreply/>


PointedEars

VK 12-22-2005 07:09 PM

Re: JSON without AJAX
 

Thomas 'PointedEars' Lahn wrote:
> bwucke@gmail.com wrote:
>
> >> Is it all?

> > A
> > APPLET
> > AREA
> > BASE
> > INPUT type=image
> > META (sometimes contains URLs...)
> > everything that takes "longdesc".



INPUT type=image
At least one hit to the piggybank. But I'm affraid by usability same as
Image - see higher in this thread.
I had no idea about "longdesc". But like META or A - just passive URI
linking.

Here is the property dump of SCRIPT object in Firefox 1.5 I'm wondering
if any of properties could be checked for presence / availability
during the script loading to emulate onreadystatechange functionality.
Not to say I cannot do it myself - but someone may have an immediate
answer or comment.

nodeName = SCRIPT
nodeValue = null
nodeType = 1
parentNode = [object HTMLHeadElement]
childNodes = [object NodeList]
firstChild = [object Text]
lastChild = [object Text]
previousSibling = [object Text]
nextSibling = null
attributes = [object NamedNodeMap]
ownerDocument = [object HTMLDocument]
insertBefore = function insertBefore() {
[native code]
}
replaceChild = function replaceChild() {
[native code]
}
removeChild = function removeChild() {
[native code]
}
appendChild = function appendChild() {
[native code]
}
hasChildNodes = function hasChildNodes() {
[native code]
}
cloneNode = function cloneNode() {
[native code]
}
normalize = function normalize() {
[native code]
}
isSupported = function isSupported() {
[native code]
}
namespaceURI = null
prefix = null
localName = SCRIPT
hasAttributes = function hasAttributes() {
[native code]
}
tagName = SCRIPT
getAttribute = function getAttribute() {
[native code]
}
setAttribute = function setAttribute() {
[native code]
}
removeAttribute = function removeAttribute() {
[native code]
}
getAttributeNode = function getAttributeNode() {
[native code]
}
setAttributeNode = function setAttributeNode() {
[native code]
}
removeAttributeNode = function removeAttributeNode() {
[native code]
}
getElementsByTagName = function getElementsByTagName() {
[native code]
}
getAttributeNS = function getAttributeNS() {
[native code]
}
setAttributeNS = function setAttributeNS() {
[native code]
}
removeAttributeNS = function removeAttributeNS() {
[native code]
}
getAttributeNodeNS = function getAttributeNodeNS() {
[native code]
}
setAttributeNodeNS = function setAttributeNodeNS() {
[native code]
}
getElementsByTagNameNS = function getElementsByTagNameNS() {
[native code]
}
hasAttribute = function hasAttribute() {
[native code]
}
hasAttributeNS = function hasAttributeNS() {
[native code]
}
id =
title =
lang =
dir =
className =
text =
function init() {
var out = document.forms[0].out;
var js = document.getElementsByTagName('SCRIPT')[0];
for (i in js) {out.value+= i+' = '+js[i]+'\n';}
}

htmlFor =
event =
charset =
defer = false
src =
type = text/javascript
ELEMENT_NODE = 1
ATTRIBUTE_NODE = 2
TEXT_NODE = 3
CDATA_SECTION_NODE = 4
ENTITY_REFERENCE_NODE = 5
ENTITY_NODE = 6
PROCESSING_INSTRUCTION_NODE = 7
COMMENT_NODE = 8
DOCUMENT_NODE = 9
DOCUMENT_TYPE_NODE = 10
DOCUMENT_FRAGMENT_NODE = 11
NOTATION_NODE = 12
offsetTop = 0
offsetLeft = 0
offsetWidth = 0
offsetHeight = 0
offsetParent = null
innerHTML =
function init() {
var out = document.forms[0].out;
var js = document.getElementsByTagName('SCRIPT')[0];
for (i in js) {out.value+= i+' = '+js[i]+'\n';}
}

scrollTop = 0
scrollLeft = 0
scrollHeight = 0
scrollWidth = 0
clientHeight = 0
clientWidth = 0
tabIndex = -1
blur = function blur() {
[native code]
}
focus = function focus() {
[native code]
}
style = [object CSSStyleDeclaration]
removeEventListener = function removeEventListener() {
[native code]
}
dispatchEvent = function dispatchEvent() {
[native code]
}
baseURI = file:///D:/JS/TMP1135277704.htm
compareDocumentPosition = function compareDocumentPosition() {
[native code]
}
textContent =
function init() {
var out = document.forms[0].out;
var js = document.getElementsByTagName('SCRIPT')[0];
for (i in js) {out.value+= i+' = '+js[i]+'\n';}
}

isSameNode = function isSameNode() {
[native code]
}
lookupPrefix = function lookupPrefix() {
[native code]
}
isDefaultNamespace = function isDefaultNamespace() {
[native code]
}
lookupNamespaceURI = function lookupNamespaceURI() {
[native code]
}
isEqualNode = function isEqualNode() {
[native code]
}
getFeature = function getFeature() {
[native code]
}
setUserData = function setUserData() {
[native code]
}
getUserData = function getUserData() {
[native code]
}
DOCUMENT_POSITION_DISCONNECTED = 1
DOCUMENT_POSITION_PRECEDING = 2
DOCUMENT_POSITION_FOLLOWING = 4
DOCUMENT_POSITION_CONTAINS = 8
DOCUMENT_POSITION_CONTAINED_BY = 16
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32



All times are GMT. The time now is 05:48 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.