PageSourceSearch

https://uriavnery.com/js/authorscript-en.js?v=20260807-1

js uriavnery.com collected 2026-10-02 08:45:42 UTC 30,805 bytes, 919 lines download raw bytes

1var minuses = {
2    'main' : 85,
3    '#auth-mod': 30
4}
5var english_months = ["january","february","march","april","may","june","july","august","september","october","november","december"];
6var hebrew_months = ["ינואר","פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"];
7var authbase = 'https://uriavnery.com/texts/uri_avnery';
8var slideshows = 'https://uriavnery.com/en/slideshows';
9//var search_template = "https://www.googleapis.com/customsearch/v1?GOOGLESEARCHQUERY&cx=006641765881684709425:t3vpkc0zyvo&fields=items%searchInformation%2FtotalResults%2Curl&key=AIzaSyCXwxmdVWn6J453z2kZhiR82DQre4gNkJs";
10var search_template = "https://www.googleapis.com/customsearch/v1?GOOGLESEARCHQUERY&cx=006641765881684709425:t3vpkc0zyvo&fields=items%2Cqueries%2CsearchInformation%2FtotalResults%2Curl&key=AIzaSyCXwxmdVWn6J453z2kZhiR82DQre4gNkJs";
11
12var pdf_embed_src = "https://docs.google.com/viewer?embedded=true&url=DOCURL";
13var vid_template = "https://www.youtube.com/embed/VIDEOID?autoplay=1";
14
15//var trickparse = document.createElement('a');
16var pageresult = /\/texts\/[\w_\-]+\/\w\d{3}\/html\/(\w\d+p\d+\w?)\.html?$/
17function padZeroes(i,l) {
18    if(i < 0) {
19        return null;
20    }
21    var bar = ""+i;
22    while(bar.length < l) {
23        bar = "0"+bar;
24   }
25   return bar;
26}  
27
28function parse_month_range(str) {
29    var months;
30    if(str.indexOf(',') > 0) {
31        months = str.split(',').map(intmonth);
32    }
33    else if(str.indexOf('-') > 0) {
34        months = months_range(str.split('-').map(intmonth));
35    }
36    else {
37        months = [intmonth(str)];
38    }
39    months = months.map(function(m) {
40        return padZeroes(m,2);
41    });
42    return months.filter(function(m) {
43        return /^\d{2}$/.test(m) &&  parseInt(m) > 0 && parseInt(m) < 13;
44    });
45}
46
47function months_range(twoarray) {
48    var [s,e] = twoarray,
49        start = Math.min(s,e),
50        end = Math.max(s,e),
51        ret = [];
52    console.log(start,end);
53    while(start < end) {
54        ret.push(start);
55        start++;
56    }
57    return ret;
58}
59
60function intmonth(m) {
61     m = m.replace(/\s*$/,'').replace(/^\s*/,'');
62     if(/^\d+$/.test(m)) {
63        return parseInt(m);
64     }
65     if(/^[a-z][A-Z]+$/.test(m)) {
66         return english_months.indexOf(m.toLowerCase()) + 1;
67     }
68     else {
69         return hebrew_months.indexOf(m) + 1;
70     }
71}
72
73function YearDocs() {
74    this.years =  Object.keys(window.YearFiles);
75    this.numyears = this.years.length;
76    this.middle  =  Math.ceil(this.numyears/2);
77    this.container = '#year-files';
78    this.selector = '#years-view';
79    this.numpickers  = Math.min(this.numyears,Math.floor($(this.selector).width()/55) - 1);
80    this.inview = [];
81    this.current = null;
82    this.step = 5;
83    
84    //initial population of years row
85    this.init = function() {
86        var left = Math.ceil(this.numpickers/2);
87        var start = this.middle - left;
88        var finish = this.middle + (this.numpickers - left - 1);
89        this.populate([start,finish]);
90        this.load_year_files(this.years[this.middle]);
91    };
92    
93    //show a given year
94    this.load_year_files = function(year) {
95        $('.year-picker').removeClass('current');
96        $(this.container).empty();
97        for(var n in YearFiles[year]) {
98            var fd = YearFiles[year][n], 
99                el = $('#file-block-template').clone();
100            el.attr('id','').removeClass('hide');
101            el.find('.file-thumb').attr('src',fd.thumb);
102            el.find('.issue').text("issue "+parseInt(fd.ord).toString());
103            el.find('.file-date').text(fd.date);
104            el.data('file',fd.file);
105            el.click(function() {
106                var d = $(this).data('file'),
107                    b = $('#static-container').data('heaplocation'),
108                    u = null;
109                if(typeof(b) == 'string') {
110                    u = authbase+'/'+b+'/'+d;
111                    tag_in_modal(u,'object','data');
112                    share('#auth-mod',location.origin+location.pathname+'?protocol='+b+'/'+d);
113                }
114            }).end();  
115            $(this.container).append(el);
116        }
117        $('.year-picker[data-year='+year+']').addClass('current');
118        this.current = this.years.indexOf(year);
119        if(this.current == this.numyears - 1) {
120            $('.years-control.next').addClass('disabled');
121        }
122        else {
123            $('.years-control.next').removeClass('disabled');
124        }
125        if(this.current == 0) {
126            $('.years-control.prev').addClass('disabled');
127        }
128        else {
129           $('.years-control.prev').removeClass('disabled');
130        }
131    };
132
133    //go to previous year
134    this.prev = function() {
135        var p = this.current - 1;
136        if(p < 0) {
137            return false;
138        }
139        if(p < this.inview[0]) {
140            goleft = Math.min(this.step,this.inview[0]);
141            if(goleft > 0) {
142                newstart = this.inview[0] - goleft; 
143                newfinish = this.inview[1] - goleft;
144                this.populate([newstart,newfinish]);
145            }
146        }
147        this.load_year_files(this.years[p]); 
148    };
149
150    //go to next year
151    this.next = function() {
152        var n = this.current + 1;
153        if(n >= this.numyears) {
154            return false;
155        }
156        if(n >= this.inview[1]) {
157            console.log(this.inview);
158            goright = Math.min(this.step,(this.numyears - this.inview[1] - 1));
159            if(goright > 0) {
160                newstart = this.inview[0] + goright;
161                newfinish = this.inview[1] + goright;
162                this.populate([newstart,newfinish]);
163            }
164        }
165        this.load_year_files(this.years[n]);
166    };
167
168    this.gotoyear = function(year) {
169        if(!year in window.YearFiles) {
170            return;
171        }
172        var ind = this.years.indexOf(year.toString());
173        if(ind == -1) {
174            return
175        }
176        if(ind >= this.inview[0] && ind <= this.inview[1]) {
177            this.load_year_files(year)
178        }
179        else {
180            this.populate(this.slice_on(ind));
181            this.load_year_files(year);
182        }
183    }
184
185    this.find_file_by_issue = function(issue) {
186        for(var year in window.YearFiles) {
187            for(var filedata in window.YearFiles[year]) {
188                var fd = window.YearFiles[year][filedata];
189                if(parseInt(fd.ord) == parseInt(issue)) {
190                    return fd.file;
191                }
192            }
193        }
194        return null;
195    }
196    
197    this.slice_on = function(ind) {
198        var left = 0,
199            right = 0,
200            added = 1;
201        while(added < this.numpickers) {
202            if(ind - left > 0){
203                added++;
204                left++;
205            }
206            if(ind + right < this.numpickers) {
207                added++;
208                right++;
209            }
210        }
211        return [ind - left, ind + right]; 
212    }
213    //populate the years row with  a given slice of this.years
214    this.populate = function(slice) {
215        var yd = this;
216        $(yd.selector).empty();
217        for(var i = slice[0]; i <= slice[1]; i++) {
218            var y = yd.years[i],
219            picker =  $('<span class="year-picker" data-year="'+y+'">'+y+'</span>').click(function() {
220               yd.load_year_files(String($(this).data('year')));
221            });
222            $(yd.selector).append(picker);
223        }
224        yd.inview = slice;
225    }; 
226}
227
228function TextualiJpgsLoader(book,pages) {
229    this.lastloaded = 0;
230    this.hasmore = true;
231    this.book = book;
232    this.pages = parseInt(pages);
233    
234    this.destroy = function() {
235        loader  = this;
236        loader.hasmore = false;
237        p = $('#phone-scroll-boook').detach();
238        $('main#content').after(p);
239    }
240             
241    this.loadmore = function() {
242        var i = 0;
243        var loader = this;
244        while(i++ < 5 && loader.hasmore) {
245           loader.loadNext() 
246        }
247    }; 
248    
249                
250    this.loadNext = function() {
251        var loader = this;
252        var loading = new Image();
253        loading.src = loader.next();
254        loading.onload = function() {
255            $('#phone-scroll-book').append(this);
256            if(loader.hasmore && loader.lastloaded < loader.pages) {
257                loader.loadNext();
258            } 
259        }
260        loading.onerror = function() {
261            loader.hasmore = false;
262        } 
263    }
264        
265    this.next = function() {
266        this.lastloaded++;
267        var ret = authbase;
268        ret += '/'+this.book+'/jpg/'+this.book;
269        ret += 'p'+padZeroes(this.lastloaded,3)+'.jpg';
270        return ret;
271    }; 
272
273    this.bind_scroll = function() {
274        var h = $('#phone-scroll-book  > img').eq(0).get(0).height;
275        $(window).scroll(function() {
276            console.log($(this).scrollTop());
277            if ($(this).scrollTop() > (tjloader.lastloaded - 2) * h && tjloader.hasmore) {
278                tjloader.loadmore();
279            }
280            else {
281                console.log($(this).scrollTop(), tjloader, h);
282            }
283        });  
284    }; 
285} 
286
287function frame_height(elem) {
288    var height = $(window).height() - minuses[elem];
289    $(elem).each(function() {
290        $(this).find('iframe,object').height(Math.max(height,300));
291    });
292}
293
294
295function tag_in_modal(url,tag,att) {
296    $('#auth-mod').modal('show').find('.modal-body').html('<'+tag+'></'+tag+'>');
297    frame_height('#auth-mod');
298    setTimeout(function() {
299        $('#auth-mod').find(tag).attr(att,url);
300    },100);
301    $('#auth-mod .share-modal').addClass('hide');
302}
303
304function iframe_in_modal(url) {
305    tag_in_modal(url,'iframe','src');
306}
307
308function element_in_modal(el) {
309    el = $(el);
310    $('#auth-mod').modal('show').find('.modal-body').html($(el).html());
311    frame_height('#auth-mod');
312}
313
314function video_in_modal(v) {
315    var h = vid_template.replace('VIDEOID',v);
316    iframe_in_modal(h);
317    share('#auth-mod', window.location.href.replace(window.location.search, '')+'?vid='+v);
318    bind_vid_adjustment();
319}
320
321function book_in_modal(bookurl,bookid) {
322    iframe_in_modal(bookurl);
323    //$('#auth-mod').data('curbook',bookid);
324    //var s = window.location.href.replace(window.location.search, '');
325    //if (bookid == undefined) {
326    //    var m  = bookurl.match(/uri_avnery\/([a-z0-9]+)/);
327    //    if (m.length == 2) {
328    //        bookid = m[1];
329    //   }
330    //}
331    //bookid = bookid.replace(/\/$/, '');
332    //if (/^[a-z0-9]{3,5}$/.test(bookid)) {
333    //    s += '?book='+bookid;
334    //    share('#auth-mod', s);
335    //}
336}
337
338function slideshow_in_modal(id,title) {
339    var t = location.origin+location.pathname.replace(/(\/[a-z_\-0-9]+\.html)$/ , "/slideshows/"+id+".htm");
340    $.ajax({
341        url: t,
342        dataType: 'HTML'
343    }).done(function(slideshow) { 
344        slideshow = $(slideshow);
345        //console.log(slideshow);
346        //if (slideshow.length == 1) {
347            slideshow.find('.loader').each(function() {
348                var loader = $(this);
349                var slide = new Image();
350                slide.src = loader.data('src');
351                slide.alt = loader.data('alt'); 
352                slide.setAttribute("class", "slide");
353                slide.onload = function() {
354                    loader.hide().after(this);
355                } 
356            });
357            //$(this).after(attr('src', $(this).data('src'));
358            $('#auth-mod').modal('show').find('.modal-body').html(slideshow);
359            slideshow.find('.carousel').height($(window).height()*0.85).fadeIn(200);
360            share('#auth-mod',window.location.href.replace(window.location.search, '')+'?slideshow='+id);
361            if(title) {
362                $('#'+id).find('.carousel').before('<h2 class="slideshow-title">'+title+'</h2>');
363            }
364        //}
365    });
366}
367
368
369function bind_vid_adjustment() {
370    $('#auth-mod').on('shown.bs.modal',function() {
371        var d = $(this).find('.modal-dialog.modal-lg');
372        d.width(d.height() * 1.5);
373    });
374}
375
376function share(modalid,url) {
377    var s = $(modalid).find('span.share');
378    $(modalid).find('.share-modal').removeClass('hide').bind('click', function() {
379        s.text(url).closest('.share-input-wrap').toggleClass('in');
380    });
381}
382
383function filename2pagenum(name) {
384    m = name.match(/^([a-z]\d{3}p)(\d{3})$/);
385    return m[2];
386}
387
388function process_fts_search_results(results) {
389    //var htm = '<h5>Search Results for "'+results.q+'"</h5>';
390    var htm = '<div id="search-results"><h3>Search Results for "'+results.q+'"</h3>';
391    if(results.status == 'success') {
392        if(results.matches.length > 0) {
393            htm += '<ul class="search-results">';
394            var m = results.matches;
395            for(var res in m) {
396                var urls = fileurls(m[res].id);
397                htm += '<li class="search-result">';
398                htm += '<a href="'+urls.fliplink+'">'+m[res].book_name+' '+urls.page+'</a>';
399                htm += '<p>'+m[res].match+'</p></li>';
400            }
401            htm += '</ul>';
402        }
403        else {
404            htm = 'sorry, no matches found';
405        } 
406   }
407   else if(results.status == 'fail') {
408       htm = results.error;
409   }
410   else {
411       htm = 'unknown error';
412   }
413   return htm;
414} 
415
416function fileurls(file) {
417    var m = file.match(/^([a-z0-9]\d+)p(\d+[a-z]?)$/);
418    if(!m) {
419        return false;
420    }
421    var fliplink = '?book='+m[1], p="";
422    if(/^\d+$/.test(m[2]) ) {
423        p = parseInt(m[2]);
424        fliplink += "/#page/"+(p + 1);
425    }
426    return {
427        "fliplink" : fliplink,
428        "page" : p 
429    };
430}
431
432
433function identify_book_page(url) {
434    var ret = false;
435    var m = url.match(pageresult);
436    if (m!=null && m.length == 2) {
437        ret = fileurls(m[1]);
438    }
439    return ret;
440}
441
442function process_google_search_results(results) {
443    var r = results.queries.request[0];
444    var htm = '<div id="search-results"><h3>Search Results for "'+r.searchTerms+'"</h3>';
445    if(r.totalResults > 0) {
446        htm += '<ul class="search-results">';
447        $(results.items).each(function(index,res) {
448            htm += '<li class="search-result">';
449            var u = identify_book_page(res.link);
450            var l = typeof(u) == 'object' ? u.fliplink : res.link;
451            //l += '&q='+r.searchTerms.replace(/\s+/,"+");
452            htm += '<a href="'+l+'">'+res.title+'</a>';
453            htm += '<p>'+res.htmlSnippet+'</p></li>';
454        });
455        htm += '</ul></div>';
456    }
457    else {
458        htm += 'sorry, no matches found</div>';
459    } 
460    return htm;
461}
462
463function process_protocols_search_results(results) {
464    var htm = '<div id="search-results"><h3>Search Results for "'+results.q+'"</h3>';
465    if(results.status == 'success') {
466        if(/.pdf$/.test(results.results_file)) {
467            htm += '<a target="_blank" class="btn btn-primary" href="http://uriavnery.com/'+results.results_file+'"></a>';
468        }
469        htm += '<ul class="search-results">';
470        var m = results.matches;
471        for(var res in m) {
472            var r = m[res];
473            htm += '<li class="search-result" >';
474            htm += '<a class="search-result" data-file="'+r.id+'" data-page="'+r.page+'" href="#NOGO" data-query="'+results.q.replace(/["']/g,'')+'">';
475            htm += r.day+'/'+r.month+'/'+r.year;
476            if(/^\d+$/.test(r.issue)){
477                htm += ', issue '+r.issue+', ';
478            }
479            htm += "page".replace("'","\'")+' '+r.page
480            htm += '</a>';
481            htm += '<p>'+r.match+'</p></li>';
482        }
483        htm += '</ul>';
484   }
485   else {
486       htm = '<div class="alert alert-danger" role="alert">';
487       htm += '<strong>the search failed. reason:</strong><br>';
488       if(results.status == 'faile') {
489             htm += results.error
490       }
491       else {
492           htm += 'unknown error';
493       }
494       htm += '</div>';
495    }
496   return htm;
497}
498
499
500function bind_protocol_click() {
501    $('.search-result').click(function(c) {
502        c.preventDefault();
503        var file = $(this).data('file'),
504            page = $(this).data('page'),
505            query = $(this).data('query'),
506            u = authbase+'/'+window.DocsFolder+'/'+file+'.pdf',
507            conc = '#';
508        if(/^\d+$/.test(page)){
509            u += '#page='+page;
510            conc = '&'
511        }
512        u += conc+'search="'+query+'"';
513
514        iframe_in_modal(u);
515        share('#auth-mod',location.origin+location.pathname+"?protocol="+file);
516
517    });
518}
519
520function search(options) {
521    $.ajax({
522        url: options.url+'&'+options.query,
523        DataType: 'json'
524    }).done(function(results) {
525        $('#auth-mod').modal('show').find('.modal-body').html(options.results_handler(results));
526        if('function' == typeof(options.post_process)) {
527            options.post_process()
528        }
529    }).fail(function(err) {
530        alert(err);
531    });
532    if(!options.share) {
533        $('#auth-mod').find('.share-modal').hide();
534    }
535}
536
537
538
539
540function highlight_menu(ul) {
541    ul.find('li').each(function() {
542        if($('body').hasClass(this.id)) {
543            $(this).children('a').eq(0).addClass('active');
544            $(this).closest('.dropdown').find('.dropdown-toggle').addClass('active');
545        }
546        if($(this).hasClass('dropdown')) {
547            highlight_menu($(this).find('.dropdown-menu'));
548        }
549   });
550}
551
552$(document).ready(function() {
553    $('[data-toggle="tooltip"]').tooltip();
554    window.addEventListener("message", function(event) {
555        //if(/textuali\.com\/avnery-timeline\/.*timeline.*html$/.test(event.source) || true) {
556            switch(event.data.type) {
557                case 'flip':
558                    book_in_modal(event.data.url); 
559                break;
560                case 'video' :
561                    video_in_modal(event.data.video);
562                break;
563                case 'slideshow':
564                    slideshow_in_modal(event.data.slideshow,false);
565                break;
566                //case 'flipped_to':
567                //    var s = $('#auth-mod').find('span.share');
568                //    cur = s.text().replace(/\/#page.*$/,'');
569                //    if(cur == "") {
570                //        cur = location.host+location.pathname+'?book='+$('#auth-mod').data('curbook');
571                //    }
572                //    s.closest('.share-input-wrap').removeClass('in');
573                //    s.replaceWith($('<span/>').addClass('share'));
574                //    share('#auth-mod',cur+'/#page/'+event.data.page);
575                //break;
576                default:
577                    $.noop();
578            }
579        //}
580    });
581    /*$('main .row.well').first().find('.collapse').eq(0).collapse('show');
582    $('main .row.well').find('button').click(function() {
583        exclude = $(this).next();
584        $('.collapse').not(exclude).each(function() {
585            if( $(this).hasClass('in') ) {
586                $(this).collapse('hide');
587            };
588        });
589    });*/
590    if(undefined != window.YearFiles) {
591        var yearsdoc = new YearDocs();
592        yearsdoc.init();
593        $('.years-control.prev').click(function() {
594            yearsdoc.prev()
595        });
596        $('.years-control.next').click(function() {
597            yearsdoc.next();
598        });
599        $('#goto-year li').click(function() {
600            yearsdoc.gotoyear($(this).data('year'));
601        });
602        $('#doc-filters').submit(function() {
603            var issue = $(this).find('[name="issue"]').val(),
604                monthrange = $(this).find('[name="months"]').val();
605            if(/^\d+$/.test(issue)) {
606                var d = yearsdoc.find_file_by_issue(issue),
607                    b = $('#static-container').data('heaplocation'),
608                    u = null;
609                if(typeof(b) == 'string' && d != null) {
610                    u = authbase+'/'+b+'/'+d;
611                    tag_in_modal(u,'object','data');
612                    share('#auth-mod',location.origin+location.pathname+'?protocol='+b+'/'+d);
613                }
614            }
615            else if(monthrange != "") {
616                var showmonths = parse_month_range(monthrange);
617                if(showmonths.length == 0) {
618                    return false;
619                }
620                $('.file-block').each(function() {
621                    var date = $(this).find('.file-date').text(),
622                        m = date.split('/')[1];
623                    if($.inArray(m,showmonths) >= 0)  {
624                        $(this).fadeIn(500);
625                    }
626                    else {
627                        $(this).fadeOut(500);
628                    }
629                });
630            }   
631            return false;
632        });
633    }
634    $('.open-protocol').click(function() {
635        var d = $(this).data('file'),
636            k = $(this).closest('.well').data('knesset'),
637            u = authbase+'/protocols/'+k+'/'+d+'.pdf';
638            
639        //iframe_in_modal(u);
640        tag_in_modal(u,'object','data');
641        share('#auth-mod',location.origin+location.pathname+'?protocol='+k+'/'+d);
642    });
643    $('.open-file').click(function() {
644        var d = $(this).data('file'),
645            b = $('#static-container').data('heaplocation'),
646            u = null;
647        if(typeof(b) == 'string') {
648            u = authbase+'/'+b+'/'+d;
649            tag_in_modal(u,'object','data');
650            share('#auth-mod',location.origin+location.pathname+'?protocol='+b+'/'+d);
651        }
652    });  
653    var display_params  = location.search.match(/^\?(vid|book|slideshow|doc|protocol)=(.*)$/);
654    
655    highlight_menu($('#primary-navigation > .nav'));
656    
657    $('.external iframe').load(function() {
658        $(this).prev('.loader').hide();
659        $('#iframe-wrap').css('height','auto');
660    });
661    
662    $(window).load(function() {
663        $('#isotope').isotope({
664            isOriginLeft: !('ltr' == 'rtl'),
665            itemSelector: window.isoIt,
666            layoutMode: 'masonry'
667        });
668        $('#isotope').addClass('in');
669    });
670    $('.langswitch').click(function() {
671        var l = $(this).data('langcode'),
672            loc = window.location;
673        if (loc.pathname == "/") {
674            h = l;
675        }
676        else if (/^\/[a-z\/]*\.html$/.test(loc.href)) {
677            h = l+loc.pathname;
678        }
679        else {
680            var cur = loc.href.replace(loc.search,"");
681            if (display_params != null && display_params[1] == 'book') {
682                cur = cur.replace(loc.hash,"");
683            }
684            h = cur.replace(/\/[a-z]{2}(?=((\/.*\.[a-z]{2,4})|\/)(#.*)?$)/,'/'+l);
685        }
686        window.location.assign(h);
687    });
688    $('.doc-wrap').click(function() {
689        var t = $(this).find('h2').clone().removeClass('col-xs-12').addClass('modal-doc-title');
690        var c = $(this).find('.document-image').clone().show();
691        $('#auth-mod').find('.modal-body').empty().append(t,c).end().modal('show');
692        $('#auth-mod .modal-dialog').addClass('multidoc').scrollTop(0);
693        share('#auth-mod', window.location.href.replace(window.location.search, '')+'?doc='+this.id);
694    });
695
696    $('.modal-content').click(function(c) {
697        if (!$(c.target).is('.share-modal')) {
698            $(this).find('span.share').removeClass('in');
699        }
700    });
701    $('#auth-mod').on('hide.bs.modal',function() {
702        $(this).find('.modal-body').empty();
703        $(this).find('.modal-dialog').width('').removeClass('multidoc');
704        $(this).find('.share-modal').show().unbind('click').next('.share-input-wrap').removeClass('in');
705       
706    });
707
708    $('.share-input-wrap button').click(function() {
709        $(this).parent().removeClass('in');
710    });
711    /*$('iframe').load(function() {
712        console.log(parent.document.getElementById('content'));
713    });*/
714    $('[data-href]').click(function(c) {
715        if($(c.target).closest('.collapse, .collapser').length > 0) {
716            return;
717        } 
718        var h = $(this).data('href'),
719            o = $(this).data('open'),
720            t = this.title;
721        switch(o) {
722            case 'blank':
723                window.open(h, '_blank');
724            break;
725            case 'modal':
726                iframe_in_modal(h);
727            break;
728            case 'social' :
729                if(h == 'email') {
730                    element_in_modal('#mailform-wrap');
731                    $('#mailform').submit(function(e) {
732                        e.preventDefault();
733                        dat = {
734                            mailfrom : $('#mailfrom').val(),
735                            mailto : $('#mailto').val(),
736                            subject : $('#subject').val(),
737                            message: $('#message').val()+"\nhttp://uriavnery.com/"
738                        } 
739                        $.ajax({
740                            url : "http://uriavnery.com//mailer/sendmail.py/",
741                            DataType: 'text/html',
742                            data : dat,
743                            method: 'POST'
744                        }).done(function(results) {
745                            $('#auth-mod').find('#mailform').fadeOut(300, function() {
746
747                                $('#auth-mod').find('.modal-body').empty().append($(results).hide()); 
748                                $('#auth-mod').find('.email-response').fadeIn(300);
749                            });
750                        }).fail(function(err) {
751                            console.log(err);
752                        });
753                        return false;
754                    });
755
756                }
757                else {
758                    window.open(h,"", "width=600, height=400");  
759                }
760            break;
761            default:
762            case undefined:
763                window.location.assign(h);
764        }
765    });
766    if(display_params != null) {
767        switch(display_params[1]) {
768            case 'book' :
769                var u = display_params[2];
770                var d = decodeURIComponent(window.location.hash);
771                if (/#page\/\d+(&q=.+)?$/.test(d)){
772                    u += d.replace('&','?');
773                }
774                book_in_modal(authbase+'/'+u,display_params[2]);        
775            break;
776            case 'vid' : 
777                video_in_modal(display_params[2]);
778            break;
779            case 'slideshow' :
780                slideshow_in_modal(display_params[2],false)
781            break;
782            case 'doc':
783                $('.doc-wrap#'+display_params[2]).trigger('click');
784            break;
785            case 'protocol':
786                var u = /knesset/.test(display_params[2]) ? authbase+'/protocols/' : authbase+"/";
787                if (!/\.pdf$/.test(display_params[2])) {
788                    iframe_in_modal(u+display_params[2]+'.pdf');
789                }
790                else {
791                    fileandpage = location.href.replace(/^.*\?protocol=/,'');
792                    iframe_in_modal(u+fileandpage);
793                }
794                share('#auth-mod',location.href);
795            break;
796            default:
797                $.noop();
798        }
799    }
800    $(window).load(function() {
801        frame_height('main');
802    });     
803    
804    $(window).resize(function() {
805        $('iframe').attr('src',this.src);
806        frame_height('main');
807    });
808    
809    $('#close-phone-scroll').click(function() {
810        tjloader.destroy();
811        $('#phone-scroll-book').fadeOut(200);
812        $('main#content,footer').fadeIn(200);
813    }); 
814      
815   $(window).scroll(function(){
816        if ($(this).scrollTop() > 100) {
817            $('#scrollup').fadeIn();
818        } else {
819            $('#scrollup').fadeOut();
820        }
821    });
822    $('#scrollup').click(function(){
823        $("html, body").animate({ scrollTop: 0 }, 600);
824        return false;
825    });
826    
827    $('.vid').click(function(c) {
828        if(!$(c.target).is('a')) {
829            video_in_modal($(this).data('vid'));
830        }
831    });
832
833    $('.flip-modal-trigger').click(function(c) {
834        c.preventDefault();
835        var h = $(this).attr('href'); 
836        if($(window).width() <= 768 ) {
837            if(typeof(tjloader) == 'object') {
838                tjloader.destroy(); 
839            }
840            tjloader = new TextualiJpgsLoader($(this).data('book'), $(this).data('pages'));
841            $('main#content,footer').fadeOut(200);
842            $('#phone-scroll-book').fadeIn(200).find('> img').detach();
843            tjloader.loadmore();
844        }
845        else {
846            book_in_modal(h,$(this).data('book'))
847        }
848    });
849    
850    $('.slideshow-modal').click(function(c) {
851        if(!$(c.target).is('a')) {
852            s = $(this).data('slideshow');
853            slideshow_in_modal(s,false);
854        }
855    });
856    
857    $('.bare-slideshow').click(function(c) {
858        c.preventDefault();
859        var s = $(this).data('slideshow');
860        slideshow_in_modal(s,$(c.target).attr('title'));
861    });
862     
863    $('#fsearch').submit(function() {
864        search({
865            query : $(this).serialize(),
866            url : location.origin+'/search/websearch.py/?pretty=1&auth=uri_avnery&book=allbooks',
867            results_handler: process_fts_search_results
868        });
869       return false; 
870    }); 
871    
872    $('#psearch').submit(function() {
873        search({
874            query : $(this).serialize(),
875            url : location.origin+'/search/websearch.py/protocols/?pretty=1&auth=uri_avnery',
876            results_handler : process_protocols_search_results,
877            post_process : bind_protocol_click,
878            share: true
879        });
880        var knesset = $(this).find('select[name="book"]').val();
881        window.DocsFolder = knesset        
882        return false;
883    });
884
885    $('#fhsearch').submit(function() {
886        var q = $(this).serialize();
887        if(window.SearchResultsDownload == "True") {
888            q += '&download_button=true';
889        }
890        search({
891            query: q,
892            url: location.origin+'/search/websearch.py/press/?pretty=1&auth=uri_avnery',
893            results_handler: process_protocols_search_results,
894            post_process : bind_protocol_click
895        });
896        window.DocsFolder = $(this).find('input[name="book"]').val();
897        return false;
898    });
899     
900    $('#gsearch').submit(function() {
901        var query = $(this).serialize();
902        search({
903            url : search_template.replace('GOOGLESEARCHQUERY',query),
904            query : $(this).serialize(),
905            results_handler : process_google_search_results
906        });
907        return false;
908   });
909        
910
911    $('.util-button').click(function() {
912        var tarid = '#'+this.id.replace('-trigger','-container'),
913            tar = $(tarid);
914        $('.utilbox').not(tarid).removeClass('in');
915        tar.toggleClass('in');
916    });
917   
918})
919

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.