File size: 6,228 Bytes
1465f5c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<link rel="apple-touch-icon" type="image/png" href="https://cpwebassets.codepen.io/assets/favicon/apple-touch-icon-5ae1a0698dcc2402e9712f7d01ed509a57814f994c660df9f7a952f3060705ee.png" />
<meta name="apple-mobile-web-app-title" content="CodePen">
<link rel="shortcut icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico" />
<link rel="mask-icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/logo-pin-8f3771b1072e3c38bd662872f6b673a722f4b3ca2421637d5596661b4e2132cc.svg" color="#111" />
<title>{{ appName }}</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" type="text/javascript"></script>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<style>
/*just bg and body style*/
body{
background-color:#1e2832;
}
.container{
background-color:#1E2832;
padding-bottom:20px;
margin-top:10px;
border-radius:5px;
}
.center{
text-align:center;
}
#top{
margin-top:20px;
}
.btn-container{
background:#fff;
border-radius:5px;
padding-bottom:20px;
margin-bottom:20px;
}
.white{
color:white;
}
.imgupload{
color:#1E2832;
padding-top:40px;
font-size:7em;
}
#namefile{
color:black;
}
h4>strong{
color:#ff3f3f
}
.btn-primary{
border-color: #ff3f3f !important;
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background-color: #ff3f3f !important;
border-color: #ff3f3f !important;
}
/*these two are set to not display at start*/
.imgupload.ok{
display:none;
color:green;
}
.imgupload.stop{
display:none;
color:red;
}
/*this sets the actual file input to overlay our button*/
#fileup{
opacity: 0;
-moz-opacity: 0;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
width:200px;
cursor: pointer;
position:absolute;
left: 50%;
transform: translateX(-50%);
bottom: 40px;
height: 50px;
}
/*switch between input and not active input*/
#submitbtn{
padding:5px 50px;
display:none;
}
#fakebtn{
padding:5px 40px;
}
/*www.emilianocostanzo.com*/
#sign{
color:#1E2832;
position:fixed;
right:10px;
bottom:10px;
text-shadow:0px 0px 0px #1E2832;
transition:all.3s;
}
#sign:hover{
color:#1E2832;
text-shadow:0px 0px 5px #1E2832;
}
</style>
<script>
window.console = window.console || function(t) {};
</script>
<script>
if (document.location.search.match(/type=embed/gi)) {
window.parent.postMessage("resize", "*");
}
</script>
</head>
<body translate="no" >
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<div class="container center">
<div class="row">
<div class="col-md-12">
<h1 class="white">{{ appName }}</h1>
<p class="white">In this APP , submit is allowed only in case the user uploads a valid image file.</p>
</div>
</div>
<form name="upload" method="post" action="predict" enctype="multipart/form-data" accept-charset="utf-8">
<div class="row">
<div class="col-md-6 col-md-offset-3 center">
<div class="btn-container">
<!--the three icons: default, ok file (img), error file (not an img)-->
<h1 class="imgupload"><i class="fa fa-file-image-o"></i></h1>
<h1 class="imgupload ok"><i class="fa fa-check"></i></h1>
<h1 class="imgupload stop"><i class="fa fa-times"></i></h1>
<!--this field changes dinamically displaying the filename we are trying to upload-->
<p id="namefile">Only pics allowed! (jpg,jpeg,bmp,png)</p>
<!--our custom btn which which stays under the actual one-->
<button type="button" id="btnup" class="btn btn-primary btn-lg">Browse for your pic!</button>
<!--this is the actual file input, is set with opacity=0 beacause we wanna see our custom one-->
<input type="file" value="" name="fileup" id="fileup">
</div>
</div>
</div>
<!--additional fields-->
<div class="row">
<div class="col-md-12">
<!--the defauld disabled btn and the actual one shown only if the three fields are valid-->
<input type="submit" value="Submit!" class="btn btn-primary" id="submitbtn">
<button type="button" class="btn btn-default" disabled="disabled" id="fakebtn">Submit! <i class="fa fa-minus-circle"></i></button>
</div>
</div>
</form>
<br>
<br>
<br>
<div class="col-md-6 col-md-offset-3 center">
<div class="btn-container">
<div class="row">
<div class="col-md-12">
<h1 class="white" style="color:darkred;">{{prediction}}</h1>
<img src="{{ image }}">
</div>
</div>
</div>
</div>
<script src="https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-2c7831bb44f98c1391d6a4ffda0e1fd302503391ca806e7fcc7b9b87197aec26.js"></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script>
<script id="rendered-js" >
$('#fileup').change(function () {
//here we take the file extension and set an array of valid extensions
var res = $('#fileup').val();
var arr = res.split("\\");
var filename = arr.slice(-1)[0];
filextension = filename.split(".");
filext = "." + filextension.slice(-1)[0];
valid = [".jpg", ".png", ".jpeg", ".bmp"];
//if file is not valid we show the error icon, the red alert, and hide the submit button
if (valid.indexOf(filext.toLowerCase()) == -1) {
$(".imgupload").hide("slow");
$(".imgupload.ok").hide("slow");
$(".imgupload.stop").show("slow");
$('#namefile').css({ "color": "red", "font-weight": 700 });
$('#namefile').html("File " + filename + " is not pic!");
$("#submitbtn").hide();
$("#fakebtn").show();
} else {
//if file is valid we show the green alert and show the valid submit
$(".imgupload").hide("slow");
$(".imgupload.stop").hide("slow");
$(".imgupload.ok").show("slow");
$('#namefile').css({ "color": "green", "font-weight": 700 });
$('#namefile').html(filename);
$("#submitbtn").show();
$("#fakebtn").hide();
}
});
//# sourceURL=pen.js
</script>
</body>
</html>
|