ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 7143


Ignore:
Timestamp:
May 11, 2008, 8:02:23 AM (11 years ago)
Author:
ebihara
Message:

#2386:DoCoMo画像の先読みをやめた。その他グローバルに定義した変数をローカルにコピーしてから参照するなどの微細なチューニング

Location:
OpenPNE/branches/stable-2.12.x/public_html/js/pc_emoji_palet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/stable-2.12.x/public_html/js/pc_emoji_palet/pc_emoji_palet.js

    r7139 r7143  
    11
    2 useAu=false;useSb=false;selfPallet=true;palletWidth=300;palletHeight=160;PalletURL='./js/pc_emoji_palet/pc_emoji_palet.html';eNumDocomo=252;eNumAu1=518;eNumAu2=822;eNumSb=485;function createEmojiPalletDoCoMo()
     2useAu=false;useSb=false;selfPallet=true;palletWidth=300;palletHeight=160;PalletURL='./js/pc_emoji_palet/pc_emoji_palet.html';var palletList={docomo:{id:"epDocomo",emoji:[{start:1,end:252}],shortname:"i"},au:{id:"epAu",emoji:[{start:1,end:518},{start:700,end:822}],shortname:"e"},softbank:{id:"epSb",emoji:[{start:1,end:485}],shortname:"s"}};function createEmojiPalletDoCoMo()
    33{document.write('<div id="epDocomo" style="display:none;"></div>');}
    44function createEmojiPalletAu()
     
    66function createEmojiPalletSoftBank()
    77{document.write('<div id="epSb" style="display:none"></div>');}
    8 function renderEmojiPalletDoCoMo()
    9 {Element.addClassName("epDocomo","isLoadEmojiImage");for(n=1;n<=eNumDocomo;n++){emojiPallet(n,"i","epDocomo");}
    10 Element.removeClassName("epDocomo","processLoadEmojiImage");}
    11 function renderEmojiPalletAu()
    12 {Element.addClassName("epAu","isLoadEmojiImage");for(n=1;n<=eNumAu1;n++){emojiPallet(n,"e","epAu");}
    13 for(n=700;n<=eNumAu2;n++){emojiPallet(n,"e","epAu");}
    14 Element.removeClassName("epAu","processLoadEmojiImage");}
    15 function renderEmojiPalletSoftBank()
    16 {Element.addClassName("epSb","isLoadEmojiImage");for(n=1;n<=eNumSb;n++){emojiPallet(n,"s","epSb");}
    17 Element.removeClassName("epSb","processLoadEmojiImage");}
     8function renderEmojiPallet(carrier)
     9{var doc=document;var pl=palletList[carrier];var emoji_set=pl.emoji;Element.addClassName(pl.id,"isLoadEmojiImage");for(var num in emoji_set){var emoji=emoji_set[num];var emoji_end=emoji.end;for(var i=emoji.start;i<=emoji_end;i++){var src="./skin/default/img/emoji/"+pl.shortname+"/"+pl.shortname+i+".gif";var alt="["+pl.shortname+":"+i+"]";var div=doc.getElementById(pl.id);var img=doc.createElement("img");img.setAttribute("src",src);img.setAttribute("alt",alt);img.onclick=function(){putEmojiToSelf(alt)};div.appendChild(img);}}
     10Element.removeClassName(pl.id,"processLoadEmojiImage");}
    1811function output(){document.write('<div id="emoji_pallet" class="padding_ss" style="width:439px;">');if(selfPallet){document.write('絵文字入力 ');document.write('<a href="#" onclick=\'togglePallet("epDocomo"); return false;\'>DoCoMo</a>');if(useAu)document.write(' <a href="#" onclick=\'togglePallet("epAu"); return false;\'>AU</a>');if(useSb)document.write(' <a href="#" onclick=\'togglePallet("epSb"); return false;\'>SoftBank</a>');createEmojiPalletDoCoMo();if(useAu){createEmojiPalletAu();}
    1912if(useSb){createEmojiPalletSoftBank();}}else{document.write('<a href="javascript:popupPallet(PalletURL)">絵文字入力</a>');}
    2013document.write('</div>');}
    21 function emojiPallet(i,career,target){var src="./skin/default/img/emoji/"+career+"/"+career+i+".gif";var alt="["+career+":"+i+"]";var onclick="putEmojiToSelf('["+career+":"+i+"]')";if(target){var div=document.getElementById(target);var img=document.createElement("img");img.setAttribute("src",src);img.setAttribute("alt",alt);Event.observe(img,"click",function(){putEmojiToSelf("["+career+":"+i+"]");});div.appendChild(img);}else{document.write('<img src="'+src+'" alt="'+alt+'" onclick="'+onclick+'">');}}
     14function emojiPallet(i,career,target){var src="./skin/default/img/emoji/"+career+"/"+career+i+".gif";var alt="["+career+":"+i+"]";if(target){var doc=document;var div=doc.getElementById(target);var img=doc.createElement("img");img.setAttribute("src",src);img.setAttribute("alt",alt);img.onclick=function(){putEmojiToSelf(alt)};div.appendChild(img);}else{var onclick="putEmojiToSelf('["+career+":"+i+"]')";document.write('<img src="'+src+'" alt="'+alt+'" onclick="'+onclick+'">');}}
    2215function putEmojiToSelf(emoji){var body=document.getElementsByName("body");for(var i=0;i<body.length;i++){if(body[i].nodeName.toLowerCase()=='textarea'){var elm=body[i];break;}}
    2316var selection=new Selection(elm);var pos=selection.create();var head=elm.value.substring(0,pos.start);var tail=elm.value.substring(pos.end,elm.value.length);elm.value=head+emoji+tail;}
    24 function togglePallet(pallet){if($(pallet).style.display=="none"){if(!Element.hasClassName(pallet,'isLoadEmojiImage')){Element.addClassName(pallet,"processLoadEmojiImage");if(pallet=='epDocomo'){renderEmojiPalletDoCoMo();}
    25 if(pallet=='epAu'){renderEmojiPalletAu();}
    26 if(pallet=='epSb'){renderEmojiPalletSoftBank();}}
     17function togglePallet(pallet){if($(pallet).style.display=="none"){if(!Element.hasClassName(pallet,'isLoadEmojiImage')){Element.addClassName(pallet,"processLoadEmojiImage");var carrier='';if(pallet=='epDocomo'){carrier='docomo';}
     18if(pallet=='epAu'){carrier='au';}
     19if(pallet=='epSb'){carrier='softbank';}
     20renderEmojiPallet(carrier);}
    2721if(Element.hasClassName(pallet,'processLoadEmojiImage')){return togglePallet(pallet);}
    2822closeAllEmojiPallet();Element.show(pallet);}else{Element.hide(pallet);}}
    29 Event.observe(window,"load",function(){renderEmojiPalletDoCoMo();});function closeAllEmojiPallet()
     23function closeAllEmojiPallet()
    3024{if(document.getElementById("epDocomo")){Element.hide(document.getElementById("epDocomo"));}
    3125if(document.getElementById("epAu")){Element.hide(document.getElementById("epAu"));}
  • OpenPNE/branches/stable-2.12.x/public_html/js/pc_emoji_palet/pc_emoji_palet.js.src

    r7139 r7143  
    2626PalletURL = './js/pc_emoji_palet/pc_emoji_palet.html';
    2727
    28 // 絵文字番号の範囲
    29 // 本線で絵文字が追加された場合のみ変更。通常は変更の必要ありません
    30 eNumDocomo = 252;
    31 eNumAu1 = 518;
    32 eNumAu2 = 822;
    33 eNumSb = 485;
     28var palletList = {
     29    docomo : {
     30        id : "epDocomo",
     31        emoji : [ {start: 1, end: 252 } ],
     32        shortname : "i"
     33    },
     34    au : {
     35        id : "epAu",
     36        emoji : [ {start: 1, end: 518}, {start: 700, end: 822}],
     37        shortname : "e"
     38    },
     39    softbank : {
     40        id : "epSb",
     41        emoji : [ {start: 1, end: 485} ],
     42        shortname : "s"
     43    }
     44};
    3445
    3546////////
     
    5162}
    5263
    53 function renderEmojiPalletDoCoMo()
    54 {
    55     Element.addClassName("epDocomo", "isLoadEmojiImage");
    56     for (n=1; n<=eNumDocomo; n++) {
    57         emojiPallet(n, "i", "epDocomo");
    58     }
    59     Element.removeClassName("epDocomo", "processLoadEmojiImage");
    60 }
    61 
    62 function renderEmojiPalletAu()
    63 {
    64     Element.addClassName("epAu", "isLoadEmojiImage");
    65     for (n=1; n<=eNumAu1; n++) {
    66         emojiPallet(n, "e", "epAu");
    67     }
    68     for (n=700; n<=eNumAu2; n++) {
    69         emojiPallet(n, "e", "epAu");
    70     }
    71     Element.removeClassName("epAu", "processLoadEmojiImage");
    72 }
    73 
    74 function renderEmojiPalletSoftBank()
    75 {
    76     Element.addClassName("epSb", "isLoadEmojiImage");
    77     for (n=1; n<=eNumSb; n++) {
    78         emojiPallet(n, "s", "epSb");
    79     }
    80     Element.removeClassName("epSb", "processLoadEmojiImage");
     64function renderEmojiPallet(carrier)
     65{
     66    var doc = document;
     67
     68    var pl = palletList[carrier];
     69    var emoji_set = pl.emoji;
     70
     71    Element.addClassName(pl.id, "isLoadEmojiImage");
     72
     73    for (var num in emoji_set) {
     74        var emoji = emoji_set[num];
     75        var emoji_end = emoji.end;
     76        for (var i = emoji.start; i <= emoji_end; i++) {
     77            var src = "./skin/default/img/emoji/" + pl.shortname + "/" + pl.shortname + i + ".gif";
     78            var alt = "[" + pl.shortname + ":" + i + "]";
     79
     80            var div = doc.getElementById(pl.id);
     81            var img = doc.createElement("img");
     82            img.setAttribute("src", src);
     83            img.setAttribute("alt", alt);
     84            img.onclick = function () { putEmojiToSelf(alt) };
     85
     86            div.appendChild(img);
     87        }
     88    }
     89
     90    Element.removeClassName(pl.id, "processLoadEmojiImage");
    8191}
    8292
     
    115125    var src = "./skin/default/img/emoji/" + career + "/" + career + i + ".gif";
    116126    var alt = "[" + career + ":" + i + "]";
    117     var onclick = "putEmojiToSelf('[" + career + ":" + i + "]')";
    118127    if (target) {
    119         var div = document.getElementById(target);
    120         var img = document.createElement("img");
     128        var doc = document;
     129
     130        var div = doc.getElementById(target);
     131        var img = doc.createElement("img");
    121132        img.setAttribute("src", src);
    122133        img.setAttribute("alt", alt);
    123 
    124         Event.observe(img, "click", function() {
    125             putEmojiToSelf("[" + career + ":" + i + "]");
    126         });
     134        img.onclick = function () { putEmojiToSelf(alt) };
    127135
    128136        div.appendChild(img);
    129137    } else {
     138        var onclick = "putEmojiToSelf('[" + career + ":" + i + "]')";
    130139        document.write('<img src="' + src + '" alt="' + alt + '" onclick="' + onclick + '">');
    131140    }
     
    155164        if (!Element.hasClassName(pallet, 'isLoadEmojiImage')) {
    156165            Element.addClassName(pallet, "processLoadEmojiImage");
     166            var carrier = '';
    157167            if (pallet == 'epDocomo') {
    158                 renderEmojiPalletDoCoMo();
     168                carrier = 'docomo';
    159169            }
    160170            if (pallet == 'epAu') {
    161                 renderEmojiPalletAu();
     171                carrier = 'au';
    162172            }
    163173            if (pallet == 'epSb') {
    164                 renderEmojiPalletSoftBank();
     174                carrier = 'softbank';
    165175            }
     176            renderEmojiPallet(carrier);
    166177        }
    167178        if (Element.hasClassName(pallet, 'processLoadEmojiImage')) {
     
    175186}
    176187
    177 Event.observe(window, "load", function() {
    178     // 確実に表示するDoCoMo絵文字は先読みする
    179     renderEmojiPalletDoCoMo();
    180 });
    181 
    182188function closeAllEmojiPallet()
    183189{
Note: See TracChangeset for help on using the changeset viewer.