Triply-Dev / YASGUI.YASR-deprecated

Deprecated, see https://github.com/TriplyDB/Yasgui for the Yasgui monorepo
MIT License
26 stars 22 forks source link

Pivot table plugin not working with Privacy Badger #28

Closed jneubert closed 9 years ago

jneubert commented 9 years ago

In FF, the table just disappears when I click the Pivot table button (reproducable on http://yasr.yasgui.org/).

LaurensRietveld commented 9 years ago

I couldnt reproduce this on firefox. Do you have more info? (e.g. browser version)

jneubert commented 9 years ago

My Firefox version on the desktop is 33.0.2.

On my notebook, with 33.1.1, it works!

I'll investigate more.

jneubert commented 9 years ago

Strange - even if I update to 34.0, desktop does not work.

LaurensRietveld commented 9 years ago

Could you try using that browser in 'privacy mode'? (ctrl shift n I believe) It might be one of your addons (these are disabled in privacy mode) On Dec 8, 2014 5:33 PM, "Joachim Neubert" notifications@github.com wrote:

Strange - even if I update to 34.0, desktop does not work.

— Reply to this email directly or view it on GitHub https://github.com/YASGUI/YASR/issues/28#issuecomment-66142522.

jneubert commented 9 years ago

Yep - that was my idea, too. The culprit is EFF's "Privacy Badger" (https://www.eff.org/privacybadger).

I'll try to find settings, with which both work, and report here.

LaurensRietveld commented 9 years ago

Great, thanks On Dec 8, 2014 5:41 PM, "Joachim Neubert" notifications@github.com wrote:

Yep - that was my idea, too. The culprit is EFF's "Privacy Badger" ( https://www.eff.org/privacybadger).

I'll try to find settings, with which both work, and report here.

— Reply to this email directly or view it on GitHub https://github.com/YASGUI/YASR/issues/28#issuecomment-66144006.

jneubert commented 9 years ago

I've to enable beeing tracked by google.com to make it work. One of the worst - gnnrrrr ... (That can be achieved by clicking on the "Privacy Badger" button, and moving the google.com slider from red to yellow or green).

Unfortunately, setting YASR.plugins.pivot.useGChart = false; did not help.

LaurensRietveld commented 9 years ago

I've made some small modifications to the pivot plugin, to keep working when there are missing dependencies. But: I couldnt make the google chart inclusions more robust. I.e., these still crash when the request is blocked from the client's side. The reasons for this is somewhere deep inside the jquery code. For regular ajax requests, the 'fail' callback is properly triggered. For this ajax request (which loads a resource via the script tag, needed to load the google visualizations), the 'fail' callback is -not- trigerred.

So, too bad that this breaks the pivot functionality for people with such a browser addon, but there is no easy solution for this (if any)

ps. I could still get the pivot to work (using the privacy badger plugin), by disabling google charts (YASR.plugins.pivot.defaults.useGChart = false;). You tried that as wel right? Did you set this value before instantiating YASR?

jneubert commented 9 years ago

Yes, I think so, my yasr related code is:

// merge fitting labels into uris, don't try to fetch from preflabel.org
YASR.plugins.table.defaults.mergeLabelsWithUris = true;
YASR.plugins.table.defaults.fetchTitlesFromPreflabel = false;
YASR.plugins.table.defaults.datatable.pageLength = 50;
YASR.plugins.pivot.useGChart = false;

var yasr = YASR(document.getElementById("yasr"), {
  //this way, the URLs in the results are prettified using the defined prefixes in the query
  getUsedPrefixes: yasqe.getPrefixesFromQuery
});
jneubert commented 9 years ago

oh, i see there is a difference ...

jneubert commented 9 years ago

When add the defaults, it works! Thanks!!

LaurensRietveld commented 9 years ago

excellent ;)

LaurensRietveld commented 9 years ago

Will still see whether I can fix this (or at least whether I can make it work when YASR is used offline (might happen frequently). haven't check that one yet)

LaurensRietveld commented 9 years ago

I'll reopen this one. I've done some testing, and noticed that this ajax call cannot fetch -any- erorr (including errors caused by user being offline). Reason is faulty error handling for this particular type of ajax call (see http://stackoverflow.com/questions/3364096/jquery-ajax-error-handling-with-script-datatype/27404908#27404908).

Solutions: either use version 2.x of jquery (and lose support for IE <=8), or backport this ajax functionality from jquery 2.x to 1.x. The latter is tricky, but a lot nicer..

LaurensRietveld commented 9 years ago

So, I've done some modifications. Some background: It is -very- difficult to catch script loader errors (see http://www.html5rocks.com/en/tutorials/speed/script-loading/) Existing libraries either ignore several browsers (e.g. jquery 2.x), or use ugly hacks (timeouts or something)

I opted for the custom hack solution as well: script are loaded using vanilla js (to avoid jquery exception crashing the whole of YASR). On success, we use the regular callbacks. To detect a fail (e.g. blocked by plugin, or offline), we poll every 100 ms whether the script is loaded yet. When, after 6 seconds, it is still not loaded, we call the failure callback (which disable google charts functionality in YASR).

And, for your reference: I mentioned the useGchart option. This is now changed to a 'useGoogleCharts' option. This option exists for the pivot plugin, but also for YASR as a whole (as google charts is now used as an additional plugin as well, seperately from the pivot plugin).

The version is not published yet. Will do that later tonight