Permalink
Browse files

MangaViewer added

  • Loading branch information...
1 parent 6c94ab5 commit 0182a89615b706ad9436ff8560a2f4698db891ec @raghothams committed Apr 7, 2012
Showing with 155 additions and 0 deletions.
  1. BIN .DS_Store
  2. BIN 1.jpg
  3. BIN 2.jpg
  4. +1 −0 dummy.log
  5. +4 −0 jquery.js
  6. +35 −0 styles.css
  7. +115 −0 viewManga.html
View
BIN .DS_Store
Binary file not shown.
View
BIN 1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN 2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1 @@
+dummy file to get URI of this file
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,35 @@
+
+*{
+ margin: 0 auto;
+ width: 700px;
+}
+
+body{
+ background-color: #fff;
+}
+
+#results{
+ background-color: #fff;
+ width: 700px;
+ height: 700px;
+ display: none;
+}
+
+#next{
+ left:860px;
+ top:350px;
+ width:100px;
+}
+
+#prev{
+ left:40px;
+ top:350px;
+ width:100px;
+}
+
+.thumb{
+ background-color: #444;
+ width: 700px;
+ height: 700px;
+ display: block;
+}
View
@@ -0,0 +1,115 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="styles.css"/>
+<script type="text/javascript"></script>
+<script type="text/javascript" src="jquery.js"></script>
+<script type="text/javascript">
+ $(function(){
+ alert("ready");
+
+ });
+ var errorFlag = false;
+ function handleError(msg, parent){
+ $('img').error(function() {
+ $(this).hide();
+ errorFlag = true;
+ alert(msg);
+ });
+ if(parent === "prev"){
+ $('#prev').hide();
+ if(currFileName == null){
+ alert("select manga");
+ return 1;
+ }
+ } else if(parent ==="next"){
+ $('#next').hide();
+ if(currFileName == null){
+ alert("select manga");
+ return 1;
+ }
+ }
+ }
+
+ var mangaFile;
+ var currFileName;
+ function handleFileChange(){
+ var fileList = document.getElementById('files');
+ mangaFile = fileList.files[0];
+
+ var reader = new FileReader();
+ reader.onload = loadFile();
+ reader.onloadend = function(){
+ $('#next').show();
+ $('#prev').show();
+ }
+ function loadFile() {
+ function changeFile(e) {
+ // Render thumbnail.
+ var span = document.getElementById('results');
+ var targetFile = e.fileName;
+ currFileName = targetFile;
+ span.outerHTML = '<img id="results" src="'+ targetFile + '"onclick="nextManga()"/>'
+ $('#results').css('display','block');
+ }
+ changeFile(mangaFile);
+ }
+ reader.readAsDataURL(mangaFile);
+
+ }
+
+ function nextManga(){
+ if(currFileName != null){
+ errorFlag = false;
+ var fileName = currFileName;
+ var parts = fileName.split('.');
+ var part1 = parts[0];
+ part1 = parseInt(part1) +1;
+ var newFileName = part1+"."+parts[1];
+ // Render new thumbnail.
+ var span = document.getElementById('results');
+ span.outerHTML = '<img id="results" src="'+ newFileName + '"/>'
+ $('#results').css('display','block');
+ currFileName = newFileName;
+ handleError("Error");
+ if(errorFlag){
+
+ }
+ } else{
+ handleError("Select first manga", "next");
+ }
+ // document.getElementById('result').insertBefore(span, null);
+ }
+
+ function previousManga(){
+ if(currFileName != null){
+ var fileName = currFileName;
+ var parts = fileName.split('.');
+ var part1 = parts[0];
+ part1 = parseInt(part1) -1;
+ var newFileName = part1+"."+parts[1];
+ // Render new thumbnail.
+ var span = document.getElementById('results');
+ span.outerHTML = '<img id="results" src="'+ newFileName + '"/>'
+ $('#results').css('display','block');
+ currFileName = newFileName;
+ handleError("Error");
+ } else{
+ handleError("Select first manga", "prev");
+ }
+ }
+
+</script>
+
+</head>
+ <body>
+ <p>hello manga</p>
+ <div id="manga_image">
+
+ <input type="file" id="files" onchange="handleFileChange()"/>
+ <input type="button" value="next" id="next" onclick="nextManga()">
+ <img id="results" src="" onclick="nextManga()">
+ <input type="button" value="previous" id="prev" onclick="previousManga()">
+ </div>
+ </body>
+</html>

0 comments on commit 0182a89

Please sign in to comment.