Comments (4)
The plot thickens!
Sometimes the bib_list in jStorage is a string and sometimes it's an array!
If you add/remove on the search result page (opac-search.pl), it'll add/remove as strings.
However, if you add 2 records to the cart, open the cart, and remove one item, the "bib_list" value in local storage will now be an array!!!
from edsapi-koha-plugin.
Four examples of "bib_list" being set:
- $.jStorage.set("bib_list",QueryString('bib_list'),{TTL:edsConfig.cookieexpiry_60_1000});
- $.jStorage.set("bib_list","",{TTL:edsConfig.cookieexpiry_60_1000}); // added this line
-
$.jStorage.set("bib_list",$ .cookie("bib_list"),{TTL:edsConfig.cookieexpiry_60_1000}); -
$.jStorage.set("bib_list",$ .cookie("bib_list"),{TTL:edsConfig.cookieexpiry_60_1000});
2-4 treat "bib_list" as a string, but 1 treats it as an array. Of course, it's worth noting that it puts the whole querystring in as a single array element.
from edsapi-koha-plugin.
It looks like "document.cookie = 'bib_list='+jbib_list;" works with jbib_list as a string or an array, because the interpreter coerces the array into a string when concatenating the values.
But naturally "jbib_list.split" will work on a string but not an array...
And "basketcount" will be defined in opac-search.pl because the jquery populates that variable with an HTML object, whereas in opac-basket.pl, it's undefined.,, so the cookie will be reset on opac-search.pl regardless of whether or not "bib_list" is a string or an array... but the updateBasket in that block will never work... because jbib_list.split will fail for an array... and if a string is used it will update the basket count with the length of the string because of "updateBasket(jbib_list.length-1);"
I figure it makes more sense to just handle bib_list as a string.
Of course, since the local storage never expires, it's probably necessary to include some data type detection when doing $.jStorage.get("bib_list")....
from edsapi-koha-plugin.
Thanks for looking into this.
These 2 lines are now commented out in the latest version which fixed cart count.
//if (basketcount != jbib_list.split('/').length - 1)
//updateBasket(jbib_list.length -1);
bib_list is stored in jStorage because the cookie path/scope is /cgi-bin/koha/ but the plugin path/scope is plugin/Koha/Plugin/EDS/opac/ so the cart values are not accessible.
Wanted to avoid changing the path of bib_list to / as it could have unintended consequences.
from edsapi-koha-plugin.
Related Issues (20)
- Can't locate object method "create_message_headers" via package "Koha::Email" error when sending email from the Cart HOT 2
- Results not updated after logging in HOT 2
- 21.05 version of plugin does not start on Koha 21.05 HOT 5
- eds-detail.pl needs to be updated for Bootstrap in 21.05+
- Plugin doesn't appear at Koha 21.11 and produces 500 error HOT 3
- Plugin will not start in Koha 21.11 HOT 2
- Plugin does not include a en.inc file
- Cannot send opac baskets in Koha 21.11 HOT 7
- 500 Error when refreshing session token HOT 9
- SetEDS() and SetKoha() functions attempt to call jQuertUI's autocomplete
- Plugin not constructing URLs correctly in 22.11.08 HOT 5
- Cannot download cart in Koha 22.11
- Cannot send cart from OPAC in 22.11
- Issues loading plugin in IE, EDGE, Safari HOT 2
- Cannot send basket with Koha 19.05 & plugin 19.05009 HOT 1
- Out of date templates with Koha 20.11 HOT 5
- Search select delayed population can cause user confusion HOT 5
- README.md appears to be incorrect regarding versions HOT 3
- Using Github's "Releases" functionality HOT 2
- Use Koha's REST API instead of relying on altered Apache configuration HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edsapi-koha-plugin.