Add in the common.js
1 var sendTypingAlertStopTimerID;
2 var hasSentTypingAlert = false;
3
4 // Request for sending typing alert [typing start]
5 function sendTypingAlertStart(contactID) {
6
7 if (!hasSentTypingAlert) {
8 hasSentTypingAlert = true;
9 var fullAddress = getContactFullAddress(contactID);
10 params = "sendTypingAlert=&messageText=[typing start]&contactID=" + fullAddress;
11 new Ajax.Request(sendMessagesUrl, {
12 onSuccess : function(xh) {
13 outputTypingAlertStart = JSON.parse(xh.responseText);
14 if (outputTypingAlertStart.code == 200) {
15 sendTypingAlertStopTimerID = setTimeout("sendTypingAlertStop('" + contactID + "')", 5000);
16 } else {
17 hasSentTypingAlert = false;
18 }
19 },
20 parameters : params
21 });
22 } else if (sendTypingAlertStopTimerID != null) {
23 clearTimeout(sendTypingAlertStopTimerID);
24 sendTypingAlertStopTimerID = setTimeout("sendTypingAlertStop('" + contactID + "')", 5000);
25 }
26 }
27
28 // Request for sending typing alert [typing stop]
29 function sendTypingAlertStop(contactID) {
30
31 sendTypingAlertStopTimerID = null;
32 var fullAddress = getContactFullAddress(contactID);
33 params = "sendTypingAlert=&messageText=[typing stopped]&contactID=" + fullAddress;
34 new Ajax.Request(sendMessagesUrl, {
35 onSuccess : function(xh) {
36 hasSentTypingAlert = false;
37 },
38 parameters : params
39 });
40 }
Added at the end.
1 // Request for sending typing alert
2 function requestSubmitOnKeyPress() {
3
4 // parse userId
5 var contactID = impsMceArrayObj[tinyMCE.selectedInstance.iframeElement.id];
6 sendTypingAlertStart(contactID);
7 }
Added in line 1278 before the return false.
1 // Sending typing alert on key press
2 // Added by Richardo Yao De Loreto
3 if (e.keyCode != 13) { // Don't send typing alert for 'Enter' key
4 requestSubmitOnKeyPress();
5 }
imps-ajax-client-resources.properties: imps.html.searchChatRoom.error.text.noSearchHitRoomName=No chat rooms found where the chat room name is {0}.
1 function searchChatRoom(searchString, searchType) {
2 params = "searchGroup=&query=" + searchString + "&queryType=" + searchType;
3 var noSearchHitRoomNameError = getResourceString("imps.ajax.seachChatRoom.error.text.noSearchHitRoomName",
4 searchString)
5 new Ajax.Request(groupSearchUrl, {
6 method : 'post',
7 onComplete: function(xh) {
8 var output = JSON.parse(xh.responseText);
9 if (output.code != null) {
10 errorHandling('newbuddy_error_msg',noSearchHitRoomNameError,
11 'block');
12 return false;
13 } else if (output.length == 0) {
14 errorHandling('newbuddy_error_msg','No chat rooms found where the chat room name is <entered value>.',
15 'block');
16 return false;
17 } else if (output.length == 1){
18 Windows.close('newBuddy');
19 setNickname(output[0]);
20 } else {
21 Windows.close('newBuddy');
22 searchListObj=output;
23 searchResultsContacts(username,type,groupname);
24 }
25 },
26 parameters: params
27 });
28 }
The alerts should be removed.
The onFailure should be the way you commonly handle error in the project.
The onLoadRequest() function can be called in line 981 of the main.js
example:
"
1 var outputResourceBundleObj;
2 var outputCommonSettingsObj;
3 var outputSpecificClientSettingsObj;
4
5 function onLoadRequest() {
6 new Ajax.Request(getResourceBundleUrl, {
7 method : 'post',
8 onComplete : function(xh) {
9 outputResourceBundleObj = JSON.parse(xh.responseText);
10 try {
11 alert("Example how to display resource:\n" + getResourceString("converter.wvaddress.invalidWVAddress", "","user1@"));
12 } catch (e) {
13 alert(e);
14 }
15 parametersGetCommonSettings = "getCommonSettings=";
16 new Ajax.Request(getConfigUrl, {
17 method : 'post',
18 onComplete : function(xh) {
19 outputCommonSettingsObj = JSON.parse(xh.responseText);
20
21 parametersGetSpecificClientSettings = "getSpecificClientSettings=";
22 new Ajax.Request(getConfigUrl, {
23 method : 'post',
24 onComplete : function(xh) {
25 outputSpecificClientSettingsObj = JSON.parse(xh.responseText);
26 return true;
27 },
28 parameters : parametersGetSpecificClientSettings,
29 onFailure : function() { alert('parametersGetSpecificClientSetting')}
30 })
31 },
32 parameters : parametersGetCommonSettings,
33 onFailure : function() { alert('parametersGetCommonSetting')}
34 })
35 },
36 parameters : null,
37 onFailure : function() { alert('getResourceBundleUrl')}
38 });
39 }
40
41 function getResourceString(key) {
42 var s = outputResourceBundleObj[key];
43 if (!s) return "undefine: "+ key;
44 for (var i = 1; i < arguments.length; i++) {
45 s = s.replace("{" + (i-1) + "}", arguments[i]);
46 }
47 return s;
48 }
Pages : 1