0

这就是我将数据存储到 html5 本地存储中的方式。新要求正在从本地存储更改为 Google 文档。那么我该怎么做呢?我真的不知道。

//function to store the feedback to the database
function saveFeedback() {
     function saveFeedback() {
      var smiley_id, word_ids, word_texts;
      if (chosen_item === null) {
        chosen_item = 'debug';
        chosen_smiley = undefined;
      }
      if ((chosen_item !== null) && (chosen_smiley !== null)) {    
        word_ids = [];
        word_texts = [];
        if (chosen_smiley != undefined) {
          smiley_id = chosen_smiley.attr('class');
        }
        for (var i = chosen_words.length - 1; i >= 0; i--) {
          word_ids[i] = $('span',chosen_words[i]).attr('class').split(' ')[1];
          word_texts[i] = chosen_words_text[i];
        };
        if (stored_data.feedbacks[chosen_item] === undefined) {
          stored_data.feedbacks[chosen_item] = [];
        }    
        if (chosen_item === 'debug') {
          smiley_id = 'positive';
        }
        stored_data.feedbacks[chosen_item].push({smiley : smiley_id, word_1 : word_ids[0], word_2 : word_ids[1], word_3 : word_ids[2], word_1_text : word_texts[0], word_2_text : word_texts[1], word_3_text : word_texts[2]});
        if (chosen_item !== 'debug') {
          storeData(stored_data);   
        }
        chosen_smiley = null;
        chosen_words = [];
        chosen_words_text = [];
      }  
    }
//store the feedback data in the local database
function storeData(data) {
  console.log('storing feedback');
  localStorage.labraryFeedback = JSON.stringify(data);
}

非常感谢 !!!

4

1 回答 1

1

检查Google Drive API JavaScript 文档

于 2012-11-21T07:35:25.103 回答