Permalink
Browse files

few changes

  • Loading branch information...
1 parent cfed3c8 commit b89f4d151d2a3684933e5068ad9d32b109d0df94 @daleharvey committed Aug 9, 2010
Showing with 440 additions and 62 deletions.
  1. +23 −16 docroot/client.dropup.js
  2. +24 −6 docroot/index.html
  3. +28 −0 docroot/modernizr-1.5.min.js
  4. +28 −12 docroot/screen.css
  5. +294 −0 mime.js
  6. +6 −20 node.dropup.js
  7. +17 −8 start.sh
  8. +20 −0 util.js
View
@@ -21,7 +21,7 @@ var DropUp = (function() {
xhr.onload = function(event) {
- li.className = "loaded";
+ $(li).addClass("loaded");
desc.innerHTML = "<a href='/" + xhr.responseText + ".html'>" +
xhr.responseText + "</a>";
@@ -43,7 +43,7 @@ var DropUp = (function() {
file = event.target.file,
getBinaryDataReader = new FileReader();
- li.className = "uploading";
+ li.className = "item";
progress.className = "progress";
loading.className = "loading";
div.className = "wrapper";
@@ -68,24 +68,34 @@ var DropUp = (function() {
function drop(e) {
- var i, len, files;
+ var i, len, files, file;
e.stopPropagation();
e.preventDefault();
files = e.dataTransfer.files;
for (i = 0; i < files.length; i++) {
- if(files[i].size < 1048576) {
- reader = new FileReader();
- reader.index = i;
- reader.file = files[i];
-
- reader.addEventListener("loadend", fileLoaded, false);
- reader.readAsDataURL(files[i]);
- } else {
- alert("file is too big, needs to be below 1mb");
- }
+
+ file = files[i];
+
+ if (file.size > 1048576) {
+ $(target).append("<li class='item warning'>1MB Limit</li>");
+ continue;
+ }
+
+ if (!file.type.match(/image.png/)) {
+ $(target).append("<li class='item warning'>Sorry, you can " +
+ "only upload png files</li>");
+ continue;
+ }
+
+ reader = new FileReader();
+ reader.index = i;
+ reader.file = file;
+
+ reader.addEventListener("loadend", fileLoaded, false);
+ reader.readAsDataURL(file);
}
};
@@ -104,6 +114,3 @@ var DropUp = (function() {
"init":init
};
})();
-
-
-DropUp.init();
View
@@ -9,18 +9,20 @@
<body>
- <header class="clearfix">
- <h1><a href="/">drop<span>up</span></a></h1>
- </header>
-
- <div id="wrapper">
+ <div id="indexwrapper">
+ <header class="clearfix">
+ <h1><a href="/">drop<span>up</span></a></h1>
+ </header>
+
<p>
The simplest way to share images, just drag and drop your images
onto this page.
</p>
- <ul id="target" class="clearfix"></ul>
+ <div id="dropzone">
+ <ul id="target" class="clearfix"></ul>
+ </div>
<p id="warnings">
* Images are public, and will be deleted after 24 hours
@@ -29,7 +31,23 @@ <h1><a href="/">drop<span>up</span></a></h1>
</div>
<script src="/jquery-1.4.2.min.js"></script>
+ <script src="/modernizr-1.5.min.js"></script>
<script src="/client.dropup.js"></script>
+ <script>
+
+ Modernizr.addTest('filereader', function() {
+ return typeof window.FileReader === "function";
+ });
+
+ if (Modernizr.filereader && Modernizr.draganddrop) {
+ DropUp.init();
+ } else {
+ $("#dropzone").html("<p>Sorry, your browser is not supported</p>")
+ .addClass("inactive");
+ }
+ </script>
+
+
</body>
</html>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -14,6 +14,10 @@ body {
}
header { display:block; margin:10px; position:relative; }
+
+#indexwrapper header { margin:10px 0px 0px 0px; }
+
+p { margin:0px 0px 10px 0px; }
h1 {
font-family: ChunkFiveRegular;
@@ -27,36 +31,44 @@ h1 span {
color:#DDD;
}
-
ul {
list-style-type:none;
}
-.uploading, .loaded {
- border:1px solid #666;
+.item {
padding:5px;
background:#111;
float:left;
- margin:5px;
+ margin:5px 5px 5px 0px;
+ width:200px;
+ height:155px;
position:relative;
}
-.uploading img, .loaded img {
- max-height:130px;
- max-width:200px;
+.item img {
+ vertical-align:middle;
+ max-height:100%;
+ max-width:100%;
opacity: 0.1;
}
-.uploading p, .loaded p {
+.item {
text-align:center;
}
.wrapper {
text-align:center;
- width:200px;
height: 130px;
overflow:hidden;
}
-.loading { background:#000; width: 180px; margin:0px 10px;
- position:absolute; bottom: 60px; height:5px; }
+.loading {
+ background:#000;
+ width: 180px;
+ margin:0px 10px;
+ position:absolute;
+ bottom: 90px;
+ height:5px;
+}
+
+#dropzone { background:#666; min-height:175px; padding-left:5px; }
.loaded img { opacity:1; }
.loaded .loading { display:none; }
@@ -85,10 +97,14 @@ a { text-decoration:none; color:orange; font-size:90%; }
#original { position:absolute; bottom:5px; right:10px; }
-#wrapper { padding: 0px 10px; }
+#indexwrapper { padding: 0px 10px; width:650px; margin:0px auto; }
#warnings { color:#666; font-size:80%; }
+.warning { vertical-align:middle; color: #666; }
+
+.inactive { text-align:center; }
+
.clearfix:after {clear: both;
content: '.';
display: block;
Oops, something went wrong.

0 comments on commit b89f4d1

Please sign in to comment.