2

I am storing the data to the Firebase when the user starts typing in the ACE editor with the help of firepad.

The data is stored in the Firebase like an Array. Each character in array index.

I just typed "Hi Its" then "Hi Its Nithi" then inserted "Hi Its Me Nithi"

It's really hard to read the data with key, value, array, index with -ve value.

Is there any plugin to convert handle the index?

Data:

B11
o
    0: 7 
    1: -1
B12
o
    0: 7
    1: "N"
B13
o
    0: 8
    1: "ithi" 
B14
o
    0: 7
    1: "M"
    2: 5
B15
o
    0: 8 
    1: "e"
    2: 5

Am really tired by constructing a code like :

Which grow and getting more complex.

codeTimeFirebaseRef.on('value', function(snapshot) {
        var data = snapshot.val();
        var i = 1;
        var jsonData = {};
        var jsonDataArray = {};
        async.forEach(Object.keys(data), function(key) {
          var code = data[key];
          if (code.o.length === 1) {
            if (jsonDataArray.length > 1) {
              jsonData.answer = jsonDataArray;
              codes.push(jsonData);
              i++;
              jsonData = {};
              jsonDataArray = {};
            } else {
              jsonData.index = i;
              jsonData.time = code.t;
              if (typeof code.o[0] === 'string') {
                jsonDataArray = code.o[0];
              } else if (typeof code.o[0] === 'number') {
                jsonDataArray = jsonDataArray.substring(0, code.o[0]);
              }
            }
          } else {
            if (typeof code.o[1] === 'string') {
              jsonDataArray += '' + code.o[1];
            } else if (typeof code.o[1] === 'number') {
              jsonDataArray = jsonDataArray.substring(code.o[0], code.o[1]);
            }
          }

Please help to get through.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Max
  • 71
  • 9
  • Why are you re-constructing the text manually? Normally you'd just use firepad to do that (e.g. call firepad.getText()). If you're trying to read it from backend node.js code, perhaps check out the "Headless Mode" in our docs (http://www.firepad.io/docs/) – Michael Lehenbauer Nov 28 '14 at 18:17
  • 1
    @Frank Am dont have clear idea about Firepad.. getText() will get form firebase or we need some editor with firepad to get data.. Actually i need all the history.. I tried with Headless Its returning empty string... Cant we just directly get data from Firebase or using Firepad? Please help with some specific example... var ref = new Firebase(fireBaseURL).push(); var headless = new Firepad.Headless(ref) headless.getText(function(text) { console.log(text); }); O/p: (an empty string) – Max Nov 29 '14 at 11:03
  • Just to refer the data Its just:"OK! test Me Now." Is there any way to retrieve as final sentence. { "A0":{ "o":["O"], }, "A1":{ "o":[1,"K"], }, "A2":{ "o":[2,""], }, "A3":{ "o":[3,"te"], }, "A4":{ "o":[5,"s"], }, "A5":{ "o":[6,"t"], }, "A6":{ "o":[7,""], }, "A7":{ "o":[8,"M"], }, "A8":{ "o":[9,"e"], }, "A9":{ "o":[2,"!",8], }, "AA":{ "o":[11,""], }, "AB":{ "o":[12,"N"], }, "AC":{ "o":[13,"o"], }, "AD":{ "o":[14,"w"], }, "AE":{ "o":[15,"?"], }, "AF":{ "o":[15,-1], }, "AG":{ "o":[15,"."], } } – Max Nov 29 '14 at 11:24
  • Hi all, Its really urgent for me.. what is the mistake am doing here... It there firepad or firebase have any way to achieve this in any latest version.. Here my : "https://sweltering-fire-469.firebaseio.com/code/5476d36b57250f0e1f1464f9/history" Anybody have solution ? Please..... – Max Nov 30 '14 at 11:51
  • @Michael Lehenbauer Thanks what you suggested works! some minor issue on my side. – Max Nov 30 '14 at 12:02
  • @user2481086 : did u find any way to retrieve final sentence as per your request on Nov29 '14 – Shruts_me Mar 29 '15 at 02:19
  • @MichaelLehenbauer I am trying to do code replay. Need to know the sentence at any point in history. fired.getText() gives just current value. I am writing a functionality, where i can get text any point in the history.Can you give any input? – Shruts_me Mar 29 '15 at 02:23
  • Could you solve this problem? – fabiocerqueira Jul 21 '16 at 23:03

0 Answers0