问题描述:

How to convert this script which use deprecadted E4X ?

Flickr Functional Suite.

i am not a programmer, but if you explain to me where i need to start, i do my best.

In first , it seems not a problem of CDATA ...

Here a link, in Buggzilla , where i describe my problem :

Firefox 17 breaks a Greasemonkey script that relies on E4X (New : Firefox 21 delete totally its support)

I obtain here a first indice where E4x is in use (search in the code "ricCB") :

requestImageComments: function( id ) {

if (!id) return;

var tkey = 'getComments';

// Set up ticket status queue if needed

if (!this.ticketStatus[tkey]) this.ticketStatus[tkey] = new Object();

return this.flickrApi

( { method: 'flickr.photos.comments.getList', photo_id: id },

'ricCB', {ticktype: tkey} );

},

ricCB: function(rsp) {

var hash = this.objects.comments;

for each (comments in rsp.comments) {

// for (var cs = 0; cs < rsp.comments.length; cs++) {

// var comments = rsp.comments[cs];

var pid = [email protected]_id;

for each (com in comments.comment) {

var uname = [email protected];

var nsid = [email protected];

this.setTranslation( { uname: uname, nsid: nsid } );

// var create = new Date( [email protected] );

var ctxt = com + '';

// Strip out HTML tags:

ctxt = ctxt.replace(/(\<|\&lt\;).+?(\>|\&gt\;)/g,'');

// Collapse all whitespace runs to single spaces:

ctxt = ctxt.replace(/[\s\n\r\t]+/g, ' ');

// Store data under both authorname and photo ID (hash

// will collide only if someone is using a pure

// integer as a name AND a photo has same integer).

var info = { txt: ctxt, uname: uname, photo: pid };

if (!hash[uname]) hash[uname] = new Array();

if (!hash[pid]) hash[pid] = new Array();

hash[uname].push(info);

hash[pid].push(info);

}

}

Initially posted here :

My Greasemonkey script stopped working after something updated

网友答案:

If there is a dependency on e4x, try including the JavaScript implementation:

  • e4x.js

As an alternative, here are other questions which cover mapping e4x syntax to XPath or XML to JSON:

  • What is the Flex/AS3/E4X equivalent of this xpath query?
  • Howto convert E4X XML Elements into JSON Notation

In addition, you can continue to use e4x by accessing the data via yql:

  • Using e4x with yql

References

  • AJAX and scripting web services with E4X, Part 1

  • E4X Missing in JS - Apache Flex - Apache Software Foundation

  • E4X Observations - Apache Flex - Apache Software Foundation

相关阅读:
Top