hci-theme 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/bibsonomy.js ADDED
@@ -0,0 +1,597 @@
1
+ import $ from "jquery";
2
+
3
+ /**
4
+ * Public
5
+ */
6
+
7
+ // Searches the DOM tree for elements with id="bib" and
8
+ // requests the bibliographies specified by the attribute "bibsonomyUrl" from bibsonomy.org
9
+ function initBibsonomy(){
10
+ $("div[bibType='ref-list']").each(function() {
11
+ requestBibsonomyEntries($(this), $(this).attr('bibsonomyUrl'))
12
+ })
13
+ $("#react-placeholder-filterInput[bibType='filter'] > div > input").keyup(function(e) {
14
+ updateBib($("#react-placeholder-filterInput[bibType='filter']").attr('bibsonomyUrl'), e.target.value);
15
+ })
16
+ $("input[type='text'][bibType='filter']").keyup(function(e) {
17
+ updateBib($(e.target).attr('bibsonomyUrl'), e.target.value)
18
+ })
19
+ $("input[type='checkbox'][bibType='filter']").change(function(e) {
20
+ updateBib($(e.target).attr('bibsonomyUrl'))
21
+ })
22
+ var query = parseGetParameters("query");
23
+ if(query != "") {
24
+ $("input[type='text'][bibType='filter']").val(query);
25
+ }
26
+ }
27
+
28
+ function parseGetParameters(val) {
29
+ var result = "",
30
+ tmp = [];
31
+ var items = location.search.substr(1).split("&");
32
+ for (var index = 0; index < items.length; index++) {
33
+ tmp = items[index].split("=");
34
+ if (tmp[0] === val) result = decodeURIComponent(tmp[1]);
35
+ }
36
+ return result;
37
+ }
38
+
39
+
40
+ /**
41
+ * Private
42
+ */
43
+
44
+ //Search in abstracts and bibtex records
45
+ var deepSearch = false
46
+ //Generated HTML-elements for processed bibsonomy requests
47
+ var requests = new Array()
48
+ //Parent div elements for bibliographies
49
+ var parents = new Array()
50
+
51
+ var bibtexSpecs = new Object()
52
+ bibtexSpecs.allKeys = new Array("address", "annote", "author", "booktitle", "chapter", "crossref", "edition", "editor", "eprint", "howpublished", "institution", "journal", "key", "month", "note", "number", "organization", "pages", "publisher", "school", "series", "title", "type", "url", "volume", "year" )
53
+ bibtexSpecs.article = new Array("author", "title", "journal", "year", "volume", "number", "pages", "month", "note", "key")
54
+ bibtexSpecs.book = new Array("author", "editor", "title", "publisher", "year", "volume", "number", "series", "address", "edition", "month", "note", "key")
55
+ bibtexSpecs.booklet = new Array("title", "author", "howpublished", "address", "month", "year", "note", "key")
56
+ bibtexSpecs.conference = new Array("author", "title", "booktitle", "year", "editor", "volume", "number", "series", "pages", "address", "month", "organization", "publisher", "note", "key")
57
+ bibtexSpecs.inbook = new Array("author", "editor", "title", "chapter", "pages", "publisher", "year", "volume", "number", "series", "type", "address", "edition", "month", "note", "key")
58
+ bibtexSpecs.incollection = new Array("author", "title", "booktitle", "publisher", "year", "editor", "volume", "number", "series", "type", "chapter", "pages", "address", "edition", "month", "note", "key")
59
+ bibtexSpecs.inproceedings = new Array("author", "title", "booktitle", "year", "editor", "volume", "number", "series", "pages", "address", "month", "organization", "publisher", "note", "key")
60
+ bibtexSpecs.manual = new Array("title", "author", "organization", "address", "edition", "month", "year", "note", "key")
61
+ bibtexSpecs.masterthesis = new Array("author", "title", "school", "year", "type", "address", "month", "note", "key")
62
+ bibtexSpecs.misc = new Array("author", "title", "howpublished", "month", "year", "note", "key")
63
+ bibtexSpecs.phdthesis = new Array("author", "title", "school", "year", "type", "address", "month", "note", "key")
64
+ bibtexSpecs.proceedings = new Array("title", "year", "editor", "volume", "number", "series", "address", "month", "publisher", "organization", "note", "key")
65
+ bibtexSpecs.techreport = new Array("author", "title", "institution", "year", "type", "number", "address", "month", "note", "key")
66
+ bibtexSpecs.unpublished = new Array("author", "title", "note", "month", "year", "key")
67
+
68
+ /**
69
+ * Retrieves entries from Bibsonomy
70
+ * See: https://www.bibsonomy.org/help_en/Integration%20with%20other%20websites
71
+ */
72
+ function requestBibsonomyEntries(parent, bibsonomyUrl) {
73
+ //Enable loading animation
74
+ parent.height('100px');
75
+ parent.html('Loading...');
76
+ // parent.activity(); // Generates bug in Firefox
77
+
78
+ $.getJSON('https://bibsonomy.org/json/' + bibsonomyUrl + '?items=1000&callback=?', handleJsonBibsonomyRequest.partial(bibsonomyUrl, parent, undefined));
79
+ }
80
+
81
+ function updateBib(bibsonomyUrl, fText) {
82
+ if(parents[bibsonomyUrl]){
83
+
84
+ var filtered = requests[bibsonomyUrl]
85
+ $("input[type='checkbox'][bibType='filter']").each(function() {
86
+ if($(this).attr('bibsonomyUrl') == bibsonomyUrl) {
87
+ if($(this).prop('checked')){
88
+ if($(this).attr('filter'))
89
+ filtered = filter(filtered, $(this).attr('filter'))
90
+ if($(this).attr('filterTag'))
91
+ filtered = filterTag(filtered, $(this).attr('filterTag'))
92
+ if($(this).attr('filterTags'))
93
+ filtered = filterTags(filtered, $(this).attr('filterTags'))
94
+ }
95
+ }
96
+ })
97
+
98
+ if(parents[bibsonomyUrl] && parents[bibsonomyUrl].attr('sortBy') == "date") {
99
+ filtered = filtered.sort(comparatorDate)
100
+ }
101
+
102
+ if(parseInt(parents[bibsonomyUrl].attr('count'))) {
103
+ filtered = filtered.slice(0, parseInt(parents[bibsonomyUrl].attr('count')))
104
+ }
105
+
106
+ if(fText)
107
+ filtered = filter(filtered, fText);
108
+
109
+ updateInfo(bibsonomyUrl, filtered.length)
110
+ insertBibsonomyElementsBelow(filtered, parents[bibsonomyUrl].empty());
111
+ }
112
+ }
113
+
114
+ function bibsonomyPathToId(path) {
115
+ return path.toString().replace(/\//g, '-');
116
+ }
117
+
118
+ function updateInfo(bibsonomyUrl, nrOfSelectedEntries){
119
+ $("[bibType='info']").each(function() {
120
+ if($(this).attr('bibsonomyUrl') == bibsonomyUrl) {
121
+ if((typeof nrOfSelectedEntries != 'undefined') && (nrOfSelectedEntries < requests[bibsonomyUrl].length))
122
+ $(this).html(nrOfSelectedEntries + " / " + requests[bibsonomyUrl].length + " entries")
123
+ else
124
+ $(this).html(requests[bibsonomyUrl].length + " entries")
125
+ }
126
+ });
127
+ }
128
+
129
+ //Processed JSON Bibsonomy request by creating HTML-elements and by inserting them into the document
130
+ function handleJsonBibsonomyRequest(bibsonomyUrl, parent, feed) {
131
+ parents[bibsonomyUrl] = parent
132
+ var elements = processJsonBibsonomyFeed(feed)
133
+ if(parent.attr('filter'))
134
+ elements = filter(elements, parent.attr('filter'))
135
+ if(parent.attr('filterTag'))
136
+ elements = filterTag(elements, parent.attr('filterTag'))
137
+ if(parent.attr('filterTags'))
138
+ elements = filterTags(elements, parent.attr('filterTags'))
139
+ requests[bibsonomyUrl] = elements;
140
+ var query = parseGetParameters("query");
141
+ if(query != "") {
142
+ updateBib(bibsonomyUrl,query);
143
+ } else {
144
+ updateBib(bibsonomyUrl);
145
+ }
146
+ }
147
+
148
+ function insertBibsonomyElementsBelow(elements, parent) {
149
+ //Disable loading animation
150
+ // parent.activity(false);
151
+ parent.height('');
152
+
153
+ var year = 0
154
+ for(var i = 0; i < elements.length; i++){
155
+ if(year != elements[i].year) {
156
+ if(!parseInt(parent.attr('count'))) {
157
+ year = elements[i].year
158
+ var heading = document.createElement("H3");
159
+ heading.innerHTML = year
160
+ heading.className = "bib-year"
161
+ parent.get(0).appendChild(heading);
162
+ }
163
+ }
164
+ parent.get(0).appendChild(elements[i].div_element);
165
+ }
166
+ }
167
+
168
+ //Processed a requested JSON Bibsonomy feed and creates HTML-elements for every entry
169
+ function processJsonBibsonomyFeed(feed) {
170
+ var result = feed.items.sort(comparator);
171
+ var elements = new Array()
172
+ for(var i = 0; i < result.length; i++){
173
+ result[i].bibtex = parseBibtexJSON(result[i])
174
+ result[i].div_element = createDivElementFromBibsonomyItem(result[i])
175
+ }
176
+ return result;
177
+ }
178
+
179
+ //Creates a HTML-element from a bibsonomy feed item
180
+ //http://www.apastyle.org/learn/tutorials/basics-tutorial.aspx
181
+ function createDivElementFromBibsonomyItem(item){
182
+ var itemId = generateLocalId(item.id);
183
+ var item_div = document.createElement("DIV");
184
+ item_div.className = "item"
185
+
186
+ if(item.type == "Bookmark") {
187
+ var title = document.createElement("SPAN");
188
+ title.innerHTML = " " + item.label
189
+ title.className = "pubtitle"
190
+ item_div.appendChild(title);
191
+
192
+ var url = document.createElement("SPAN");
193
+ url.innerHTML = item.url
194
+ url.className = "puburl"
195
+ item_div.appendChild(document.createTextNode(", "));
196
+ item_div.appendChild(url);
197
+
198
+ var date = document.createElement("SPAN");
199
+ date.innerHTML = item.date.split(" ")[0]
200
+ date.className = "pubdate"
201
+ item_div.appendChild(document.createTextNode(", "));
202
+ item_div.appendChild(date);
203
+ }
204
+ else {
205
+ if (item.editors){
206
+ var editors = document.createElement("SPAN");
207
+ editors.innerHTML = editors2txt(item.editors)
208
+ editors.className = "pubeditors"
209
+ }
210
+
211
+ if (item.authors){
212
+ var authors = document.createElement("SPAN");
213
+ authors.innerHTML = authors2txt(item.authors)
214
+ authors.className = "pubauthors"
215
+ }
216
+
217
+ if (authors){
218
+ item_div.appendChild(authors)
219
+ item_div.appendChild(document.createTextNode(", "));
220
+ }else if (editors)
221
+ item_div.appendChild(editors)
222
+
223
+ // if (item.title){
224
+ // var title = document.createElement("SPAN");
225
+ // title.innerHTML = " " + item.label
226
+ // title.className = "pubtitle"
227
+ // item_div.appendChild(document.createTextNode(", "));
228
+ // item_div.appendChild(title);
229
+ // }
230
+
231
+ if (item.label){
232
+ var title = document.createElement("SPAN");
233
+ title.innerHTML = item.label
234
+ title.className = "pubtitle"
235
+ item_div.appendChild(title);
236
+ }
237
+
238
+ if (item.booktitle){
239
+ var booktitle = document.createElement("SPAN");
240
+ booktitle.innerHTML = item.booktitle
241
+ booktitle.className = "pubbooktitle"
242
+ item_div.appendChild(document.createTextNode(", In "))
243
+ }
244
+
245
+ if (item.journal){
246
+ var journal = document.createElement("SPAN");
247
+ journal.innerHTML = item.journal
248
+ journal.className = "pubjournal"
249
+ item_div.appendChild(document.createTextNode(", In "))
250
+ }
251
+
252
+ if(authors && editors)
253
+ item_div.appendChild(editors)
254
+
255
+ if (booktitle)
256
+ item_div.appendChild(booktitle);
257
+
258
+ if (journal)
259
+ item_div.appendChild(journal);
260
+
261
+
262
+ if (item.volume){
263
+ var volume = document.createElement("SPAN");
264
+ volume.innerHTML = item.volume
265
+ volume.className = "pubvolume"
266
+ item_div.appendChild(document.createTextNode(", Vol. "))
267
+ item_div.appendChild(volume);
268
+ }
269
+ if (item.number){
270
+ var number = document.createElement("SPAN");
271
+ number.innerHTML = item.number
272
+ number.className = "pubnumber"
273
+ item_div.appendChild(document.createTextNode(" ("))
274
+ item_div.appendChild(number);
275
+ item_div.appendChild(document.createTextNode(")"))
276
+ }
277
+
278
+ if(item.pages) {
279
+ var pages = document.createElement("SPAN");
280
+ pages.innerHTML = ", " + pages2txt(item.pages)
281
+ pages.className = "pubpages"
282
+ item_div.appendChild(pages);
283
+ }
284
+
285
+ item_div.appendChild(document.createTextNode(". "))
286
+
287
+ if(item.address) {
288
+ var address = document.createElement("SPAN");
289
+ address.innerHTML = item.address
290
+ address.className = "pubaddress"
291
+ item_div.appendChild(address);
292
+ }
293
+
294
+ if(item.publisher) {
295
+ if(item.address)
296
+ item_div.appendChild(document.createTextNode(": "))
297
+
298
+ var publisher = document.createElement("SPAN");
299
+ publisher.innerHTML = item.publisher
300
+ publisher.className = "pubpublisher"
301
+ item_div.appendChild(publisher);
302
+ }
303
+
304
+ if(item.year) {
305
+ var year = document.createElement("SPAN");
306
+ if(item.publisher)
307
+ year.innerHTML = ", "
308
+ year.innerHTML = year.innerHTML + item.year + "."
309
+ year.className = "year"
310
+ item_div.appendChild(year);
311
+ }
312
+
313
+ if(item.note) {
314
+ var note = document.createElement("SPAN");
315
+ note.innerHTML = " " + item.note
316
+ note.className = "note"
317
+ item_div.appendChild(note);
318
+ }
319
+
320
+ }
321
+
322
+ return appendLinks(item_div, item, itemId);
323
+ }
324
+
325
+ function appendLinks(item_div, item, itemId) {
326
+ item_div.appendChild(document.createElement("BR"))
327
+
328
+ var bibtex = document.createElement("A");
329
+ bibtex.className = "bibtexLink"
330
+ bibtex.innerHTML = "[BibTeX]";
331
+ bibtex.id = "bibtex_" + itemId
332
+ bibtex.onclick = () => toggleBibtex(itemId)
333
+ item_div.appendChild(bibtex);
334
+
335
+ if (item.abstract) {
336
+ var abstract = document.createElement("A");
337
+ abstract.className = "abstractLink"
338
+ abstract.innerHTML = "[Abstract]"
339
+ abstract.onclick = () => toggleAbstract(itemId)
340
+ abstract.id = "abstract_" + itemId
341
+ item_div.appendChild(abstract);
342
+ }
343
+
344
+ if (item.url){
345
+ var file = document.createElement("A");
346
+ var isAcmAuthorizorLink = item.url.toLowerCase().indexOf("dl.acm.org/authorize") >= 0;
347
+ file.href = item.url
348
+ file.className = "fileLink"
349
+ file.innerHTML = "[Download]"
350
+ //http://dl.acm.org/authorize?N93641
351
+ if(isAcmAuthorizorLink) {
352
+ //Not on main publication page
353
+ if(window.location.href.toLowerCase().indexOf("http://www.hci.uni-wuerzburg.de/publications") != 0) {
354
+ file.innerHTML = "[Download page]";
355
+ file.className += " acmUnAuthorized";
356
+ file.href = "http://www.hci.uni-wuerzburg.de/publications/?query=" + encodeURIComponent(item.label);
357
+ var tooltip = document.createElement("span");
358
+ tooltip.innerHTML = "This ACM Author-Izer link allows to obtain the definitive version of the article from the ACM Digital Library at no charge. However, the link is only authorized if it is clicked on our main publications page: <i>http://<b>www</b>.hci.uni-wuerzburg.de/publications/</i>.";
359
+ file.appendChild(tooltip);
360
+ } else /* On main publication page */ {
361
+ file.className += " acmAuthorized";
362
+ var tooltip = document.createElement("span");
363
+ tooltip.innerHTML = "This ACM Author-Izer link allows to obtain the definitive version of the article from the ACM Digital Library at no charge.";
364
+ file.appendChild(tooltip);
365
+ }
366
+ }
367
+
368
+ item_div.appendChild(file);
369
+ }
370
+
371
+ var bibsonomy = document.createElement("A");
372
+ bibsonomy.href = item.id
373
+ bibsonomy.className = "bibsonomyLink"
374
+ bibsonomy.innerHTML = "[BibSonomy]"
375
+ item_div.appendChild(bibsonomy)
376
+
377
+ var bibtex_txt = document.createElement("DIV")
378
+ bibtex_txt.id = "bibtexDIV_" + itemId
379
+ bibtex_txt.style.display = "none"
380
+ bibtex_txt.className = "bibtex";
381
+ bibtex_txt.innerHTML = item.bibtex;
382
+ item_div.appendChild(bibtex_txt)
383
+
384
+ if (item.abstract) {
385
+ var abstract_txt = document.createElement("DIV");
386
+ abstract_txt.id = "abstractDIV_" + itemId
387
+ abstract_txt.style.display = "none"
388
+ abstract_txt.innerHTML = "<strong>Abstract:</strong> " + item.abstract
389
+ abstract_txt.className = "abstract"
390
+ item_div.appendChild(abstract_txt)
391
+ }
392
+ return item_div;
393
+ }
394
+
395
+ function toggleAbstract(itemId) {
396
+ if(document.getElementById("abstractDIV_" + itemId).style.display == "none") {
397
+ document.getElementById("abstractDIV_" + itemId).style.display = "block";
398
+ }
399
+ else {
400
+ document.getElementById("abstractDIV_" + itemId).style.display = "none";
401
+ }
402
+ }
403
+
404
+ function toggleBibtex(itemId) {
405
+ if(document.getElementById("bibtexDIV_" + itemId).style.display == "none") {
406
+ document.getElementById("bibtexDIV_" + itemId).style.display = "block";
407
+ }
408
+ else {
409
+ document.getElementById("bibtexDIV_" + itemId).style.display = "none";
410
+ }
411
+ }
412
+
413
+ function parseBibtexJSON(item){
414
+ var pubtype = item['pub-type'];
415
+ var fields = bibtexSpecs[pubtype];
416
+ var retString = "@" + pubtype + "{" + item.bibtexKey + ",\n title" + makeTabs("title") +" = {" + item.label + "}";
417
+ for (var i in fields){
418
+ var key = fields[i];
419
+ if (item[key]){
420
+ retString += ",\n "+ key + makeTabs(key);
421
+ if (key != "author" && key != "editor")
422
+ retString += " = {" + item[key] + "}" ;
423
+ else {
424
+ var items = [];
425
+
426
+ if (key == "author") {
427
+ items = item.authors;
428
+ }
429
+ if (key == "editor") {
430
+ items = item.editors;
431
+ }
432
+
433
+ retString += " = {" + items[0].last + ", " + items[0].first ;
434
+ for (var i = 1; i < items.length; i++ ) {
435
+ retString += " and " + items[i].last + ", " + items[i].first
436
+ }
437
+ retString += "}"
438
+ }
439
+ }
440
+ }
441
+ return retString + "\n}"
442
+ }
443
+
444
+ function filterTag(elements, fTag){
445
+ if(fTag == "") return elements;
446
+ var _res = new Array();
447
+ for (var i=0; i<elements.length; i++){
448
+ if (_filterTag(elements[i], fTag)) _res.push(elements[i])
449
+ }
450
+ return _res;
451
+ }
452
+
453
+ function filterTags(elements, fTags){
454
+ if(fTags == "") return elements;
455
+ var _res = new Array();
456
+ for (var i=0; i<elements.length; i++){
457
+ if (_filterTags(elements[i], fTags.split('|'))) _res.push(elements[i])
458
+ }
459
+ return _res;
460
+ }
461
+
462
+ function filter(elements, fText){
463
+ if(fText == "") return elements;
464
+ var _res = new Array();
465
+ for (var i=0; i<elements.length; i++){
466
+ if (_filter(elements[i], fText)) _res.push(elements[i])
467
+ }
468
+ return _res;
469
+ }
470
+
471
+ function ciFilter(elem, text){
472
+ return elem.toLowerCase().indexOf(text.toLowerCase()) != -1
473
+ }
474
+
475
+ function _filter(item, fText){
476
+ return (item.label && ciFilter(item.label, fText)) ||
477
+ (item.authors && ciFilter(authors2txt(item.authors), fText)) ||
478
+ (item.editors && ciFilter(editors2txt(item.editors), fText)) ||
479
+ (item.booktitle && ciFilter(item.booktitle, fText)) ||
480
+ (item.journal && ciFilter(item.journal, fText)) ||
481
+ (item.publisher && ciFilter(item.publisher, fText)) ||
482
+ (item.year && ciFilter(item.year, fText)) ||
483
+ (deepSearch && item.abstract && ciFilter(item.abstract, fText))||
484
+ (deepSearch && item.bibtex && ciFilter(item.bibtex, fText))
485
+ }
486
+
487
+ function _filterTag(item, fTag){
488
+ if(item.tags)
489
+ return $.inArray(fTag, item.tags) != -1
490
+ else
491
+ return false
492
+ }
493
+
494
+ function _filterTags(item, fTags){
495
+ for (var i=0; i<fTags.length; i++){
496
+ if (_filterTag(item, fTags[i])) {
497
+ return true;
498
+ }
499
+ }
500
+ return false;
501
+ }
502
+
503
+ function makeTabs(key){
504
+ var maxLength = 0
505
+ for (var i in bibtexSpecs.allKeys)
506
+ maxLength = bibtexSpecs.allKeys[i].length > maxLength ? bibtexSpecs.allKeys[i].length : maxLength
507
+ var retVal = ""
508
+ for (var i =0; i<maxLength - key.length; i++)
509
+ retVal += " "
510
+ return retVal
511
+ }
512
+
513
+ function authors2txt(authors){
514
+ if (!authors)
515
+ return "";
516
+ /* var retVal = " " + authors[0].last + ", " + authors[0].first*/
517
+ var retVal = " " + authors[0].first + " " + authors[0].last
518
+ for (var i=1; i<authors.length; i++) {
519
+ retVal += ", " + authors[i].first + " " + authors[i].last
520
+ /* retVal += ", " + authors[i].last + ", " + authors[i].first*/
521
+ }
522
+ return retVal
523
+ }
524
+
525
+ function editors2txt(editors){
526
+ if (!editors)
527
+ return ""
528
+ /* var retVal = " " + editors[0].last + ", " + editors[0].first*/
529
+ var retVal = " " + editors[0].first + " " + editors[0].last
530
+ for (var i=1; i<editors.length; i++) {
531
+ /* retVal += ", " + editors[i].last + ", " + editors[i].first*/
532
+ retVal += ", " + editors[i].first + " " + editors[i].last
533
+ }
534
+ return retVal + (editors.length == 1 ? " (Ed.), " : " (Eds.), ")
535
+ }
536
+
537
+ function pages2txt(pages) {
538
+ if(ciFilter(pages,"-"))
539
+ return "pp. " + pages.replace("--","-").replace(/ /g, "")
540
+ else
541
+ return "p. " + pages
542
+ }
543
+
544
+ /**
545
+ * comparator function for array sort
546
+ **/
547
+ function comparator(x,y) {
548
+ var yearX = "0"
549
+ if(x.year) yearX = x.year.toLowerCase();
550
+ var yearY = "0"
551
+ if(y.year) yearY = y.year.toLowerCase();
552
+
553
+ if (yearX != yearY)
554
+ return (yearX > yearY) ? -1 : 1
555
+
556
+ if (x.label && y.label)
557
+ return (x.label.toLowerCase() < y.label.toLowerCase()) ? -1 : 1
558
+ return 0
559
+ }
560
+
561
+ /**
562
+ * comparator function for array sort
563
+ **/
564
+ function comparatorDate(x,y) {
565
+ if (x.date && y.date)
566
+ if (x.date.toLowerCase() != y.date.toLowerCase())
567
+ return (x.date.toLowerCase() > y.date.toLowerCase()) ? -1 : 1
568
+ if (x.label && y.label)
569
+ return (x.label.toLowerCase() < y.label.toLowerCase()) ? -1 : 1
570
+ return 0
571
+ }
572
+
573
+ /**
574
+ * sorts array to frequency
575
+ **/
576
+ function softFreq(x,y) {
577
+ return y.count - x.count;
578
+ }
579
+
580
+ //From: http://ejohn.org/blog/partial-functions-in-javascript/
581
+ //Currying support for functions
582
+ Function.prototype.partial = function(){
583
+ var fn = this, args = Array.prototype.slice.call(arguments);
584
+ return function(){
585
+ var arg = 0;
586
+ for ( var i = 0; i < args.length && arg < arguments.length; i++ )
587
+ if ( args[i] === undefined )
588
+ args[i] = arguments[arg++];
589
+ return fn.apply(this, args);
590
+ };
591
+ };
592
+
593
+ function generateLocalId(bibsonomyId){
594
+ return bibsonomyPathToId(bibsonomyId.toString().replace(/https:\/\/www\.bibsonomy\.org\/*/, "")) + "-" + Math.random().toString().replace("0.","");
595
+ }
596
+
597
+ export default initBibsonomy;