hupu_faceText

虎扑颜文字输入

  1. // ==UserScript==
  2. // @name hupu_faceText
  3. // @description 虎扑颜文字输入
  4. // @include http://bbs.hupu.com*
  5. // @author congxz6688
  6. // @version 2016.10.12.0
  7. // @require http://code.jquery.com/jquery-latest.min.js
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @grant GM_deleteValue
  11. // @grant GM_addStyle
  12. // @namespace https://greasyfork.org/scripts/164
  13. // ==/UserScript==
  14.  
  15. //初始颜文字表情
  16. const defaultFaceText = {
  17. "faceText0" : ["(>_<)", "o(>< )o", "o( ><)o", "(>д<)", "ヽ(#`Д´)ノ", "ヽ(≧Д≦)ノ", ">﹏<", "┌( ಠ_ಠ)┘"],
  18. "faceText1" : ["( ̄︿ ̄)", "(¬д¬。)", "(¬、¬)", "(;¬_¬)", "(;¬_¬)", "(;¬д¬)", "( ;´Д`)", "o( ̄ヘ ̄o#)"],
  19. "faceText2" : ["T_T", "(T_T)", "( TДT)", "(ToT)", "(T▽T)", "(T_T)", "(;へ:)", "(ノД`)・゜・。", "(´_`。)", "(´A`。)", "(´∩`。)", "(*´;ェ;`*)", "(个_个)", ",,Ծ‸Ծ,,", "〒▽〒"],
  20. "faceText3" : ["(*゚∇゚)", "(*´∀`)", "( ゚∀゚)", "o(ノ゚∀゚)ノ", "( ̄∇ ̄)", "o(*≥▽≤)ツ", "(`・ω・´)", "(。◕∀◕。)", "ノ( ◕‿‿◕ )ノ", "(๑→ܫ←)", "(@ ̄) ̄@)", "(●'‿'●)", "(✿✪‿✪。)ノ♡", "(O ^ ~ ^ O)"],
  21. "faceText4" : ["( ̄(エ) ̄)", "(^(エ)^)", "⊂(・(ェ)・)⊃", "(* ̄(エ) ̄*)", "(=^・ェ・^=)", "(=;ェ;=)", "ヽ(=^・ω・^=)丿", "<(*ΦωΦ*)>", "Uo・ェ・oU", "ヾ(●ω●)ノ", "U・♀・U", "U^ェ^U", "(´(ェ)‘)"],
  22. "faceText5" : ["(*・_・)ノ⌒ ⌒ ⌒╭*", "*★.°*:.☆( ̄▽ ̄)ノ:*.°★* 。", "╭∩╮( ̄︿ ̄)╭∩╮", "(╯`□′)╯~~╧╧", "((((*。_。)_", "⊂彡☆))д`)", "( ̄3 ̄)", "(|||゚д゚)", "( д ) ゚ ゚", "@_@", "-_-!!!", "(`ε´ )", "(→_→)", "(@[]@!!)"],
  23. "faceText6" : ["⊙﹏⊙‖∣°", "(—。—) . z Z"],
  24. "faceText7" : ["段落演示"]
  25. };
  26. const EasyInsertTextDemo = {
  27. "段落演示" : "虎扑是个好地方,我们都要爱护它。"
  28. };
  29.  
  30. //脚本双存储相互恢复
  31. if (!localStorage.userFaceText && GM_getValue("userFaceText", "") != "") {
  32. localStorage.userFaceText = GM_getValue("userFaceText");
  33. }
  34. if (GM_getValue("userFaceText", "") == "" && localStorage.userFaceText) {
  35. GM_setValue("userFaceText", localStorage.userFaceText);
  36. }
  37.  
  38. if (!localStorage.EasyInsertText && GM_getValue("EasyInsertText", "") != "") {
  39. localStorage.EasyInsertText = GM_getValue("EasyInsertText");
  40. }
  41. if (GM_getValue("EasyInsertText", "") == "" && localStorage.EasyInsertText) {
  42. GM_setValue("EasyInsertText", localStorage.EasyInsertText);
  43. }
  44.  
  45. //脚本主CSS
  46. var replyCss = "";
  47. replyCss += ".insertFacetxt,.quickInsert{background-color: #E5E5E0; padding:0px 3px; margin:2px 6px; cursor:pointer; display:inline-block;}";
  48. replyCss += "#faceTextDiv{background-color:lightGrey; width:653px;}#faceTextDiv td{padding:0px !important;}";
  49. replyCss += ".FTLeftDiv{cursor:pointer; display:inline-block; background-color:lightGrey;padding:3px 10px; width:36px;}";
  50. replyCss += ".FTRightDiv{display:inline-block; background-color:lightGrey; padding:3px 6px; width:579px;}";
  51. replyCss += ".closeFTDivbt{cursor:pointer; float:right; margin:0px -2px; width:16px; height:16px;}";
  52. replyCss += "#editorButton{cursor:pointer; padding:10px 8px 0px 8px; display:inline-block; color:#3163B6;}";
  53. replyCss += "#editorButton_lzl{margin:0 5px 3px 5px; float:right;cursor:pointer; font-size:1.2em; display:inline-block; color:#3163B6;}";
  54. replyCss += ".editFaceTxtTb{width:200px; padding:1px 1px 0 0;} .inputInTdFt{width:199px;} .FTbutton{float:right; padding:0px 10px; margin:15px 10px 0px 0px}";
  55. replyCss += "#defaultDiv{color: red; padding:0px 10px; margin:15px 0px 0px 159px}";
  56. replyCss += "#newEditDiv{border: 1px solid gray; width:612px; z-index:2000; background-color:#EEEEEE; padding:20px; position:fixed; left:200px; bottom:80px;} #newEditDiv *:not(.pageTitle),#faceTextDiv *{font-size:12px !important;}";
  57. replyCss += ".quickEditdiv{margin:1px; border: 1px solid gray; width:200px; display:inline-block;}"
  58. replyCss += ".qdisplayDiv{margin-left:3px; width:137px; display:inline-block;}.face_button{display: inline-block !important;}"
  59. replyCss += ".modifyQuichText{padding-left:3px; background-color:#D0FFD0; cursor:pointer; width:27px; display:inline-block;}"
  60. replyCss += ".deleteQuichText{padding-left:3px; background-color:#FFD0D0; cursor:pointer; width:27px; display:inline-block;}";
  61. replyCss += "#fuuuffs{width:612px;} .margin-top30{padding-top:20px;} .editSbuttom{ display:inline-block; padding:0px 10px; margin-right:9px; margin-top:10px;}"
  62. replyCss += "#titleInput{width:136px;} #lotTextArea{width:454px} #inSertThenSubmit{position:relative; top:1px;} .checkboxDiv{float:right; margin:18px 50px 0px 0px}";
  63. GM_addStyle(replyCss);
  64.  
  65. var Tds = []; //数据修改用列表
  66.  
  67.  
  68. //函数 数组字符串重排序
  69. Array.prototype.reIndex = function () {
  70. var lastStr = this.sort(function (a, b) {
  71. return a.localeCompare(b)
  72. });
  73. return lastStr;
  74. }
  75. //提取localStorage的参数
  76. function getLSJS(a) {
  77. return JSON.parse(localStorage[a] ? localStorage[a] : "{}");
  78. }
  79. //简化脚本
  80. function crE(a) {
  81. return document.createElement(a);
  82. }
  83. function getId(a) {
  84. return document.getElementById(a);
  85. }
  86. //函数 载入各名单
  87. function loadThe(ff) {
  88. function ffe(ww) {
  89. $("#tdRightDiv" + ww + ">.insertFacetxt,#tdRightDiv" + ww + ">.quickInsert").remove();
  90. var searchSave = getLSJS("userFaceText");
  91. myFri = (searchSave["faceText" + ww]) ? searchSave["faceText" + ww] : defaultFaceText["faceText" + ww];
  92. if (ww == "7") {
  93. aqq = (localStorage.EasyInsertText) ? JSON.parse(localStorage.EasyInsertText) : EasyInsertTextDemo;
  94. myFri = myFri.reIndex();
  95. }
  96. var parentDiv = $("#tdRightDiv" + ww);
  97. if (myFri.length != 0) {
  98. for (l = 0; l < myFri.length; l++) {
  99. $("<span>", {
  100. html : myFri[l],
  101. title : ((ww == "7") ? ((aqq[myFri[l]].length < 30) ? aqq[myFri[l]] : aqq[myFri[l]].substr(0, 30) + "...") : undefined),
  102. class : ((ww == "7") ? "quickInsert" : "insertFacetxt"),
  103. click : insertEdiror
  104. }).appendTo(parentDiv);
  105. }
  106. }
  107. }
  108. if (ff == "all") {
  109. for (p = 0; p < 8; p++) {
  110. ffe("" + p);
  111. }
  112. } else {
  113. ffe(ff);
  114. }
  115. }
  116. //保存数据
  117. function saveData(a, b) {
  118. if ($.isEmptyObject(a)) {
  119. localStorage.removeItem(b);
  120. GM_deleteValue(b);
  121. } else {
  122. localStorage[b] = JSON.stringify(a);
  123. GM_setValue(b, JSON.stringify(a));
  124. }
  125. }
  126. //函数 插入到编辑器
  127. function insertEdiror(e) {
  128. var whh = e.target.innerHTML;
  129. var insertKind = e.target.getAttribute("class");
  130. if (insertKind == "quickInsert") {
  131. var InsertText = ((localStorage.EasyInsertText) ? JSON.parse(localStorage.EasyInsertText) : EasyInsertTextDemo)[whh];
  132. } else {
  133. var InsertText = " " + whh + " ";
  134. }
  135. document.getElementById("atc_content").value = document.getElementById("atc_content").value.slice(0, document.getElementById("atc_content").selectionStart) + InsertText + document.getElementById("atc_content").value.slice(document.getElementById("atc_content").selectionEnd);
  136. closeFaceTxttable();
  137. }
  138. //列表创建函数
  139. function creaseTable(UrlLength) {
  140. var tablepp = crE("table");
  141. tablepp.id = "tablepp";
  142. var trs = [];
  143. for (ly = 0; ly <= Math.ceil(UrlLength / 3); ly++) {
  144. var tr = crE("tr");
  145. mmd = trs.push(tr);
  146. tablepp.appendChild(tr);
  147. }
  148. for (ls = 0; ls < trs.length * 3; ls++) {
  149. var td = crE("td");
  150. td.className = "editFaceTxtTb";
  151. td.innerHTML = "<input type='text' class='inputInTdFt' value=''>";
  152. wq = Tds.push(td);
  153. trs[Math.floor(ls / 3)].appendChild(td);
  154. }
  155. return tablepp
  156. }
  157. //函数 编辑我的自定义颜文字
  158. function promptUserFT(ev) {
  159. if (!getId("newEditDiv")) {
  160. var wK = ev.target.id.split("tdLeftDiv")[1];
  161. var ujuy = getLSJS("userFaceText");
  162. var faceText = (ujuy["faceText" + wK]) ? ujuy["faceText" + wK] : defaultFaceText["faceText" + wK];
  163.  
  164. var newEditDiv = crE("div");
  165. newEditDiv.id = "newEditDiv";
  166.  
  167. $("<div>", {
  168. class : "pageTitle",
  169. html : "可直接修改表格内容或添加新表情到表格中:"
  170. }).css({
  171. "font-size" : "16px",
  172. "margin-bottom" : "15px"
  173. }).appendTo(newEditDiv);
  174.  
  175. newTable = creaseTable(faceText.length);
  176. newEditDiv.appendChild(newTable);
  177.  
  178. var yesButton = crE("input");
  179. yesButton.type = "button";
  180. yesButton.className = "FTbutton";
  181. yesButton.value = "确定";
  182. yesButton.addEventListener("click", function () {
  183. var reGetArray = [];
  184. var hht = document.getElementsByClassName("inputInTdFt");
  185. for (hh = 0; hh < hht.length; hh++) {
  186. if (hht[hh].value != "") {
  187. ko = reGetArray.push(hht[hh].value.trim());
  188. }
  189. }
  190. if (reGetArray.length > 0) {
  191. if (reGetArray.toString() != faceText.toString()) {
  192. ujuy["faceText" + wK] = reGetArray;
  193. }
  194. } else {
  195. delete ujuy["faceText" + wK];
  196. }
  197. saveData(ujuy, "userFaceText")
  198. loadThe(wK);
  199.  
  200. $(".inputInTdFt").html("");
  201. $("#tablepp").detach();
  202. $("#newEditDiv").detach();
  203. }, false);
  204. newEditDiv.appendChild(yesButton);
  205.  
  206. var addButton = crE("input");
  207. addButton.type = "button";
  208. addButton.className = "FTbutton";
  209. addButton.value = "加行";
  210. addButton.addEventListener("click", function () {
  211. var tdNum = document.getElementsByClassName("inputInTdFt").length;
  212. var newTr = crE("tr");
  213. getId("tablepp").appendChild(newTr);
  214. for (es = 0; es < 3; es++) {
  215. var newTD = crE("td");
  216. newTD.className = "editFaceTxtTb";
  217. newTD.innerHTML = "<input type='text' class='inputInTdFt' value=''>";
  218. newTr.appendChild(newTD);
  219. }
  220. }, false);
  221. newEditDiv.appendChild(addButton);
  222.  
  223. if (ujuy["faceText" + wK]) {
  224. var addButton = crE("input");
  225. addButton.type = "button";
  226. addButton.className = "FTbutton";
  227. addButton.value = "恢复本类默认";
  228. addButton.addEventListener("click", function () {
  229. var alertMe = confirm("这一动作将删除本类表情的修改和添加,\r\n你确定要这么做吗?");
  230. if (alertMe) {
  231. delete ujuy["faceText" + wK];
  232. saveData(ujuy, "userFaceText");
  233. loadThe(wK);
  234. $(".inputInTdFt").html("");
  235. $("#tablepp").detach();
  236. $("#newEditDiv").detach();
  237. }
  238. }, false);
  239. newEditDiv.appendChild(addButton);
  240. }
  241.  
  242. document.body.appendChild(newEditDiv);
  243.  
  244. for (ss = 0; ss < faceText.length; ss++) {
  245. document.getElementsByClassName("inputInTdFt")[ss].value = faceText[ss];
  246. }
  247. }
  248. }
  249. //函数 编辑我的快速输入文字
  250. function promptEasyInsert() {
  251. if (!getId("newEditDiv")) {
  252. var newEditDiv = crE("div");
  253. newEditDiv.id = "newEditDiv";
  254. document.body.appendChild(newEditDiv);
  255.  
  256. $("<div>", {
  257. html : "段落快速输入功能的设置页",
  258. class : "pageTitle"
  259. }).css({
  260. "font-size" : "16px",
  261. "margin-bottom" : "15px"
  262. }).appendTo(newEditDiv);
  263.  
  264. var tablepp = crE("table");
  265. var tr1 = crE("tr");
  266. var td1 = crE("td");
  267. td1.setAttribute("colspan", "2");
  268. var ffdiv = crE("div");
  269. ffdiv.id = "fuuuffs";
  270. td1.appendChild(ffdiv);
  271. tr1.appendChild(td1);
  272.  
  273. var tr3 = crE("tr");
  274. var td6 = crE("td");
  275. td6.className = "margin-top30";
  276. td6.innerHTML = "这里输入段落名称:";
  277. var td7 = crE("td");
  278. td7.className = "margin-top30";
  279. td7.innerHTML = "这里输入段落内容:";
  280. tr3.appendChild(td6);
  281. tr3.appendChild(td7);
  282.  
  283. var tr2 = crE("tr");
  284. var td2 = crE("td");
  285.  
  286. var inputTit = crE("input");
  287. inputTit.type = "text";
  288. inputTit.id = "titleInput";
  289. inputTit.value = "";
  290. td2.appendChild(inputTit);
  291.  
  292. var saveButton = crE("input");
  293. saveButton.className = "editSbuttom";
  294. saveButton.type = "button";
  295. saveButton.value = "保 存";
  296. saveButton.addEventListener("click", function () {
  297. var titValue = getId("titleInput").value;
  298. var innText = getId("lotTextArea").value.replace(/\n/g, "<br>");
  299. if (innText.indexOf('<img') == -1) {
  300. //自动识别图片并加标签
  301. innText = innText.replace(/(http:\/\/(?!static\.tieba).*?)(\.jpg|\.png|\.gif)/i, '<img class="BDE_Image" src="$1$2">');
  302. //自动识别表情并加标签
  303. innText = innText.replace(/(http:\/\/static\.tieba\.baidu\.com.*?)(\.jpg|\.png|\.gif)/i, '<img src="$1$2" class="BDE_Smiley">');
  304. }
  305. if (titValue != "" && innText != "") {
  306. var userFacee = getLSJS("userFaceText");
  307. var temmm = (userFacee.faceText7) ? userFacee.faceText7 : [];
  308. if (temmm.indexOf(titValue) != -1) {
  309. var coverAlert = confirm("已经有了一个同名的段落,要覆盖吗?");
  310. if (coverAlert) {
  311. var temss = getLSJS("EasyInsertText");
  312. temss[titValue] = innText;
  313. localStorage.EasyInsertText = JSON.stringify(temss);
  314. GM_setValue("EasyInsertText", JSON.stringify(temss));
  315.  
  316. getId("titleInput").value = "";
  317. getId("lotTextArea").value = "";
  318. EditQuickLoad();
  319. }
  320. } else {
  321. sdd = temmm.push(titValue);
  322. userFacee.faceText7 = temmm;
  323. localStorage.userFaceText = JSON.stringify(userFacee);
  324. GM_setValue("userFaceText", JSON.stringify(userFacee));
  325.  
  326. var temss = getLSJS("EasyInsertText");
  327. temss[titValue] = innText;
  328. localStorage.EasyInsertText = JSON.stringify(temss);
  329. GM_setValue("EasyInsertText", JSON.stringify(temss));
  330.  
  331. getId("titleInput").value = "";
  332. getId("lotTextArea").value = "";
  333. EditQuickLoad();
  334. }
  335. } else {
  336. var message = (titValue == "") ? "段落名称" : "段落内容";
  337. alert(message + "不能为空!请填好再按保存。");
  338. }
  339. }, false);
  340. td2.appendChild(saveButton);
  341.  
  342. var clearButton = crE("input");
  343. clearButton.className = "editSbuttom";
  344. clearButton.type = "button";
  345. clearButton.value = "清 除";
  346. clearButton.addEventListener("click", function () {
  347. getId("titleInput").value = "";
  348. getId("lotTextArea").value = "";
  349. }, false);
  350. td2.appendChild(clearButton);
  351.  
  352. var td3 = crE("td");
  353. var inTextArea = crE("textarea");
  354. inTextArea.id = "lotTextArea";
  355. inTextArea.rows = "3";
  356. td3.appendChild(inTextArea);
  357.  
  358. tr2.appendChild(td2);
  359. tr2.appendChild(td3);
  360. tablepp.appendChild(tr1);
  361. tablepp.appendChild(tr3);
  362. tablepp.appendChild(tr2);
  363. newEditDiv.appendChild(tablepp);
  364.  
  365. function EditQuickLoad() {
  366. $(".quickEditdiv").remove();
  367. var ujuy = getLSJS("userFaceText");
  368. var faceText = (ujuy["faceText7"]) ? ujuy["faceText7"] : defaultFaceText["faceText7"];
  369. faceText = faceText.reIndex();
  370. for (ls = 0; ls < faceText.length; ls++) {
  371. var inlineBlock = crE("div");
  372. inlineBlock.className = "quickEditdiv";
  373.  
  374. var newspan = crE("span");
  375. newspan.innerHTML = faceText[ls];
  376. newspan.className = "qdisplayDiv";
  377. inlineBlock.appendChild(newspan);
  378.  
  379. var modifyBu = crE("span");
  380. modifyBu.className = "modifyQuichText";
  381. modifyBu.setAttribute("qval", faceText[ls]);
  382. modifyBu.title = "点击以后到下面修改";
  383. modifyBu.innerHTML = "修改";
  384. modifyBu.addEventListener("click", modifyQuickText, false);
  385. inlineBlock.appendChild(modifyBu);
  386.  
  387. var deleteBu = crE("span");
  388. deleteBu.className = "deleteQuichText";
  389. deleteBu.setAttribute("qval", faceText[ls]);
  390. deleteBu.title = "删除这一条";
  391. deleteBu.innerHTML = "删除";
  392. deleteBu.addEventListener("click", deleteQuickText, false);
  393. inlineBlock.appendChild(deleteBu);
  394.  
  395. ffdiv.appendChild(inlineBlock);
  396. }
  397. }
  398. function modifyQuickText(ee) {
  399. var yaa = ee.target.getAttribute("qval");
  400. getId("titleInput").value = yaa;
  401. getId("lotTextArea").value = ((localStorage.EasyInsertText) ? JSON.parse(localStorage.EasyInsertText) : EasyInsertTextDemo)[yaa];
  402. }
  403. function deleteQuickText(ee) {
  404. var yaa = ee.target.getAttribute("qval");
  405. var deleteAlert = confirm("删除段落: " + yaa + "\r\n\r\n你确定吗?");
  406. if (deleteAlert) {
  407. var userFace = getLSJS("userFaceText");
  408. var temm = (userFace.faceText7) ? userFace.faceText7.toString().replace("," + yaa, "").replace(yaa + ",", "").replace(yaa, "") : "";
  409. if (temm == "") {
  410. delete userFace.faceText7;
  411. } else {
  412. userFace.faceText7 = temm.split(",");
  413. }
  414. saveData(userFace, "userFaceText");
  415. var tema = getLSJS("EasyInsertText");
  416. delete tema[yaa];
  417. saveData(tema, "EasyInsertText");
  418. EditQuickLoad();
  419. }
  420. }
  421. EditQuickLoad();
  422.  
  423. //确定按钮
  424. var yesButton = crE("input");
  425. yesButton.type = "button";
  426. yesButton.className = "FTbutton";
  427. yesButton.value = "关 闭 本 页";
  428. yesButton.addEventListener("click", function () {
  429. loadThe("7");
  430. document.body.removeChild(getId("newEditDiv"));
  431. }, false);
  432. newEditDiv.appendChild(yesButton);
  433.  
  434. //福利
  435. var smallDiv = crE("div");
  436. smallDiv.className = "checkboxDiv";
  437. var inSertThenSubmit = crE("input");
  438. inSertThenSubmit.type = "checkbox";
  439. inSertThenSubmit.id = "inSertThenSubmit";
  440. inSertThenSubmit.checked = GM_getValue('inSertThenSubmit', false);
  441. inSertThenSubmit.addEventListener('click', function () {
  442. GM_setValue('inSertThenSubmit', getId("inSertThenSubmit").checked);
  443. }, true);
  444. smallDiv.appendChild(inSertThenSubmit);
  445. var smallSpan = crE("span");
  446. smallSpan.innerHTML = " 插入后自动发表";
  447. smallDiv.appendChild(smallSpan);
  448. newEditDiv.appendChild(smallDiv);
  449.  
  450. //全部恢复默认
  451. var defaultDiv = crE("input");
  452. defaultDiv.type = "button";
  453. defaultDiv.title = "除非保存的数据出现无法恢复的异常,否则最好不要用这个!";
  454. defaultDiv.id = "defaultDiv";
  455. defaultDiv.value = "删 除 所 有 段 落";
  456. defaultDiv.addEventListener('click', function () {
  457. var deleteAlert = confirm("!!!把所有保存的段落全部删除!!!\r\n\r\n数据将无法恢复!你确定吗?");
  458. if (deleteAlert) {
  459. var defaultTemp = getLSJS("userFaceText");
  460. delete defaultTemp.faceText7;
  461. saveData(defaultTemp, "userFaceText");
  462. localStorage.removeItem("EasyInsertText");
  463. GM_deleteValue("EasyInsertText");
  464. EditQuickLoad();
  465. }
  466. }, true);
  467. newEditDiv.appendChild(defaultDiv);
  468. }
  469. }
  470. //函数 绝对定位
  471. function getElementLeft(element) {
  472. var actualLeft = element.offsetLeft;
  473. var current = element.offsetParent;
  474. while (current !== null) {
  475. actualLeft += current.offsetLeft;
  476. current = current.offsetParent;
  477. }
  478. return actualLeft;
  479. }
  480. //函数 绝对定位
  481. function getElementTop(element) {
  482. var actualTop = element.offsetTop;
  483. var current = element.offsetParent;
  484. while (current !== null) {
  485. actualTop += current.offsetTop;
  486. current = current.offsetParent;
  487. }
  488. return actualTop;
  489. }
  490. //主函数 由编辑窗上方的按钮调用,展开主列表
  491. function createFaceTexttable(ete) {
  492. if ($("#faceTextDiv").length == 0) {
  493. var ortt = ete.target;
  494. var getTop = getElementTop(ortt) - 100;
  495. //定位主列表位置
  496. var faceTextDiv = $("<div>", {
  497. id : "faceTextDiv"
  498. }).css({
  499. "position" : "absolute",
  500. "z-index" : "1000",
  501. "left" : getElementLeft(ortt) - 110,
  502. "top" : getTop,
  503. }).appendTo(document.body);
  504. //建表
  505. var atTable = crE("table");
  506. atTable.setAttribute("border", "1");
  507. atTable.setAttribute("bordercolor", "#B8B3FF");
  508. atTable.setAttribute("cellpadding", "1");
  509. getId("faceTextDiv").appendChild(atTable);
  510. //TR
  511. var tdLeftName = ["愤怒啊", "不高兴", "哭、苦", "欢喜悦", "狗熊猫", "其它类", "自定义", "快输入"]
  512. for (lk = 0; lk < 8; lk++) {
  513. var creaFttr = crE("tr");
  514.  
  515. var tdLeft = crE("td");
  516. var tdLeftDiv = crE("div");
  517. tdLeftDiv.className = "FTLeftDiv";
  518. tdLeftDiv.id = "tdLeftDiv" + lk;
  519. tdLeftDiv.innerHTML = tdLeftName[lk];
  520. tdLeftDiv.title = "点击可编辑";
  521. if (lk == 7) {
  522. tdLeftDiv.addEventListener("click", promptEasyInsert, false);
  523. } else {
  524. tdLeftDiv.addEventListener("click", promptUserFT, false);
  525. }
  526. tdLeft.appendChild(tdLeftDiv);
  527.  
  528. var tdRight = crE("td");
  529. var tdRightDiv = crE("div");
  530. tdRightDiv.className = "FTRightDiv";
  531. tdRightDiv.id = "tdRightDiv" + lk;
  532. tdRight.appendChild(tdRightDiv);
  533.  
  534. creaFttr.appendChild(tdLeft);
  535. creaFttr.appendChild(tdRight);
  536. atTable.appendChild(creaFttr);
  537. }
  538.  
  539. //关闭按钮
  540. var closeFTDivbt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA8UlEQVR42pWSMQrCQBBFcwPvI3gNKwtvYGVhaStqJYiFjY0IFmIrWEXRFIISiIqohYUYFcTC1gc/BFkSEmGyzMz/f3ZmNlaxMSvU7JQG2eJzdvdEW3j++vgstZ1AsNz6OgHkG6EpCFPe5S2qjHBzfgGZAuLV4TGw952Rg6MMVEKSZEyB7V6BW8NlJlcu1ccUPt0+1e6UkBMIgtkSKUi9iStSsz/H4SQJFD00ALXRZPMV2FxISDJ2S2qMpiVggFhB2BJsjaEB0ES3FO4k7dAqQHmm/F0rISMBRWxJjFQPF8IC9DsYoV42EOAlGtdyWyD4y76WWDtXsJol3gAAAABJRU5ErkJggg==";
  541. $("<span>", {
  542. class : "closeFTDivbt",
  543. click : closeFaceTxttable,
  544. html : "<img src='" + closeFTDivbt + "' alt='X' />"
  545. }).appendTo("#tdRightDiv0");
  546.  
  547. //载入各种颜文字到列表中
  548. loadThe("all");
  549. }
  550. }
  551. //关闭输入窗列表
  552. function closeFaceTxttable() {
  553. $(".insertFacetxt").detach();
  554. $(".FTRightDiv").detach();
  555. $(".FTLeftDiv").detach();
  556. $("#faceTextDiv").detach();
  557. }
  558.  
  559. //主编辑器添加按钮
  560. $("<span>", {
  561. id : "faceTextButtonEasy",
  562. html : "('ェ ' )",
  563. title : "颜文字",
  564. style : "cursor:pointer",
  565. click : createFaceTexttable
  566. }).css({
  567. "background-color" : "white",
  568. "padding" : "1px 3px 2px 3px",
  569. "border" : "1px solid #DDDDDD",
  570. "position" : "relative",
  571. "top" : "1px",
  572. "margin" : "0px 0px 0px 6px"
  573. }).insertAfter($('#j_face'));