JavaScript - bloc de notas

 
Vista:
Imágen de perfil de miguel
Val: 49
Ha aumentado 1 puesto en JavaScript (en relación al último mes)
Gráfica de JavaScript

bloc de notas

Publicado por miguel (23 intervenciones) el 29/07/2017 13:21:49
hola, tengo ke realizar la siguiente tarea con html y javascript, pues un compañero me dijo que lo publicara en PHP si alguien hizo algo parecido:
tengo ke crear un bloc de notas y tengo poca practica, si alguien a echo algo parecido y me puede ayudar por lo menos la estructura pues tiene varios detalles:
Listar las notas creadas; de no haber ninguna, la lista aparecerá vacía.
Mostrar un botón de “añadir nueva nota” que lanzará la ventana con el formulario de inserción.
Indicar el título y el cuerpo de texto para cada nota.
Almacenar las notas en SQLite. Los campos de la tabla serán: el identificador de nota, el título,
el cuerpo del texto y la fecha de la nota.
vaya lio, a ver si alguien lo ha echo.
un saludo y gracias a todos por estar ahi.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Vainas
Val: 95
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

bloc de notas

Publicado por Vainas (258 intervenciones) el 29/07/2017 15:13:36
Buenas:

Lo que pides se puede hacer si pero es un planteamiento extenso (pero no por ello complicado).

Del lado del server hay que implementar algun CRUD (Create, Read, Update, Delete) de las notas para poder guardarlas, aqui el lenguaje que quieras.

En el lado del cliente vas a recibir las notas como algun json (titulo, body, algo_mas) y puedes mostrarlas con un boton modificar nota por ejemplo para editarla, otro para borrar, crear...etc. Y luego ya funcionalidades extras (el body de las notas van a llevar html?).

Librerias... pues te puede valer desde jQuery hasta Angular todo depende del conocimiento o si quieres hacer un poco de I+D.

Si buscas algun tutorial que te diga como crear usuarios, listar borrar etc etc... te puede valer y donde van usuarios cambias por notas y en vez de guardar correo, nombre y apellido lo cambias por titulo body y todo lo demas.

Un saludo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de miguel
Val: 49
Ha aumentado 1 puesto en JavaScript (en relación al último mes)
Gráfica de JavaScript

bloc de notas

Publicado por miguel (23 intervenciones) el 30/07/2017 13:35:40
hola, lo kiero hacer con html y javascrip, para crear la estructura. luego ya haria base de datos local.
muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de miguel
Val: 49
Ha aumentado 1 puesto en JavaScript (en relación al último mes)
Gráfica de JavaScript

bloc de notas

Publicado por miguel (23 intervenciones) el 26/08/2017 23:16:02
Hola, ya tengo practicamente el codigo del blog de notas, pero no funciona muy bien porque no le tengo bien estructurarado.
Tengo duda en mostrarle pues esta echo con Titanium, no se si habras currado con ese fraeback alguna vez.
Necesito ayuda para colocarle un poco, pues no consigodar con elllo.
Adjunto un archivo con mi codigo, va en tres partes(codigos) diferentes, relaccionados entre si.
Muchas gracias y un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de miguel
Val: 49
Ha aumentado 1 puesto en JavaScript (en relación al último mes)
Gráfica de JavaScript

bloc de notas

Publicado por miguel (23 intervenciones) el 19/10/2017 11:51:59
Aki dejo el codigo del bloc de notas realizado. Las notas se guardan en un base de datos, de la cual se pueden eliminar o modificar.
Para el formato de fechas me ayude de un modulo llamado " moment", con el que tambien me ayuda para los colores de las tableRow.
Gracias por la ayuda prestada.
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
var win=Ti.UI.createWindow();
var db=require('mydata/DataBase');
var _moment=require('ui/moment');
 
win.title='Bloc de Notas';
 
var portada=Ti.UI.createTableView({
    backgroundColor:'grey',
    width:'100%',height:'100%',
    top:0
});
 
var boton=Ti.UI.createButton({
    title:'Nueva Nota',
    left:4, bottom:10,
    width:'98%', height:38,
    borderRadius:6,
    borderWidth:2,
    borderColor:'#13E339',
    backgroundColor:'#2403F8',
    font:{fontSize:16, fontWeight:'bold'}
});
 
win.add(portada);
win.add(boton);
 
//creamos  la nota
boton.addEventListener('click', function(e){
    var self=Ti.UI.createWindow({
        title:'Nueva Nota',
        width:'100%', height:'100%',
        backgroundColor:'white'
    });
 
    var view=Ti.UI.createView({
        width:'100%', height:'100%',
        backgroundColor:'#DFECE1',
        borderRadius:6,
        borderWidth:6,
        borderColor:'#5BC606',
    });
 
    var titulo=Ti.UI.createTextField({
        hintText:'Introduce un Titulo...',
        hintTextColor:'red',
        top:16, left:12, color:'blue',
        font:{fontSize:24}
    });
 
    var txtarea=Ti.UI.createTextArea({
        width:'92%', top:65,
        bottom:50, color:'#000',
        borderColor:'blue'
    });
 
    var guarda=Ti.UI.createButton({
        title:'guardar',
        width:160, height:32, bottom:16,
        borderRadius:6,
        borderWidth:6,
        backgroundColor:'#1309EA'
    });
 
    guarda.addEventListener('click', function(e){
        var current_date = new Date();
        var modified_date= _moment(current_date).format("MMM Do YYYY, h:mm:ss a");
        var mycolor= getRandomColor();
 
        if (txtarea.value.length < 1){
            guardanotas(txtarea, self);
        }else if(titulo.value.length< 1){
            guardanotas(titulo, self);
        }else {
            var db=Ti.Database.open('cuentas');
            var res=db.execute('INSERT INTO notes(title, nota, fecha, color)VALUES (?,?,?,?)', titulo.value, txtarea.value, modified_date, mycolor);
            db.close();
            carganotas();
            self.close();
        }
    });
 
    function guardanotas(txtarea, self){
        var dialog=Ti.UI.createAlertDialog({
            message:'Introducca titulo y texto, por favor...!!!',
            ok:'OK',
            title:'Campo vacio.'
        });
        dialog.show();
    }
    view.add(titulo);
    view.add(txtarea);
    view.add(guarda);
    self.add(view);
    self.open({'modal':true});
});
 
function carganotas(){
    var db=Ti.Database.open('cuentas');
    var query='SELECT * FROM notes ORDER BY fecha DESC';
    var res=db.execute(query);
 
    var filas= [];
 
    while(res.isValidRow()){
        var id_nota=res.fieldByName('id_nota');
        var fecha_txt=res.fieldByName('fecha');
        var nota_txt= res.fieldByName('nota');
        var myTitle= res.fieldByName('title');
        var myColor= res.fieldByName('color');
 
        var publica = Ti.UI.createLabel({
            objName:'publica',
            text :  '>>>>>>>>>>>>>desliza la nota para compartir...>>>>>>>>>>>>>>>',
            top : 0,
            width : '100%',
            height : 28,
            color : '#000',
            font : {fontSize : 12, fontWeight : 'bold'  },
            touchEnabled : false
        });
        var elimina = Ti.UI.createLabel({
            objName:'elimina',
            text :  '<<<<<<<<<<<<desliza la nota para borrar<<<<<<<<<',
            textColor:'blue',
            top : 5,
            width : '90%',
            height : 28,
            color : '#000',
            font : {fontSize : 12, fontWeight : 'bold',fontColor:'blue'  },
            touchEnabled : false
        });
 
 
 
        var id_label=Ti.UI.createLabel({
            objName:'id_label',
            text:id_nota,
            top:5, color:'#000',
            width:'90%', height:18,
            font:{fontSize:16, fontWeight:'bold'},
            touchEnabled:false
        });
 
        var fecha_label=Ti.UI.createLabel({
            objName:'fecha_label',
            text:fecha_txt,
            color:'#000', top:5,
            width:'90%', height:Ti.UI.SIZE,
            font:{fontSize:18, fontWeight:'bold'}
        });
 
        var labelTitle=Ti.UI.createLabel({
            objName:'labelTitle',
            text:myTitle,
            color:'#000', top:5,
            width:'90%',
            font:{fontSize:18, fontWeight:'bold'},
            touchEnable:false
        });
 
        var nota_label=Ti.UI.createLabel({
            objName:'nota_label',
            text:nota_txt,
            color:'#333', top:5,
            width:'90%', height:28,
            font:{fontSize:18, fontWeight:'bold'},
            touchEnable:false
        });
 
        var newview=Ti.UI.createView({
            objName:'newview',
            layout:"vertical",
            width:'100%', height:200,
            touchEnabled:false
        });
       // newview.add(comparte);
        newview.add(elimina);
        newview.add(publica);
        newview.add(id_label);
        newview.add(fecha_label);
        newview.add(labelTitle);
        newview.add(nota_label);
 
        var tablas=Ti.UI.createTableViewRow({
           selectedColor:"black",
           backgroundColor: myColor,
           id_nota:id_nota,
           height:200,
           touchEnabled:false
       });
       tablas.add(newview);
       filas.push(tablas);
       res.next();
    }
    res.close();
    db.close();
    portada.setData(filas);
}
carganotas();
 
function onClickItem(e){
   // CREO UN IF POR SI TENGO BOTON DE COMPARTIR
    /*if(e.source.objName=='comparte'){
        //COMPARTE
       / alert('COMPARTE CIRUELO');
    /}else{*/
 
        //EDITAR NOTA
        console.log(e.rowData.id_nota);
 
        var db=Ti.Database.open('cuentas');
        var query='SELECT * FROM notes WHERE id_nota='+e.rowData.id_nota;
        var res=db.execute(query);
 
        while(res.isValidRow()){
            var nota_id= res.fieldByName('id_nota');
            var fecha_txt= res.fieldByName('fecha');
            var nota_txt= res.fieldByName('nota');
 
            var win_row=Ti.UI.createWindow({
                title:'Nueva Nota',
                width:'100%', height:'100%',
                backgroundColor:'white'
            });
            var view_row = Ti.UI.createView({
                width:'100%', height:'110%',
                backgroundColor:'white',
                borderWidth:6,
                borderColor:'#BFC9CA',
                borderRadius:6,
            });
 
            var txtarea= Ti.UI.createTextArea({
                color:"#000", top:65,
                width:'92%', bottom:60,
            });
 
            txtarea.addEventListener('change', function(e){
           });
           txtarea.value  = nota_txt;
 
           var actualiza = Ti.UI.createButton({
               title:'guardar',
               width:160, height:32,
               bottom:20,
               borderWidth:6,
               borderRadius:6,
               backgroundColor:'#1309EA'
           });
 
          actualiza.addEventListener('click', function(e){
              if(txtarea.value.length < 1){
                  guardanotas(txtarea, win_row);
              }else{
                  var db=Ti.Database.open('cuentas');
                  var query='UPDATE notes SET nota="' + txtarea.value+'" WHERE id_nota=' + nota_id;
                  var res= db.execute(query);
                  db.close();
                  carganotas();
                  win_row.close();
              }
          });
          win_row.add(view_row);
          view_row.add(txtarea);
          view_row.add(actualiza);
          win_row.open({modal:true});
 
          console.log(fecha_txt + " " + nota_txt);
          res.next();
      }
   // }
};
var db=Ti.Database.open('cuentas');
var filas = [];
 
portada.addEventListener("click", onClickItem);
 
//Borrar las notas deslizando
 
portada.addEventListener('swipe', function(note){
    console.log(JSON.stringify(note));
    if (note.direction==='left'){
        var dialog=Ti.UI.createAlertDialog({
        cancel:0,
        buttonNames: ['Cancel','Aceptar'],
        message:'Si Aceptas, se borrara la ultima nota...!!',
        title:'Deseas borrar...???'
        });
        dialog.addEventListener('click', function(e) {
            if (e.index == 1) {
 
                var db=Ti.Database.open('cuentas');
                //var query='DELETE FROM notes';
                var query='DELETE FROM notes WHERE id_nota='+note.row.id_nota;
                portada.deleteRow(note.index);
                db.execute(query);
                db.close();
           }
       });
       dialog.show();
    }
});
 
//funcion de compartir
portada.addEventListener('swipe', function(e){
    if (e.direction==='right'){
        var win = Ti.UI.createWindow({
            backgroundColor : 'white'
        });
 
    win.open();
    var fb = require('facebook');
    fb.initialize();
 
    // Create a Button.
    var share = Ti.UI.createButton({
        backgroundImage: "descarga.jpg",
        width:180, height:52,
        //height : Ti.UI.SIZE,
        //width : Ti.UI.SIZE,
    });
 
    //Agregar a la vista principal.
    win.add(share);
 
   var webLink ='https://paseandoporlanubedelared.blogspot.com.es/';
   //Escuchar eventos de clic
   var db=Ti.Database.open('cuentas');
   share.addEventListener('click', function(){
       fb.presentShareDialog({
           link : webLink,
           title :'title text',
           description : 'nota text',
           picture : 'http://i64.tinypic.com/miic6a.jpg',
           mode : fb.SHARE_DIALOG_MODE_AUTOMATIC
    });
 
   });
 
   fb.addEventListener('shareCompleted', function(e){
       if (e.success){
           Ti.API.info('Se ha completado la solicitud de recurso compartido.');
       } else {
           Ti.API.info('No se pudo compartir.');
       }
   });
 
    }
});
 
function getRandomColor(){
    var letters = '0123456789ABCDEF';
    var color='#';
    for(var i = 0; i < 6; i++){
        color += letters[Math.floor(Math.random() * 16)];
    }
    return color;
};
 
portada.setData(filas);
 
carganotas();
db.close();
win.open();

1
2
3
4
var db= Ti.Database.open('cuentas');
var query = ('CREATE TABLE IF NOT EXISTS notes(id_nota INTEGER PRIMARY KEY AUTOINCREMENT,title text, nota text ,fecha DATETIME DEFAULT CURRENT_TIMESTAMP, color text);');
db.execute(query);
db.close();
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

bloc de notas

Publicado por xve (2100 intervenciones) el 19/10/2017 19:57:06
Hola Miguel, entiendo que este es solo el código de javascript, no? faltara el código HTML?

Lo he puesto en una pagina html, y tal cual, no hace nada!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de miguel
Val: 49
Ha aumentado 1 puesto en JavaScript (en relación al último mes)
Gráfica de JavaScript

bloc de notas

Publicado por miguel (23 intervenciones) el 19/10/2017 21:18:26
Vale, esta creado Appcelerator, en el cual no hace falta html, solo usa XHTML, no me he dado cuenta de eso.
Si te hiciera falta me comentas, voy a ir buscando algo ke me pasaron para Cordova, kiza sea lo que tu necesitas.
Ya me dices
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar