public override void HandleRequest(string jsonString, AjaxBase ajax)
        {
            MangaListItemCoverRequest request = Utility.ParseJson<MangaListItemCoverRequest>(jsonString);
            Manga manga = Manga.GetById(request.id);

            if (manga == null || !manga.ParentCollection.Accessible(ajax))
            {
                ajax.BadRequest();
                return;
            }

            MangaImageResponse response = new MangaImageResponse();

            if (manga.Status == 0)
            {
                string cover = manga.GetCover();
                response.status = cover == null ? 1 : 0;
                response.url = cover;
            }
            else
            {
                response.status = 2;
            }

            ajax.ReturnJson(response);
        }
Пример #2
0
        public override void HandleRequest(string jsonString, AjaxBase ajax)
        {
            MangaPageRequest request = Utility.ParseJson<MangaPageRequest>(jsonString);
            Manga manga = Manga.GetById(request.id);

            if (manga == null || request.page < 0 || request.page >= manga.NumberOfPages || (request.width <= 0 && request.height <= 0))
            {
                ajax.BadRequest();
                return;
            }

            if (!manga.ParentCollection.Accessible(ajax))
            {
                ajax.Unauthorized();
                return;
            }

            MangaImageResponse response = new MangaImageResponse();

            if (manga.Status == 0)
            {
                if (request.page < 0 || request.page >= manga.NumberOfPages)
                {
                    ajax.BadRequest();
                    return;
                }

                string page = manga.GetPage(request.page, request.width, request.height, request.part);
                response.status = page == null ? 1 : 0;
                response.url = page;
                response.dimensions = request.dimensions && request.part == 0 && page != null ? manga.GetDimensions(request.page) : null;

                ThreadHelper.Run(request.part == 0 ? "MangaPreprocessFiles" : "MangaPreprocessParts", request.id, request.page, request.width, request.height);
            }
            else
            {
                response.status = 2;
            }

            ajax.ReturnJson(response);
        }
Пример #3
0
 private void CoverRequestSuccess(MangaImageResponse response)
 {
     if (response.status == 0)
     {
         coverCache[data.id] = response.url;
         if (attachedObject.Is(":visible"))
         {
             LoadCover(coverCache[data.id]);
         }
     }
     else if (response.status == 1 && attachedObject.Is(":visible"))
     {
         Window.SetTimeout(
             delegate
             {
                 Request.Send(coverRequest, CoverRequestSuccess);
             },
             coverRequestDelay = Math.Round(coverRequestDelay * 1.1));
     }
     else if (response.status == 2)
     {
         attachedObject.Remove();
         callback();
     }
 }
Пример #4
0
        private void MangaPageRequestSucess(MangaImageResponse response)
        {
            if (unloaded)
            {
                return;
            }

            if (response.status == 0)
            {
                imageObject = jQuery.FromHtml("<img>").Bind(
                    "load",
                    delegate(jQueryEvent e)
                    {
                        // check iOS downscale issue
                        if (pageRequest.dimensions
                            && (pageRequest.width == 0 || (imageElement.Width < pageRequest.width && imageElement.Width < response.dimensions[0]))
                            && (pageRequest.height == 0 || (imageElement.Height < pageRequest.height && imageElement.Height < response.dimensions[1])))
                        {
                            imageObject.Unbind("load").Attribute("src", "");
                            imageObject = null;
                            LoadPart1();
                            return;
                        }

                        LoadFinish();
                    }).Attribute("src", response.url);
            }
            else if (response.status == 1)
            {
                Window.SetTimeout(
                    delegate
                    {
                        Request.Send(pageRequest, MangaPageRequestSucess);
                    },
                    pageRequestDelay = pageRequestDelay + 1000);
            }
            else
            {
                ErrorModal.ShowError(Strings.Get("MangaNotAvailable"));
                onfailure();
            }
        }
Пример #5
0
        private void MangaPagePart2RequestSucess(MangaImageResponse response)
        {
            if (unloaded)
            {
                return;
            }

            if (response.status == 0)
            {
                imagePart2Object = jQuery.FromHtml("<img>").Bind(
                    "load",
                    delegate(jQueryEvent e)
                    {
                        LoadFinish();
                    }).Attribute("src", response.url);
            }
            else if (response.status == 1)
            {
                Window.SetTimeout(
                    delegate
                    {
                        Request.Send(pageRequest, MangaPagePart2RequestSucess);
                    },
                    pageRequestDelay = pageRequestDelay * 2 + 1000);
            }
            else
            {
                ErrorModal.ShowError(Strings.Get("MangaNotAvailable"));
                onfailure();
            }
        }