Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Work around for iOS downscale issue.

  • Loading branch information...
commit 972f5ce603174f8126bbe262f422ffcdfbe3a7fd 1 parent de24bb4
a-fung authored

Showing 23 changed files with 275 additions and 67 deletions. Show diff stats Hide diff stats

  1. +2 1  source/aspnetserver/Handler/MangaPageRequestHandler.cs
  2. +7 7 source/aspnetserver/Manga.cs
  3. +8 4 source/aspnetserver/Provider/ImageProvider.cs
  4. +1 1  source/aspnetserver/ThreadHelper.cs
  5. +1 1  source/aspnetserver/css/mangaweb.css
  6. +1 1  source/aspnetserver/lang/en-us.html
  7. +1 1  source/aspnetserver/lang/zh-hk.html
  8. +2 2 source/aspnetserver/template/client.html
  9. +1 0  source/csharpcommon/MangaImageResponse.cs
  10. +2 0  source/csharpcommon/MangaPageRequest.cs
  11. +1 0  source/haxe/afung/mangaWeb3/common/MangaImageResponse.hx
  12. +2 0  source/haxe/afung/mangaWeb3/common/MangaPageRequest.hx
  13. +7 7 source/haxe/afung/mangaWeb3/server/Manga.hx
  14. +1 1  source/haxe/afung/mangaWeb3/server/ThreadHelper.hx
  15. +2 1  source/haxe/afung/mangaWeb3/server/handler/MangaPageRequestHandler.hx
  16. +15 2 source/haxe/afung/mangaWeb3/server/provider/ImageProvider.hx
  17. +13 5 source/less/mangaweb.less
  18. +9 0 source/scriptsharp/Environment.cs
  19. +7 1 source/scriptsharp/Module/MangasModule.cs
  20. +6 7 source/scriptsharp/Module/ReadModule.cs
  21. +4 4 source/scriptsharp/Module/SettingsModule.cs
  22. +3 3 source/scriptsharp/Settings.cs
  23. +179 18 source/scriptsharp/Widget/MangaPage.cs
3  source/aspnetserver/Handler/MangaPageRequestHandler.cs
@@ -34,9 +34,10 @@ public override void HandleRequest(string jsonString, AjaxBase ajax)
34 34
35 35 if (manga.Status == 0)
36 36 {
37   - string page = manga.GetPage(request.page, request.width, request.height);
  37 + string page = manga.GetPage(request.page, request.width, request.height, request.part);
38 38 response.status = page == null ? 1 : 0;
39 39 response.url = page;
  40 + response.dimensions = request.dimensions && request.part == 0 && page != null ? manga.GetDimensions(request.page) : null;
40 41 }
41 42 else
42 43 {
14 source/aspnetserver/Manga.cs
@@ -602,7 +602,7 @@ public string GetCover()
602 602 int[] resizedDimensions = GetResizedDimensions(0, 260, 200);
603 603 if (resizedDimensions != null)
604 604 {
605   - ThreadHelper.Run("MangaProcessFile", Id, Content[0], resizedDimensions[0], resizedDimensions[1], coverPath, lockPath);
  605 + ThreadHelper.Run("MangaProcessFile", Id, Content[0], resizedDimensions[0], resizedDimensions[1], 0, coverPath, lockPath);
606 606 }
607 607
608 608 return null;
@@ -613,7 +613,7 @@ public string GetCover()
613 613 }
614 614 }
615 615
616   - public string GetPage(int page, int width, int height)
  616 + public string GetPage(int page, int width, int height, int part)
617 617 {
618 618 int[] resizedDimensions = GetResizedDimensions(page, width, height);
619 619 if (resizedDimensions == null)
@@ -621,7 +621,7 @@ public string GetPage(int page, int width, int height)
621 621 return null;
622 622 }
623 623
624   - string hash = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1]);
  624 + string hash = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1] + "." + part);
625 625 string lockPath = Path.Combine(AjaxBase.DirectoryPath, "mangacache", hash + ".lock");
626 626 string outputRelativePath = "mangacache/" + hash + ".jpg";
627 627 string outputPath = Path.Combine(AjaxBase.DirectoryPath, "mangacache", hash + ".jpg");
@@ -632,7 +632,7 @@ public string GetPage(int page, int width, int height)
632 632 }
633 633 else if (!File.Exists(outputPath))
634 634 {
635   - ThreadHelper.Run("MangaProcessFile", Id, Content[page], resizedDimensions[0], resizedDimensions[1], outputPath, lockPath);
  635 + ThreadHelper.Run("MangaProcessFile", Id, Content[page], resizedDimensions[0], resizedDimensions[1], part, outputPath, lockPath);
636 636 return null;
637 637 }
638 638 else
@@ -658,7 +658,7 @@ private string TryOutputFile(string content)
658 658 return tempFilePath;
659 659 }
660 660
661   - public void ProcessFile(string content, int width, int height, string outputPath, string lockPath)
  661 + public void ProcessFile(string content, int width, int height, int part, string outputPath, string lockPath)
662 662 {
663 663 if (!File.Exists(outputPath))
664 664 {
@@ -679,7 +679,7 @@ public void ProcessFile(string content, int width, int height, string outputPath
679 679
680 680 if (tempFilePath != null)
681 681 {
682   - ImageProvider.ResizeFile(tempFilePath, outputPath, width, height);
  682 + ImageProvider.ResizeFile(tempFilePath, outputPath, width, height, part);
683 683 File.Delete(tempFilePath);
684 684 }
685 685 }
@@ -689,7 +689,7 @@ public void ProcessFile(string content, int width, int height, string outputPath
689 689 }
690 690 }
691 691
692   - private int[] GetDimensions(int page)
  692 + public int[] GetDimensions(int page)
693 693 {
694 694 if (Dimensions[page] == null)
695 695 {
12 source/aspnetserver/Provider/ImageProvider.cs
@@ -43,9 +43,13 @@ private static EncoderParameters EncoderParams
43 43 }
44 44 }
45 45
46   - public static void ResizeFile(string inputFile, string outputFile, int width, int height)
  46 + public static void ResizeFile(string inputFile, string outputFile, int width, int height, int part)
47 47 {
48   - int part = -1;
  48 + if (part != 0)
  49 + {
  50 + width = (int)Math.Round(width / 2.0);
  51 + }
  52 +
49 53 using (Image image = Image.FromFile(inputFile))
50 54 {
51 55 using (Bitmap resizedImage = new Bitmap(width, height))
@@ -57,13 +61,13 @@ public static void ResizeFile(string inputFile, string outputFile, int width, in
57 61 g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
58 62 g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
59 63
60   - if (part == -1)
  64 + if (part == 0)
61 65 {
62 66 g.DrawImage(image, 0, 0, resizedImage.Width, resizedImage.Height);
63 67 }
64 68 else
65 69 {
66   - g.DrawImage(image, part == 0 ? 0 : -resizedImage.Width, 0, resizedImage.Width * 2, resizedImage.Height);
  70 + g.DrawImage(image, part == 1 ? 0 : -resizedImage.Width, 0, resizedImage.Width * 2, resizedImage.Height);
67 71 }
68 72 }
69 73
2  source/aspnetserver/ThreadHelper.cs
@@ -29,7 +29,7 @@ private static void MangaProcessFile(object data)
29 29
30 30 if (manga != null)
31 31 {
32   - manga.ProcessFile((string)parameters[1], (int)parameters[2], (int)parameters[3], (string)parameters[4], (string)parameters[5]);
  32 + manga.ProcessFile((string)parameters[1], (int)parameters[2], (int)parameters[3], (int)parameters[4], (string)parameters[5], (string)parameters[6]);
33 33 }
34 34 }
35 35 }
2  source/aspnetserver/css/mangaweb.css
... ... @@ -1 +1 @@
1   -body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}code,pre{font-family:Monaco,Menlo,Consolas,"Courier New",monospace,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.navbar-search .search-query{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.temp{display:none}.text-left{text-align:left}.text-center{text-align:center}.modal{overflow:hidden}.modal form{margin:0}.nav-admin,.nav-main{margin-top:15px}.select-tall{height:100px}.table tr.vmiddle input[type="checkbox"]{position:relative;bottom:2px}.table tr.vmiddle td{vertical-align:middle}.table th.text-center,.table td.text-center{text-align:center}.table th.td-mini,.table td.td-mini{width:30px}.table th.td-small,.table td.td-small{width:100px}.table td.break-word{word-wrap:break-word}.row-after-table .btn-toolbar{margin-top:0}.row-after-table .pagination{margin-top:0}@media (max-width: 767px){.modal.fade.in{ top:50%}}#error-modal.modal{z-index:1500}#confirm-modal.modal{z-index:1450}#login-modal.modal{z-index:1400}#admin-finder-modal.modal{z-index:1350}#admin-finder-body.modal-body{height:400px;padding:0}#admin-finder-body.modal-body iframe{display:block;height:400px}.typeahead{z-index:2000}.dropdown.open>a>[class^="icon-"],.dropdown.open>a>[class*=" icon-"]{background-image:url("../img/glyphicons-halflings-white.png")}#mangas-list .thumbnails .thumbnail:hover{border-color:#08C;-webkit-box-shadow:0 1px 4px rgba(0,105,214,.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,.25);box-shadow:0 1px 4px rgba(0,105,214,.25)}#mangas-list .thumbnails .thumbnail{overflow:hidden}#mangas-list .thumbnails .thumbnail .caption h4:first-child{margin-top:0}#mangas-list .thumbnails .thumbnail .caption .mangas-list-item-details p{font-size:12px;line-height:16px;margin-bottom:8px}#mangas-list .thumbnails .thumbnail .caption p:last-child{margin-bottom:0}#mangas-list .thumbnails .thumbnail img{display:block;margin-left:auto;margin-right:auto;background-image:url("../img/loading.gif");background-repeat:no-repeat;background-position:center center;max-height:200px}#folders-module td{vertical-align:baseline;white-space:nowrap}.height-transition{-webkit-transition:height .15s ease-out;-moz-transition:height .15s ease-out;-o-transition:height .15s ease-out;transition:height .15s ease-out}.height-transition-suppress{-webkit-transition:height 0;-moz-transition:height 0;-o-transition:height 0;transition:height 0}@media (max-width: 767px){#read-module{ margin:0 -20px}}#read-module{display:block;position:relative;overflow:hidden;min-width:300px;min-height:300px}#read-module #read-manga-area{position:absolute;width:100%;height:100%}#read-module #read-manga-area #read-manga-area-inner{-webkit-transition:all 0;-moz-transition:all 0;-o-transition:all 0;transition:all 0}#read-module #read-manga-area #read-manga-area-inner.navigate{-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;-o-transition:all .2s ease-out;transition:all .2s ease-out}#read-module #read-manga-area #read-manga-area-inner.fade{-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}#read-module #read-manga-area #read-manga-area-inner.inertia{-webkit-transition:all .4s ease-out;-moz-transition:all .4s ease-out;-o-transition:all .4s ease-out;transition:all .4s ease-out}#read-module #read-manga-area .read-manga-page{border:1px solid white;border-width:0 1px}#read-module #read-manga-area img{display:block;position:absolute;width:auto;height:auto;max-width:none;max-height:none}#read-module #read-button-area.show a{opacity:1}#read-module #read-button-area a{display:block;position:absolute}#read-module #read-button-area a:hover{opacity:1}#read-module #read-button-area .arrow-btn{text-align:center;width:44px;height:40%;top:50%}#read-module #read-button-area .arrow-btn span{position:relative;top:50%;margin:-12px auto 0}#read-module #read-button-area .arrow-btn-right{right:0}#read-module #read-button-area .arrow-btn-upper{top:10%}#read-module #read-button-area #read-info-btn{right:5px;bottom:5px}#read-module #read-info-area #read-next-btn{position:absolute;left:5px;bottom:5px}#read-module #read-info-area #read-exit-btn{position:absolute;right:5px;top:5px}#read-module #read-info-area #read-info-page{position:absolute;top:80px;left:50%}#read-module #read-info-area #read-slider-area{position:absolute;bottom:5px;width:100%}#read-module #read-info-area #read-slider-area #read-slider-inner{position:relative;margin:0 100px}#read-module #read-info-area #read-slider-area #read-slider-inner #read-slider-bar{margin:-3px 0 0 -4px;width:100%;top:50%;position:absolute;padding-left:3px;padding-right:3px;cursor:default}#read-module #read-info-area #read-slider-area #read-slider-inner #read-slider-handle{position:relative}
  1 +body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}code,pre{font-family:Monaco,Menlo,Consolas,"Courier New",monospace,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.navbar-search .search-query{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif,"Meiryo UI","MS UI Gothic","MS PGothic","MS Pゴシック","MS Gothic","MS ゴシック","Microsoft JHengHei UI","Microsoft JHengHei","微軟正黑體",MingLiU,"細明體"}.temp{display:none}.text-left{text-align:left}.text-center{text-align:center}.modal{overflow:hidden}.modal form{margin:0}.nav-admin,.nav-main{margin-top:15px}.select-tall{height:100px}.table tr.vmiddle input[type="checkbox"]{position:relative;bottom:2px}.table tr.vmiddle td{vertical-align:middle}.table th.text-center,.table td.text-center{text-align:center}.table th.td-mini,.table td.td-mini{width:30px}.table th.td-small,.table td.td-small{width:100px}.table td.break-word{word-wrap:break-word}.row-after-table .btn-toolbar{margin-top:0}.row-after-table .pagination{margin-top:0}@media (max-width: 767px){.modal.fade.in{ top:50%}}#error-modal.modal{z-index:1500}#confirm-modal.modal{z-index:1450}#login-modal.modal{z-index:1400}#admin-finder-modal.modal{z-index:1350}#admin-finder-body.modal-body{height:400px;padding:0}#admin-finder-body.modal-body iframe{display:block;height:400px}.typeahead{z-index:2000}.dropdown.open>a>[class^="icon-"],.dropdown.open>a>[class*=" icon-"]{background-image:url("../img/glyphicons-halflings-white.png")}#mangas-list .thumbnails .thumbnail:hover{border-color:#08C;-webkit-box-shadow:0 1px 4px rgba(0,105,214,.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,.25);box-shadow:0 1px 4px rgba(0,105,214,.25)}#mangas-list .thumbnails .thumbnail{overflow:hidden}#mangas-list .thumbnails .thumbnail .caption h4:first-child{margin-top:0}#mangas-list .thumbnails .thumbnail .caption .mangas-list-item-details p{font-size:12px;line-height:16px;margin-bottom:8px}#mangas-list .thumbnails .thumbnail .caption p:last-child{margin-bottom:0}#mangas-list .thumbnails .thumbnail img{display:block;margin-left:auto;margin-right:auto;background-image:url("../img/loading.gif");background-repeat:no-repeat;background-position:center center;max-height:200px}#folders-module td{vertical-align:baseline;white-space:nowrap}.height-transition{-webkit-transition:height .15s ease-out;-moz-transition:height .15s ease-out;-o-transition:height .15s ease-out;transition:height .15s ease-out}.height-transition-suppress{-webkit-transition:height 0;-moz-transition:height 0;-o-transition:height 0;transition:height 0}@media (max-width: 767px){#read-module{ margin:0 -20px}}#read-module{display:block;position:relative;overflow:hidden;min-width:300px;min-height:300px}#read-module #read-manga-area{position:absolute;width:100%;height:100%}#read-module #read-manga-area #read-manga-area-inner{-webkit-transition:all 0;-moz-transition:all 0;-o-transition:all 0;transition:all 0}#read-module #read-manga-area #read-manga-area-inner.navigate{-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}#read-module #read-manga-area #read-manga-area-inner.fade{-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}#read-module #read-manga-area #read-manga-area-inner.inertia{-webkit-transition:all .4s ease-out;-moz-transition:all .4s ease-out;-o-transition:all .4s ease-out;transition:all .4s ease-out}#read-module #read-manga-area .read-manga-page{position:absolute;border:1px solid white;border-width:0 1px}#read-module #read-manga-area .read-manga-page img:first-child{float:left}#read-module #read-manga-area .read-manga-page img:last-child{float:right}#read-module #read-manga-area img{display:block;width:auto;height:auto;max-width:none;max-height:none}#read-module #read-button-area.show a{opacity:1}#read-module #read-button-area a{display:block;position:absolute}#read-module #read-button-area a:hover{opacity:1}#read-module #read-button-area .arrow-btn{text-align:center;width:44px;height:40%;top:50%}#read-module #read-button-area .arrow-btn span{position:relative;top:50%;margin:-12px auto 0}#read-module #read-button-area .arrow-btn-right{right:0}#read-module #read-button-area .arrow-btn-upper{top:10%}#read-module #read-button-area #read-info-btn{right:5px;bottom:5px}#read-module #read-info-area #read-next-btn{position:absolute;left:5px;bottom:5px}#read-module #read-info-area #read-exit-btn{position:absolute;right:5px;top:5px}#read-module #read-info-area #read-info-page{position:absolute;top:80px;left:50%}#read-module #read-info-area #read-slider-area{position:absolute;bottom:5px;width:100%}#read-module #read-info-area #read-slider-area #read-slider-inner{position:relative;margin:0 100px}#read-module #read-info-area #read-slider-area #read-slider-inner #read-slider-bar{margin:-3px 0 0 -4px;width:100%;top:50%;position:absolute;padding-left:3px;padding-right:3px;cursor:default}#read-module #read-info-area #read-slider-area #read-slider-inner #read-slider-handle{position:relative}
2  source/aspnetserver/lang/en-us.html
@@ -153,7 +153,7 @@
153 153 <p id="FitHeight">Fit Height</p>
154 154 <p id="FitScreen">Fit Screen</p>
155 155 <p id="FitWidth">Fit Width</p>
156   -<p id="FixAutoResize">Fix Auto Resize</p>
  156 +<p id="FixiOSAutoDownscale">Fix iOS Auto Downscale</p>
157 157 <p id="CurrentPassword">Current Password</p>
158 158 <p id="NewPassword">New Password</p>
159 159 <p id="ChangePasswordInvalidInput">The new password is invalid. Please correct it and try again.</p>
2  source/aspnetserver/lang/zh-hk.html
@@ -45,7 +45,7 @@
45 45 <p id="FitHeight">切合高度</p>
46 46 <p id="FitScreen">切合畫面</p>
47 47 <p id="FitWidth">切合寬度</p>
48   -<p id="FixAutoResize">修正自動縮圖</p>
  48 +<p id="FixiOSAutoDownscale">修正 iOS 自動縮圖</p>
49 49 <p id="CurrentPassword">目前的密碼</p>
50 50 <p id="NewPassword">新密碼</p>
51 51 <p id="ChangePasswordInvalidInput">新的密碼無效,請更正它,然後再試一次。</p>
4 source/aspnetserver/template/client.html
@@ -383,10 +383,10 @@ <h4 class="mangas-list-item-title"></h4>
383 383 </div>
384 384 </div>
385 385 <div class="control-group">
386   - <label class="msg msg-FixAutoResize control-label" for="settings-fix-auto-resize"></label>
  386 + <label class="msg msg-FixiOSAutoDownscale control-label" for="settings-fix-auto-downscale"></label>
387 387 <div class="controls">
388 388 <label class="checkbox">
389   - <input type="checkbox" id="settings-fix-auto-resize" />
  389 + <input type="checkbox" id="settings-fix-auto-downscale" />
390 390 </label>
391 391 </div>
392 392 </div>
1  source/csharpcommon/MangaImageResponse.cs
@@ -10,5 +10,6 @@ public class MangaImageResponse : JsonResponse
10 10 {
11 11 public int status;
12 12 public string url;
  13 + public int[] dimensions;
13 14 }
14 15 }
2  source/csharpcommon/MangaPageRequest.cs
@@ -12,5 +12,7 @@ public class MangaPageRequest : JsonRequest
12 12 public int page;
13 13 public int width;
14 14 public int height;
  15 + public int part;
  16 + public bool dimensions;
15 17 }
16 18 }
1  source/haxe/afung/mangaWeb3/common/MangaImageResponse.hx
@@ -9,4 +9,5 @@ class MangaImageResponse extends JsonResponse
9 9 {
10 10 public var status:Int;
11 11 public var url:String;
  12 + public var dimensions:Array<Int>;
12 13 }
2  source/haxe/afung/mangaWeb3/common/MangaPageRequest.hx
@@ -11,4 +11,6 @@ class MangaPageRequest extends JsonRequest
11 11 public var page:Int;
12 12 public var width:Int;
13 13 public var height:Int;
  14 + public var part:Int;
  15 + public var dimensions:Bool;
14 16 }
14 source/haxe/afung/mangaWeb3/server/Manga.hx
@@ -577,7 +577,7 @@ class Manga
577 577 var resizedDimensions:Array<Int> = GetResizedDimensions(0, 260, 200);
578 578 if (resizedDimensions != null)
579 579 {
580   - ThreadHelper.Run("MangaProcessFile", [Id, Content[0], resizedDimensions[0], resizedDimensions[1], coverPath, lockPath]);
  580 + ThreadHelper.Run("MangaProcessFile", [Id, Content[0], resizedDimensions[0], resizedDimensions[1], 0, coverPath, lockPath]);
581 581 }
582 582
583 583 return null;
@@ -588,7 +588,7 @@ class Manga
588 588 }
589 589 }
590 590
591   - public function GetPage(page:Int, width:Int, height:Int):String
  591 + public function GetPage(page:Int, width:Int, height:Int, part:Int):String
592 592 {
593 593 var resizedDimensions:Array<Int> = GetResizedDimensions(page, width, height);
594 594 if (resizedDimensions == null)
@@ -596,7 +596,7 @@ class Manga
596 596 return null;
597 597 }
598 598
599   - var hash:String = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1]);
  599 + var hash:String = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1] + "." + part);
600 600 var lockPath:String = "mangacache/" + hash + ".lock";
601 601 var outputRelativePath:String = "mangacache/" + hash + ".jpg";
602 602 var outputPath:String = outputRelativePath;
@@ -607,7 +607,7 @@ class Manga
607 607 }
608 608 else if (!FileSystem.exists(outputPath))
609 609 {
610   - ThreadHelper.Run("MangaProcessFile", [Id, Content[page], resizedDimensions[0], resizedDimensions[1], outputPath, lockPath]);
  610 + ThreadHelper.Run("MangaProcessFile", [Id, Content[page], resizedDimensions[0], resizedDimensions[1], part, outputPath, lockPath]);
611 611 return null;
612 612 }
613 613 else
@@ -640,7 +640,7 @@ class Manga
640 640 return tempFilePath;
641 641 }
642 642
643   - public function ProcessFile(content:String, width:Int, height:Int, outputPath:String, lockPath:String):Void
  643 + public function ProcessFile(content:String, width:Int, height:Int, part:Int, outputPath:String, lockPath:String):Void
644 644 {
645 645 if (!FileSystem.exists(outputPath))
646 646 {
@@ -655,7 +655,7 @@ class Manga
655 655
656 656 if (tempFilePath != null)
657 657 {
658   - ImageProvider.ResizeFile(tempFilePath, outputPath, width, height);
  658 + ImageProvider.ResizeFile(tempFilePath, outputPath, width, height, part);
659 659 FileSystem.deleteFile(tempFilePath);
660 660 }
661 661 }
@@ -666,7 +666,7 @@ class Manga
666 666 }
667 667 }
668 668
669   - private function GetDimensions(page:Int):Array<Int>
  669 + public function GetDimensions(page:Int):Array<Int>
670 670 {
671 671 if (Dimensions[page] == null)
672 672 {
2  source/haxe/afung/mangaWeb3/server/ThreadHelper.hx
@@ -55,7 +55,7 @@ class ThreadHelper
55 55
56 56 if (manga != null)
57 57 {
58   - manga.ProcessFile(parameters[1], parameters[2], parameters[3], parameters[4], parameters[5]);
  58 + manga.ProcessFile(parameters[1], parameters[2], parameters[3], parameters[4], parameters[5], parameters[6]);
59 59 }
60 60 }
61 61 }
3  source/haxe/afung/mangaWeb3/server/handler/MangaPageRequestHandler.hx
@@ -37,9 +37,10 @@ class MangaPageRequestHandler extends HandlerBase
37 37
38 38 if (manga.Status == 0)
39 39 {
40   - var page:String = manga.GetPage(request.page, request.width, request.height);
  40 + var page:String = manga.GetPage(request.page, request.width, request.height, request.part);
41 41 response.status = page == null ? 1 : 0;
42 42 response.url = page;
  43 + response.dimensions = request.dimensions && request.part == 0 && page != null ? manga.GetDimensions(request.page) : null;
43 44 }
44 45 else
45 46 {
17 source/haxe/afung/mangaWeb3/server/provider/ImageProvider.hx
@@ -11,7 +11,7 @@ import php.Lib;
11 11
12 12 class ImageProvider
13 13 {
14   - public static function ResizeFile(inputFile:String, outputFile:String, width:Int, height:Int):Void
  14 + public static function ResizeFile(inputFile:String, outputFile:String, width:Int, height:Int, part:Int):Void
15 15 {
16 16 var image:Dynamic;
17 17 var ext:String = "." + Path.extension(inputFile).toLowerCase();
@@ -27,11 +27,24 @@ class ImageProvider
27 27 return;
28 28 }
29 29
  30 + if (part != 0)
  31 + {
  32 + width = Math.round(width / 2.0);
  33 + }
  34 +
30 35 if (image != false)
31 36 {
32 37 var imageSize:Array<Dynamic> = Lib.toHaxeArray(untyped __call__("getimagesize", inputFile));
33 38 var resizedImage:Dynamic = untyped __call__("imagecreatetruecolor", width, height);
34   - untyped __call__("imagecopyresampled", resizedImage, image, 0, 0, 0, 0, width, height, imageSize[0], imageSize[1]);
  39 + if (part == 0)
  40 + {
  41 + untyped __call__("imagecopyresampled", resizedImage, image, 0, 0, 0, 0, width, height, imageSize[0], imageSize[1]);
  42 + }
  43 + else
  44 + {
  45 + untyped __call__("imagecopyresampled", resizedImage, image, part == 1 ? 0 : -width, 0, 0, 0, width * 2, height, imageSize[0], imageSize[1]);
  46 + }
  47 +
35 48 untyped __call__("imagejpeg", resizedImage, outputFile, 90);
36 49 untyped __call__("imagedestroy", resizedImage);
37 50 untyped __call__("imagedestroy", image);
18 source/less/mangaweb.less
@@ -214,10 +214,10 @@ textarea {
214 214 }
215 215
216 216 #read-manga-area-inner.navigate {
217   - -webkit-transition: all 0.2s ease-out;
218   - -moz-transition: all 0.2s ease-out;
219   - -o-transition: all 0.2s ease-out;
220   - transition: all 0.2s ease-out;
  217 + -webkit-transition: all 0.2s ease-in-out;
  218 + -moz-transition: all 0.2s ease-in-out;
  219 + -o-transition: all 0.2s ease-in-out;
  220 + transition: all 0.2s ease-in-out;
221 221 }
222 222
223 223 #read-manga-area-inner.fade {
@@ -235,13 +235,21 @@ textarea {
235 235 }
236 236
237 237 .read-manga-page {
  238 + position: absolute;
238 239 border: 1px solid white;
239 240 border-width: 0 1px;
240 241 }
241 242
  243 + .read-manga-page img:first-child {
  244 + float: left;
  245 + }
  246 +
  247 + .read-manga-page img:last-child {
  248 + float: right;
  249 + }
  250 +
242 251 img {
243 252 display:block;
244   - position: absolute;
245 253 width: auto;
246 254 height: auto;
247 255 max-width: none;
9 source/scriptsharp/Environment.cs
... ... @@ -1,5 +1,6 @@
1 1 using System;
2 2 using System.Html;
  3 +using jQueryApi;
3 4
4 5 namespace afung.MangaWeb3.Client
5 6 {
@@ -36,6 +37,14 @@ public static double PixelRatio
36 37 return 1.0;
37 38 }
38 39 }
  40 +
  41 + public static bool IsiOS
  42 + {
  43 + get
  44 + {
  45 + return jQuery.Browser.WebKit && (Window.Navigator.UserAgent.IndexOf("iPhone") != -1 || Window.Navigator.UserAgent.IndexOf("iPad") != -1 || Window.Navigator.UserAgent.IndexOf("iPod") != -1);
  46 + }
  47 + }
39 48 }
40 49
41 50 /// <summary>
8 source/scriptsharp/Module/MangasModule.cs
@@ -53,7 +53,13 @@ protected override void OnShow()
53 53 public extern void Refresh();
54 54 public void Refresh(MangaFilter filter)
55 55 {
56   - Show();
  56 + if (!attachedObject.Is("visible"))
  57 + {
  58 + items = new MangaListItemJson[] { };
  59 + ChangePage(1);
  60 + pagination.Refresh(true);
  61 + Show();
  62 + }
57 63
58 64 if (Script.IsNullOrUndefined(filter))
59 65 {
13 source/scriptsharp/Module/ReadModule.cs
@@ -206,9 +206,9 @@ private void ToggleInfo()
206 206
207 207 private void ToggleInfoButtonClicked(jQueryEvent e)
208 208 {
  209 + e.PreventDefault();
209 210 if (!inTransition)
210 211 {
211   - e.PreventDefault();
212 212 ToggleInfo();
213 213 }
214 214 }
@@ -592,14 +592,14 @@ private void TouchHandler(jQueryTouchEvent e)
592 592 if (Offset < minOffset || Offset > maxOffset)
593 593 {
594 594 inTransition = true;
595   - mangaArea.AddClass("inertia");
  595 + mangaArea.AddClass("navigate");
596 596 Offset = Offset < minOffset ? minOffset : maxOffset;
597 597 Utility.OnTransitionEnd(
598 598 mangaArea,
599 599 delegate
600 600 {
601 601 inTransition = false;
602   - mangaArea.RemoveClass("inertia");
  602 + mangaArea.RemoveClass("navigate");
603 603 RefreshMangaArea();
604 604 });
605 605 }
@@ -641,9 +641,9 @@ private void SliderTouchHandler(jQueryTouchEvent e)
641 641
642 642 private void ExitButtonClicked(jQueryEvent e)
643 643 {
  644 + e.PreventDefault();
644 645 if (!inTransition)
645 646 {
646   - e.PreventDefault();
647 647 Exit();
648 648 }
649 649 }
@@ -661,10 +661,9 @@ private void Exit()
661 661
662 662 private void NextButtonClicked(jQueryEvent e)
663 663 {
  664 + e.PreventDefault();
664 665 if (!inTransition)
665 666 {
666   - e.PreventDefault();
667   -
668 667 if (!sendingReadReqeust && manga.nextId != -1)
669 668 {
670 669 sendingReadReqeust = true;
@@ -692,9 +691,9 @@ private void ReadRequestFailure(Exception error)
692 691
693 692 private void ArrowButtonClicked(jQueryEvent e)
694 693 {
  694 + e.PreventDefault();
695 695 if (!inTransition)
696 696 {
697   - e.PreventDefault();
698 697 jQueryObject target = jQuery.FromElement(e.Target);
699 698 while (!target.Is("a"))
700 699 {
8 source/scriptsharp/Module/SettingsModule.cs
@@ -37,13 +37,13 @@ protected override void OnShow()
37 37 jQuery.Select("#settings-sort").Value(Settings.Sort.ToString());
38 38 jQuery.Select("#settings-display-type").Value(Settings.DisplayType.ToString());
39 39
40   - if (Settings.FixAutoResize)
  40 + if (Settings.FixAutoDownscale)
41 41 {
42   - jQuery.Select("#settings-fix-auto-resize").Attribute("checked", "checked");
  42 + jQuery.Select("#settings-fix-auto-downscale").Attribute("checked", "checked");
43 43 }
44 44 else
45 45 {
46   - jQuery.Select("#settings-fix-auto-resize").RemoveAttr("checked");
  46 + jQuery.Select("#settings-fix-auto-downscale").RemoveAttr("checked");
47 47 }
48 48 }
49 49
@@ -53,7 +53,7 @@ private void ApplyChange(jQueryEvent e)
53 53
54 54 Settings.Sort = int.Parse(jQuery.Select("#settings-sort").GetValue(), 10);
55 55 Settings.DisplayType = int.Parse(jQuery.Select("#settings-display-type").GetValue(), 10);
56   - Settings.FixAutoResize = jQuery.Select("#settings-fix-auto-resize").GetAttribute("checked") == "checked";
  56 + Settings.FixAutoDownscale = jQuery.Select("#settings-fix-auto-downscale").GetAttribute("checked") == "checked";
57 57
58 58 string newLanguage = jQuery.Select("#settings-language").GetValue();
59 59 if (newLanguage != Settings.UserLanguage)
6 source/scriptsharp/Settings.cs
@@ -48,15 +48,15 @@ public static int DisplayType
48 48 }
49 49 }
50 50
51   - public static bool FixAutoResize
  51 + public static bool FixAutoDownscale
52 52 {
53 53 get
54 54 {
55   - return Load("FixAutoResize") == "true";
  55 + return Load("FixAutoDownscale") == "true";
56 56 }
57 57 set
58 58 {
59   - Save("FixAutoResize", value ? "true" : "false");
  59 + Save("FixAutoDownscale", value ? "true" : "false");
60 60 }
61 61 }
62 62
197 source/scriptsharp/Widget/MangaPage.cs
@@ -19,6 +19,8 @@ public class MangaPage
19 19 private int height;
20 20 private Action onload;
21 21 private jQueryObject imageObject;
  22 + private jQueryObject imagePart1Object;
  23 + private jQueryObject imagePart2Object;
22 24 private MangaPageRequest pageRequest;
23 25 private int pageRequestDelay;
24 26 private bool loaded;
@@ -72,6 +74,22 @@ private ImageElement imageElement
72 74 }
73 75 }
74 76
  77 + private ImageElement imageElementPart1
  78 + {
  79 + get
  80 + {
  81 + return imagePart1Object == null ? null : (ImageElement)imagePart1Object.GetElement(0);
  82 + }
  83 + }
  84 +
  85 + private ImageElement imageElementPart2
  86 + {
  87 + get
  88 + {
  89 + return imagePart2Object == null ? null : (ImageElement)imagePart2Object.GetElement(0);
  90 + }
  91 + }
  92 +
75 93 public MangaPage(int mangaId, int page, int width, int height)
76 94 {
77 95 this.mangaId = mangaId;
@@ -98,6 +116,8 @@ public void Load(Action onload)
98 116 pageRequest.page = page;
99 117 pageRequest.width = Settings.DisplayType == 0 ? 0 : (int)Math.Round(width * Environment.PixelRatio); // Fit Height?
100 118 pageRequest.height = Settings.DisplayType == 2 ? 0 : (int)Math.Round(height * Environment.PixelRatio); // Fit Width?
  119 + pageRequest.dimensions = Environment.IsiOS && Settings.FixAutoDownscale;
  120 + pageRequest.part = 0;
101 121
102 122 Request.Send(pageRequest, MangaPageRequestSucess);
103 123 }
@@ -117,27 +137,18 @@ private void MangaPageRequestSucess(MangaImageResponse response)
117 137 "load",
118 138 delegate(jQueryEvent e)
119 139 {
120   - if (Settings.DisplayType == 0)
121   - {
122   - imageObject.Height(height);
123   - }
124   - else if (Settings.DisplayType == 2)
  140 + // check iOS downscale issue
  141 + if (pageRequest.dimensions
  142 + && (pageRequest.width == 0 || (imageElement.Width < pageRequest.width && imageElement.Width < response.dimensions[0]))
  143 + && (pageRequest.height == 0 || (imageElement.Height < pageRequest.height && imageElement.Height < response.dimensions[1])))
125 144 {
126   - imageObject.Width(width);
127   - }
128   - else
129   - {
130   - double widthFactor = width / imageElement.Width;
131   - double heightFactor = height / imageElement.Height;
132   - double factor = widthFactor < heightFactor ? widthFactor : heightFactor;
133   - imageObject
134   - .Width(Math.Round(imageElement.Width * factor))
135   - .Height(Math.Round(imageElement.Height * factor));
  145 + imageObject.Unbind("load").Attribute("src", "");
  146 + imageObject = null;
  147 + LoadPart1();
  148 + return;
136 149 }
137 150
138   - loading = false;
139   - loaded = true;
140   - onload();
  151 + LoadFinish();
141 152 }).Attribute("src", response.url);
142 153 }
143 154 else if (response.status == 1)
@@ -155,6 +166,144 @@ private void MangaPageRequestSucess(MangaImageResponse response)
155 166 }
156 167 }
157 168
  169 + private void LoadPart1()
  170 + {
  171 + pageRequestDelay = 0;
  172 + pageRequest.dimensions = false;
  173 + pageRequest.part = 1;
  174 + Request.Send(pageRequest, MangaPagePart1RequestSucess);
  175 + }
  176 +
  177 + [AlternateSignature]
  178 + private extern void MangaPagePart1RequestSucess(JsonResponse response);
  179 + private void MangaPagePart1RequestSucess(MangaImageResponse response)
  180 + {
  181 + if (unloaded)
  182 + {
  183 + return;
  184 + }
  185 +
  186 + if (response.status == 0)
  187 + {
  188 + imagePart1Object = jQuery.FromHtml("<img>").Bind(
  189 + "load",
  190 + delegate(jQueryEvent e)
  191 + {
  192 + LoadPart2();
  193 + }).Attribute("src", response.url);
  194 + }
  195 + else if (response.status == 1)
  196 + {
  197 + Window.SetTimeout(
  198 + delegate
  199 + {
  200 + Request.Send(pageRequest, MangaPagePart1RequestSucess);
  201 + },
  202 + pageRequestDelay = pageRequestDelay * 2 + 1000);
  203 + }
  204 + else
  205 + {
  206 + ErrorModal.ShowError(Strings.Get("MangaNotAvailable"));
  207 + }
  208 + }
  209 +
  210 + private void LoadPart2()
  211 + {
  212 + pageRequestDelay = 0;
  213 + pageRequest.part = 2;
  214 + Request.Send(pageRequest, MangaPagePart2RequestSucess);
  215 + }
  216 +
  217 + [AlternateSignature]
  218 + private extern void MangaPagePart2RequestSucess(JsonResponse response);
  219 + private void MangaPagePart2RequestSucess(MangaImageResponse response)
  220 + {
  221 + if (unloaded)
  222 + {
  223 + return;
  224 + }
  225 +
  226 + if (response.status == 0)
  227 + {
  228 + imagePart2Object = jQuery.FromHtml("<img>").Bind(
  229 + "load",
  230 + delegate(jQueryEvent e)
  231 + {
  232 + LoadFinish();
  233 + }).Attribute("src", response.url);
  234 + }
  235 + else if (response.status == 1)
  236 + {
  237 + Window.SetTimeout(
  238 + delegate
  239 + {
  240 + Request.Send(pageRequest, MangaPagePart2RequestSucess);
  241 + },
  242 + pageRequestDelay = pageRequestDelay * 2 + 1000);
  243 + }
  244 + else
  245 + {
  246 + ErrorModal.ShowError(Strings.Get("MangaNotAvailable"));
  247 + }
  248 + }
  249 +
  250 + private void LoadFinish()
  251 + {
  252 + if (imageObject != null && imageObject.Is("img"))
  253 + {
  254 + if (Settings.DisplayType == 0)
  255 + {
  256 + imageObject.Height(height);
  257 + }
  258 + else if (Settings.DisplayType == 2)
  259 + {
  260 + imageObject.Width(width);
  261 + }
  262 + else
  263 + {
  264 + double widthFactor = width / imageElement.Width;
  265 + double heightFactor = height / imageElement.Height;
  266 + double factor = widthFactor < heightFactor ? widthFactor : heightFactor;
  267 + imageObject
  268 + .Width(Math.Round(imageElement.Width * factor))
  269 + .Height(Math.Round(imageElement.Height * factor));
  270 + }
  271 + }
  272 + else
  273 + {
  274 + imageObject = jQuery.FromHtml("<div></div>").Append(imagePart1Object).Append(imagePart2Object);
  275 +
  276 + if (Settings.DisplayType == 0)
  277 + {
  278 + imagePart1Object.Height(height);
  279 + imagePart2Object.Height(height);
  280 + imageObject.Height(height).Width(imageElementPart1.Width / imageElementPart1.Height * height * 2);
  281 + }
  282 + else if (Settings.DisplayType == 2)
  283 + {
  284 + int halfWidth = Math.Round(width / 2);
  285 + imagePart1Object.Width(halfWidth);
  286 + imagePart2Object.Width(halfWidth);
  287 + imageObject.Width(halfWidth * 2);
  288 + }
  289 + else
  290 + {
  291 + double widthFactor = width / imageElementPart1.Width / 2;
  292 + double heightFactor = height / imageElementPart1.Height;
  293 + double factor = widthFactor < heightFactor ? widthFactor : heightFactor;
  294 + int halfWidth = Math.Round(imageElementPart1.Width * factor);
  295 + int sHeight = Math.Round(imageElementPart1.Height * factor);
  296 + imagePart1Object.Width(halfWidth).Height(sHeight);
  297 + imagePart2Object.Width(halfWidth).Height(sHeight);
  298 + imageObject.Width(halfWidth * 2).Height(sHeight);
  299 + }
  300 + }
  301 +
  302 + loading = false;
  303 + loaded = true;
  304 + onload();
  305 + }
  306 +
158 307 public void AppendTo(jQueryObject mangaArea, int offset, int sign, MangaPage otherPage)
159 308 {
160 309 imageObject.AddClass("read-manga-page fade").AppendTo(mangaArea);
@@ -194,6 +343,18 @@ public void Unload(bool loadNext)
194 343 imageObject = null;
195 344 }
196 345
  346 + if (imagePart1Object != null && imagePart1Object.Is("img"))
  347 + {
  348 + imagePart1Object.Unbind("load").Attribute("src", "");
  349 + imagePart1Object = null;
  350 + }
  351 +
  352 + if (imagePart2Object != null && imagePart2Object.Is("img"))
  353 + {
  354 + imagePart2Object.Unbind("load").Attribute("src", "");
  355 + imagePart1Object = null;
  356 + }
  357 +
197 358 if (loading && loadNext)
198 359 {
199 360 loading = false;

0 comments on commit 972f5ce

Please sign in to comment.
Something went wrong with that request. Please try again.