﻿// コメントにカスタマイズ絵文字入力機能：画像設定
function getCommentEmojiList() {
    var list = new Array();
    // 画像名、画像URLの設定
    

list[list.length] = new Array('d001_1.gif', 'http://pukupe.com/docomo/d001_1.gif');
    
list[list.length] = new Array('d002_1.gif', 'http://pukupe.com/docomo/d002_1.gif');
   
list[list.length] = new Array('d003_1.gif', 'http://pukupe.com/docomo/d003_1.gif');
  
list[list.length] = new Array('d004_1.gif', 'http://pukupe.com/docomo/d004_1.gif');
    
list[list.length] = new Array('d005_1.gif', 'http://pukupe.com/docomo/d005_1.gif');
   
list[list.length] = new Array('d006_1.gif', 'http://pukupe.com/docomo/d006_1.gif');
  
list[list.length] = new Array('d007_1.gif', 'http://pukupe.com/docomo/d007_1.gif');
    
list[list.length] = new Array('d008_1.gif', 'http://pukupe.com/docomo/d008_1.gif');
   
list[list.length] = new Array('d009_1.gif', 'http://pukupe.com/docomo/d009_1.gif');
  
list[list.length] = new Array('d010_1.gif', 'http://pukupe.com/docomo/d010_1.gif');
    
list[list.length] = new Array('d011_1.gif', 'http://pukupe.com/docomo/d011_1.gif');
   
list[list.length] = new Array('d012_1.gif', 'http://pukupe.com/docomo/d012_1.gif');
  
list[list.length] = new Array('d013_1.gif', 'http://pukupe.com/docomo/d013_1.gif');
    
list[list.length] = new Array('d014_1.gif', 'http://pukupe.com/docomo/d014_1.gif');
   
list[list.length] = new Array('d015_1.gif', 'http://pukupe.com/docomo/d015_1.gif');
  
list[list.length] = new Array('d016_1.gif', 'http://pukupe.com/docomo/d016_1.gif');
    
list[list.length] = new Array('d017_1.gif', 'http://pukupe.com/docomo/d017_1.gif');
   
list[list.length] = new Array('d018_1.gif', 'http://pukupe.com/docomo/d018_1.gif');
  
list[list.length] = new Array('d019_1.gif', 'http://pukupe.com/docomo/d019_1.gif');
    
list[list.length] = new Array('d020_1.gif', 'http://pukupe.com/docomo/d020_1.gif');
   
list[list.length] = new Array('d021_1.gif', 'http://pukupe.com/docomo/d021_1.gif');
  
list[list.length] = new Array('d022_1.gif', 'http://pukupe.com/docomo/d022_1.gif');
    
list[list.length] = new Array('d023_1.gif', 'http://pukupe.com/docomo/d023_1.gif');
   
list[list.length] = new Array('d024_1.gif', 'http://pukupe.com/docomo/d024_1.gif');
  
list[list.length] = new Array('d025_1.gif', 'http://pukupe.com/docomo/d025_1.gif');
    
list[list.length] = new Array('d026_1.gif', 'http://pukupe.com/docomo/d026_1.gif');
   
list[list.length] = new Array('d027_1.gif', 'http://pukupe.com/docomo/d027_1.gif');
  
list[list.length] = new Array('d028_1.gif', 'http://pukupe.com/docomo/d028_1.gif');
    
list[list.length] = new Array('d029_1.gif', 'http://pukupe.com/docomo/d029_1.gif');
   
list[list.length] = new Array('d030_1.gif', 'http://pukupe.com/docomo/d030_1.gif');
  
list[list.length] = new Array('d069_1.gif', 'http://pukupe.com/docomo/d069_1.gif');
    
list[list.length] = new Array('d070_1.gif', 'http://pukupe.com/docomo/d070_1.gif');
   
list[list.length] = new Array('d071_1.gif', 'http://pukupe.com/docomo/d071_1.gif');
  
list[list.length] = new Array('d072_1.gif', 'http://pukupe.com/docomo/d072_1.gif');
    
list[list.length] = new Array('d073_1.gif', 'http://pukupe.com/docomo/d073_1.gif');
   
list[list.length] = new Array('d074_1.gif', 'http://pukupe.com/docomo/d074_1.gif');
  
list[list.length] = new Array('d075_1.gif', 'http://pukupe.com/docomo/d075_1.gif');
    
list[list.length] = new Array('d084_1.gif', 'http://pukupe.com/docomo/d084_1.gif');
   
list[list.length] = new Array('d085_1.gif', 'http://pukupe.com/docomo/d085_1.gif');
  
list[list.length] = new Array('d086_1.gif', 'http://pukupe.com/docomo/d086_1.gif');
    
list[list.length] = new Array('d087_1.gif', 'http://pukupe.com/docomo/d087_1.gif');
   
list[list.length] = new Array('d089_1.gif', 'http://pukupe.com/docomo/d089_1.gif');
  
list[list.length] = new Array('d090_1.gif', 'http://pukupe.com/docomo/d090_1.gif');
    
list[list.length] = new Array('d091_1.gif', 'http://pukupe.com/docomo/d091_1.gif');
   
list[list.length] = new Array('d092_1.gif', 'http://pukupe.com/docomo/d092_1.gif');
  
list[list.length] = new Array('d098_1.gif', 'http://pukupe.com/docomo/d098_1.gif');
    
list[list.length] = new Array('d100_1.gif', 'http://pukupe.com/docomo/d100_1.gif');
   
list[list.length] = new Array('d101_1.gif', 'http://pukupe.com/docomo/d101_1.gif');
  
list[list.length] = new Array('d102_1.gif', 'http://pukupe.com/docomo/d102_1.gif');
   
list[list.length] = new Array('d103_1.gif', 'http://pukupe.com/docomo/d103_1.gif');
    
list[list.length] = new Array('d104_1.gif', 'http://pukupe.com/docomo/d104_1.gif');
   
list[list.length] = new Array('d105_1.gif', 'http://pukupe.com/docomo/d105_1.gif');
  
list[list.length] = new Array('d106_1.gif', 'http://pukupe.com/docomo/d106_1.gif');
    
list[list.length] = new Array('d107_1.gif', 'http://pukupe.com/docomo/d107_1.gif');
   
list[list.length] = new Array('d108_1.gif', 'http://pukupe.com/docomo/d108_1.gif');
  
list[list.length] = new Array('d109_1.gif', 'http://pukupe.com/docomo/d109_1.gif');
    
list[list.length] = new Array('d110_1.gif', 'http://pukupe.com/docomo/d110_1.gif');
   
list[list.length] = new Array('d111_1.gif', 'http://pukupe.com/docomo/d111_1.gif');
  
list[list.length] = new Array('d112_1.gif', 'http://pukupe.com/docomo/d112_1.gif');
   
list[list.length] = new Array('d122_1.gif', 'http://pukupe.com/docomo/d122_1.gif');
   
list[list.length] = new Array('d124_1.gif', 'http://pukupe.com/docomo/d124_1.gif');
  
list[list.length] = new Array('d127_1.gif', 'http://pukupe.com/docomo/d127_1.gif');
    
list[list.length] = new Array('d128_1.gif', 'http://pukupe.com/docomo/d128_1.gif');
   
list[list.length] = new Array('d129_1.gif', 'http://pukupe.com/docomo/d129_1.gif');
  
list[list.length] = new Array('d131_1.gif', 'http://pukupe.com/docomo/d131_1.gif');
    
list[list.length] = new Array('d132_1.gif', 'http://pukupe.com/docomo/d132_1.gif');
   
list[list.length] = new Array('d133_1.gif', 'http://pukupe.com/docomo/d133_1.gif');
  
list[list.length] = new Array('d134_1.gif', 'http://pukupe.com/docomo/d134_1.gif');
    
list[list.length] = new Array('d136_1.gif', 'http://pukupe.com/docomo/d136_1.gif');
   
list[list.length] = new Array('d137_1.gif', 'http://pukupe.com/docomo/d137_1.gif');
  
list[list.length] = new Array('d138_1.gif', 'http://pukupe.com/docomo/d138_1.gif');
   
list[list.length] = new Array('d159_1.gif', 'http://pukupe.com/docomo/d159_1.gif');
   
list[list.length] = new Array('d160_1.gif', 'http://pukupe.com/docomo/d160_1.gif');
  
list[list.length] = new Array('d161_1.gif', 'http://pukupe.com/docomo/d161_1.gif');
    
list[list.length] = new Array('d162_1.gif', 'http://pukupe.com/docomo/d162_1.gif');
  
list[list.length] = new Array('d163_1.gif', 'http://pukupe.com/docomo/d163_1.gif');
    
list[list.length] = new Array('d164_1.gif', 'http://pukupe.com/docomo/d164_1.gif');
   
list[list.length] = new Array('d197_1.gif', 'http://pukupe.com/docomo/d197_1.gif');
  
list[list.length] = new Array('d198_1.gif', 'http://pukupe.com/docomo/d198_1.gif');
    
list[list.length] = new Array('d199_1.gif', 'http://pukupe.com/docomo/d199_1.gif');
   
list[list.length] = new Array('d200_1.gif', 'http://pukupe.com/docomo/d200_1.gif');
  
list[list.length] = new Array('d201_1.gif', 'http://pukupe.com/docomo/d201_1.gif');
   
list[list.length] = new Array('d202_1.gif', 'http://pukupe.com/docomo/d202_1.gif');
   
list[list.length] = new Array('d203_1.gif', 'http://pukupe.com/docomo/d203_1.gif');
  
list[list.length] = new Array('d204_1.gif', 'http://pukupe.com/docomo/d204_1.gif');
    
list[list.length] = new Array('d205_1.gif', 'http://pukupe.com/docomo/d205_1.gif');
    
list[list.length] = new Array('d206_1.gif', 'http://pukupe.com/docomo/d206_1.gif');
  
list[list.length] = new Array('d207_1.gif', 'http://pukupe.com/docomo/d207_1.gif');
    
list[list.length] = new Array('d208_1.gif', 'http://pukupe.com/docomo/d208_1.gif');
   
list[list.length] = new Array('d209_1.gif', 'http://pukupe.com/docomo/d209_1.gif');
  
list[list.length] = new Array('d210_1.gif', 'http://pukupe.com/docomo/d210_1.gif');
    
list[list.length] = new Array('d211_1.gif', 'http://pukupe.com/docomo/d211_1.gif');
   
list[list.length] = new Array('d216_1.gif', 'http://pukupe.com/docomo/d216_1.gif');
  
list[list.length] = new Array('d217_1.gif', 'http://pukupe.com/docomo/d217_1.gif');
   
list[list.length] = new Array('d227_1.gif', 'http://pukupe.com/docomo/d227_1.gif');
   
list[list.length] = new Array('d228_1.gif', 'http://pukupe.com/docomo/d228_1.gif');
  
list[list.length] = new Array('d230_1.gif', 'http://pukupe.com/docomo/d230_1.gif');
 
list[list.length] = new Array('d231_1.gif', 'http://pukupe.com/docomo/d231_1.gif');
   
list[list.length] = new Array('d232_1.gif', 'http://pukupe.com/docomo/d232_1.gif');
  
list[list.length] = new Array('d233_1.gif', 'http://pukupe.com/docomo/d233_1.gif');
    
list[list.length] = new Array('d234_1.gif', 'http://pukupe.com/docomo/d234_1.gif');
    
list[list.length] = new Array('d235_1.gif', 'http://pukupe.com/docomo/d235_1.gif');
  
list[list.length] = new Array('d236_1.gif', 'http://pukupe.com/docomo/d236_1.gif');
    
list[list.length] = new Array('d237_1.gif', 'http://pukupe.com/docomo/d237_1.gif');
   
list[list.length] = new Array('d238_1.gif', 'http://pukupe.com/docomo/d238_1.gif');
  
list[list.length] = new Array('d239_1.gif', 'http://pukupe.com/docomo/d239_1.gif');
    
list[list.length] = new Array('d240_1.gif', 'http://pukupe.com/docomo/d240_1.gif');
   
list[list.length] = new Array('d241_1.gif', 'http://pukupe.com/docomo/d241_1.gif');
  
list[list.length] = new Array('d242_1.gif', 'http://pukupe.com/docomo/d242_1.gif');
   
list[list.length] = new Array('d243_1.gif', 'http://pukupe.com/docomo/d243_1.gif');
   
list[list.length] = new Array('d244_1.gif', 'http://pukupe.com/docomo/d244_1.gif');
  
list[list.length] = new Array('d245_1.gif', 'http://pukupe.com/docomo/d245_1.gif');
     
list[list.length] = new Array('d246_1.gif', 'http://pukupe.com/docomo/d246_1.gif');
   
list[list.length] = new Array('d247_1.gif', 'http://pukupe.com/docomo/d247_1.gif');
  
list[list.length] = new Array('d248_1.gif', 'http://pukupe.com/docomo/d248_1.gif');
   
list[list.length] = new Array('d249_1.gif', 'http://pukupe.com/docomo/d249_1.gif');
   
list[list.length] = new Array('d250_1.gif', 'http://pukupe.com/docomo/d250_1.gif');
  
list[list.length] = new Array('d251_1.gif', 'http://pukupe.com/docomo/d251_1.gif');
  
list[list.length] = new Array('d252_1.gif', 'http://pukupe.com/docomo/d252_1.gif');
   

return list;
}

function getCustmizeEmojiAttribute() {
    // 画像タグに含める属性値（alt属性以外）
    var att = 'border="0" style="vertical-align:middle"';

    // ***************** 設定ここまで *****************
    att = (att != '') ? (' ' + att) : '';
    return att;
}

function writeCustmizeEmojiTagList(textarea) {

    // ***************** 設定ここまで *****************
    var list = getCommentEmojiList();
    var att = getCustmizeEmojiAttribute();
    for (var i = 0; i < list.length; i++) {
        window.document.write('<a href="javascript:;" onClick="addCustmizeEmoji(' + textarea + ', \'' + list[i][0] + '\');"><img src="' + list[i][1] + '"' + att + ' alt="' + list[i][0] + '" /></a>');
    }
}

// reference from jugem.jp (c)
function addCustmizeEmoji(obj, tag) {
    var item = '[' + tag + ']';
    if (document.selection) {
        obj.focus();
        sel = document.selection.createRange();
        sel.text = item;
    } else if (obj.selectionStart || obj.selectionStart == '0') {
        var startPos = obj.selectionStart;
        var endPos = obj.selectionEnd;
        obj.value = obj.value.substring(0, startPos) + item + obj.value.substring(endPos, obj.value.length);
    } else {
        obj.value += item;
    }
}
// コメントにカスタマイズ絵文字入力機能：画像変換
function changeCustmizeEmojiTag(commentAreaIdName, commentAreaTag, commentBodyClassName) {

    // ***************** 設定ここまで *****************
    var list = getCommentEmojiList();
    var att = getCustmizeEmojiAttribute();
    var objComArea;
    var classComArea;
    var objComBody = new Array();
    if (commentAreaIdName != '') {
        objComArea = document.getElementById(commentAreaIdName);
        if (!objComArea || !objComArea.innerHTML) return;
        classComArea = objComArea.getElementsByTagName(commentAreaTag);
    } else {
        classComArea = document.getElementsByTagName('*');
    }
    for (var i = 0; i < classComArea.length; i++) {
        if (classComArea[i].className == commentBodyClassName) objComBody[objComBody.length] = classComArea[i];
    }
    for (var i = 0; i < objComBody.length; i++) {
        objComBody[i].innerHTML = getStringCustmizeEmojiTag(list, objComBody[i].innerHTML, att);
    }
}

function getStringCustmizeEmojiTag(list, s, att) {
    for (var i = 0; i < list.length; i++) {
        s = s.split('[' + list[i][0] + ']').join('<img src="' + list[i][1] + '"' + att + ' alt="' + list[i][0] + '" class="emoji" />');
    }
    return s;
}

