Closed remygithub closed 3 years ago
I would suspect something goes wrong with deferred JS execution. Which versions of DW and RefNotes do you use?
Running DW Release 2020-07-29 "Hogfather" and RefNotes version 2020-08-10.
I tried disabling defer_js
but no change: config settings still unavailable.
Is there anything else I could try to test your hypothesis on the deferred JS execution?
Given the latest versions of both DW and plugin, and the fact that defer_js
had no effect (BTW, did you wipe the cache?) I would assume that deferred JS is not the issue. In #52 multiple people tried these versions and it worked okay for them. There should be something specific to your setup. I use FF 78 myself and that works fine, but maybe you could try another browser. Since we talk about JS error I doubt it makes much sense to look into server side PHP code.
If you are familiar with JS, try to add some logging around the place of the error. To start with, I would look what is field name
and value returned by fields.getItem(name)
right before the error.
I tried it in Chrome -- same result.
TBH I don't have any JS or PHP experience...can't say that I understand how all of this works.
That said, I've written quite a bit of code over the past 20y and I do not mind learning new things, especially if it helps my work -- I absolutely need your plugin for a current project! I apologize for not saying it earlier: thank you for developing and sharing it!
So far I changed updateFields()
(containing he first error, around line 710) as follows:
function updateFields() {
jQuery('#name-namespaces').val(current.getName());
jQuery('#rename-namespaces').prop('disabled', current.isReadOnly());
jQuery('#delete-namespaces').prop('disabled', current.isReadOnly());
console.group("Refnotes Debug");
for (var name in fields.items) {
console.log("\n updating field...");
console.log(name);
console.log("\n with item...");
console.log(fields.getItem(name));
fields.getItem(name).update();
}
console.groupEnd()
}
Everything seems fine for fields style
, font
, etc. until it gets to shuffle
, which does not have an update()
function:
Sorry for the rudimentary debugging experience in JS. Let me know if the above is helpful or if you want me to do something else.
Well, we start to get somewhere. That shuffle
thing looks rather surprising as there is no such field. The fields are added to a hash map in initialize()
lines 599-624. There you can see all names that should show up during updateFields()
call, and shuffle
is not there. BTW, congratulations on not having to deal with JS over the past 20 years ;)
I suspect that some other plugin injects shuffle
into Array
prototype, which is usually frowned upon. Try to grep your plugin directory for shuffle
to see if that's the case. Temporarily disable plugin messing with the prototype if you find one to see if that helps.
You were right about interference but it was the sprintdoc template causing the problem:
$grep -Ril shuffle lib
lib/tpl/sprintdoc/js/base/spc.js
lib/scripts/jquery/jquery-ui-theme/smoothness.css
In lib/tpl/sprintdoc/js/base/spc.js
:
200 // + + + + + + + + + + + + + + + + + + + + + + + + + + + +
201 // shuffle func for random values
202 // + + + + + + + + + + + + + + + + + + + + + + + + + + + +
203 Array.prototype.shuffle = function(){
204 var tmp, rand;
205 for(var i =0; i < this.length; i++){
206 rand = Math.floor(Math.random() * this.length);
207 tmp = this[i];
208 this[i] = this[rand];
209 this[rand] =tmp;
210 }
211 };
After disabling the sprintdoc template Refnotes config worked as expected! Too bad about sprintdoc as I really liked it...
Thank you for your guidance on solving the issue! Remy
PS: what is the preferred way to get help in configuring Refnotes?
If you really like that template, you can try a workaround suggested in the SO page I linked above:
Object.defineProperty(Array.prototype, 'shuffle', {
var tmp, rand;
for(var i =0; i < this.length; i++){
rand = Math.floor(Math.random() * this.length);
tmp = this[i];
this[i] = this[rand];
this[rand] =tmp;
}
});
As for the configuration, you could give an example of formatting you look for. Just create some dummy DW page using whatever formatting you need. I will see how close RefNotes can get to that.
Apparently, since 2009 when admin page was created there was some progress in JS. In ECMAScript 6 (released in June 2015) they got a proper Map
object, so here is no need to cook-up your own implementation anymore. Also the page from which I copied HashMap
updated quite a bit and doesn't use Array
as a base container anymore. I guess, it's time to update that part in RefNotes as well.
I tried the re-write of shuffle
you suggested and sprintdoc
does not seem to play nice.
admin.js
bugs out way before reaching line 710 like before and I get the following errors:
Uncaught ReferenceError: DOKU_BASE is not defined
sendRequest http://127.0.1.1:XXXX/lib/plugins/refnotes/admin.js:196
loadSettings http://127.0.1.1:XXXX/lib/plugins/refnotes/admin.js:224
initialize http://127.0.1.1:XXXX/lib/plugins/refnotes/admin.js:1024
<anonymous> http://127.0.1.1:XXXX/lib/plugins/refnotes/admin.js:1091
Line 196 in admin.js
:
url : DOKU_BASE + 'lib/exe/ajax.php',
There are also weird and changing syntax errors in js.php
:
Uncaught SyntaxError: expected expression, got '='
Uncaught SyntaxError: missing : after property id
That js.php
script has only 490 lines but it seems to source a bunch of other scripts. The weird parts are that the template related script seems to have only comments and that the syntax errors listed above are changing when changing settings on the DW config page.
Anyway, all of the above seem related to sprintdoc and RefNote
works when that template is not used.
Let me know if you want me to test anything when you decide to update admin.js
As far as configuring Refnotes, I just want to have a Bibliography/References section that combines footnotes and citations in a format like IEEE, for example.
Here is an example for referring page:
====== Testing References ======
Testing footnote1[(Footnote_1)] and footnote2[(Footnote_2)]
Citing reference1 [(qpm_tomography:park_diffraction_2006)] and reference2 [(qpm_tomography:pan_computational_1983)].
Again citing reference1 [(qpm_tomography:park_diffraction_2006)] and reference2 [(qpm_tomography:pan_computational_1983)].
===== References =====
[(Footnote_1>FIrst footnote)]
[(Footnote_2>Second footnote)]
Bibliography page in :refnotes:
namespace (sorry, I copied an existing page):
====== Initial Work On QPM Tomography ======
<refnotes qpm_tomography> inherit: :cite: </refnotes>
<code bibtex>
@Comment{refnotes,
namespace = "qpm_tomography"
}
@article{park_diffraction_2006,
title = {Diffraction phase and fluorescence microscopy},
volume = {14},
url = {http://www.opticsexpress.org/abstract.cfm?URI=oe-14-18-8263},
doi = {10.1364/OE.14.008263},
number = {18},
urldate = {2014-04-08},
journal = {Optics Express},
author = {Park, YongKeun and Popescu, Gabriel and Badizadegan, Kamran and Dasari, Ramachandra R. and Feld, Michael S.},
month = sep,
year = {2006},
keywords = {Fluorescence microscopy, Microscopy},
pages = {8263--8268},
file = {oe-14-18-8263.pdf:/home/remy/Zotero/storage/B4KZFRSC/oe-14-18-8263.pdf:application/pdf;Opt. Express Snapshot:/home/remy/Zotero/storage/4EFR4AG9/abstract.html:text/html;Opt. Express Full Text PDF:/home/remy/Zotero/storage/ENH4TXIA/Park et al. - 2006 - Diffraction phase and fluorescence microscopy.pdf:application/pdf}
}
@article{pan_computational_1983,
title = {A computational study of reconstruction algorithms for diffraction tomography: {Interpolation} versus filtered-backpropagation},
volume = {31},
issn = {0096-3518},
shorttitle = {A computational study of reconstruction algorithms for diffraction tomography},
doi = {10.1109/TASSP.1983.1164196},
abstract = {From the standpoint of reporting a new contribution, this paper shows that by using bilinear interpolation followed by direct two-dimensional Fourier inversion, one can obtain reconstructions of quality which is comparable to that produced by the filtered-backpropagation algorithm proposed recently by Devaney. For an N × N image reconstructed from N diffracted projections, the former approach requires approximately 4N FFT's, whereas the backpropagation technique requires approximately N2FFT's. We have also taken this opportunity to present the reader with a tutorial introduction to diffraction tomography, an area that is becoming increasingly important not only in medical imaging, but also in underwater and seismic mapping with microwaves and sound. The main feature of the tutorial part is the statement of the Fourier diffraction projection theorem, which is an extension of the traditional Fourier slice theorem to the case of image formation with diffracting illumination.},
number = {5},
journal = {IEEE Transactions on Acoustics, Speech and Signal Processing},
author = {Pan, S. X. and Kak, A.C.},
year = {1983},
keywords = {Image reconstruction, Interpolation, Tomography, Acoustic diffraction, Biomedical imaging, Reconstruction algorithms, Lighting, Backpropagation algorithms},
pages = {1262--1275}
}
</code>
I get:
instead of the citations section to have
[1] Y. Park, G. Popescu, K. Badizadegan, R. R. Dasari, and M. S. Feld, “Diffraction phase and fluorescence microscopy,” Opt. Express, vol. 14, no. 18, pp. 8263–8268, Sep. 2006,
[2] S. X. Pan and A. C. Kak, “A computational study of reconstruction algorithms for diffraction tomography: Interpolation versus filtered-backpropagation,” IEEE Transactions on Acoustics, Speech and Signal Processing, vol. 31, no. 5, pp. 1262–1275, 1983.
Also
Anyway the current output is not what I am used to and I find it to clutter the page. That said, it is not the end of the world.
Finally, a useful enhancement would be for the pop-up to display the title and the abstract (if available in the bibtex reference -- see above) for when an internet connection is not available.
Thanks again for helping me figure this thing out!
Sorry, my bad. I missed one more layer of wrapping in that example. It should be:
Object.defineProperty(Array.prototype, 'shuffle', {
value: function() {
var tmp, rand;
for(var i =0; i < this.length; i++){
rand = Math.floor(Math.random() * this.length);
tmp = this[i];
this[i] = this[rand];
this[rand] =tmp;
}
}
});
To get formatting closer to what you want try to inherit harvard
styling for qpm_tomography
namespace:
...
===== References =====
[(Footnote_1>FIrst footnote)]
[(Footnote_2>Second footnote)]
<refnotes></refnotes>
<refnotes qpm_tomography>
inherit: harvard
</refnotes>
The result:
The Object.defineProperty
change to lib/tpl/sprintdoc/js/base/spc.js
worked: now I can use sprintdoc with refnotes!
The changes to Testing References
worked out to what I wanted as well after some tuning of :harvard:
.
Thank you again! Let me know if there is any way I can pay back you kindness in helping with this.
You are welcome :)
Migrated to ES6 Map in 20b44e6.
Description
General Settings
andNamespaces
sections are disabledNotes
section appear to be enabled but no action when trying to add a test noteSave
button is enabled but seems no actionAttempted use
:refnotes:
namespace inroot
Bibtex
code section with one reference@Comment
for namespace per instructionsDesired behaviour
bibtex
notes to reference throughout the dokuwiki siteSite configuration
Using Firefox 78.0 with nginx.
Other plugins enabled:
Debugger Feedback
Debugger console output when loading
Refnotes
config pageError:
Warning: