1/// <reference path="~/scripts/jquery-1.7.2-vsdoc.js"/> 2jQuery.fn.extend({ insertAtCaret: function (a) { return this.each(function () { if (document.selection) this.focus(), sel = document.selection.createRange(), sel.text = a, this.focus(); else if (this.selectionStart || "0" == this.selectionStart) { var b = this.selectionStart, c = this.selectionEnd, g = this.scrollTop; this.value = this.value.substring(0, b) + a + this.value.substring(c, this.value.length); this.focus(); this.selectionStart = b + a.length; this.selectionEnd = b + a.length; this.scrollTop = g } else this.value += a, this.focus() }) } }); 3jQuery.fn.geoKeyboard = function (a) { 4 5 var a = $.extend({ enable: !0, switcher: "switcher" }, a), b = a.enable, c = $("input#" + a.switcher); c.prop("checked", a.enable); $(c).change(function () { b = c.prop("checked") }); return this.find("input, textarea").each(function () { 6 var a = $(this); 7 8 9 10 a.keypress(function (d) { 11 12 13 14 15 e = d.keyCode ? d.keyCode : d.charCode, f = "abgdevzTiklmnopJrstufqRySCcZwWxjh".indexOf(String.fromCharCode(e)); 16 17 96==e && (b = !b, c.prop("checked", !c.prop("checked")), d.preventDefault()); 18 if($("#language-change").html()=='<img width="19" src="/content/img/UK.png">'){ 19 b=false; 20 21 } 22 else{ 23 b=true; 24 } 25 26 b && -1 < f && (a.insertAtCaret(String.fromCharCode(f + 4304)), $("#switcher").focus(), $(this).focus(), d.preventDefault()) 27 }) 28 }) 29}; 30 31 32 33var _FBID = '276975905743776' 34_SCOPE = 'email', 35_checkPermissions = true; 36function share(a) { 37 FB.ui({ 38 display: "popup", 39 method: "stream.share", 40 u: a 41 }); 42}; 43 44function BookToRead(bookId,_this) { 45 AjaxCall({ 46 "Message": "BookToRead", 47 "Data": { "BookId": bookId } 48 }, function (response) { 49 if (response.Message == "Success") { 50 if (response.Data) { 51 OG('sababooks:wish', 'book', 'https://saba.com.ge/books/details/' + bookId); 52 $(_this).addClass('to-readActive'); 53 } else { 54 $(_this).removeClass('to-readActive'); 55 } 56 } else { 57 $('#auth-log').click(); 58 } 59 }); 60} 61 62function BookFavorite(bookId, _this) { 63 AjaxCall({ 64 "Message": "BookFavorite", 65 "Data": { "BookId": bookId } 66 }, function (response) { 67 if (response.Message == "Success") { 68 if (response.Data) { 69 OG('sababooks:love', 'book', 'https://saba.com.ge/books/details/' + bookId); 70 $(_this).addClass('favoriteActive'); 71 } else { 72 $(_this).removeClass('favoriteActive'); 73 } 74 } else { 75 $('#auth-log').click(); 76 } 77 }); 78} 79 80function OG(action, object, url, callBack) { 81 82 var obj; 83 if (object == "book") { 84 obj = { book: url }; 85 } else { 86 obj = { object: url }; 87 } 88 89 FB.api('/me/' + action,'post',obj,function (response) { 90 console.log(response); 91 if ($.isFunction(callBack)) 92 callBack(response); 93 }); 94 //OG('sababooks:read', 'book', 'http://saba.com.ge/books/details/32'); 95}; 96 97function AjaxCall(object, callBack) { 98 99 $.ajax({
100 url: '/Ajax/Call', 101 type: 'POST', 102 contentType: 'application/json', 103 dataType: 'json', 104 data: JSON.stringify(object), 105 success: function (json) { 106 107 if ($.isFunction(callBack)) 108 callBack(json); 109 }, 110 error: function () { 111 //alert('Oops!'); 112 113 } 114 }); 115} 116function Slider( config ){ 117 this.container = config.container; 118 this.nav = config.nav; 119 this.wrapper = this.container.find('div'); 120 this.ul = this.wrapper.find('ul'); 121 this.boxes = this.ul.find('li'); 122 this.boxWidth = this.boxes[0].clientWidth; 123 this.boxesLen = this.boxes.length; 124 this.showNum = this.boxesLen - this.wrapper.width()/this.boxWidth; 125 this.corrent = 0; 126} 127Slider.prototype.init = function(){ 128 //console.log('init'); 129 var $this = this; 130 131 if (this.boxesLen<1) 132 { 133 this.container.fadeTo(500,0); 134 this.nav.fadeTo(500,0); 135 } else { 136 this.container.fadeTo(500,1); 137 this.nav.fadeTo(500,1); 138 } 139 140 this.ul.width( this.boxesLen * this.boxWidth ); 141 this.ul.off('click'); 142 this.ul.on('click','li',function(){ 143 //$this.setCorrent( $(this).index() ); 144 $this.move(); 145 }); 146 147 this.nav.off('click'); 148 this.nav.on('click',function(){ 149 $this.setCorrent( $(this).data('dir') ); 150 $this.move(); 151 }); 152}; 153 154Slider.prototype.setCorrent = function( dir ){ 155 if (this.wrapper.selector == '#gs1 div') { 156 var pos = this.corrent; 157 158 pos += (~~(dir === 'next') || -1); 159 160 if (typeof dir === 'number' && dir <= this.showNum) { 161 pos = dir; 162 } else if (typeof dir === 'number') { 163 return; 164 } 165 this.corrent = (pos < 0) ? this.showNum : pos % this.boxesLen; 166 if (this.corrent > this.showNum) { 167 this.corrent = 0; 168 } 169 return this; 170 } 171 172 var pos = this.corrent / 6; 173 174 if (dir === 'next') { 175 pos += 1 176 } 177 else { 178 if (pos == 0) { 179 pos = Math.floor(this.boxesLen / 6) 180 } 181 else { 182 pos -= 1 183 } 184 } 185 186 if (typeof dir === 'number' && dir <= this.showNum ) { 187 pos = dir; 188 } else if (typeof dir === 'number') { 189 return; 190 } 191 //console.log("show num" + this.showNum + " " + pos + " " + this.boxesLen) 192 this.corrent = (pos < 0) ? this.showNum : pos * 6 % this.boxesLen; 193 //console.log("show" + this.corrent + " " + this.showNum + " " + this.ul.width()) 194 if (this.corrent - 6 > this.showNum || pos * 6 > this.boxesLen) 195 { 196 this.corrent = 0; 197 } 198 return this; 199}; 200 201Slider.prototype.move = function(before,after){ 202 203 if ($.isFunction(before)) 204 before(); 205// console.log(this.corrent + " " + this.boxWidth) 206 this.ul.animate({ 207 marginLeft: -(this.corrent * this.boxWidth) 208 }); 209}; 210 211function AuthStep2() { 212 var form = $('#auth-html'); 213 if (form.length != 0) { 214 form.html( 215 $('#auth-step-2').html() 216 .replace('{Img}', gFB.user.picture) 217 .replace('{Name}', gFB.user.first_name + ' ' + gFB.user.last_name)); 218 initAuthBtns(); 219 } 220 221 if ($('#auth-fb-btn').length != 0) { 222 var temp = $('#auth-step-2').html(); 223 if (temp != null) { 224 $('#auth-html2').html( 225 temp.replace('{Img}', gFB.user.picture) 226 .replace('{Name}', gFB.user.first_name + ' ' + gFB.user.last_name)); 227 228 initAuthBtns(); 229 } else { 230 top.location.href = "/home"; 231 } 232 } 233}; 234 235function initAuthBtns() { 236 $('.focusBlur').focusBlur(); 237 238 $('div#auth-login-new').find('form').on('keyup', function (e) { 239 e.preventDefault(); 240 if (e.keyCode == 13) { 241 $('a#auth-login').css('backgroundColor', '#313D47').click(); 242 } 243 return false; 244 }).submit(function (e) { 245 e.preventDefault(); 246 return false; 247 }); 248 249 $("div#auth-registration").find('form').on('keyup', function (e) { 250 e.preventDefault(); 251 if (e.keyCode == 13) { 252 $('div#auth-submit').css('backgroundColor', '#313D47').click(); 253 } 254 return false; 255 }).submit(function (e) { 256 e.preventDefault(); 257 return false; 258 });
259 260 $('a#auth-login').off('click').on('click', function (e) { 261 e.preventDefault(); 262 263 264 265 $.post('/Auth/Login', $("div#auth-login-new").find('form').serialize(), function (response) { 266 if (response.Message == "Success") { 267 //alert(top.location); 268 // top.location.reload(true); 269 window.location.href = "/Home/Index"; 270 } else { 271 $('div#auth-login-new').find('div.auth-input').css('borderColor', 'red'); 272 $('#AUTH-RED').fadeIn(); 273 } 274 }); 275 }); 276 277 278 $('div#auth-submit').off('click').on('click', function () { 279 280 var firstName = $('input[name="FirstName"]').val(); 281 var lastName = $('input[name="LastName"]').val(); 282 283 $.post('/Auth/Registration', $("#auth-registration").find('form').serialize(), function (response) { 284 285 $('div#auth-registration').find('.auth-input').removeClass('auth-error'); 286 287 if (response.Message == "Success") { 288 if (response.Data == 2) { 289 var form = $('#auth-html').html( 290 $('#auth-step-2').html() 291 .replace('{Img}', "/content/images/user/default.png") 292 .replace('{Name}', firstName + " " + lastName)); 293 initAuthBtns(); 294 } 295 296 } else { 297 $.each(response.Message.split(","), function () { 298 //console.log(this); 299 $('input[name="' + this + '"]').parent('.auth-input').addClass('auth-error'); 300 }); 301 302 } 303 }, 'json'); 304 }); 305 306 307 $('#auth-submit-fb').off('click').on('click', function () { 308 309 $.ajax({
310 url: '/Auth/Facebook/' + gFB.user.token, 311 type: 'POST', 312 data: $("#auth").find('form').serialize(), 313 success: function (html) { 314 if (html == 2) 315 AuthStep2(); 316 317 if (html == 4) { 318 $('input[name="email"], input[name="password"]').closest('.auth-input').css('border-color', 'red'); 319 } 320 }, 321 error: function () { 322 //alert('Oops!'); 323 } 324 }); 325 }); 326 327 $('#auth-submit-activate').off('click').on('click', function () { 328 $.ajax({ 329 url: '/auth/sendconfirmcode/', 330 success: function (int) { 331 if (int == 0) { 332 top.location.reload(); 333 } 334 }, 335 error: function () { 336 //alert('Oops!'); 337 } 338 }); 339 }); 340 341 $('#auth-fb-btn').off('click').on('click', function () { 342 gFB.init(_FBID, _SCOPE); 343 gFB.login(); 344 console.log("login"); 345 }); 346}; 347 348var gFB = 349{ 350 user: { 351 id: '0', 352 first_name: null, 353 last_name: null, 354 picture: null, 355 link: null, 356 sr: null, 357 token: null 358 }, 359 app: { 360 id: null, 361 scope: '' 362 }, 363 showUserForm: function () { 364 //console.log('showUserForm'); 365 }, 366 showLoginForm: function () { 367 $('#auth-html').html($('#auth-step-0').html()); 368 initAuthBtns(); 369 370 }, 371 initUser: function (response) { 372 373 if (response.authResponse) { 374 375 gFB.user.id = response.authResponse.userID; 376 gFB.user.token = response.authResponse.accessToken; 377 gFB.user.SR = response.authResponse.signedRequest; 378 var bool; 379 FB.api('/me/permissions', function (response) { 380 381 382 var arr = _SCOPE.split(','); 383 for (var i = 0; i < arr.length; i++) { 384 bool = arr[i] in response.data[0]; 385 if (!bool && _checkPermissions) { 386 _checkPermissions = false; 387 gFB.login(); 388 // console.log("login"); 389 return; 390 } 391 } 392 393 FB.api('/me?fields=id,name,first_name,last_name,picture', function (response) { 394 395 gFB.user.name = response.name; 396 gFB.user.first_name = response.first_name; 397 gFB.user.last_name = response.last_name; 398 gFB.user.picture = response.picture; 399 400 // =============================================== 401 //console.log("initUser: function (token) {"); 402 //return; 403 $.ajax({
404 url: '/Auth/Facebook/' + gFB.user.token, 405 type: 'POST', 406 dataType: 'json', 407 success: function (html) { 408 //console.log("Response: facebook"); 409 //console.log(html); 410 411 switch (parseInt(html)) { 412 case 1: 413 var count = $('#auth-wrapper').length; 414 415 $('#auth-wrapper').slideUp(function () { 416 $(this).remove(); 417 top.location.reload(); 418 }); 419 420 if (count != 0 || top.location.href.indexOf('/reader/library') != -1) { 421 top.location.href = top.location.href.replace('?registration=confirm', ''); 422 } 423 break; 424 case 2: 425 AuthStep2(); 426 break; 427 case 3: 428 //confirm email 429 var form = $('#auth-html').html( 430 $('#auth-step-1').html() 431 .replace('{Img}', gFB.user.picture) 432 .replace('{Name}', gFB.user.first_name + ' ' + gFB.user.last_name)); 433 initAuthBtns(); 434 break; 435 case 4: 436 //alert(4); 437 break; 438 default: 439 break; 440 } 441 }, 442 error: function () { 443 //alert('Oops!'); 444 } 445 }); 446 //================================================ 447 448 }); 449 450 451 }); 452 453 454 } else { 455 gFB.user = { 456 id: '0', 457 first_name: null, 458 last_name: null, 459 picture: null, 460 link: null, 461 sr: null 462 } 463 gFB.showLoginForm(); 464 } 465 }, 466 init: function (appId, scope) { 467 468 this.app.id = appId || null; 469 this.app.scope = scope || ''; 470 471 FB.init({ 472 appId: this.app.id, 473 status: true, cookie: true, 474 xfbml: true, oauth: true 475 }); 476 }, 477 login: function () { 478 FB.login(function (response) { 479 480 if (response.authResponse) { 481 gFB.initUser(response); 482 } else { 483 console.log('User cancelled login or did not fully authorize.'); 484 } 485 }, { scope: this.app.scope }); 486 }, 487 logout: function () { 488 FB.logout(function (response) { 489 gFB.user = { 490 id: '0', 491 first_name: null, 492 last_name: null, 493 picture: null, 494 link: null, 495 sr: null, 496 token: null 497 }; 498 }); 499 } 500}; 501 502jQuery.fn.focusBlur = function () { 503 504 return this.each(function () { 505 506 var val = $(this).val(); 507 $(this).focus(function () { 508 if ($(this).val() == val) $(this).val(''); 509 }).blur(function () { 510 if ($(this).val() == '') $(this).val(val); 511 }); 512 513 }); 514}; 515 516function AddToCart(BookId) { 517 var cartTemp = '<div id="card-info"><div id="card-info-title">á©ááá ááá á</div><div id="card-info-count">á áááááááá <span>{Num}</span></div><div id="card-info-sum"><span>{Sum}</span></div></div><ul>{Books}</ul>'; 518 519 $.ajax({
520 url: '/Ajax/AddbookToCart/' + BookId, 521 type: 'POST', 522 dataType: 'json', 523 success: function (json) { 524 //console.log("Response:"); 525 //console.log(json); 526 527 if (json.Message == "Success") { 528 //console.log(json.Message); 529 var html = ""; 530 var arr = []; 531 for (var i = 0; i < json.Data.Books.length; i++) { 532 arr.push(json.Data.Books[i]); 533 if (i == 2) 534 break; 535 } 536 arr = arr.reverse(); 537 for (var i = 0; i < arr.length; i++) { 538 html += '<li style="background-image:url({Thumb});"><div class="name">{Name}</div><div class="author">{Author}</div></li>' 539 .replace('{Thumb}', arr[i].Thumb) 540 .replace('{Name}', arr[i].Thumb.match("default") == null ? '' : arr[i].Name) 541 .replace('{Author}', arr[i].Thumb.match("default") == null ? '' : arr[i].Author); 542 } 543 $('div#header-card').html( 544 cartTemp 545 .replace('{Num}', json.Data.Books.length) 546 .replace('{Sum}', parseInt(json.Data.Price) / 100.0) 547 .replace('{Books}', html)); 548 } else { 549 //alert('Oops!'); 550 } 551 // 552 }, 553 error: function () { 554 // alert('Oops!'); 555 console.log(error); 556 } 557 }); 558}; 559 560$(function () { 561 var ajaxSearchObject = { 562 source: "/Autocomplete/SearchBookByName",
563 href: "/books/shop#bookName:", 564 singlesHref: "/books/details/" 565 566 }; 567 568 var headerSearch = $("input#header-search"); 569 headerSearch.autocomplete({ 570 source: ajaxSearchObject.source, 571 focus: function (event, ui) { 572 headerSearch.val(ui.item.label); 573 return false; 574 }, 575 select: function (event, ui) { 576 headerSearch.val(ui.item.label); 577 578 if (ui.item.count > 1) { 579 location.href = ajaxSearchObject.href + ui.item.label; 580 } 581 else if (ui.item.count == 1) { 582 location.href = "" 583 location.href = ajaxSearchObject.singlesHref + ui.item.value; 584 } 585 else { 586 587 headerSearch.val(ui.item.label); 588 location.href = ajaxSearchObject.href.replace('{id}', ui.item.value); 589 590 } 591 return false; 592 }, 593 open: function (event, ui) { 594 $(this).autocomplete("widget").css({ 595 'width': '626px', 596 'top': '+=5px', 597 'left': '-=26px' 598 }); 599 } 600 }); 601 602 603 var searchType = $('div#header-search-type').find('.select'), 604 searchUl = $('div#header-search-type').find('ul').find('li').on('click', function () { 605 606 var $this = $(this); 607 608 ajaxSearchObject.source = $this.data('source'); 609 ajaxSearchObject.href = $this.data('href'); 610 611 headerSearch.autocomplete('option', 'source', ajaxSearchObject.source); 612 613 searchType.html($this.html()); 614 //searchUl.slideUp(200); 615 }).end(); 616 617 618 var searchType2 = $('div#header-search-type2').find('.select'), 619 searchUl2 = $('div#header-search-type2').find('ul').find('li').on('click', function () { 620 621 var $this = $(this); 622 623 624 searchType2.html($this.html()); 625 //searchUl.slideUp(200); 626 }).end(); 627 628 $('div#header-search').geoKeyboard(); 629 630
631 FB.Event.subscribe('comment.create', function (response) { 632 633 $.post('/user/FBComment', { 634 commentID: response.commentID, 635 href: response.href 636 }); 637 638 }); 639 640 try { 641 $('.gSlider').each(function () { 642 // console.log(this) 643 var s = new Slider({ 644 container: $(this), 645 nav: $(this).find('> button') 646 }); 647 s.init(); 648 }); 649 } catch (err) { 650 } 651 652 $('div#header-card').on('click', function () { 653 if ($(this).find('li').length != 0) { 654 top.location.href = "/user/cartedit" 655 } 656 }); 657 658 $('a.book-shell').live({ 659 mouseenter: function () { 660 $(this).find('div.thumb-btns').stop(true, false).animate({ 661 top: 85 662 }, 200); 663 }, 664 mouseleave: function () { 665 $(this).find('div.thumb-btns').animate({ 666 top: 130 667 }, 200); 668 } 669 }); 670 //////////////////////////////////////////////////////////////////////////////////// 671 var navPrev, navNext, 672 navL = $('div#nav-corner-l') 673 navR = $('div#nav-corner-r'); 674 $('ul#nav > li').not('.nav').hover(function () { 675 var $this = $(this); 676 navPrev = $this.prev('.nav').find('div').css('background-position', '0 0'); 677 navNext = $this.next('.nav').find('div').css('background-position', '0 -50px'); 678 679 if (navPrev.length == 0) { 680 navL.css('background-position', '0 -50px'); 681 } 682 683 if (navNext.length == 0) { 684 navR.css('background-position', '0 -50px'); 685 } 686 687 688 }, function () { 689 var $this = $(this); 690 navPrev = $this.prev('.nav').find('div').css('background-position', '0 -100px'); 691 navNext = $this.next('.nav').find('div').css('background-position', '0 -100px'); 692 693 if (navPrev.length == 0) { 694 navL.css('background-position', '0 0'); 695 } 696 697 if (navNext.length == 0) { 698 navR.css('background-position', '-25px 0'); 699 } 700 }); 701 702 703 704 $('#bodyWrapper').css('minHeight', $(document).height() - 270); 705 706 var headLogo = $('#header-logo').css('cursor', 'pointer').on('click', function () { 707 top.location.href = "/"; 708 }); 709 710 if (top.location.href.indexOf('award') > -1) { 711 $('#header').css('backgroundImage', 'url(/content/img/saba-logo-2.png)'); 712 } 713 714}); 715 716$(window).load(function () { 717 var ua = navigator.userAgent.toLowerCase(); 718 if (ua.indexOf('msie 6') > -1 || ua.indexOf('msie 7') > -1) { 719 $("#headerWrapper, #bodyWrapper, #footerWrapper").remove(); 720 top.location.href = "/about/browsers"; 721 return; 722 } 723 //$("div#Loader").remove(); 724 //return; 725 $("div#Loader").fadeOut(function () { 726 $(this).remove(); 727 }); 728 729 $('.share').on('click', function () { 730 share($(this).data('url')); 731 }); 732 733 if (location.href.indexOf("start=registration") != -1) { 734 setTimeout('$("#auth-reg").click()', 1000); 735 } 736 737});
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.