-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dosyaya çoklu yazabilme gerçekleştirildi ve tasarımda değişiklikler y…
…apıldı related #3
- Loading branch information
1 parent
df277db
commit 7fceb44
Showing
3 changed files
with
145 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters