Skip to content

Commit

Permalink
dosyaya çoklu yazabilme gerçekleştirildi ve tasarımda değişiklikler y…
Browse files Browse the repository at this point in the history
…apıldı related #3
  • Loading branch information
aylincsknpnr committed Mar 1, 2015
1 parent df277db commit 7fceb44
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 63 deletions.
44 changes: 44 additions & 0 deletions tripwire/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

#h3{
background: #ffff
}
#head{
background: #ffff
}
body {

background-color:#7F0E0E;
}

label {
display:block;
position:static;
padding:0 10px;
font-size:18px;
line-height:30px;
text-decoration:none;
background-color:#FB6423;
color:white;
border-radius:15px 50px 50px 15px;
-webkit-border-radius:0px 5px 5px 0px;
-moz-border-radius:0px 5px 5px 0px;

}

}
label span {

width: 10px;
height: 10px;
background: #ddd;
margin-right: 3px;
}
label.checked {
color: green;
}
label.checked span {
background: green;
}
div{
background-color:#ffff;
}
130 changes: 72 additions & 58 deletions tripwire/app.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,84 @@
function listContents(storagename) {

//Clear up the list first
$('#results').html("");
var files = navigator.getDeviceStorage(storagename);

var cursor = files.enumerate();

cursor.onsuccess = function () {
//alert("Got something");
var file = this.result;
if (file != null) {
$("<p><input type='checkbox' class='sec' name='file[]' value='" + file.name + "'/>" + file.name + "</p>").appendTo('#results');
this.done = false;
}
else {
$('<p><input type="button" class="btn btn-primary" value="Kaydet" /></p>').appendTo('#results');
this.done = true;
}

if (!this.done) {
this.continue();
}
}
//storage file list
function listContents(storagename) {
console.log("app lunch");
//Clear up the list first
$('#results').html("");
var files = navigator.getDeviceStorage(storagename);
var cursor = files.enumerate();
cursor.onsuccess = function () {
var file = this.result;
if (file != null) {
//file name add checkbox
$("<label><p><input type='checkbox' class='sec' name='file[]' value='" + file.name + "'/>" + file.name + "</p></label>").appendTo('#results');
this.done = false;
}
else {
//save button
$('<p><input type="button" class="btn btn-primary" value="Kaydet" /></p>').appendTo('#results');
this.done = true;
}
if (!this.done) {
this.continue();
}
}
}

$('input.btn').live('click', function() {
$('input.sec:checked').each(function() {
// alert($(this).val())
$('#results').html("start")
var sdcard = navigator.getDeviceStorage("sdcard");
var file = new Blob([$(this).val()], {type: "text/plain"});


var request = sdcard.addNamed(file, d.yyyymmdd()+".txt");

request.onsuccess = function () {
var name = this.result;
$('#results').html("yazıldı")
console.log('File "' + name + '" successfully wrote on the sdcard storage area');
}
//button click event
$('input.btn').live('click', function() {
console.log("buton click");
var fileNames = [];
$('input.sec:checked').each(function() {
alert($(this).val())
//creating files in sdcard
$('#results').html("start")
fileNames.push($(this).val());
});

var fileString = fileNames.join("\n");
var file = new Blob([fileString], {type: "text/plain"});
//files named with the time information
var sdcard = navigator.getDeviceStorage("sdcard");
var request = sdcard.addNamed(file, d.yyyymmdd()+".txt");
//var request = sdcard.addNamed(file, "2015.02.25-23.41.03.txt");
//is printed on the selected files in the file
request.onsuccess = function () {
// for(i=0;i<$('input.sec:checked').length;i++){
// var temp = new Array();
//temp = $(this).split(' ');
var name = $(this).result;
// var name2=name.toString();
//var name=$('input.sec:checked').val()
//.toString();
$('#results').html("yazıldı");
console.log('File "' + name + '" successfully wrote on the sdcard storage area');
//alert(name);
}

// An error typically occur if a file with the same name already exist
request.onerror = function () {
$('#results').html("hata")
console.warn('Unable to write the file: ' + this.error);
}

// An error typically occur if a file with the same name already exist
request.onerror = function () {
$('#results').html("hata")
console.warn('Unable to write the file: ' + this.error);
}

});

$('#results').html("text")
$('#results').html("text")
});

//listed files stored on sdcard
$(document).ready(function(){
listContents("sdcard");

listContents("sdcard");
});

//Retrieving current date time information
Date.prototype.yyyymmdd = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
var h = this.getHours().toString();
var m = this.getMinutes().toString();
var s = this.getSeconds().toString();
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
var h = this.getHours().toString();
var m = this.getMinutes().toString();
var s = this.getSeconds().toString();

return yyyy + "." + (mm[1]?mm:"0"+mm[0]) + "." + (dd[1]?dd:"0"+dd[0]) + "-" + (h[1]?h:"0"+h[0]) +"." + (m[1]?m:"0"+m[0]) +"." + (s[1]?s:"0"+s[0]); // padding
return yyyy + "." + (mm[1]?mm:"0"+mm[0]) + "." + (dd[1]?dd:"0"+dd[0]) + "-" + (h[1]?h:"0"+h[0]) +"." + (m[1]?m:"0"+m[0]) +"." + (s[1]?s:"0"+s[0]); // padding
};

d = new Date();
alert( d.yyyymmdd() );
alert( d.yyyymmdd() );
34 changes: 29 additions & 5 deletions tripwire/index.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<!DOCTYPE html>
<html>

<head>
<head class="head">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=0">
<title>Notes</title>
<link rel="stylesheet" href="jquery.mobile-1.3.1.min.css" />
<link rel="stylesheet" href="app.css" />
<script src="jquery-1.7.1.min.js"></script>
<script src="jquery.mobile-1.3.1.min.js"></script>
<script src="app.js"></script>
<script src="app2.js"></script>
</head>

<body>


<div data-role="page" id="home">

<div data-role="header" data-position="fixed" id="header">
<h3>Tripwire</h3>
<div data-role="header" data-position="fixed" id="header" class="header">
<h3 class="h3">Tripwire</h3>
</div><!-- /header -->

<div data-role="content">
Expand All @@ -30,8 +32,30 @@ <h3>Tripwire</h3>
<div style="text-align: center;"><span style="color: rgb(0, 0, 0);">

<div id="clock" style="text-align: center;">&nbsp;</div>


<style type="text/css">
.h3{
background-color:#ed8223;
}
.head{
background-color:#ed8223;
}
.btn {
background-color:#FB6423;
color:#fff;
font-family:'Helvetica Neue';
font-size:20px;
line-height:50px;
border-radius:30px;
-webkit-border-radius:20px;
-moz-border-radius:20px;
border:0;
text-shadow:#C17C3A 0 -1px 0;
width:300px;
height:50px
}
</style>

</style>


</div><!-- /page home -->
Expand Down

0 comments on commit 7fceb44

Please sign in to comment.