Replacement of QQ emoticons and page display

Source: Internet
Author: User

During work, you need to parse and display QQ emoticons. In the following code, data and data2 correspond to Chinese and English emoticons respectively, "\" indicates escape.

VaR url = 'HTTP: // res.mail.qq.com/zh_cn/images/mo/default2 /';
VaR DATA = {
"0": "Smile", "1": "grin", "2": "color", "3": "Daze", "4": "satisfied ", "5": "Tears", "6": "Shy", "7": "shut up", "8": "Sleep", "9": "cry ", "10": "embarrassing"
, "11": "Angry", "12": "naughty", "13": "fangya", "14": "surprised", "15 ": "sad", "16": "cool", "17": "leng Han", "18": "crazy", "19": "vomit", "20 ": "sneer"
, "21": "cute", "22": "white eyes", "23": "arrogant", "24": "Hunger", "25 ": "sleepy", "26": "Frightened", "27": "sweating", "28": "Xiao", "29": "da bing", "30 ": "struggle"
, "31": "curse", "32": "Doubt", "33": "Hush... "," 34 ":" Dizzy "," 35 ":" torture "," 36 ":" aging "," 37 ":" skeleton "," 38 ": "Knock", "39": "goodbye", "40": "Wipe sweat"
, "41": "nose", "42": "applaud", "43": "nose", "44": "gib", "45 ": "Left hum", "46": "right hum", "47": "yawning", "48": "contempt", "49": "Grievance ", "50": "crying"
, "51": "sinister", "52": "kiss", "53": "scare", "54": "poor", "55 ": "Chopper", "56": "watermelon", "57": "beer", "58": "basketball", "59": "ping pong", "60 ": "coffee"
, "61": "rice", "62": "pig", "63": "Rose", "64": "Fade", "65 ": "show love", "66": "Love", "67": "Heartbroken", "68": "cake", "69": "lightning", "70 ": "bomb"
, "71": "Knife", "72": "football", "73": "Ladybug", "74": "poop", "75 ": "moon", "76": "sun", "77": "gift", "78": "hug", "79": "strong", "80 ": "weak"
, "81": "handshake", "82": "victory", "83": "hug", "84": "Seduce", "85 ": "Fist", "86": "poor", "87": "love you", "88": "no", "89": "OK", "90 ": "Love"
, "91": "Blow kiss", "92": "jump", "93": "trembling", "94": "fire", "95 ": "circle", "96": "Bow", "97": "back", "98": "jump rope", "99": "wave", "100 ": "excited"
, "101": "street dance", "102": "kiss", "103": "Left Taiji", "104": "right Taiji"
};
VaR data2 = {
"0": ": \)", "1 ":"::~ "," 2 ":": B "," 3 ":": \ | "," 4 ":": 8 \\-\\)", "5": "::\\<", "6": "::\$", "7": ": X", "8 ":":: Z "," 9 ":": '\ ("," 10 ":": \-\ |"
, "11": "::@", "12": ": P", "13": ": D", "14 ":":: O "," 15 ":": \ ("," 16 ":": \ + "," 17 ":": \-B "," 18 ":": Q "," 19 ":": T "," 20 ":":, @ P"
, "21": ":, @ \-d", "22": ": D", "23": ":, @ O", "24 ": ": G", "25": ":\|\\- \\)", "26 ":"::! "," 27 ":": l "," 28 ":" ::\\> "," 29 ":" ::, @ "," 30 ": ":, @ F"
, "31": "::\\-s", "32 ":":\\? "," 33 ":":, @ X "," 34 ":":, @ "," 35 ":": 8 "," 36 ": ":,@! "," 37 ":":!!! "," 38 ":": XX "," 39 ":": Bye "," 40 ":": Wipe"
, "41": ": Dig", "42": ": handclap", "43": ": & \-\ (", "44 ":": B \-\) "," 45 ":": <@ "," 46 ":": @> "," 47 ":":-o ", "48": ": \> \-\ |", "49": ": P \-\ (", "50 ":":: '\ |"
, "51": ": x \-\)", "52": ": \ *", "53": ": @ X ", "54": ": 8 \ *", "55": ": PD", "56": ": <W>", "57 ":": beer "," 58 ":": basketb "," 59 ":": oo "," 60 ":": coffee"
, "61": ": Eat", "62": ": pig", "63": ": Rose", "64": ": fade ", "65": ": showlove", "66": ": Heart", "67": ": Break", "68": ": Cake", "69 ": ": Li", "70": ": bome"
, "71": ": kN", "72": ": footb", "73": ": ladybug", "74": ": Shit ", "75": ": Moon", "76": ": Sun", "77": ": Gift", "78": ": hug", "79 ": ": Strong", "80": ": weak"
, "81": ": Share", "82": ": V", "83": ": @ \)", "84": ": JJ ", "85": ": @", "86": ": Bad", "87": ": lvu", "88": ": No ", "89": ": OK", "90": ": Love"
, "91": ": <L>", "92": ": Jump", "93": ": Shake", "94 ":": <o> "," 95 ":": Circle "," 96 ":": kotow "," 97 ":": Turn "," 98 ":": skip "," 99 ":": Oy "," 100 ":": # \-0"
, "101": ": hiphot", "102": ": Kiss", "103": ":\< &", "104 ":": & \\>"
};
VaR ext = '.gif ';

The code for replacing emoticon is as follows:

Function replaceemoji (STR ){

Var key, reg;
For (key in data ){
// Reg = '/' + data [Key];
Reg = new Regexp ('/' + data [Key], 'G ');
STR = Str. Replace (
Reg,
''
);
// Reg = '/' + data2 [Key];
Reg = new Regexp ('/' + data2 [Key], 'G ');
STR = Str. Replace (
Reg,
''
);

}
Return STR;
}

Then, for STR = "/: T/:, @-D/: |-)/:, @-D/: T /:,@ P/:-|/: </: |/: B/: @/: Wipe/:, @ X/: + /:? /: 8 /:!!! /:,@! /:Handclap/: &-("; string,

You can replace STR = replaceemoji (STR );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.