var local_emotion = []; var new_emotion = []; $(function() { local_emotion = JSON.parse(localStorage.getItem("emotion")); if (local_emotion && local_emotion.length > 0) { var content = ''; $.each(local_emotion, function(index, value) { if (value) { var emotionArray = value.split("-"); if (emotionArray.length > 0) { if ($('link[href^="https:\/\/attach2\.mobile01\.com\/css\/main-set-dark.css"]').length == 1 || $('link[href^="https:\/\/attach2\.mobile01\.com\/css\/mobile-main-set-dark.css"]').length == 1) { emotionArray[0] = emotionArray[0].replace('/emotions/', '/emotions/dark/'); } content = content + ''; } } }); if (isMobile && !magEmotion) { var template = '
'+ '
'+ '
'+ '
    '+ '
  • '+ content+ '
  • '+ '
'+ '
'+ '
'+ '
'; $(".l-textEditor__textArea").after(template); } else { $("#favorite_emotion").html(content); $("#favorite_emotion_tab").trigger('click'); } } $(document).on('click', '.emotion > .l-tab__container > a', function(e) { var emotion_src = $(this).find('img').attr('src').replace('/dark', ''); new_emotion.push(emotion_src + '-' + $(this).find('img').attr('title')); }); }); function localStorageEmotion() { if (new_emotion && new_emotion.length > 0) { if (local_emotion) { var emotion = new_emotion.concat(local_emotion); } else { var emotion = new_emotion; } var emotion_uniqe = emotion.filter(function(element, index, arr){ return arr.indexOf(element) === index; }); localStorage.setItem("emotion", JSON.stringify(emotion_uniqe.slice(0,10))); } }