Advertisement
riNnE_

Untitled

Mar 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.30 KB | None | 0 0
  1. $(function(){
  2. var postAction, getAction;
  3.  
  4. var formElement,
  5. pformElement,
  6. textareaElement,
  7. ptextareaElement,
  8. userProfElement,
  9. talksElement,
  10. ptalksElement,
  11. membersElement,
  12. logoutElement,
  13. buttonElement,
  14. pbuttonElement,
  15. menuElement,
  16. roomNameElement,
  17. roomLimitElement,
  18. settingPannelElement,
  19. userListElement,
  20. uploadElement,
  21. pmElement;
  22.  
  23. var lastMessage = '',
  24. lastUpdate = 0,
  25. lastPmUpdate = 0,
  26. isSubmitting = false,
  27. isSubmittingPM = false,
  28. isLoggedOut = false,
  29. isLoading = false,
  30. isShowingSettinPannel = false,
  31. isMobileMode = $.cookie("m"),
  32. cookie_noimg = $.cookie("noimg"),
  33. cookie_noanime = $.cookie("noanime"),
  34. cookie_nosound = $.cookie("nosound"),
  35. isAnimeOn = cookie_noanime == null,
  36. isSoundOn = cookie_nosound == null,
  37. isShowMember = false,
  38. isShowUpimg = false,
  39. isPrivate = false,
  40. userId,
  41. userName,
  42. userIcon,
  43. counter = 0,
  44. ispminit = false,
  45. destId = '',
  46. enableNotify = false,
  47. messageLimit = 40,
  48. updateInterval = 1700,
  49. ignoreList = [],
  50. useStorage = false;
  51.  
  52. window.onerror = function(message, url, line) {
  53. return true;
  54. }
  55.  
  56. /*
  57. var isMobile = false;
  58. if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
  59. isMobile = true;
  60. }
  61. var _touch = ('ontouchstart' in document) && isMobile ? 'touchstart' : 'click';
  62. */
  63. var _touch = 'click';
  64.  
  65. var construct = function() {
  66. var url = location.href.replace(/#/, '');
  67.  
  68. if (url.replace(/\?/, '') != url)
  69. postAction = url + "&ajax=1";
  70. else
  71. postAction = url + "?ajax=1";
  72.  
  73. getAction = duraUrl + '/ajax.php';
  74.  
  75. formElement = $("#message");
  76. pformElement = $("#pmessage");
  77. textareaElement = $("#message textarea");
  78. ptextareaElement = $("#pmessage textarea");
  79. userProfElement = $(".userprof");
  80. talksElement = $("#talks");
  81. ptalksElement = $("#pmtalks");
  82. membersElement = $("#members");
  83. logoutElement = $("input[name=logout]");
  84. buttonElement = $(".submit input[name=post]");
  85. pbuttonElement = $(".submit2 input[name=post]");
  86. menuElement = $("ul.menu");
  87. roomNameElement = $("#room_name");
  88. roomLimitElement = $("#room_limit");
  89. settingPannelElement = $("#setting_pannel");
  90. settingPannelElement2 = $("#setting_pannel2");
  91. userListElement = $("#user_list");
  92. userListElement2 = $("#user_list2");
  93. uploadElement = $("#upimg");
  94. pmElement = $("#pmes");
  95.  
  96. userId = trim($("#user_id").text());
  97. userName = trim($("#user_name").text());
  98. userIcon = trim($("#user_icon").text());
  99.  
  100. messageMaxLength = 140;
  101.  
  102. if ( typeof(GlobalMessageMaxLength) != 'undefined' )
  103. messageMaxLength = GlobalMessageMaxLength;
  104.  
  105. useStorage = supportStorage();
  106. if(useStorage) {
  107. var txt = localStorage.getItem("ignore");
  108. if (txt != null)
  109. ignoreList = txt.split(",");
  110. }
  111.  
  112. if(isSafari()) {
  113. isSoundOn = false;
  114. menuElement.find("li.sound").addClass("sound_off");
  115. menuElement.find("li.sound").removeClass("sound_on");
  116. }
  117.  
  118. appendEvents();
  119. separateMemberList();
  120. roundBaloons();
  121. showControllPanel();
  122.  
  123. var timer = setInterval(function() { getMessagesOnce(); }, updateInterval);
  124.  
  125. $.each($(".bubble"), addTail);
  126. }
  127.  
  128. var appendEvents = function() {
  129.  
  130. formElement.submit(submitMessage);
  131. textareaElement.keyup(enterToSubmit);
  132.  
  133. pformElement.submit(submitPMessage);
  134. ptextareaElement.keyup(enterToPSubmit);
  135.  
  136. $(".mobile").on(_touch, function() {
  137. if(isMobileMode)
  138. $.removeCookie("m", {path: "/" });
  139. else
  140. $.cookie('m', 'true', { expires: 9999, path: '/' });
  141.  
  142. location.href = duraUrl + "/room/";
  143. });
  144.  
  145. $("#imgswt").on(_touch, function() {
  146. if(cookie_noimg)
  147. $.removeCookie("noimg", { path: "/" });
  148. else
  149. $.cookie('noimg', 'true', { expires: 9999, path: '/' });
  150.  
  151. location.href = duraUrl + "/room/";
  152. });
  153.  
  154. logoutElement.on(_touch, logout);
  155. talksElement.on(_touch, 'dt', addUserNameToTextarea);
  156. menuElement.find("li.sound").on(_touch, toggleSound);
  157. menuElement.find("li.member").on(_touch, toggleMember);
  158. menuElement.find("li.animation").on(_touch, toggleAnimation);
  159. menuElement.find("li.setting").on(_touch, toggleSettingPannel);
  160. menuElement.find("li.upimg").on(_touch, toggleUpimg);
  161. settingPannelElement.find("input[name=save]").on(_touch, changeRoomName);
  162. settingPannelElement.find("input[name=save2]").on(_touch, changeRoomLimit);
  163. settingPannelElement.find("input[name=save3]").on(_touch, changeKnock);
  164. settingPannelElement.find("input[name=handover]").on(_touch, handoverHost);
  165. settingPannelElement.find("input[name=ban]").on(_touch, banUser);
  166. settingPannelElement.find("input[name=block]").on(_touch, blockUser);
  167. settingPannelElement2.find("input[name=pmbtn]").on(_touch, startPrivate);
  168. settingPannelElement2.find("input[name=igbtn]").on(_touch, updateIgnore);
  169.  
  170. menuElement.find("li.private").on(_touch, function() {
  171. if( isPrivate ) {
  172. $("#pm_box").show();
  173. return;
  174. }
  175. toggleSettingPannel2();
  176. });
  177.  
  178. $("#change").on(_touch, function() {
  179. $("#pm_box").hide();
  180. });
  181.  
  182. $("#close").on(function() {
  183. destId = "";
  184. $("#pm_box").hide();
  185. $("#pmtalks .talk").remove();
  186. isPrivate = false;
  187. });
  188. }
  189.  
  190. var submitMessage = function() {
  191.  
  192. if(isLoggedOut)
  193. return false;
  194.  
  195. var message = textareaElement.val();
  196. message = message.replace(/[\r\n]+/g, "");
  197. if ( message.replace(/^[ \n]+$/, '') == '' ) {
  198. if ( message.replace(/^\n+$/, '') == '' )
  199. textareaElement.val('');
  200. return false;
  201. }
  202.  
  203.  
  204.  
  205. if ( isSubmitting )
  206. return false;
  207.  
  208. var data = formElement.serialize();
  209. if(counter == 5) {
  210. alert("エラーが発生しました");
  211. logout();
  212. }
  213.  
  214. if ( message.length - 1 > messageMaxLength ) {
  215. message = message.substring(0, messageMaxLength)+"...";
  216. }
  217.  
  218. if ( message == lastMessage && message!="/image" ) {
  219. counter += 1;
  220. if ( confirm(t("Will you stop sending the same message? If you click 'Cancel' you can send it again.")) ) {
  221. textareaElement.val('');
  222. return false;
  223. }
  224. } else {
  225. counter = 0;
  226. }
  227.  
  228. textareaElement.val('');
  229. isSubmitting = true;
  230. buttonElement.val(t("Sending..."));
  231. lastMessage = message;
  232.  
  233. writeSelfMessage(message);
  234. $.post(postAction, data,
  235. function(result) {
  236. isSubmitting = false;
  237. buttonElement.val(t("POST!"));
  238. }
  239. );
  240.  
  241. return false;
  242. }
  243.  
  244. var submitPMessage = function() {
  245. if(isLoggedOut)
  246. return false;
  247. var message = ptextareaElement.val();
  248. message = message.replace(/[\r\n]+/g, "");
  249. if ( message.replace(/^[ \n]+$/, '') == '' ) {
  250. if ( message.replace(/^\n+$/, '') == '' ) ptextareaElement.val('');
  251. return false;
  252. }
  253.  
  254.  
  255. if ( isSubmitting ) return false;
  256. var data = pformElement.serialize();
  257. ptextareaElement.val('');
  258. isSubmitting = true;
  259. pbuttonElement.val(t("Sending..."));
  260. if ( message.length - 1 > messageMaxLength ) {
  261. message = message.substring(0, messageMaxLength)+"...";
  262. }
  263. isSubmittingPM = true;
  264. writeSelfMessage(message);
  265. isSubmittingPM = false;
  266. $.post(postAction+'&id='+destId, data,
  267. function(result) {
  268. isSubmitting = false;
  269. pbuttonElement.val(t("POST!"));
  270. }
  271. );
  272. return false;
  273. }
  274.  
  275. var getMessagesOnce = function() {
  276. if (isLoading || isLoggedOut) return;
  277.  
  278. isLoading = true;
  279.  
  280. var url = isPrivate ? getAction+'?id=' + destId : getAction;
  281. $.ajax({
  282. type : "POST",
  283. url: url,
  284. dataType: 'xml',
  285. timeout: 12000,
  286. success: function(data, status, xhr) {
  287. isLoading = false;
  288. updateProccess(data);
  289. },
  290. error: function() {
  291. isLoading = false;
  292. }
  293. });
  294. }
  295.  
  296. var loadMessages = function() {
  297. $.post(getAction, {},
  298. function(data) {
  299. loadMessages();
  300. updateProccess(data);
  301. }
  302. , 'xml');
  303. }
  304.  
  305. var updateProccess = function(data) {
  306. var update = $(data).find('room > update').text() * 1;
  307. if ( lastUpdate == update || settingPannelElement.is(":visible") || settingPannelElement2.is(":visible")) return;
  308.  
  309. lastUpdate = update;
  310. validateResult(data);
  311. writeRoomName(data);
  312. writeMessages(data);
  313.  
  314. if(isPrivate) writePMessages(data);
  315. else checkPMessages(data);
  316.  
  317. writeUserList(data);
  318. markHost(data);
  319. }
  320.  
  321. var writeRoomName = function(data) {
  322. roomNameElement.text($(data).find('room > name').text()+" ("+$(data).find("users").length+"/"+$(data).find('room > limit').text()+")");
  323. }
  324.  
  325. var writeMessages = function(data) {
  326. $.each($(data).find("talks"), writeMessage);
  327. }
  328. var writePMessages = function(data) {
  329. $.each($(data).find("pm"), writePMessage);
  330. }
  331.  
  332. var checkPMessages = function(data) {
  333. $.each($(data).find("pm"), checkPMessage);
  334. enableNotify = true;
  335. }
  336.  
  337. var checkPMessage = function(data) {
  338. var uid = trim($(this).find("uid").text());
  339. var time = trim($(this).find("time").text());
  340. if(time > lastPmUpdate) {
  341. lastPmUpdate = time;
  342. if(enableNotify) {
  343. destId = uid;
  344. startPrivate();
  345. }
  346. }
  347. }
  348.  
  349. var writeMessage = function() {
  350. var id = $(this).find("id").text();
  351. if ( $("#"+id).length > 0 ) return;
  352. var uid = trim($(this).find("uid").text());
  353.  
  354. var isIgnoreMember = false;
  355. $.each(ignoreList, function(i, value) {
  356. if(uid == value) {
  357. isIgnoreMember = true;
  358. return false;
  359. }
  360. });
  361.  
  362. if(isIgnoreMember) return;
  363.  
  364. var name = trim($(this).find("name").text());
  365. var message = trim($(this).find("message").text());
  366. var icon = trim($(this).find("icon").text());
  367. var time = trim($(this).find("time").text());
  368. var image = trim($(this).find("image").text());
  369.  
  370. name = escapeHTML(name);
  371. message = escapeHTML(message);
  372. if (image != '') {
  373. var content = '<dl class="talk '+icon+'" id="'+id+'"><dt>'+name+'</dt><dd><div class="bubble"><p style="margin-left:30px;"><a href="'+ image +'" target="_blank">';
  374. if(!cookie_noimg) content += '<img src="/l.gif" />';
  375. else content += "[画像を表示する]";
  376.  
  377. content += '</a></p></div></dd></dl>';
  378. talksElement.prepend(content);
  379. ringSound(); // bluelovers
  380.  
  381. if(!cookie_noimg) {
  382. var img = new Image();
  383. img.src = image;
  384. $(img).bind("load", function() {
  385. $("#"+id+" a").html($(img));
  386. $("#"+id+" img").css({
  387. "max-width": "200px",
  388. "max-height": "200px",
  389. "width": "auto",
  390. "height": "auto"
  391. });
  392. });
  393. }
  394.  
  395. } else if ( uid == 0 || uid == '0' ) {
  396. var content = '<div class="talk system" id="'+id+'">'+message+'</div>';
  397. talksElement.prepend(content);
  398. ringSound(); // bluelovers
  399. } else if (uid != userId){
  400. var content = '<dl class="talk '+icon+'" id="'+id+'">';
  401. content += '<dt>'+name+'</dt>';
  402. content += '<dd><div class="bubble">';
  403. content += '<p class="body">' + urlize(message) + '</p>';
  404. content += '</div></dd></dl>';
  405.  
  406. talksElement.prepend(content);
  407. effectBaloon();
  408. }
  409. weepMessages();
  410. }
  411.  
  412. var writePMessage = function() {
  413. var id = $(this).find("id").text();
  414. if ( $("#"+id).length > 0 ) return;
  415. var uid = trim($(this).find("uid").text());
  416. var name = trim($(this).find("name").text());
  417. var message = trim($(this).find("message").text());
  418. var icon = trim($(this).find("icon").text());
  419. var time = trim($(this).find("time").text());
  420. var image = trim($(this).find("image").text());
  421. var dest = trim($(this).find("dest").text());
  422.  
  423. if (uid != destId && dest != destId) return;
  424. name = escapeHTML(name);
  425. message = escapeHTML(message);
  426. if ((uid != userId) || ispminit == true) {
  427. var content = '<dl class="talk '+icon+'" id="'+id+'">';
  428. content += '<dt>'+name+'</dt>';
  429. content += '<dd><div class="bubble">';
  430. content += '<p class="body">' + urlize(message) + '</p>';
  431. content += '</div></dd></dl>';
  432. ptalksElement.prepend(content);
  433. effectPBaloon();
  434. }
  435. weepPMessages();
  436. }
  437.  
  438. var writeUserList = function(data) {
  439. membersElement.find("li").remove();
  440. userListElement.find("li").remove();
  441. userListElement2.find("li").remove();
  442.  
  443. var host = $(data).find("host").text();
  444.  
  445. $.each($(data).find("users"),
  446. function() {
  447. var name = $(this).find("name").text();
  448. var id = $(this).find("id").text();
  449. var icon = $(this).find("icon").text();
  450. var trip = $(this).find("trip").text();
  451. var hostMark = "";
  452. icon = "icon_" + icon;
  453. if ( host == id ) hostMark = " "+t("(host)");
  454.  
  455. if(trip != "") trip = '<span style="color:#009900;font-weight:bold">◆' + trip + '</span>';
  456.  
  457. membersElement.append('<li>' + name + trip + hostMark + '</li>');
  458.  
  459. if(userId != id){
  460. var userNameElm = $('<li/>').text(name).appendTo(userListElement2);
  461. $.each(ignoreList, function(i, value) {
  462. if( id == value ) {
  463. userNameElm.append('<span class="ignore">(無視)</span>');
  464. return false;
  465. }
  466. });
  467. userNameElm.css({
  468. 'background':'transparent url("'+duraUrl+'/css/'+icon+'.png") center top no-repeat'
  469. }).attr('name', id).click(
  470. function() {
  471. if ( $(this).hasClass('select') ) {
  472. $(this).removeClass('select');
  473. settingPannelElement2.find("input[type=button]").prop('disabled', true);
  474. } else {
  475. userListElement2.find("li").removeClass('select');
  476. $(this).addClass('select');
  477. settingPannelElement2.find("input[type=button]").prop('disabled', false);
  478. }
  479. }
  480. );
  481. }
  482.  
  483. if ( host == id ) return;
  484.  
  485. userListElement.append('<li>'+name+'</li>');
  486. userListElement.find("li:last").css({
  487. 'background':'transparent url("'+duraUrl+'/css/'+icon+'.png") center top no-repeat'
  488. }).attr('name', id).click(
  489. function() {
  490. if ( $(this).hasClass('select') ) {
  491. $(this).removeClass('select');
  492. settingPannelElement.find("input[name=handover], input[name=ban], input[name=block]").prop('disabled', true);
  493. } else {
  494. userListElement.find("li").removeClass('select');
  495. $(this).addClass('select');
  496. settingPannelElement.find("input[name=handover], input[name=ban], input[name=block]").prop('disabled', false);
  497. }
  498. }
  499. );
  500. }
  501. );
  502.  
  503. separateMemberList();
  504. }
  505.  
  506. var writeSelfMessage = function(message) {
  507. var name = escapeHTML(userName);
  508. var message = escapeHTML(message);
  509.  
  510. if (message == '/image'){
  511. location.reload();
  512. } else {
  513. var content = '<dl class="talk '+userIcon+'" id="'+userId+'">';
  514. content += '<dt>'+name+'</dt>';
  515. content += '<dd><div class="bubble">';
  516. content += '<p class="body">' + urlize(message) + '</p>';
  517. content += '</div></dd></dl>';
  518.  
  519. if(!isSubmittingPM) {
  520. talksElement.prepend(content);
  521. effectBaloon();
  522. } else {
  523. ptalksElement.prepend(content);
  524. effectPBaloon();
  525. }
  526.  
  527. weepMessages();
  528. }
  529. }
  530.  
  531. var validateResult = function(data) {
  532. var error = $(data).find("error").text() * 1;
  533.  
  534. if ( error == 0 || isLoggedOut ) {
  535. return;
  536. }
  537. else if ( error == 1 ) {
  538. isLoggedOut = true;
  539. alert(t("Session time out."));
  540. }
  541. else if ( error == 2 ) {
  542. isLoggedOut = true;
  543. }
  544. else if ( error == 3 ) {
  545. isLoggedOut = true;
  546. alert(t("Login error."));
  547. }
  548.  
  549. location.href = duraUrl;
  550. }
  551.  
  552. var effectBaloon = function() {
  553. var thisBobble = $(".bubble .body").first();
  554. var thisBobblePrent = thisBobble.parent();
  555. var oldWidth = thisBobble.width() + 1 + 'px';
  556. var oldHeight = thisBobble.height() + 'px';
  557. var newWidth = ( 5 + thisBobble.width() ) + 'px';
  558. var newHeight = ( 5 + thisBobble.height() ) + 'px';
  559.  
  560. ringSound();
  561.  
  562. if ( !isAnimeOn ) {
  563. $.each(thisBobblePrent, addTail);
  564. $.each(thisBobble, roundBaloon);
  565. return;
  566. }
  567.  
  568. if ( !isIE() ) {
  569. $.each(thisBobblePrent, addTail);
  570.  
  571. thisBobblePrent.css({
  572. 'opacity' : '0',
  573. 'width': '0px',
  574. 'height': '0px'
  575. });
  576. thisBobblePrent.animate({
  577. 'opacity' : 1,
  578. 'width': '22px',
  579. 'height': '16px'
  580. }, 200, "easeInQuart");
  581. }
  582.  
  583. thisBobble.css({
  584. 'border-width' : '0px',
  585. 'font-size' : '0px',
  586. 'text-indent' : '-100000px',
  587. 'opacity' : '0',
  588. 'width': '0px',
  589. 'height': '0px'
  590. });
  591.  
  592. thisBobble.animate({
  593. 'fontSize': "16px",
  594. 'borderWidth': "4px",
  595. 'width': newWidth,
  596. 'height': newHeight,
  597. 'opacity': 1,
  598. 'textIndent': 0
  599. }, 200, "easeInQuart",
  600. function() {
  601. $.each(thisBobble, roundBaloon);
  602.  
  603. if ( isIE() )
  604. {
  605. thisBobblePrent.animate({
  606. 'width': thisBobblePrent.width() - 5 + "px"
  607. }, 100);
  608. }
  609.  
  610. thisBobble.animate({
  611. 'width': oldWidth,
  612. 'height': oldHeight
  613. }, 100);
  614. }
  615. );
  616. }
  617.  
  618. var effectPBaloon = function() {
  619. var thisBobble = $("#pmtalks .bubble .body").first();
  620. var thisBobblePrent = thisBobble.parent();
  621. $.each(thisBobblePrent, addPTail);
  622. }
  623.  
  624. var ringSound = function() {
  625. if ( !isSoundOn ) {
  626. return;
  627. }
  628.  
  629. try {
  630. messageSound.play();
  631. }
  632. catch(e) {
  633.  
  634. }
  635. }
  636.  
  637. var escapeHTML = function(ch) {
  638. ch = ch.replace(/&/g,"&amp;");
  639. ch = ch.replace(/"/g,"&quot;");
  640. ch = ch.replace(/'/g,"&#039;");
  641. ch = ch.replace(/</g,"&lt;");
  642. ch = ch.replace(/>/g,"&gt;");
  643. return ch;
  644. }
  645.  
  646. var urlize = function(text) {
  647. return text.replace(/((http:|https:)\/\/[\x21-\x26\x28-\x7e]+)/gi, "<a href='/jump.php?url=$1' target='_blank'>$1</a>");
  648. }
  649.  
  650. var containEmail = function(text) {
  651. var re = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
  652. return re.test(text);
  653. }
  654.  
  655. var enterToSubmit = function(e) {
  656. var content = textareaElement.val();
  657. if ( content != content.replace(/[\r\n]+/g, "") )
  658. {
  659. formElement.submit();
  660. return false;
  661. }
  662. }
  663.  
  664. var enterToPSubmit = function(e) {
  665. var content = ptextareaElement.val();
  666. if ( content != content.replace(/[\r\n]+/g, "") ) {
  667. pformElement.submit();
  668. return false;
  669. }
  670. }
  671.  
  672. var logout = function() {
  673. isLoggedOut = true;
  674. if(useStorage) {
  675. localStorage.removeItem("ignore");
  676. }
  677.  
  678. $.post(postAction, {'logout':'logout'},
  679. function(result) {
  680. location.href = duraUrl;
  681. }
  682. );
  683. }
  684.  
  685. var weepMessages = function() {
  686. if ( $("#talks .talk").length > messageLimit ) {
  687. while ( $("#talks .talk").length > messageLimit ) {
  688. $("#talks .talk").last().remove();
  689. }
  690. }
  691. }
  692. var weepPMessages = function() {
  693. if ( $("#pmtalks .talk").length > messageLimit ) {
  694. while ( $("#pmtalks .talk").length > messageLimit ) {
  695. $("#pmtalks .talk").last().remove();
  696. }
  697. }
  698. }
  699.  
  700. var separateMemberList = function() {
  701. membersElement.find('li:not(:last)').each(
  702. function() {
  703. $(this).append(', ');
  704. }
  705. );
  706. }
  707.  
  708. var addUserNameToTextarea = function() {
  709. var name = $(this).text();
  710. var text = textareaElement.val();
  711. textareaElement.focus();
  712.  
  713. if ( text.length > 0 ) {
  714. textareaElement.val(text + ' @' + name);
  715. } else {
  716. textareaElement.val(text + '@' + name + ' ');
  717. }
  718. }
  719.  
  720. var trim = function(text) {
  721. return text.replace(/^\s+|\s+$/g, '');
  722. }
  723.  
  724. var roundBaloons = function() {
  725. $("#talks dl.talk dd div.bubble p.body").each(roundBaloon);
  726. }
  727.  
  728. var roundBaloon = function() {
  729. // IE 7 only... orz
  730. if ( !isIE() || !window.XMLHttpRequest || document.querySelectorAll)
  731. return;
  732.  
  733. var width = $(this).width();
  734. var borderWidth = $(this).css('border-width');
  735. var padding = $(this).css('padding-left');
  736. var color = $(this).css('border-color');
  737. width = width + padding.replace(/px/, '') * 2;
  738.  
  739. $(this).corner("round 10px cc:"+color)
  740. .parent().css({
  741. "background" : color,
  742. "padding" : borderWidth,
  743. "width" : width
  744. }).corner("round 13px");
  745. }
  746.  
  747. var addTail = function() {
  748. if ( isIE() ) return;
  749. var height = $(this).find(".body").height() + 30 + 8;
  750. var top = (Math.round((180 - height) / 2) + 23) * -1;
  751. var bgimg = $(this).find(".body").css("background-image");
  752. var rand = Math.floor(Math.random()*2);
  753. var tailTop = "0px";
  754. if ( rand == 1 ) tailTop = "-17px";
  755. top += 1;
  756. $(this).find(".body").css({"margin": "0 0 0 15px"});
  757. $(this).prepend('<div><div></div></div>').css({"margin":"-16px 0 0 0"});
  758. $(this).children("div").css({
  759. "position":"relative",
  760. "float":"left",
  761. "margin":"0 0 0 0",
  762. "top": "39px",
  763. "left": "-3px",
  764. "width":"22px",
  765. "height":"16px",
  766. "background":"transparent "+bgimg+" left "+top+"px repeat-x"
  767. });
  768. $(this).children("div").children("div").css({
  769. "width":"100%",
  770. "height":"100%",
  771. "background":"transparent url('"+duraUrl+"/css/tail.png') left "+tailTop+" no-repeat"
  772. });
  773. }
  774.  
  775. var addPTail = function() {
  776. if ( isIE() ) return;
  777. var bgcolor = $(this).find(".body").css("border-color");
  778. $(this).find(".body").css({"margin": "-18px 0 0 15px"});
  779. $(this).prepend('<div style="width: 0;height: 0;border-style: solid;border-width: 0 0 16px 22px;border-color: transparent transparent '+bgcolor+' transparent;position: relative; float: left;top:21px;left:-3px;"><div style="width: 0;height: 0;border-style: solid;border-width:0px 0px 7px 10px;border-color: transparent transparent #fff transparent;margin-left:-9px;padding-top:5px;"></div></div>');
  780.  
  781. }
  782.  
  783. var showControllPanel = function() {
  784. if ( isIE() ) {
  785. isSoundOn = isAnimeOn = false;
  786. }
  787.  
  788. menuElement.find("li:hidden:not(.setting, .private)").show();
  789. menuElement.find("li.sound").addClass( ( isSoundOn ) ? "sound_on" : "sound_off" );
  790. menuElement.find("li.member").addClass( ( isShowMember ) ? "member_on" : "member_off" );
  791. menuElement.find("li.animation").addClass( ( isAnimeOn ) ? "animation_on" : "animation_off" );
  792. menuElement.find("li.upimg").addClass( ( isShowUpimg ) ? "upimg_on" : "upimg_off" );
  793. }
  794.  
  795. var toggleSettingPannel2 = function() {
  796. if(isMobileMode) {
  797. var height = ($('div.message_box').css('height') != '1300px') ? '1300px' : '100%';
  798. $('div.message_box').css('height', height);
  799. }
  800. settingPannelElement2.find("input[name=handover], input[name=ban], input[name=black]").attr('disabled', 'disabled');
  801. buttonElement.slideToggle();
  802. textareaElement.slideToggle();
  803. userProfElement.slideToggle();
  804. settingPannelElement2.slideToggle();
  805. }
  806.  
  807. var toggleSound = function() {
  808.  
  809. if ( isSoundOn )
  810. $.cookie('nosound', 'true', { expires: 9999, path: '/' });
  811. else
  812. if(cookie_nosound)
  813. $.removeCookie("nosound", { path: "/" });
  814.  
  815. isSoundOn = !isSoundOn;
  816. $(this).toggleClass("sound_on sound_off");
  817.  
  818. if(isSoundOn && isSafari()) {
  819. ringSound();
  820. }
  821. }
  822.  
  823. var toggleMember = function() {
  824. membersElement.slideToggle("slow");
  825. isShowMember = !isShowMember;
  826. $(this).toggleClass("member_on member_off");
  827. }
  828.  
  829. var toggleAnimation = function() {
  830.  
  831. if ( isAnimeOn )
  832. $.cookie('noanime', 'true', { expires: 9999, path: '/' });
  833. else
  834. if(cookie_noanime) $.removeCookie("noanime", { path: "/" });
  835.  
  836. isAnimeOn = !isAnimeOn;
  837. $(this).toggleClass("animation_on animation_off");
  838. }
  839.  
  840. var toggleUpimg = function() {
  841. uploadElement.slideToggle("slow");
  842. isShowUpimg = !isShowUpimg;
  843. $(this).toggleClass("upimg_on upimg_off");
  844. }
  845.  
  846. var toggleSettingPannel = function() {
  847. if(isMobileMode) {
  848. if ($('div.message_box').css('height') != '800px') $('div.message_box').css('height', '800px');
  849. else $('div.message_box').css('height', '100%');
  850. }
  851. settingPannelElement.find("input[name=handover], input[name=ban], input[name=block]").attr('disabled', 'disabled');
  852. buttonElement.slideToggle();
  853. textareaElement.slideToggle();
  854. userProfElement.slideToggle();
  855. settingPannelElement.slideToggle();
  856. }
  857.  
  858. var markHost = function(data) {
  859. menuElement.find("li.private").show();
  860. if ( $(data).find('host').text() == userId) {
  861. menuElement.find("li.setting").show();
  862. } else {
  863. menuElement.find("li.setting").hide();
  864. }
  865. }
  866.  
  867. var changeRoomName = function() {
  868. var roomName = settingPannelElement.find("input[name=room_name]").val();
  869.  
  870. $.post(postAction, {'room_name': roomName},
  871. function(result) {
  872. alert(result);
  873. toggleSettingPannel();
  874. }
  875. );
  876. }
  877. var changeRoomLimit = function() {
  878. var roomLimit = settingPannelElement.find("select[name=room_limit]").val();
  879. $.post(postAction, {'room_limit': roomLimit},
  880. function(result) {
  881. alert(result);
  882. toggleSettingPannel();
  883. }
  884. );
  885. }
  886. var changeKnock = function() {
  887. var knock = settingPannelElement.find("input[name=change_knock]:checked").val();
  888. $.post(postAction, {'change_knock': knock},
  889. function(result) {
  890. alert(result);
  891. toggleSettingPannel();
  892. }
  893. );
  894. }
  895.  
  896. var handoverHost = function() {
  897. var id = userListElement.find("li.select").attr("name");
  898.  
  899. if ( confirm(t("Are you sure to handover host rights?")) ) {
  900. $.post(postAction, {'new_host': id},
  901. function(result) {
  902. alert(result);
  903. toggleSettingPannel();
  904. }
  905. );
  906. }
  907. }
  908.  
  909. var banUser = function() {
  910. var id = userListElement.find("li.select").attr("name");
  911.  
  912. if ( confirm(t("Are you sure to ban this user?")) ) {
  913. $.post(postAction, {'ban_user': id},
  914. function(result) {
  915. alert(result);
  916. toggleSettingPannel();
  917. }
  918. );
  919. }
  920. }
  921.  
  922. var blockUser = function() {
  923. var id = userListElement.find("li.select").attr("name");
  924.  
  925. if ( confirm(t("Are you sure to ban this user?")) )
  926. {
  927. $.post(postAction, {'ban_user': id, block: 1},
  928. function(result) {
  929. alert(result);
  930. toggleSettingPannel();
  931. }
  932. );
  933. }
  934. }
  935.  
  936. var startPrivate = function() {
  937. if(destId == "") {
  938. destId = userListElement2.find("li.select").attr("name");
  939. toggleSettingPannel2();
  940. }
  941.  
  942. $("#pm_box").show();
  943. isPrivate = true;
  944. ispminit = true;
  945. isLoading = true;
  946. $.post(getAction+'?id='+destId, {},
  947. function(data) {
  948. isLoading = false;
  949. $.each($(data).find("pm"), writePMessage);
  950. ispminit = false;
  951. }
  952. , 'xml');
  953. }
  954.  
  955. var updateIgnore = function() {
  956. var id = userListElement2.find("li.select").attr("name");
  957. var isSetIgnore = false;
  958. $.each(ignoreList, function(i, value) {
  959. if(id == value) {
  960. isSetIgnore = true;
  961. if(confirm("無視リストを解除しますか?")) {
  962. ignoreList.splice(i, 1);
  963.  
  964. if( useStorage )
  965. localStorage.setItem("ignore", ignoreList.toString());
  966.  
  967. alert("無視リストを解除しました。");
  968. userListElement2.find("li.select span.ignore").remove();
  969. toggleSettingPannel2();
  970. }
  971. return false;
  972. }
  973. });
  974. if(!isSetIgnore) {
  975. if(!confirm("無視リストに加えると表の発言と内緒メッセージの両方が表示されなくなります。よろしいですか?")) return false;
  976. ignoreList.push(id);
  977.  
  978. if( useStorage )
  979. localStorage.setItem("ignore", ignoreList.toString());
  980.  
  981. alert("無視リストに追加しました。");
  982. userListElement2.find("li.select").append("<span class='ignore'> "+"(無視)</span>");
  983. toggleSettingPannel2();
  984. }
  985. }
  986.  
  987. var isIE = function() {
  988. return /*@cc_on!@*/false;
  989. }
  990.  
  991. var supportStorage = function() {
  992. var res = false;
  993. if(('localStorage' in window) && window['localStorage'] !== null) {
  994. res = true;
  995. try {
  996. window.localStorage.setItem('test', '1');
  997. } catch(e) {
  998. res = false;
  999. }
  1000. }
  1001. return res;
  1002. }
  1003.  
  1004. var isSafari = function() {
  1005. return /Safari/i.test(navigator.userAgent);
  1006. }
  1007.  
  1008. construct();
  1009. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement