Modified: openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java (original) +++ openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java Sun Feb 5 15:46:17 2017 @@ -111,13 +111,13 @@ public class ImportInitvalues { private RoomDao roomDao; @Autowired private LabelDao labelDao; - + private int progress = 0; public int getProgress() { return progress; } - + public void loadMainMenu() { /* * ######################## Dashboard Menu Points @@ -157,7 +157,7 @@ public class ImportInitvalues { navimanagement.addMainStructure("adminModuleEmail", null, 24, "main.menu.admin.email", LEVEL_ADMIN, "Administration of Emails", admin.getId(), "main.menu.admin.email.desc"); log.debug("MainMenu ADDED"); } - + public void loadErrorMappingsFromXML() throws Exception { SAXReader reader = new SAXReader(); Document document = reader.read(new File(OmFileHelper.getLanguagesDir(), OmFileHelper.nameOfErrorFile)); @@ -222,10 +222,10 @@ public class ImportInitvalues { cfgDao.add("email_userpass", cfg.mailAuthPass, null, "System auth email password"); cfgDao.add("mail.smtp.starttls.enable", cfg.mailUseTls, null, "Enable TLS 1=true, 0=false"); - + cfgDao.add("mail.smtp.connection.timeout", "30000", null, "Socket connection timeout value in milliseconds. Default is 30 seconds (30000)."); - + cfgDao.add("mail.smtp.timeout", "30000", null, "Socket I/O timeout value in milliseconds. Default is 30 seconds (30000)."); @@ -268,7 +268,7 @@ public class ImportInitvalues { + "The Font has to exist on the Server which runs Red5"); cfgDao.add(CONFIG_APPLICATION_BASE_URL, cfg.baseUrl, null, "Base URL your OPenmeetings installation will be accessible at."); - + // *************************************** // *************************************** // red5SIP Integration Coniguration Values @@ -329,7 +329,7 @@ public class ImportInitvalues { // mute/unmute audio key code cfgDao.add("mute.keycode", "118", null, "A hot key code for the 'mute/unmute audio' functionality. Keycode 118 is F7"); - + // system-wide ldap params cfgDao.add(CONFIG_DEFAULT_LDAP_ID, "0", null, "Ldap domain selected by default in the login screen"); @@ -341,9 +341,9 @@ public class ImportInitvalues { , "Area to be shown to the user after login. Possible values are: " + "user/dashboard, user/calendar, user/record, rooms/my, rooms/group, rooms/public, admin/user, admin/connection" + ", admin/group, admin/room, admin/config, admin/lang, admin/ldap, admin/backup, admin/server, admin/oauth2"); - + // oauth2 params - cfgDao.add(CONFIG_IGNORE_BAD_SSL, "no", null, + cfgDao.add(CONFIG_IGNORE_BAD_SSL, "no", null, "Set \"yes\" or \"no\" to enable/disable ssl certifications checking for OAuth2"); cfgDao.add(CONFIG_REDIRECT_URL_FOR_EXTERNAL_KEY, "", null, @@ -382,7 +382,7 @@ public class ImportInitvalues { r.setWaitForRecording(false); r.setAllowRecording(true); - + if (groupId != null) { RoomGroup ro = new RoomGroup(); ro.setRoom(r); @@ -393,7 +393,7 @@ public class ImportInitvalues { r = roomDao.update(r, null); return r; } - + public void loadDefaultRooms(boolean createRooms, long langId) { if (createRooms) { createRoom(labelDao.getString("install.room.public.interview", langId), Type.interview, 16L, true, null); @@ -461,7 +461,7 @@ public class ImportInitvalues { yandexServer.setFirstnameParamName("first_name"); yandexServer.setLastnameParamName("last_name"); oauthDao.update(yandexServer, null); - + // Google OAuthServer googleServer = new OAuthServer(); googleServer.setName("Google"); @@ -480,7 +480,7 @@ public class ImportInitvalues { googleServer.setFirstnameParamName("given_name"); googleServer.setLastnameParamName("family_name"); oauthDao.update(googleServer, null); - + // Facebook OAuthServer facebookServer = new OAuthServer(); facebookServer.setName("Facebook"); @@ -499,7 +499,7 @@ public class ImportInitvalues { facebookServer.setLastnameParamName("last_name"); oauthDao.update(facebookServer, null); } - + // ------------------------------------------------------------------------------ public void loadSystem(InstallationConfig cfg, boolean force) throws Exception {
Modified: openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java (original) +++ openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java Sun Feb 5 15:46:17 2017 @@ -54,7 +54,7 @@ public class OpenmeetingsVariables { public static int DEFAULT_MINUTES_REMINDER_SEND = 15; public static String DEFAULT_BASE_URL = "http://localhost:5080/openmeetings/"; - + public static final String WEB_DATE_PATTERN = "dd.MM.yyyy HH:mm:ss"; //FIXME need to be made locale based public static String webAppRootKey = null; public static String webAppRootPath = null; Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java Sun Feb 5 15:46:17 2017 @@ -75,9 +75,9 @@ import com.googlecode.wicket.jquery.ui.w /** * CRUD operations in form for {@link User} - * + * * @author swagner - * + * */ public class UserForm extends AdminBaseForm<User> { private static final long serialVersionUID = 1L; Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomSidebar.java Sun Feb 5 15:46:17 2017 @@ -40,6 +40,7 @@ import org.apache.openmeetings.web.commo import org.apache.openmeetings.web.common.ConfirmableAjaxBorder.ConfirmableBorderDialog; import org.apache.openmeetings.web.room.RoomPanel; import org.apache.openmeetings.web.room.RoomPanel.Action; +import org.apache.wicket.AttributeModifier; import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; @@ -47,6 +48,7 @@ import org.apache.wicket.extensions.mark import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.PriorityHeaderItem; import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; @@ -78,8 +80,7 @@ public class RoomSidebar extends Panel { public static final String PARAM_SETTINGS = "s"; private final RoomPanel room; private final TabbedPanel tabs; - private final ITab userTab; - private final ITab fileTab; + private final ITab userTab, fileTab; private UploadDialog upload; private RoomFilePanel roomFiles; private final SelfIconsPanel selfRights; @@ -232,7 +233,7 @@ public class RoomSidebar extends Panel { this.room = room; updateShowFiles(); - userTab = new ITab() { + userTab = new OmTab() { private static final long serialVersionUID = 1L; @Override @@ -241,6 +242,11 @@ public class RoomSidebar extends Panel { } @Override + public String getCssClass() { + return "om-icon big tab user"; + } + + @Override public IModel<String> getTitle() { return Model.of(getString("613")); } @@ -250,7 +256,7 @@ public class RoomSidebar extends Panel { return new UserFragment(containerId, "user-panel"); } }; - fileTab = new ITab() { + fileTab = new OmTab() { private static final long serialVersionUID = 1L; @Override @@ -259,6 +265,11 @@ public class RoomSidebar extends Panel { } @Override + public String getCssClass() { + return "om-icon big tab file"; + } + + @Override public IModel<String> getTitle() { return Model.of(getString("614")); } @@ -281,6 +292,17 @@ public class RoomSidebar extends Panel { public void onActivate(AjaxRequestTarget target, int index, ITab tab) { selectedIdx = index; } + + @Override + protected WebMarkupContainer newTabContainer(String id, String tabId, ITab tab, int index) { + WebMarkupContainer t = super.newTabContainer(id, tabId, tab, index); + Label link = newTitleLabel("link", tab.getTitle()); + link.add(AttributeModifier.replace("href", "#" + tabId)); + link.add(AttributeModifier.append("class", ((OmTab)tab).getCssClass())); + link.add(AttributeModifier.append("title", tab.getTitle())); + t.replace(link); + return t; + } }).setOutputMarkupId(true)); selfRights = new SelfIconsPanel("icons", room.getClient(), room, true); add(addFolder); @@ -433,4 +455,11 @@ public class RoomSidebar extends Panel { selectedIdx = 1; tabs.reload(handler); } + + private static abstract class OmTab implements ITab { + private static final long serialVersionUID = 1L; + + public abstract String getCssClass(); + } } + Added: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.html URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.html?rev=1781776&view=auto ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.html (added) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.html Sun Feb 5 15:46:17 2017 @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<html xmlns:wicket="http://wicket.apache.org"> +<wicket:panel> + <div id="chatTabs"> + <ul> + <li><a href="#chatTab-all"><wicket:message key="1494"/></a></li> + </ul> + <div id="chatTab-all" class="messageArea"></div> + </div> + <form wicket:id="sendForm"> + <div style="display: inline-block;" wicket:id="toolbarContainer"></div> + <div style="display: inline-block; float: right; margin-right: 10px;"> + <div class="formCancelButton" wicket:id="ajax-cancel-button" wicket:message="title:442"></div> + </div> + <table style="width: 100%"> + <tr> + <td><div id="chatMessage" wicket:id="chatMessage"></div></td> + <td style="width: 50px"> + <div wicket:id="send"><wicket:message key="220"/></div> + <input type="hidden" wicket:id="activeTab" id="activeChatTab"/> + </td> + </tr> + </table> + </form> +</wicket:panel> +</html> Added: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java?rev=1781776&view=auto ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java (added) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/Chat.java Sun Feb 5 15:46:17 2017 @@ -0,0 +1,350 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License") + you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openmeetings.web.user.chat; + +import static org.apache.openmeetings.db.util.AuthLevelUtil.hasAdminLevel; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; +import static org.apache.openmeetings.web.app.Application.getBean; +import static org.apache.openmeetings.web.app.Application.getRoomClients; +import static org.apache.openmeetings.web.app.Application.getUserRooms; +import static org.apache.openmeetings.web.app.Application.isUserInRoom; +import static org.apache.openmeetings.web.app.WebSession.getDateFormat; +import static org.apache.openmeetings.web.app.WebSession.getRights; +import static org.apache.openmeetings.web.app.WebSession.getUserId; +import static org.apache.openmeetings.web.room.RoomPanel.isModerator; +import static org.apache.openmeetings.web.user.chat.EmotionsResources.EMOTIONS_CSS_REFERENCE; +import static org.apache.openmeetings.web.user.chat.EmotionsResources.EMOTIONS_JS_REFERENCE; +import static org.apache.openmeetings.web.util.CallbackFunctionHelper.getNamedFunction; +import static org.apache.openmeetings.web.util.ProfileImageResourceReference.getUrl; +import static org.apache.wicket.ajax.attributes.CallbackParameter.explicit; + +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.apache.openmeetings.db.dao.basic.ChatDao; +import org.apache.openmeetings.db.dao.room.RoomDao; +import org.apache.openmeetings.db.dao.user.UserDao; +import org.apache.openmeetings.db.entity.basic.ChatMessage; +import org.apache.openmeetings.db.entity.room.Room; +import org.apache.openmeetings.db.entity.room.Room.Right; +import org.apache.openmeetings.db.entity.user.User; +import org.apache.openmeetings.web.app.Application; +import org.apache.openmeetings.web.app.Client; +import org.apache.openmeetings.web.common.ConfirmableAjaxBorder; +import org.apache.wicket.Component; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.behavior.Behavior; +import org.apache.wicket.markup.head.CssHeaderItem; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.head.PriorityHeaderItem; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.HiddenField; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.Model; +import org.apache.wicket.protocol.ws.WebSocketSettings; +import org.apache.wicket.protocol.ws.api.IWebSocketConnection; +import org.apache.wicket.protocol.ws.api.registry.IWebSocketConnectionRegistry; +import org.apache.wicket.protocol.ws.api.registry.PageIdKey; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.json.JSONArray; +import org.json.JSONObject; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; + +import com.googlecode.wicket.jquery.ui.form.button.AjaxButton; +import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor; + +public class Chat extends Panel { + private static final long serialVersionUID = 1L; + private static final Logger log = Red5LoggerFactory.getLogger(Chat.class, webAppRootKey); + private static final String ID_TAB_PREFIX = "chatTab-"; + private static final String ID_USER_PREFIX = ID_TAB_PREFIX + "u"; + public static final String ID_ROOM_PREFIX = ID_TAB_PREFIX + "r"; + private static final String ID_ALL = ID_TAB_PREFIX + "all"; + private static final String PARAM_MSG_ID = "msgid"; + private static final String PARAM_ROOM_ID = "roomid"; + private final AbstractDefaultAjaxBehavior acceptMessage = new AbstractDefaultAjaxBehavior() { + private static final long serialVersionUID = 1L; + + @Override + protected void respond(AjaxRequestTarget target) { + try { + long msgId = getRequest().getRequestParameters().getParameterValue(PARAM_MSG_ID).toLong(); + long roomId = getRequest().getRequestParameters().getParameterValue(PARAM_ROOM_ID).toLong(); + ChatDao dao = getBean(ChatDao.class); + ChatMessage m = dao.get(msgId); + if (m.isNeedModeration() && isModerator(getUserId(), roomId)) { + m.setNeedModeration(false); + dao.update(m); + sendRoom(m, getMessage(Arrays.asList(m)).put("mode", "accept").toString()); + } else { + log.error("It seems like we are being hacked!!!!"); + } + } catch (Exception e) { + log.error("Unexpected exception while accepting chat message", e); + } + } + }; + + private static JSONObject setScope(JSONObject o, ChatMessage m, long curUserId) { + String scope, scopeName; + if (m.getToUser() != null) { + User u = curUserId == m.getToUser().getId() ? m.getFromUser() : m.getToUser(); + scope = ID_USER_PREFIX + u.getId(); + scopeName = String.format("%s %s", u.getFirstname(), u.getLastname()); + } else if (m.getToRoom() != null) { + scope = ID_ROOM_PREFIX + m.getToRoom().getId(); + scopeName = String.format("%s %s", Application.getString(406), m.getToRoom().getId()); + o.put("needModeration", m.isNeedModeration()); + } else { + scope = ID_ALL; + scopeName = Application.getString(1494); + } + return o.put("scope", scope).put("scopeName", scopeName); + } + + public JSONObject getMessage(List<ChatMessage> list) { + return getMessage(getUserId(), list); + } + + private JSONObject getMessage(long curUserId, List<ChatMessage> list) { + JSONArray arr = new JSONArray(); + for (ChatMessage m : list) { + String smsg = m.getMessage(); + smsg = smsg == null ? smsg : " " + smsg.replaceAll(" ", " ") + " "; + arr.put(setScope(new JSONObject(), m, curUserId) + .put("id", m.getId()) + .put("message", smsg) + .put("from", new JSONObject() + .put("id", m.getFromUser().getId()) + .put("name", m.getFromUser().getFirstname() + " " + m.getFromUser().getLastname()) + .put("img", getUrl(getRequestCycle(), m.getFromUser().getId())) + + ) + .put("actions", curUserId == m.getFromUser().getId() ? "short" : "full") + .put("sent", getDateFormat().format(m.getSent()))); + } + return new JSONObject() + .put("type", "chat") + .put("msg", arr); + } + + public Chat(String id) { + super(id); + setOutputMarkupPlaceholderTag(true); + setMarkupId(id); + + add(acceptMessage, new Behavior() { + private static final long serialVersionUID = 1L; + + @Override + public void renderHead(Component component, IHeaderResponse response) { + ChatDao dao = getBean(ChatDao.class); + //FIXME limited count should be loaded with "earlier" link + List<ChatMessage> list = new ArrayList<ChatMessage>(dao.getGlobal(0, 30)); + for(Long roomId : getUserRooms(getUserId())) { + Room r = getBean(RoomDao.class).get(roomId); + list.addAll(dao.getRoom(roomId, 0, 30, !r.isChatModerated() || isModerator(getUserId(), roomId))); + } + list.addAll(dao.getUserRecent(getUserId(), Date.from(Instant.now().minus(Duration.ofHours(1L))), 0, 30)); + if (list.size() > 0) { + StringBuilder sb = new StringBuilder(); + sb.append("addChatMessage(").append(getMessage(list).toString()).append(");"); + response.render(OnDomReadyHeaderItem.forScript(sb.toString())); + } + super.renderHead(component, response); + } + }); + add(new ChatForm("sendForm")); + } + + public CharSequence addRoom(Room r) { + StringBuilder sb = new StringBuilder(); + sb.append(String.format("addChatTab('%1$s%2$d', '%3$s %2$d');", ID_ROOM_PREFIX, r.getId(), Application.getString(406))); + List<ChatMessage> list = getBean(ChatDao.class).getRoom(r.getId(), 0, 30, !r.isChatModerated() || isModerator(getUserId(), r.getId())); + if (list.size() > 0) { + sb.append("addChatMessage(").append(getMessage(list).toString()).append(");"); + } + return sb; + } + + @Override + public void renderHead(IHeaderResponse response) { + super.renderHead(response); + response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(EMOTIONS_JS_REFERENCE))); + response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(Chat.class, "chat.js")))); + response.render(CssHeaderItem.forReference(EMOTIONS_CSS_REFERENCE)); + response.render(CssHeaderItem.forUrl("css/chat.css")); + response.render(new PriorityHeaderItem(getNamedFunction("acceptMessage", acceptMessage, explicit(PARAM_ROOM_ID), explicit(PARAM_MSG_ID)))); + } + + private static void sendRoom(ChatMessage m, String msg) { + IWebSocketConnectionRegistry reg = WebSocketSettings.Holder.get(Application.get()).getConnectionRegistry(); + for (Client c : getRoomClients(m.getToRoom().getId())) { + try { + if (!m.isNeedModeration() || (m.isNeedModeration() && c.hasRight(Right.moderator))) { + IWebSocketConnection con = reg.getConnection(Application.get(), c.getSessionId(), new PageIdKey(c.getPageId())); + if (con != null) { + con.sendMessage(msg); + } + } + } catch (Exception e) { + log.error("Error while sending message to room", e); + } + } + } + + private class ChatForm extends Form<Void> { + private static final long serialVersionUID = 1L; + private final ChatToolbar toolbar = new ChatToolbar("toolbarContainer"); + private final WysiwygEditor chatMessage = new WysiwygEditor("chatMessage", Model.of(""), toolbar); + private final HiddenField<String> activeTab = new HiddenField<String>("activeTab", Model.of("")); + + ChatForm(String id) { + super(id); + add(toolbar + , activeTab + , chatMessage.setOutputMarkupId(true) + , new AjaxButton("send") { + private static final long serialVersionUID = 1L; + + @Override + protected void onSubmit(AjaxRequestTarget target) { + ChatDao dao = getBean(ChatDao.class); + ChatMessage m = new ChatMessage(); + m.setMessage(chatMessage.getDefaultModelObjectAsString()); + m.setSent(new Date()); + m.setFromUser(getBean(UserDao.class).get(getUserId())); + try { + String scope = activeTab.getModelObject(); + if (scope != null) { + if (ID_ALL.equals(scope)) { + //we done + } else if (scope.startsWith(ID_ROOM_PREFIX)) { + Room r = getBean(RoomDao.class).get(Long.parseLong(scope.substring(ID_ROOM_PREFIX.length()))); + if (isUserInRoom(r.getId(), getUserId())) { + m.setToRoom(r); + } else { + log.error("It seems like we are being hacked!!!!"); + return; + } + m.setNeedModeration(r.isChatModerated() && !isModerator(m.getFromUser().getId(), r.getId())); + } else if (scope.startsWith(ID_USER_PREFIX)) { + User u = getBean(UserDao.class).get(Long.parseLong(scope.substring(ID_USER_PREFIX.length()))); + m.setToUser(u); + } + } + } catch (Exception e) { + //no-op + } + dao.update(m); + String msg = getMessage(Arrays.asList(m)).toString(); + if (m.getToRoom() != null) { + sendRoom(m, msg); + } else if (m.getToUser() != null) { + IWebSocketConnectionRegistry reg = WebSocketSettings.Holder.get(Application.get()).getConnectionRegistry(); + for (Client c : Application.getClients(getUserId())) { + try { + IWebSocketConnection con = reg.getConnection(Application.get(), c.getSessionId(), new PageIdKey(c.getPageId())); + if (con != null) { + con.sendMessage(msg); + } + } catch (Exception e) { + log.error("Error while sending message to room", e); + } + } + msg = getMessage(m.getToUser().getId(), Arrays.asList(m)).toString(); + for (Client c : Application.getClients(m.getToUser().getId())) { + try { + IWebSocketConnection con = reg.getConnection(Application.get(), c.getSessionId(), new PageIdKey(c.getPageId())); + if (con != null) { + con.sendMessage(msg); + } + } catch (Exception e) { + log.error("Error while sending message to room", e); + } + } + } else { + IWebSocketConnectionRegistry reg = WebSocketSettings.Holder.get(getApplication()).getConnectionRegistry(); + for (IWebSocketConnection c : reg.getConnections(getApplication())) { + try { + c.sendMessage(msg); + } catch(Exception e) { + log.error("Error while sending message", e); + } + } + } + chatMessage.setDefaultModelObject(""); + target.add(chatMessage); + }; + }); + } + + @Override + protected void onInitialize() { + super.onInitialize(); + ConfirmableAjaxBorder delBtn = new ConfirmableAjaxBorder("ajax-cancel-button", getString("80"), getString("832"), this) { + private static final long serialVersionUID = 1L; + + @Override + protected void onError(AjaxRequestTarget target, Form<?> form) { + } + + @Override + protected void onSubmit(AjaxRequestTarget target, Form<?> form) { + ChatDao dao = getBean(ChatDao.class); + String scope = activeTab.getModelObject(); + boolean clean = false; + try { + if (scope == null || ID_ALL.equals(scope)) { + scope = ID_ALL; + dao.deleteGlobal(); + clean = true; + } else if (scope.startsWith(ID_ROOM_PREFIX)) { + Room r = getBean(RoomDao.class).get(Long.parseLong(scope.substring(ID_ROOM_PREFIX.length()))); + if (r != null) { + dao.deleteRoom(r.getId()); + clean = true; + } + } else if (scope.startsWith(ID_USER_PREFIX)) { + User u = getBean(UserDao.class).get(Long.parseLong(scope.substring(ID_USER_PREFIX.length()))); + if (u != null) { + dao.deleteUser(u.getId()); + clean = true; + } + } + } catch (Exception e) { + //no-op + } + if (clean) { + target.appendJavaScript("$('#" + scope + "').html('')"); + } + } + }; + add(delBtn.setVisible(hasAdminLevel(getRights()))); + } + } +} Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.html URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.html?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.html (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.html Sun Feb 5 15:46:17 2017 @@ -22,27 +22,8 @@ <wicket:panel> <div id="chat" class="ui-state-default"> <div onclick="toggleChat();" class="control block clickable ui-widget-header ui-state-active"><div class="ui-icon ui-icon-caret-1-n sort-icon"></div><div class="label"><wicket:message key="244"/></div></div> - <div id="chatTabs"> - <ul> - <li><a href="#chatTab-all"><wicket:message key="1494"/></a></li> - </ul> - <div id="chatTab-all" class="messageArea"></div> - </div> - <form wicket:id="sendForm"> - <div style="display: inline-block;" wicket:id="toolbarContainer"></div> - <div style="display: inline-block; float: right; margin-right: 10px;"> - <div class="formCancelButton" wicket:id="ajax-cancel-button" wicket:message="title:442"></div> - </div> - <table style="width: 100%"> - <tr> - <td><div id="chatMessage" wicket:id="chatMessage"></div></td> - <td style="width: 50px"> - <div wicket:id="send"><wicket:message key="220"/></div> - <input type="hidden" wicket:id="activeTab" id="activeChatTab"/> - </td> - </tr> - </table> - </form> + <div wicket:id="chat"></div> </div> </wicket:panel> </html> + Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.java URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.java?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.java (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatPanel.java Sun Feb 5 15:46:17 2017 @@ -18,174 +18,31 @@ */ package org.apache.openmeetings.web.user.chat; -import static org.apache.openmeetings.db.util.AuthLevelUtil.hasAdminLevel; import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DASHBOARD_SHOW_CHAT; -import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import static org.apache.openmeetings.web.app.Application.getBean; -import static org.apache.openmeetings.web.app.Application.getRoomClients; -import static org.apache.openmeetings.web.app.Application.getUserRooms; -import static org.apache.openmeetings.web.app.Application.isUserInRoom; -import static org.apache.openmeetings.web.app.WebSession.getDateFormat; -import static org.apache.openmeetings.web.app.WebSession.getRights; -import static org.apache.openmeetings.web.app.WebSession.getUserId; -import static org.apache.openmeetings.web.room.RoomPanel.isModerator; -import static org.apache.openmeetings.web.user.chat.EmotionsResources.EMOTIONS_CSS_REFERENCE; -import static org.apache.openmeetings.web.user.chat.EmotionsResources.EMOTIONS_JS_REFERENCE; -import static org.apache.openmeetings.web.util.CallbackFunctionHelper.getNamedFunction; -import static org.apache.openmeetings.web.util.ProfileImageResourceReference.getUrl; -import static org.apache.wicket.ajax.attributes.CallbackParameter.explicit; -import java.time.Duration; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import org.apache.openmeetings.db.dao.basic.ChatDao; import org.apache.openmeetings.db.dao.basic.ConfigurationDao; -import org.apache.openmeetings.db.dao.room.RoomDao; -import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.entity.basic.ChatMessage; import org.apache.openmeetings.db.entity.room.Room; -import org.apache.openmeetings.db.entity.room.Room.Right; import org.apache.openmeetings.db.entity.room.Room.RoomElement; -import org.apache.openmeetings.db.entity.user.User; -import org.apache.openmeetings.web.app.Application; -import org.apache.openmeetings.web.app.Client; import org.apache.openmeetings.web.common.BasePanel; -import org.apache.openmeetings.web.common.ConfirmableAjaxBorder; -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation; -import org.apache.wicket.behavior.Behavior; import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; -import org.apache.wicket.markup.head.CssHeaderItem; import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.markup.head.OnDomReadyHeaderItem; -import org.apache.wicket.markup.head.PriorityHeaderItem; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.HiddenField; -import org.apache.wicket.model.Model; -import org.apache.wicket.protocol.ws.WebSocketSettings; -import org.apache.wicket.protocol.ws.api.IWebSocketConnection; -import org.apache.wicket.protocol.ws.api.registry.IWebSocketConnectionRegistry; -import org.apache.wicket.protocol.ws.api.registry.PageIdKey; -import org.apache.wicket.request.resource.JavaScriptResourceReference; -import org.json.JSONArray; -import org.json.JSONObject; -import org.red5.logging.Red5LoggerFactory; -import org.slf4j.Logger; - -import com.googlecode.wicket.jquery.ui.form.button.AjaxButton; -import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor; @AuthorizeInstantiation({"Dashboard", "Room"}) public class ChatPanel extends BasePanel { private static final long serialVersionUID = 1L; - private static final Logger log = Red5LoggerFactory.getLogger(ChatPanel.class, webAppRootKey); - private static final String ID_TAB_PREFIX = "chatTab-"; - private static final String ID_USER_PREFIX = ID_TAB_PREFIX + "u"; - public static final String ID_ROOM_PREFIX = ID_TAB_PREFIX + "r"; - private static final String ID_ALL = ID_TAB_PREFIX + "all"; - private static final String PARAM_MSG_ID = "msgid"; - private static final String PARAM_ROOM_ID = "roomid"; private boolean showDashboardChat = getBean(ConfigurationDao.class).getConfValue(CONFIG_DASHBOARD_SHOW_CHAT, Integer.class, "1") == 1; - private final AbstractDefaultAjaxBehavior acceptMessage = new AbstractDefaultAjaxBehavior() { - private static final long serialVersionUID = 1L; - - @Override - protected void respond(AjaxRequestTarget target) { - try { - long msgId = getRequest().getRequestParameters().getParameterValue(PARAM_MSG_ID).toLong(); - long roomId = getRequest().getRequestParameters().getParameterValue(PARAM_ROOM_ID).toLong(); - ChatDao dao = getBean(ChatDao.class); - ChatMessage m = dao.get(msgId); - if (m.isNeedModeration() && isModerator(getUserId(), roomId)) { - m.setNeedModeration(false); - dao.update(m); - sendRoom(m, getMessage(Arrays.asList(m)).put("mode", "accept").toString()); - } else { - log.error("It seems like we are being hacked!!!!"); - } - } catch (Exception e) { - log.error("Unexpected exception while accepting chat message", e); - } - } - }; - - private static JSONObject setScope(JSONObject o, ChatMessage m, long curUserId) { - String scope, scopeName; - if (m.getToUser() != null) { - User u = curUserId == m.getToUser().getId() ? m.getFromUser() : m.getToUser(); - scope = ID_USER_PREFIX + u.getId(); - scopeName = String.format("%s %s", u.getFirstname(), u.getLastname()); - } else if (m.getToRoom() != null) { - scope = ID_ROOM_PREFIX + m.getToRoom().getId(); - scopeName = String.format("%s %s", Application.getString(406), m.getToRoom().getId()); - o.put("needModeration", m.isNeedModeration()); - } else { - scope = ID_ALL; - scopeName = Application.getString(1494); - } - return o.put("scope", scope).put("scopeName", scopeName); - } - - public JSONObject getMessage(List<ChatMessage> list) { - return getMessage(getUserId(), list); - } - - private JSONObject getMessage(long curUserId, List<ChatMessage> list) { - JSONArray arr = new JSONArray(); - for (ChatMessage m : list) { - String smsg = m.getMessage(); - smsg = smsg == null ? smsg : " " + smsg.replaceAll(" ", " ") + " "; - arr.put(setScope(new JSONObject(), m, curUserId) - .put("id", m.getId()) - .put("message", smsg) - .put("from", new JSONObject() - .put("id", m.getFromUser().getId()) - .put("name", m.getFromUser().getFirstname() + " " + m.getFromUser().getLastname()) - .put("img", getUrl(getRequestCycle(), m.getFromUser().getId())) - - ) - .put("actions", curUserId == m.getFromUser().getId() ? "short" : "full") - .put("sent", getDateFormat().format(m.getSent()))); - } - return new JSONObject() - .put("type", "chat") - .put("msg", arr); - } + private final Chat chat; public ChatPanel(String id) { super(id); setOutputMarkupPlaceholderTag(true); setMarkupId(id); - add(acceptMessage, new Behavior() { - private static final long serialVersionUID = 1L; - - @Override - public void renderHead(Component component, IHeaderResponse response) { - ChatDao dao = getBean(ChatDao.class); - //FIXME limited count should be loaded with "earlier" link - List<ChatMessage> list = new ArrayList<ChatMessage>(dao.getGlobal(0, 30)); - for(Long roomId : getUserRooms(getUserId())) { - Room r = getBean(RoomDao.class).get(roomId); - list.addAll(dao.getRoom(roomId, 0, 30, !r.isChatModerated() || isModerator(getUserId(), roomId))); - } - list.addAll(dao.getUserRecent(getUserId(), Date.from(Instant.now().minus(Duration.ofHours(1L))), 0, 30)); - if (list.size() > 0) { - StringBuilder sb = new StringBuilder(); - sb.append("addChatMessage(").append(getMessage(list).toString()).append(");"); - response.render(OnDomReadyHeaderItem.forScript(sb.toString())); - } - super.renderHead(component, response); - } - }); - add(new ChatForm("sendForm")); + add(chat = new Chat("chat")); } public void roomEnter(Room r, AjaxRequestTarget target) { @@ -198,12 +55,8 @@ public class ChatPanel extends BasePanel if (!showDashboardChat) { sb.append("$('#chat').show();"); } - sb.append(String.format("addChatTab('%1$s%2$d', '%3$s %2$d');", ID_ROOM_PREFIX, r.getId(), Application.getString(406))); + sb.append(chat.addRoom(r)); sb.append(r.isChatOpened() ? "openChat();" : "closeChat();"); - List<ChatMessage> list = getBean(ChatDao.class).getRoom(r.getId(), 0, 30, !r.isChatModerated() || isModerator(getUserId(), r.getId())); - if (list.size() > 0) { - sb.append("addChatMessage(").append(getMessage(list).toString()).append(");"); - } sb.append("});"); target.appendJavaScript(sb); } @@ -212,7 +65,7 @@ public class ChatPanel extends BasePanel if (r.isHidden(RoomElement.Chat)) { return; } - handler.appendJavaScript(String.format("if (typeof removeChatTab == 'function') { removeChatTab('%1$s%2$d'); }", ID_ROOM_PREFIX, r.getId())); + handler.appendJavaScript(String.format("if (typeof removeChatTab == 'function') { removeChatTab('%1$s%2$d'); }", Chat.ID_ROOM_PREFIX, r.getId())); if (!showDashboardChat) { StringBuilder sb = new StringBuilder(); sb.append("$(function() {"); @@ -227,7 +80,7 @@ public class ChatPanel extends BasePanel if (handler != null) { handler.add(this); if (visible) { - handler.appendJavaScript("reinit();"); + handler.appendJavaScript("chatReinit();"); } } } @@ -235,11 +88,6 @@ public class ChatPanel extends BasePanel @Override public void renderHead(IHeaderResponse response) { super.renderHead(response); - response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(EMOTIONS_JS_REFERENCE))); - response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(ChatPanel.class, "chat.js")))); - response.render(CssHeaderItem.forReference(EMOTIONS_CSS_REFERENCE)); - response.render(CssHeaderItem.forUrl("css/chat.css")); - response.render(new PriorityHeaderItem(getNamedFunction("acceptMessage", acceptMessage, explicit(PARAM_ROOM_ID), explicit(PARAM_MSG_ID)))); if (!showDashboardChat) { StringBuilder sb = new StringBuilder(); sb.append("$(document).ready(function(){"); @@ -249,151 +97,5 @@ public class ChatPanel extends BasePanel response.render(OnDomReadyHeaderItem.forScript(sb.toString())); } } - - private static void sendRoom(ChatMessage m, String msg) { - IWebSocketConnectionRegistry reg = WebSocketSettings.Holder.get(Application.get()).getConnectionRegistry(); - for (Client c : getRoomClients(m.getToRoom().getId())) { - try { - if (!m.isNeedModeration() || (m.isNeedModeration() && c.hasRight(Right.moderator))) { - IWebSocketConnection con = reg.getConnection(Application.get(), c.getSessionId(), new PageIdKey(c.getPageId())); - if (con != null) { - con.sendMessage(msg); - } - } - } catch (Exception e) { - log.error("Error while sending message to room", e); - } - } - } - - private class ChatForm extends Form<Void> { - private static final long serialVersionUID = 1L; - private final ChatToolbar toolbar = new ChatToolbar("toolbarContainer"); - private final WysiwygEditor chatMessage = new WysiwygEditor("chatMessage", Model.of(""), toolbar); - private final HiddenField<String> activeTab = new HiddenField<String>("activeTab", Model.of("")); - - ChatForm(String id) { - super(id); - add(toolbar - , activeTab - , chatMessage.setOutputMarkupId(true) - , new AjaxButton("send") { - private static final long serialVersionUID = 1L; - - @Override - protected void onSubmit(AjaxRequestTarget target) { - ChatDao dao = getBean(ChatDao.class); - ChatMessage m = new ChatMessage(); - m.setMessage(chatMessage.getDefaultModelObjectAsString()); - m.setSent(new Date()); - m.setFromUser(getBean(UserDao.class).get(getUserId())); - try { - String scope = activeTab.getModelObject(); - if (scope != null) { - if (ID_ALL.equals(scope)) { - //we done - } else if (scope.startsWith(ID_ROOM_PREFIX)) { - Room r = getBean(RoomDao.class).get(Long.parseLong(scope.substring(ID_ROOM_PREFIX.length()))); - if (isUserInRoom(r.getId(), getUserId())) { - m.setToRoom(r); - } else { - log.error("It seems like we are being hacked!!!!"); - return; - } - m.setNeedModeration(r.isChatModerated() && !isModerator(m.getFromUser().getId(), r.getId())); - } else if (scope.startsWith(ID_USER_PREFIX)) { - User u = getBean(UserDao.class).get(Long.parseLong(scope.substring(ID_USER_PREFIX.length()))); - m.setToUser(u); - } - } - } catch (Exception e) { - //no-op - } - dao.update(m); - String msg = getMessage(Arrays.asList(m)).toString(); - if (m.getToRoom() != null) { - sendRoom(m, msg); - } else if (m.getToUser() != null) { - IWebSocketConnectionRegistry reg = WebSocketSettings.Holder.get(Application.get()).getConnectionRegistry(); - for (Client c : Application.getClients(getUserId())) { - try { - IWebSocketConnection con = reg.getConnection(Application.get(), c.getSessionId(), new PageIdKey(c.getPageId())); - if (con != null) { - con.sendMessage(msg); - } - } catch (Exception e) { - log.error("Error while sending message to room", e); - } - } - msg = getMessage(m.getToUser().getId(), Arrays.asList(m)).toString(); - for (Client c : Application.getClients(m.getToUser().getId())) { - try { - IWebSocketConnection con = reg.getConnection(Application.get(), c.getSessionId(), new PageIdKey(c.getPageId())); - if (con != null) { - con.sendMessage(msg); - } - } catch (Exception e) { - log.error("Error while sending message to room", e); - } - } - } else { - IWebSocketConnectionRegistry reg = WebSocketSettings.Holder.get(getApplication()).getConnectionRegistry(); - for (IWebSocketConnection c : reg.getConnections(getApplication())) { - try { - c.sendMessage(msg); - } catch(Exception e) { - log.error("Error while sending message", e); - } - } - } - chatMessage.setDefaultModelObject(""); - target.add(chatMessage); - }; - }); - } - - @Override - protected void onInitialize() { - super.onInitialize(); - ConfirmableAjaxBorder delBtn = new ConfirmableAjaxBorder("ajax-cancel-button", getString("80"), getString("832"), this) { - private static final long serialVersionUID = 1L; - - @Override - protected void onError(AjaxRequestTarget target, Form<?> form) { - } - - @Override - protected void onSubmit(AjaxRequestTarget target, Form<?> form) { - ChatDao dao = getBean(ChatDao.class); - String scope = activeTab.getModelObject(); - boolean clean = false; - try { - if (scope == null || ID_ALL.equals(scope)) { - scope = ID_ALL; - dao.deleteGlobal(); - clean = true; - } else if (scope.startsWith(ID_ROOM_PREFIX)) { - Room r = getBean(RoomDao.class).get(Long.parseLong(scope.substring(ID_ROOM_PREFIX.length()))); - if (r != null) { - dao.deleteRoom(r.getId()); - clean = true; - } - } else if (scope.startsWith(ID_USER_PREFIX)) { - User u = getBean(UserDao.class).get(Long.parseLong(scope.substring(ID_USER_PREFIX.length()))); - if (u != null) { - dao.deleteUser(u.getId()); - clean = true; - } - } - } catch (Exception e) { - //no-op - } - if (clean) { - target.appendJavaScript("$('#" + scope + "').html('')"); - } - } - }; - add(delBtn.setVisible(hasAdminLevel(getRights()))); - } - } } + Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.html URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.html?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.html (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.html Sun Feb 5 15:46:17 2017 @@ -36,31 +36,36 @@ var editor = $('#chatMessage .wysiwyg-editor'); editor.html(editor.html() + ' ' + emoticon + ' '); } - $(function() { - var emots = [":-)", ":)", ":o)", ":c)", ":^)", ":-D", ":-(", ":-9", ";-)", ":-P", ":-p", ":-Ã", ":-b" - , ":-O", ":-/", ":-X", ":-#", ":'(", "B-)", "8-)", ":-\\", ";*(", ":-*", ":]", ":>", "=]", "=)", "8)" - , ":}", ":D", "8D", "XD", "xD", "=D", ":(", ":<", ":[", ":{", "=(", ";)", ";]", ";D", ":P", ":p" - , "=P", "=p", ":b", ":Ã", ":O", "8O", ":/", "=/", ":S", ":#", ":X", "B)", "O:)", "<3", ";(", ">:)" - , ">;)", ">:(", "O_o", "O_O", "o_o", "0_o", "T_T", "^_^", "?-)"]; + function initChatToolbar() { + var emtBtn = $('#emoticons'); + emtBtn.html(''); + emtBtn.append(' ' + emoticon.emoticonize(':)') + ' <b class="caret"></b>'); + var emots = [].concat.apply([], [emoticon.threeCharEmoticons, emoticon.twoCharEmoticons]); + for (var ei in emoticon.specialEmoticons) { + emots.push(ei); + } var emotMenuList = $('#emotMenuList'); - var rowSize = 15; + emotMenuList.html(''); + var rowSize = 20; var row = $('<tr></tr>'); for (var i = 0; i < emots.length; ++i) { row.append('<td><div class="emt" onclick="emtClick(\'' + emots[i] + '\');">' - + emots[i] + '</div></td>'); + + emoticon.emoticonize(emots[i]) + '</div></td>'); if (i != 0 && i % rowSize == 0) { emotMenuList.append(row); row = $('<tr></tr>'); } } - //$('.emt').emoticonize(); + } + $(function() { + initChatToolbar(); }); </script> </wicket:head> <wicket:panel> <div wicket:id="toolbar" class="btn-toolbar" data-role="editor-toolbar"> <div class="btn-group"> - <a id="emoticons" class="chat btn emt dropdown-toggle" data-toggle="dropdown" title="Emoticons"> :) <b class="caret"></b></a> + <a id="emoticons" class="chat btn emt dropdown-toggle" data-toggle="dropdown" title="Emoticons"></a> <ul class="chat dropdown-menu" > <li> <table id="emotMenuList"> @@ -83,3 +88,4 @@ </div> </wicket:panel> </html> + Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/chat.js URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/chat.js?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/chat.js (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/chat.js Sun Feb 5 15:46:17 2017 @@ -42,9 +42,10 @@ $(function() { //no-op } }); - reinit(); + chatReinit(); }); -function reinit() { +function chatReinit() { + initChatToolbar(); chatTabs = $("#chatTabs").tabs({ activate: function(event, ui) { $('#activeChatTab').val(ui.newPanel[0].id); @@ -84,9 +85,12 @@ function toggleChat() { function activateTab(id) { chatTabs.tabs("option", "active", chatTabs.find('a[href="#' + id + '"]').parent().index()); } +function chatInited() { + return !!$("#chatTabs").data("ui-tabs"); +} function addChatTab(id, label) { - if (!$("#chatTabs").data("ui-tabs")) { - reinit(); + if (!chatInited()) { + chatReinit(); } if ($('#chat').length < 1 || $('#' + id).length) { return; @@ -103,7 +107,9 @@ function addChatTab(id, label) { function removeChatTab(id) { $('li[aria-controls="' + id + '"]').remove(); $('#' + id).remove(); - chatTabs.tabs("refresh"); + if (chatInited()) { + chatTabs.tabs("refresh"); + } } function addChatMessage(m) { if ($('#chat').length > 0 && m && m.type == "chat") { Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.js URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.js?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.js (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.js Sun Feb 5 15:46:17 2017 @@ -16,10 +16,11 @@ var CSSEmoticon = function() { ":-)", ":o)", ":c)", ":^)", ":-D", ":-(", ":-9", ";-)", ":-P", ":-p", ":-Ã", ":-b", ":-O", ":-/", ":-X", ":-#", ":'(", "B-)", "8-)", ";*(", ":-*", ":-\\", "?-)" // <== This is my own invention, it's a smiling pirate (with an eye-patch)! ]; - + this.threeCharEmoticons = this.threeCharacterEmoticons.slice(); this.twoCharacterEmoticons = [ // separate these out so that we can add a letter-spacing between the characters for better proportions ":)", ":]", "=]", "=)", "8)", ":}", ":D", ":(", ":[", ":{", "=(", ";)", ";]", ";D", ":P", ":p", "=P", "=p", ":b", ":Ã", ":O", ":/", "=/", ":S", ":#", ":X", "B)", ":|", ":\\", "=\\", ":*", ":>", ":<" ]; + this.twoCharEmoticons = this.twoCharacterEmoticons.slice(); this.specialEmoticons = { // emoticons to be treated with a special class, hash specifies the additional class to add, along with standard css-emoticon class ">:)": {cssClass: "red-emoticon small-emoticon spaced-emoticon"}, Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.min.js URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.min.js?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.min.js (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/cssemoticons.min.js Sun Feb 5 15:46:17 2017 @@ -1,2 +1,2 @@ /* Dual licensed under the MIT and GPL licenses */ -var CSSEmoticon=function(){this.escapeCharacters=[")","(","*","[","]","{","}","|","^","<",">","\\","?","+","=","."];this.threeCharacterEmoticons=[":-)",":o)",":c)",":^)",":-D",":-(",":-9",";-)",":-P",":-p",":-Ã",":-b",":-O",":-/",":-X",":-#",":'(","B-)","8-)",";*(",":-*",":-\\","?-)"];this.twoCharacterEmoticons=[":)",":]","=]","=)","8)",":}",":D",":(",":[",":{","=(",";)",";]",";D",":P",":p","=P","=p",":b",":Ã",":O",":/","=/",":S",":#",":X","B)",":|",":\\","=\\",":*",":>",":<"];this.specialEmoticons={">:)":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},">;)":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},">:(":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},">: )":{cssClass:"red-emoticon small-emoticon"},">; )":{cssClass:"red-emoticon small-emoticon"},">: (":{cssClass:"red-emoticon small-emoticon"},";(":{cssClass:"red-emoticon spaced-emoticon"},"<3":{cssClass:"pink-emoticon counter-rotated"},"O_O":{cssClass:"no-rotate"},"o _o":{cssClass:"no-rotate"},"0_o":{cssClass:"no-rotate"},"O_o":{cssClass:"no-rotate"},"T_T":{cssClass:"no-rotate"},"^_^":{cssClass:"no-rotate"},"O:)":{cssClass:"small-emoticon spaced-emoticon"},"O: )":{cssClass:"small-emoticon"},"8D":{cssClass:"small-emoticon spaced-emoticon"},"XD":{cssClass:"small-emoticon spaced-emoticon"},"xD":{cssClass:"small-emoticon spaced-emoticon"},"=D":{cssClass:"small-emoticon spaced-emoticon"},"8O":{cssClass:"small-emoticon spaced-emoticon"},"[+=..]":{cssClass:"no-rotate nintendo-controller"}};var a=new RegExp('(\\'+this.escapeCharacters.join('|\\')+')','g');var b='(^|[\\s\\0])';for(var c=this.threeCharacterEmoticons.length-1;c>=0;--c){this.threeCharacterEmoticons[c]=this.threeCharacterEmoticons[c].replace(a,'\\$1');this.threeCharacterEmoticons[c]=new RegExp(b+'('+this.threeCharacterEmoticons[c]+')','g');}for(var c=this.twoCharacterEmoticons.length-1;c>=0;--c){this.twoCharacterEmoticons[c]=this.twoCharacterEmoticons[c].replace(a,'\\$1');this.twoCharacterEm oticons[c]=new RegExp(b+'('+this.twoCharacterEmoticons[c]+')','g');}for(var d in this.specialEmoticons){this.specialEmoticons[d].regexp=d.replace(a,'\\$1');this.specialEmoticons[d].regexp=new RegExp(b+'('+this.specialEmoticons[d].regexp+')','g');}this.defaults={animate:true,delay:500,exclude:'pre,code,.no-emoticons'};};CSSEmoticon.prototype.emoticonize=function(a,b){var c={};for(var d in this.defaults)c[d]=this.defaults[d];for(var d in b)c[d]=b[d];var e='span.css-emoticon';if(c.exclude)e+=','+c.exclude;var f=e.split(',');var g='css-emoticon';if(c.animate)g+=' un-transformed-emoticon animated-emoticon';for(var h in this.specialEmoticons){var i=g+" "+this.specialEmoticons[h].cssClass;a=a.replace(this.specialEmoticons[h].regexp,"$1<span class='"+i+"'>$2</span>");}for(var d in this.threeCharacterEmoticons){var j=this.threeCharacterEmoticons[d];a=a.replace(j,"$1<span class='"+g+"'>$2</span>");}for(var d in this.twoCharacterEmoticons){var j=this.twoCharacterEmoticons[d];a=a.replace(j,"$1< span class='"+g+" spaced-emoticon'>$2</span>");}if(c.animate)setTimeout(function(){var a=document.body.getElementsByClassName("un-transformed-emoticon");for(var b in a)if(typeof a[b]=="object")a[b].classList.remove("un-transformed-emoticon");},c.delay);return a;}; \ No newline at end of file +var CSSEmoticon=function(){this.escapeCharacters=[")","(","*","[","]","{","}","|","^","<",">","\\","?","+","=","."];this.threeCharacterEmoticons=[":-)",":o)",":c)",":^)",":-D",":-(",":-9",";-)",":-P",":-p",":-Ã",":-b",":-O",":-/",":-X",":-#",":'(","B-)","8-)",";*(",":-*",":-\\","?-)"];this.threeCharEmoticons=this.threeCharacterEmoticons.slice();this.twoCharacterEmoticons=[":)",":]","=]","=)","8)",":}",":D",":(",":[",":{","=(",";)",";]",";D",":P",":p","=P","=p",":b",":Ã",":O",":/","=/",":S",":#",":X","B)",":|",":\\","=\\",":*",":>",":<"];this.twoCharEmoticons=this.twoCharacterEmoticons.slice();this.specialEmoticons={">:)":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},">;)":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},">:(":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},">: )":{cssClass:"red-emoticon small-emoticon"},">; )":{cssClass:"red-emoticon small-emoticon"},">: (":{cssClass:"red-emoticon small-emoticon"},";(":{cssCl ass:"red-emoticon spaced-emoticon"},"<3":{cssClass:"pink-emoticon counter-rotated"},"O_O":{cssClass:"no-rotate"},"o_o":{cssClass:"no-rotate"},"0_o":{cssClass:"no-rotate"},"O_o":{cssClass:"no-rotate"},"T_T":{cssClass:"no-rotate"},"^_^":{cssClass:"no-rotate"},"O:)":{cssClass:"small-emoticon spaced-emoticon"},"O: )":{cssClass:"small-emoticon"},"8D":{cssClass:"small-emoticon spaced-emoticon"},"XD":{cssClass:"small-emoticon spaced-emoticon"},"xD":{cssClass:"small-emoticon spaced-emoticon"},"=D":{cssClass:"small-emoticon spaced-emoticon"},"8O":{cssClass:"small-emoticon spaced-emoticon"},"[+=..]":{cssClass:"no-rotate nintendo-controller"}};var a=new RegExp('(\\'+this.escapeCharacters.join('|\\')+')','g');var b='(^|[\\s\\0])';for(var c=this.threeCharacterEmoticons.length-1;c>=0;--c){this.threeCharacterEmoticons[c]=this.threeCharacterEmoticons[c].replace(a,'\\$1');this.threeCharacterEmoticons[c]=new RegExp(b+'('+this.threeCharacterEmoticons[c]+')','g');}for(var c=this.twoCharacterEmoticon s.length-1;c>=0;--c){this.twoCharacterEmoticons[c]=this.twoCharacterEmoticons[c].replace(a,'\\$1');this.twoCharacterEmoticons[c]=new RegExp(b+'('+this.twoCharacterEmoticons[c]+')','g');}for(var d in this.specialEmoticons){this.specialEmoticons[d].regexp=d.replace(a,'\\$1');this.specialEmoticons[d].regexp=new RegExp(b+'('+this.specialEmoticons[d].regexp+')','g');}this.defaults={animate:true,delay:500,exclude:'pre,code,.no-emoticons'};};CSSEmoticon.prototype.emoticonize=function(a,b){var c={};for(var d in this.defaults)c[d]=this.defaults[d];for(var d in b)c[d]=b[d];var e='span.css-emoticon';if(c.exclude)e+=','+c.exclude;var f=e.split(',');var g='css-emoticon';if(c.animate)g+=' un-transformed-emoticon animated-emoticon';for(var h in this.specialEmoticons){var i=g+" "+this.specialEmoticons[h].cssClass;a=a.replace(this.specialEmoticons[h].regexp,"$1<span class='"+i+"'>$2</span>");}for(var d in this.threeCharacterEmoticons){var j=this.threeCharacterEmoticons[d];a=a.replace(j,"$1<span clas s='"+g+"'>$2</span>");}for(var d in this.twoCharacterEmoticons){var j=this.twoCharacterEmoticons[d];a=a.replace(j,"$1<span class='"+g+" spaced-emoticon'>$2</span>");}if(c.animate)setTimeout(function(){var a=document.body.getElementsByClassName("un-transformed-emoticon");for(var b in a)if(typeof a[b]=="object")a[b].classList.remove("un-transformed-emoticon");},c.delay);return a;}; Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/OmUrlFragment.java URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/OmUrlFragment.java?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/OmUrlFragment.java (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/OmUrlFragment.java Sun Feb 5 15:46:17 2017 @@ -75,7 +75,7 @@ public class OmUrlFragment implements Se public static final OmUrlFragment PROFILE_MESSAGES = new OmUrlFragment(AreaKeys.profile, TYPE_MESSAGES); public static final OmUrlFragment CALENDAR = new OmUrlFragment(AreaKeys.user, TYPE_CALENDAR); public static final OmUrlFragment ROOMS_PUBLIC = new OmUrlFragment(AreaKeys.rooms, TYPE_PUBLIC); - + public enum AreaKeys { user , admin @@ -83,7 +83,7 @@ public class OmUrlFragment implements Se , room , rooms } - + public enum MenuActions { dashboardModuleStartScreen , dashboardModuleCalendar @@ -104,13 +104,13 @@ public class OmUrlFragment implements Se , adminModuleOAuth , adminModuleEmail } - + public enum MenuParams { publicTabButton , privateTabButton , myTabButton } - + public static OmUrlFragment get() { String[] arr = getBean(ConfigurationDao.class).getConfValue(CONFIG_DEFAULT_LANDING_ZONE, String.class, "").split("/"); if (arr != null && arr.length == 2) { @@ -122,16 +122,16 @@ public class OmUrlFragment implements Se } return DASHBOARD; } - + public OmUrlFragment(AreaKeys area, String type) { this.setArea(area); this.setType(type); } - + public OmUrlFragment(MenuActions action) { this(action, MenuParams.myTabButton); } - + public OmUrlFragment(MenuActions action, MenuParams params) { switch(action) { case dashboardModuleStartScreen: @@ -228,7 +228,7 @@ public class OmUrlFragment implements Se public void setType(String type) { this.type = type; } - + public static BasePanel getPanel(AreaKeys area, String type) { BasePanel basePanel = null; switch(area) { @@ -301,7 +301,7 @@ public class OmUrlFragment implements Se } return basePanel; } - + public String getLink() { return getBean(ConfigurationDao.class).getBaseUrl() + "#" + getArea().name() + "/" + getType(); } Modified: openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/chat.css URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/chat.css?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/chat.css (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/chat.css Sun Feb 5 15:46:17 2017 @@ -27,47 +27,47 @@ #chatPanel #chat { height: 20px; } -#chatPanel #chat .btn-toolbar { +##chat .btn-toolbar { margin-top: 2px; margin-bottom: 0; margin-left: 5px; } -#chatPanel #chat #chatTabs.ui-tabs { +#chat #chatTabs.ui-tabs { padding: 0; } -#chatPanel #chat #chatTabs.ui-tabs .ui-tabs-nav { +#chat #chatTabs.ui-tabs .ui-tabs-nav { padding: 0; } -#chatPanel #chat #chatTabs.ui-tabs .ui-tabs-nav li { +#chat #chatTabs.ui-tabs .ui-tabs-nav li { margin: 0; } -#chatPanel #chat #chatTabs.ui-tabs .ui-tabs-nav li .ui-icon.ui-icon-close { +#chat #chatTabs.ui-tabs .ui-tabs-nav li .ui-icon.ui-icon-close { float: left; } -#chatPanel #chat #chatTabs.ui-tabs .ui-tabs-nav .ui-tabs-anchor { +#chat #chatTabs.ui-tabs .ui-tabs-nav .ui-tabs-anchor { padding: 2px .5em; float: left; } -#chatPanel #chat .control.block .ui-icon { +#chat .control.block .ui-icon { text-align: center; } -#chatPanel #chat .control.block .label { +#chat .control.block .label { display: inline-block; padding-left: 20px; } -#chatPanel #chat .messageArea .date { - margin-right: 5px; - font-style: italic; - font-size: smaller; +#chat .messageArea .date { + margin-right: 5px; + font-style: italic; + font-size: smaller; } -#chatPanel #chat .messageArea img.profile { +#chat .messageArea img.profile { vertical-align: middle; - max-height: 38px; - max-width: 38px; + max-height: 38px; + max-width: 38px; } -#chatPanel #chat .messageArea .from { +#chat .messageArea .from { margin-left: 5px; - margin-right: 5px; + margin-right: 5px; font-weight: bold; } .ui-tabs .ui-tabs-panel.messageArea { Added: openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/images/folder_explore.png URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/images/folder_explore.png?rev=1781776&view=auto ============================================================================== Binary file - no diff available. Propchange: openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/images/folder_explore.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/images/group.png URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/images/group.png?rev=1781776&view=auto ============================================================================== Binary file - no diff available. Propchange: openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/images/group.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/room.css URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/room.css?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/room.css (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/room.css Sun Feb 5 15:46:17 2017 @@ -271,3 +271,14 @@ padding: .1em .7em; font-weight: bolder; } +.room.sidebar.left .tab.om-icon.big { + padding: 0em 1em 0 2.5em; + line-height: 30px; +} +.room.sidebar.left .tab.om-icon.big.user { + background-image: url(images/group.png); +} +.room.sidebar.left .tab.om-icon.big.file { + background-image: url(images/folder_explore.png); +} + Modified: openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/theme.css URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/theme.css?rev=1781776&r1=1781775&r2=1781776&view=diff ============================================================================== --- openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/theme.css (original) +++ openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/theme.css Sun Feb 5 15:46:17 2017 @@ -322,7 +322,7 @@ html, body { background-image: url(images/email_add.png); } .user.om-icon { - background: url(images/user.png); + background-image: url(images/user.png); } .refresh.om-icon { background-image: url(images/refresh.png); @@ -686,3 +686,4 @@ form .input { width: 75%; vertical-align: middle; } +
