Permalink
Browse files

Work around for iOS downscale issue.

  • Loading branch information...
1 parent de24bb4 commit 972f5ce603174f8126bbe262f422ffcdfbe3a7fd @a-fung committed Oct 12, 2012
View
3 source/aspnetserver/Handler/MangaPageRequestHandler.cs
@@ -34,9 +34,10 @@ public override void HandleRequest(string jsonString, AjaxBase ajax)
if (manga.Status == 0)
{
- string page = manga.GetPage(request.page, request.width, request.height);
+ 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;
}
else
{
View
14 source/aspnetserver/Manga.cs
@@ -602,7 +602,7 @@ public string GetCover()
int[] resizedDimensions = GetResizedDimensions(0, 260, 200);
if (resizedDimensions != null)
{
- ThreadHelper.Run("MangaProcessFile", Id, Content[0], resizedDimensions[0], resizedDimensions[1], coverPath, lockPath);
+ ThreadHelper.Run("MangaProcessFile", Id, Content[0], resizedDimensions[0], resizedDimensions[1], 0, coverPath, lockPath);
}
return null;
@@ -613,15 +613,15 @@ public string GetCover()
}
}
- public string GetPage(int page, int width, int height)
+ public string GetPage(int page, int width, int height, int part)
{
int[] resizedDimensions = GetResizedDimensions(page, width, height);
if (resizedDimensions == null)
{
return null;
}
- string hash = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1]);
+ string hash = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1] + "." + part);
string lockPath = Path.Combine(AjaxBase.DirectoryPath, "mangacache", hash + ".lock");
string outputRelativePath = "mangacache/" + hash + ".jpg";
string outputPath = Path.Combine(AjaxBase.DirectoryPath, "mangacache", hash + ".jpg");
@@ -632,7 +632,7 @@ public string GetPage(int page, int width, int height)
}
else if (!File.Exists(outputPath))
{
- ThreadHelper.Run("MangaProcessFile", Id, Content[page], resizedDimensions[0], resizedDimensions[1], outputPath, lockPath);
+ ThreadHelper.Run("MangaProcessFile", Id, Content[page], resizedDimensions[0], resizedDimensions[1], part, outputPath, lockPath);
return null;
}
else
@@ -658,7 +658,7 @@ private string TryOutputFile(string content)
return tempFilePath;
}
- public void ProcessFile(string content, int width, int height, string outputPath, string lockPath)
+ public void ProcessFile(string content, int width, int height, int part, string outputPath, string lockPath)
{
if (!File.Exists(outputPath))
{
@@ -679,7 +679,7 @@ public void ProcessFile(string content, int width, int height, string outputPath
if (tempFilePath != null)
{
- ImageProvider.ResizeFile(tempFilePath, outputPath, width, height);
+ ImageProvider.ResizeFile(tempFilePath, outputPath, width, height, part);
File.Delete(tempFilePath);
}
}
@@ -689,7 +689,7 @@ public void ProcessFile(string content, int width, int height, string outputPath
}
}
- private int[] GetDimensions(int page)
+ public int[] GetDimensions(int page)
{
if (Dimensions[page] == null)
{
View
12 source/aspnetserver/Provider/ImageProvider.cs
@@ -43,9 +43,13 @@ private static EncoderParameters EncoderParams
}
}
- public static void ResizeFile(string inputFile, string outputFile, int width, int height)
+ public static void ResizeFile(string inputFile, string outputFile, int width, int height, int part)
{
- int part = -1;
+ if (part != 0)
+ {
+ width = (int)Math.Round(width / 2.0);
+ }
+
using (Image image = Image.FromFile(inputFile))
{
using (Bitmap resizedImage = new Bitmap(width, height))
@@ -57,13 +61,13 @@ public static void ResizeFile(string inputFile, string outputFile, int width, in
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
- if (part == -1)
+ if (part == 0)
{
g.DrawImage(image, 0, 0, resizedImage.Width, resizedImage.Height);
}
else
{
- g.DrawImage(image, part == 0 ? 0 : -resizedImage.Width, 0, resizedImage.Width * 2, resizedImage.Height);
+ g.DrawImage(image, part == 1 ? 0 : -resizedImage.Width, 0, resizedImage.Width * 2, resizedImage.Height);
}
}
View
2 source/aspnetserver/ThreadHelper.cs
@@ -29,7 +29,7 @@ private static void MangaProcessFile(object data)
if (manga != null)
{
- manga.ProcessFile((string)parameters[1], (int)parameters[2], (int)parameters[3], (string)parameters[4], (string)parameters[5]);
+ manga.ProcessFile((string)parameters[1], (int)parameters[2], (int)parameters[3], (int)parameters[4], (string)parameters[5], (string)parameters[6]);
}
}
}
View
2 source/aspnetserver/css/mangaweb.css
@@ -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}
+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}
View
2 source/aspnetserver/lang/en-us.html
@@ -153,7 +153,7 @@
<p id="FitHeight">Fit Height</p>
<p id="FitScreen">Fit Screen</p>
<p id="FitWidth">Fit Width</p>
-<p id="FixAutoResize">Fix Auto Resize</p>
+<p id="FixiOSAutoDownscale">Fix iOS Auto Downscale</p>
<p id="CurrentPassword">Current Password</p>
<p id="NewPassword">New Password</p>
<p id="ChangePasswordInvalidInput">The new password is invalid. Please correct it and try again.</p>
View
2 source/aspnetserver/lang/zh-hk.html
@@ -45,7 +45,7 @@
<p id="FitHeight">切合高度</p>
<p id="FitScreen">切合畫面</p>
<p id="FitWidth">切合寬度</p>
-<p id="FixAutoResize">修正自動縮圖</p>
+<p id="FixiOSAutoDownscale">修正 iOS 自動縮圖</p>
<p id="CurrentPassword">目前的密碼</p>
<p id="NewPassword">新密碼</p>
<p id="ChangePasswordInvalidInput">新的密碼無效,請更正它,然後再試一次。</p>
View
4 source/aspnetserver/template/client.html
@@ -383,10 +383,10 @@ <h4 class="mangas-list-item-title"></h4>
</div>
</div>
<div class="control-group">
- <label class="msg msg-FixAutoResize control-label" for="settings-fix-auto-resize"></label>
+ <label class="msg msg-FixiOSAutoDownscale control-label" for="settings-fix-auto-downscale"></label>
<div class="controls">
<label class="checkbox">
- <input type="checkbox" id="settings-fix-auto-resize" />
+ <input type="checkbox" id="settings-fix-auto-downscale" />
</label>
</div>
</div>
View
1 source/csharpcommon/MangaImageResponse.cs
@@ -10,5 +10,6 @@ public class MangaImageResponse : JsonResponse
{
public int status;
public string url;
+ public int[] dimensions;
}
}
View
2 source/csharpcommon/MangaPageRequest.cs
@@ -12,5 +12,7 @@ public class MangaPageRequest : JsonRequest
public int page;
public int width;
public int height;
+ public int part;
+ public bool dimensions;
}
}
View
1 source/haxe/afung/mangaWeb3/common/MangaImageResponse.hx
@@ -9,4 +9,5 @@ class MangaImageResponse extends JsonResponse
{
public var status:Int;
public var url:String;
+ public var dimensions:Array<Int>;
}
View
2 source/haxe/afung/mangaWeb3/common/MangaPageRequest.hx
@@ -11,4 +11,6 @@ class MangaPageRequest extends JsonRequest
public var page:Int;
public var width:Int;
public var height:Int;
+ public var part:Int;
+ public var dimensions:Bool;
}
View
14 source/haxe/afung/mangaWeb3/server/Manga.hx
@@ -577,7 +577,7 @@ class Manga
var resizedDimensions:Array<Int> = GetResizedDimensions(0, 260, 200);
if (resizedDimensions != null)
{
- ThreadHelper.Run("MangaProcessFile", [Id, Content[0], resizedDimensions[0], resizedDimensions[1], coverPath, lockPath]);
+ ThreadHelper.Run("MangaProcessFile", [Id, Content[0], resizedDimensions[0], resizedDimensions[1], 0, coverPath, lockPath]);
}
return null;
@@ -588,15 +588,15 @@ class Manga
}
}
- public function GetPage(page:Int, width:Int, height:Int):String
+ public function GetPage(page:Int, width:Int, height:Int, part:Int):String
{
var resizedDimensions:Array<Int> = GetResizedDimensions(page, width, height);
if (resizedDimensions == null)
{
return null;
}
- var hash:String = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1]);
+ var hash:String = Utility.Md5(MangaPath) + "_" + Utility.Md5(page + "." + resizedDimensions[0] + "x" + resizedDimensions[1] + "." + part);
var lockPath:String = "mangacache/" + hash + ".lock";
var outputRelativePath:String = "mangacache/" + hash + ".jpg";
var outputPath:String = outputRelativePath;
@@ -607,7 +607,7 @@ class Manga
}
else if (!FileSystem.exists(outputPath))
{
- ThreadHelper.Run("MangaProcessFile", [Id, Content[page], resizedDimensions[0], resizedDimensions[1], outputPath, lockPath]);
+ ThreadHelper.Run("MangaProcessFile", [Id, Content[page], resizedDimensions[0], resizedDimensions[1], part, outputPath, lockPath]);
return null;
}
else
@@ -640,7 +640,7 @@ class Manga
return tempFilePath;
}
- public function ProcessFile(content:String, width:Int, height:Int, outputPath:String, lockPath:String):Void
+ public function ProcessFile(content:String, width:Int, height:Int, part:Int, outputPath:String, lockPath:String):Void
{
if (!FileSystem.exists(outputPath))
{
@@ -655,7 +655,7 @@ class Manga
if (tempFilePath != null)
{
- ImageProvider.ResizeFile(tempFilePath, outputPath, width, height);
+ ImageProvider.ResizeFile(tempFilePath, outputPath, width, height, part);
FileSystem.deleteFile(tempFilePath);
}
}
@@ -666,7 +666,7 @@ class Manga
}
}
- private function GetDimensions(page:Int):Array<Int>
+ public function GetDimensions(page:Int):Array<Int>
{
if (Dimensions[page] == null)
{
View
2 source/haxe/afung/mangaWeb3/server/ThreadHelper.hx
@@ -55,7 +55,7 @@ class ThreadHelper
if (manga != null)
{
- manga.ProcessFile(parameters[1], parameters[2], parameters[3], parameters[4], parameters[5]);
+ manga.ProcessFile(parameters[1], parameters[2], parameters[3], parameters[4], parameters[5], parameters[6]);
}
}
}
View
3 source/haxe/afung/mangaWeb3/server/handler/MangaPageRequestHandler.hx
@@ -37,9 +37,10 @@ class MangaPageRequestHandler extends HandlerBase
if (manga.Status == 0)
{
- var page:String = manga.GetPage(request.page, request.width, request.height);
+ var page:String = 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;
}
else
{
View
17 source/haxe/afung/mangaWeb3/server/provider/ImageProvider.hx
@@ -11,7 +11,7 @@ import php.Lib;
class ImageProvider
{
- public static function ResizeFile(inputFile:String, outputFile:String, width:Int, height:Int):Void
+ public static function ResizeFile(inputFile:String, outputFile:String, width:Int, height:Int, part:Int):Void
{
var image:Dynamic;
var ext:String = "." + Path.extension(inputFile).toLowerCase();
@@ -27,11 +27,24 @@ class ImageProvider
return;
}
+ if (part != 0)
+ {
+ width = Math.round(width / 2.0);
+ }
+
if (image != false)
{
var imageSize:Array<Dynamic> = Lib.toHaxeArray(untyped __call__("getimagesize", inputFile));
var resizedImage:Dynamic = untyped __call__("imagecreatetruecolor", width, height);
- untyped __call__("imagecopyresampled", resizedImage, image, 0, 0, 0, 0, width, height, imageSize[0], imageSize[1]);
+ if (part == 0)
+ {
+ untyped __call__("imagecopyresampled", resizedImage, image, 0, 0, 0, 0, width, height, imageSize[0], imageSize[1]);
+ }
+ else
+ {
+ untyped __call__("imagecopyresampled", resizedImage, image, part == 1 ? 0 : -width, 0, 0, 0, width * 2, height, imageSize[0], imageSize[1]);
+ }
+
untyped __call__("imagejpeg", resizedImage, outputFile, 90);
untyped __call__("imagedestroy", resizedImage);
untyped __call__("imagedestroy", image);
View
18 source/less/mangaweb.less
@@ -214,10 +214,10 @@ textarea {
}
#read-manga-area-inner.navigate {
- -webkit-transition: all 0.2s ease-out;
- -moz-transition: all 0.2s ease-out;
- -o-transition: all 0.2s ease-out;
- transition: all 0.2s ease-out;
+ -webkit-transition: all 0.2s ease-in-out;
+ -moz-transition: all 0.2s ease-in-out;
+ -o-transition: all 0.2s ease-in-out;
+ transition: all 0.2s ease-in-out;
}
#read-manga-area-inner.fade {
@@ -235,13 +235,21 @@ textarea {
}
.read-manga-page {
+ position: absolute;
border: 1px solid white;
border-width: 0 1px;
}
+ .read-manga-page img:first-child {
+ float: left;
+ }
+
+ .read-manga-page img:last-child {
+ float: right;
+ }
+
img {
display:block;
- position: absolute;
width: auto;
height: auto;
max-width: none;
View
9 source/scriptsharp/Environment.cs
@@ -1,5 +1,6 @@
using System;
using System.Html;
+using jQueryApi;
namespace afung.MangaWeb3.Client
{
@@ -36,6 +37,14 @@ public static double PixelRatio
return 1.0;
}
}
+
+ public static bool IsiOS
+ {
+ get
+ {
+ return jQuery.Browser.WebKit && (Window.Navigator.UserAgent.IndexOf("iPhone") != -1 || Window.Navigator.UserAgent.IndexOf("iPad") != -1 || Window.Navigator.UserAgent.IndexOf("iPod") != -1);
+ }
+ }
}
/// <summary>
View
8 source/scriptsharp/Module/MangasModule.cs
@@ -53,7 +53,13 @@ protected override void OnShow()
public extern void Refresh();
public void Refresh(MangaFilter filter)
{
- Show();
+ if (!attachedObject.Is("visible"))
+ {
+ items = new MangaListItemJson[] { };
+ ChangePage(1);
+ pagination.Refresh(true);
+ Show();
+ }
if (Script.IsNullOrUndefined(filter))
{
View
13 source/scriptsharp/Module/ReadModule.cs
@@ -206,9 +206,9 @@ private void ToggleInfo()
private void ToggleInfoButtonClicked(jQueryEvent e)
{
+ e.PreventDefault();
if (!inTransition)
{
- e.PreventDefault();
ToggleInfo();
}
}
@@ -592,14 +592,14 @@ private void TouchHandler(jQueryTouchEvent e)
if (Offset < minOffset || Offset > maxOffset)
{
inTransition = true;
- mangaArea.AddClass("inertia");
+ mangaArea.AddClass("navigate");
Offset = Offset < minOffset ? minOffset : maxOffset;
Utility.OnTransitionEnd(
mangaArea,
delegate
{
inTransition = false;
- mangaArea.RemoveClass("inertia");
+ mangaArea.RemoveClass("navigate");
RefreshMangaArea();
});
}
@@ -641,9 +641,9 @@ private void SliderTouchHandler(jQueryTouchEvent e)
private void ExitButtonClicked(jQueryEvent e)
{
+ e.PreventDefault();
if (!inTransition)
{
- e.PreventDefault();
Exit();
}
}
@@ -661,10 +661,9 @@ private void Exit()
private void NextButtonClicked(jQueryEvent e)
{
+ e.PreventDefault();
if (!inTransition)
{
- e.PreventDefault();
-
if (!sendingReadReqeust && manga.nextId != -1)
{
sendingReadReqeust = true;
@@ -692,9 +691,9 @@ private void ReadRequestFailure(Exception error)
private void ArrowButtonClicked(jQueryEvent e)
{
+ e.PreventDefault();
if (!inTransition)
{
- e.PreventDefault();
jQueryObject target = jQuery.FromElement(e.Target);
while (!target.Is("a"))
{
View
8 source/scriptsharp/Module/SettingsModule.cs
@@ -37,13 +37,13 @@ protected override void OnShow()
jQuery.Select("#settings-sort").Value(Settings.Sort.ToString());
jQuery.Select("#settings-display-type").Value(Settings.DisplayType.ToString());
- if (Settings.FixAutoResize)
+ if (Settings.FixAutoDownscale)
{
- jQuery.Select("#settings-fix-auto-resize").Attribute("checked", "checked");
+ jQuery.Select("#settings-fix-auto-downscale").Attribute("checked", "checked");
}
else
{
- jQuery.Select("#settings-fix-auto-resize").RemoveAttr("checked");
+ jQuery.Select("#settings-fix-auto-downscale").RemoveAttr("checked");
}
}
@@ -53,7 +53,7 @@ private void ApplyChange(jQueryEvent e)
Settings.Sort = int.Parse(jQuery.Select("#settings-sort").GetValue(), 10);
Settings.DisplayType = int.Parse(jQuery.Select("#settings-display-type").GetValue(), 10);
- Settings.FixAutoResize = jQuery.Select("#settings-fix-auto-resize").GetAttribute("checked") == "checked";
+ Settings.FixAutoDownscale = jQuery.Select("#settings-fix-auto-downscale").GetAttribute("checked") == "checked";
string newLanguage = jQuery.Select("#settings-language").GetValue();
if (newLanguage != Settings.UserLanguage)
View
6 source/scriptsharp/Settings.cs
@@ -48,15 +48,15 @@ public static int DisplayType
}
}
- public static bool FixAutoResize
+ public static bool FixAutoDownscale
{
get
{
- return Load("FixAutoResize") == "true";
+ return Load("FixAutoDownscale") == "true";
}
set
{
- Save("FixAutoResize", value ? "true" : "false");
+ Save("FixAutoDownscale", value ? "true" : "false");
}
}
View
197 source/scriptsharp/Widget/MangaPage.cs
@@ -19,6 +19,8 @@ public class MangaPage
private int height;
private Action onload;
private jQueryObject imageObject;
+ private jQueryObject imagePart1Object;
+ private jQueryObject imagePart2Object;
private MangaPageRequest pageRequest;
private int pageRequestDelay;
private bool loaded;
@@ -72,6 +74,22 @@ private ImageElement imageElement
}
}
+ private ImageElement imageElementPart1
+ {
+ get
+ {
+ return imagePart1Object == null ? null : (ImageElement)imagePart1Object.GetElement(0);
+ }
+ }
+
+ private ImageElement imageElementPart2
+ {
+ get
+ {
+ return imagePart2Object == null ? null : (ImageElement)imagePart2Object.GetElement(0);
+ }
+ }
+
public MangaPage(int mangaId, int page, int width, int height)
{
this.mangaId = mangaId;
@@ -98,6 +116,8 @@ public void Load(Action onload)
pageRequest.page = page;
pageRequest.width = Settings.DisplayType == 0 ? 0 : (int)Math.Round(width * Environment.PixelRatio); // Fit Height?
pageRequest.height = Settings.DisplayType == 2 ? 0 : (int)Math.Round(height * Environment.PixelRatio); // Fit Width?
+ pageRequest.dimensions = Environment.IsiOS && Settings.FixAutoDownscale;
+ pageRequest.part = 0;
Request.Send(pageRequest, MangaPageRequestSucess);
}
@@ -117,27 +137,18 @@ private void MangaPageRequestSucess(MangaImageResponse response)
"load",
delegate(jQueryEvent e)
{
- if (Settings.DisplayType == 0)
- {
- imageObject.Height(height);
- }
- else if (Settings.DisplayType == 2)
+ // 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.Width(width);
- }
- else
- {
- double widthFactor = width / imageElement.Width;
- double heightFactor = height / imageElement.Height;
- double factor = widthFactor < heightFactor ? widthFactor : heightFactor;
- imageObject
- .Width(Math.Round(imageElement.Width * factor))
- .Height(Math.Round(imageElement.Height * factor));
+ imageObject.Unbind("load").Attribute("src", "");
+ imageObject = null;
+ LoadPart1();
+ return;
}
- loading = false;
- loaded = true;
- onload();
+ LoadFinish();
}).Attribute("src", response.url);
}
else if (response.status == 1)
@@ -155,6 +166,144 @@ private void MangaPageRequestSucess(MangaImageResponse response)
}
}
+ private void LoadPart1()
+ {
+ pageRequestDelay = 0;
+ pageRequest.dimensions = false;
+ pageRequest.part = 1;
+ Request.Send(pageRequest, MangaPagePart1RequestSucess);
+ }
+
+ [AlternateSignature]
+ private extern void MangaPagePart1RequestSucess(JsonResponse response);
+ private void MangaPagePart1RequestSucess(MangaImageResponse response)
+ {
+ if (unloaded)
+ {
+ return;
+ }
+
+ if (response.status == 0)
+ {
+ imagePart1Object = jQuery.FromHtml("<img>").Bind(
+ "load",
+ delegate(jQueryEvent e)
+ {
+ LoadPart2();
+ }).Attribute("src", response.url);
+ }
+ else if (response.status == 1)
+ {
+ Window.SetTimeout(
+ delegate
+ {
+ Request.Send(pageRequest, MangaPagePart1RequestSucess);
+ },
+ pageRequestDelay = pageRequestDelay * 2 + 1000);
+ }
+ else
+ {
+ ErrorModal.ShowError(Strings.Get("MangaNotAvailable"));
+ }
+ }
+
+ private void LoadPart2()
+ {
+ pageRequestDelay = 0;
+ pageRequest.part = 2;
+ Request.Send(pageRequest, MangaPagePart2RequestSucess);
+ }
+
+ [AlternateSignature]
+ private extern void MangaPagePart2RequestSucess(JsonResponse response);
+ 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"));
+ }
+ }
+
+ private void LoadFinish()
+ {
+ if (imageObject != null && imageObject.Is("img"))
+ {
+ if (Settings.DisplayType == 0)
+ {
+ imageObject.Height(height);
+ }
+ else if (Settings.DisplayType == 2)
+ {
+ imageObject.Width(width);
+ }
+ else
+ {
+ double widthFactor = width / imageElement.Width;
+ double heightFactor = height / imageElement.Height;
+ double factor = widthFactor < heightFactor ? widthFactor : heightFactor;
+ imageObject
+ .Width(Math.Round(imageElement.Width * factor))
+ .Height(Math.Round(imageElement.Height * factor));
+ }
+ }
+ else
+ {
+ imageObject = jQuery.FromHtml("<div></div>").Append(imagePart1Object).Append(imagePart2Object);
+
+ if (Settings.DisplayType == 0)
+ {
+ imagePart1Object.Height(height);
+ imagePart2Object.Height(height);
+ imageObject.Height(height).Width(imageElementPart1.Width / imageElementPart1.Height * height * 2);
+ }
+ else if (Settings.DisplayType == 2)
+ {
+ int halfWidth = Math.Round(width / 2);
+ imagePart1Object.Width(halfWidth);
+ imagePart2Object.Width(halfWidth);
+ imageObject.Width(halfWidth * 2);
+ }
+ else
+ {
+ double widthFactor = width / imageElementPart1.Width / 2;
+ double heightFactor = height / imageElementPart1.Height;
+ double factor = widthFactor < heightFactor ? widthFactor : heightFactor;
+ int halfWidth = Math.Round(imageElementPart1.Width * factor);
+ int sHeight = Math.Round(imageElementPart1.Height * factor);
+ imagePart1Object.Width(halfWidth).Height(sHeight);
+ imagePart2Object.Width(halfWidth).Height(sHeight);
+ imageObject.Width(halfWidth * 2).Height(sHeight);
+ }
+ }
+
+ loading = false;
+ loaded = true;
+ onload();
+ }
+
public void AppendTo(jQueryObject mangaArea, int offset, int sign, MangaPage otherPage)
{
imageObject.AddClass("read-manga-page fade").AppendTo(mangaArea);
@@ -194,6 +343,18 @@ public void Unload(bool loadNext)
imageObject = null;
}
+ if (imagePart1Object != null && imagePart1Object.Is("img"))
+ {
+ imagePart1Object.Unbind("load").Attribute("src", "");
+ imagePart1Object = null;
+ }
+
+ if (imagePart2Object != null && imagePart2Object.Is("img"))
+ {
+ imagePart2Object.Unbind("load").Attribute("src", "");
+ imagePart1Object = null;
+ }
+
if (loading && loadNext)
{
loading = false;

0 comments on commit 972f5ce

Please sign in to comment.