mirror of
				https://github.com/Mibew/java.git
				synced 2025-10-31 02:26:00 +03:00 
			
		
		
		
	Add 'answer' button to invitation
This commit is contained in:
		
							parent
							
								
									bc5c274c8f
								
							
						
					
					
						commit
						862e23e79c
					
				| @ -8,11 +8,11 @@ | ||||
| var Mibew={}; | ||||
| (function(b){b.Objects={};b.Widget=function(a){this.requestedScripts={};this.handlers=[];this.handlersDependences={};this.requestURL=a.requestURL;this.requestTimeout=a.requestTimeout;this.visitorCookieName=a.visitorCookieName;this.inviteStyle=a.inviteStyle;this.locale=a.locale;this.dataToSend={};var c=document.createElement("link");c.setAttribute("rel","stylesheet");c.setAttribute("type","text/css");c.setAttribute("href",a.inviteStyle);document.getElementsByTagName("head")[0].appendChild(c)};b.Widget.prototype.makeRequest= | ||||
| function(){var a=b.Utils.readCookie(this.visitorCookieName);this.dataToSend.entry=escape(document.referrer);this.dataToSend.locale=this.locale;this.dataToSend.rnd=Math.random();!1!==a?this.dataToSend.user_id=a:this.dataToSend.user_id&&delete this.dataToSend.user_id;this.doLoadScript(this.requestURL+"?"+this.getQuery(),"responseScript");this.dataToSend={}};b.Widget.prototype.getQuery=function(){var a=[],c;for(c in this.dataToSend)this.dataToSend.hasOwnProperty(c)&&a.push(c+"="+this.dataToSend[c]); | ||||
| return a.join("&")};b.Widget.prototype.sendToServer=function(a){for(var c in a)if(a.hasOwnProperty(c)){var b=a[c];"string"!==typeof b&&"number"!==typeof b||("string"===typeof b&&(b=encodeURIComponent(b)),this.dataToSend[c]=b)}};b.Widget.prototype.onResponse=function(a){var c=a.load,d=a.handlers,e=a.data;a=a.dependences;var j=this,f;for(f in c)c.hasOwnProperty(f)&&!(f in this.requestedScripts)&&(this.requestedScripts[f]={},this.requestedScripts[f].url=c[f],this.requestedScripts[f].status="loading", | ||||
| this.loadScript(f));for(var h in a)a.hasOwnProperty(h)&&(h in this.handlersDependences||(this.handlersDependences[h]=a[h]));for(c=0;c<d.length;c++){var g=d[c];if(this.canRunHandler(g))b.APIFunctions[g](e);else g in this.handlers||(this.handlers[g]=function(){b.APIFunctions[g](e)})}this.cleanUpAfterRequest();window.setTimeout(function(){j.makeRequest()},this.requestTimeout)};b.Widget.prototype.cleanUpAfterRequest=function(){document.getElementsByTagName("head")[0].removeChild(document.getElementById("responseScript"))}; | ||||
| return a.join("&")};b.Widget.prototype.sendToServer=function(a){for(var c in a)if(a.hasOwnProperty(c)){var b=a[c];"string"!==typeof b&&"number"!==typeof b||("string"===typeof b&&(b=encodeURIComponent(b)),this.dataToSend[c]=b)}};b.Widget.prototype.onResponse=function(a){var c=a.load,d=a.handlers,e=a.data;a=a.dependences;var h=this,f;for(f in c)c.hasOwnProperty(f)&&!(f in this.requestedScripts)&&(this.requestedScripts[f]={},this.requestedScripts[f].url=c[f],this.requestedScripts[f].status="loading", | ||||
| this.loadScript(f));for(var j in a)a.hasOwnProperty(j)&&(j in this.handlersDependences||(this.handlersDependences[j]=a[j]));for(c=0;c<d.length;c++){var g=d[c];if(this.canRunHandler(g))b.APIFunctions[g](e);else g in this.handlers||(this.handlers[g]=function(){b.APIFunctions[g](e)})}this.cleanUpAfterRequest();window.setTimeout(function(){h.makeRequest()},this.requestTimeout)};b.Widget.prototype.cleanUpAfterRequest=function(){document.getElementsByTagName("head")[0].removeChild(document.getElementById("responseScript"))}; | ||||
| b.Widget.prototype.loadScript=function(a){var c=this,b=this.doLoadScript(this.requestedScripts[a].url,a);b.onload=function(){c.scriptReady(a)};b.onreadystatechange=function(){("complete"==this.readyState||"loaded"==this.readyState)&&c.scriptReady(a)}};b.Widget.prototype.doLoadScript=function(a,b){var d=document.createElement("script");d.setAttribute("type","text/javascript");d.setAttribute("src",a);d.setAttribute("id",b);document.getElementsByTagName("head")[0].appendChild(d);return d};b.Widget.prototype.scriptReady= | ||||
| function(a){this.requestedScripts[a].status="ready";for(var b in this.handlers)this.handlers.hasOwnProperty(b)&&this.canRunHandler(b)&&(this.handlers[b](),delete this.handlers[b])};b.Widget.prototype.canRunHandler=function(a){a=this.handlersDependences[a];for(var b=0;b<a.length;b++)if("ready"!=this.requestedScripts[a[b]].status)return!1;return!0};b.Widget.init=function(a){b.Objects.widget=new b.Widget(a);b.Objects.widget.makeRequest()};b.Utils={};b.Utils.createCookie=function(a,b){var d=/([^\.]+\.[^\.]+)$/.exec(document.location.hostname)[1]; | ||||
| document.cookie=""+a+"="+b+"; path=/; "+(d?"domain="+d+";":"")};b.Utils.readCookie=function(a){var b=document.cookie.split("; ");a+="=";for(var d=!1,e=0;e<b.length;e++)if(-1!=b[e].indexOf(a)){d=b[e].substr(a.length);break}return d};b.Invitation={};b.Invitation.create=function(a){var b=a.operatorName,d=a.avatarUrl,e=a.threadUrl;a='<div id="mibewinvitationpopup" style="display: none;"><div id="mibewinvitationclose"><a href="javascript:void(0);" onclick="Mibew.Invitation.reject();">×</a></div>'; | ||||
| b&&(a+='<h1 onclick="Mibew.Invitation.accept();">'+b+"</h1>");d&&(a+='<img id="mibewinvitationavatar" src="'+d+'" title="'+b+'" alt="'+b+'" onclick="Mibew.Invitation.accept();" />');e&&(a+='<iframe id="mibewinvitationframe" src="'+e+'" onload="Mibew.Invitation.show();"></iframe>');a+='<div style="clear: both;"></div></div>';if(b=document.getElementById("mibewinvitation"))b.innerHTML=a};b.Invitation.show=function(){var a=document.getElementById("mibewinvitationpopup");a&&(a.style.display="block")}; | ||||
| b.Invitation.hide=function(){var a=document.getElementById("mibewinvitationpopup");a&&a.parentNode.removeChild(a)};b.Invitation.accept=function(){document.getElementById("mibewAgentButton")&&(document.getElementById("mibewAgentButton").onclick(),b.Invitation.hide())};b.Invitation.reject=function(){b.Objects.widget.sendToServer({invitation_rejected:1});b.Invitation.hide()};b.APIFunctions={};b.APIFunctions.updateUserId=function(a){b.Utils.createCookie(b.Objects.widget.visitorCookieName,a.user.id)}; | ||||
| b.APIFunctions.invitationCreate=function(a){b.Invitation.create(a.invitation)};b.APIFunctions.invitationClose=function(){b.Invitation.hide()}})(Mibew); | ||||
| document.cookie=""+a+"="+b+"; path=/; "+(d?"domain="+d+";":"")};b.Utils.readCookie=function(a){var b=document.cookie.split("; ");a+="=";for(var d=!1,e=0;e<b.length;e++)if(-1!=b[e].indexOf(a)){d=b[e].substr(a.length);break}return d};b.Invitation={};b.Invitation.create=function(a){var b=a.operatorName,d=a.avatarUrl,e=a.threadUrl,h=a.acceptCaption;a='<div id="mibewinvitationpopup" style="display: none;"><div id="mibewinvitationclose"><a href="javascript:void(0);" onclick="Mibew.Invitation.reject();">×</a></div>'; | ||||
| b&&(a+='<h1 onclick="Mibew.Invitation.accept();">'+b+"</h1>");d&&(a+='<img id="mibewinvitationavatar" src="'+d+'" title="'+b+'" alt="'+b+'" onclick="Mibew.Invitation.accept();" />');e&&(a+='<iframe id="mibewinvitationframe" src="'+e+'" onload="Mibew.Invitation.show();"></iframe>');h&&(a+='<div id="mibewinvitationaccept" onclick="Mibew.Invitation.accept();">'+h+"</div>");a+='<div style="clear: both;"></div></div>';if(b=document.getElementById("mibewinvitation"))b.innerHTML=a};b.Invitation.show=function(){var a= | ||||
| document.getElementById("mibewinvitationpopup");a&&(a.style.display="block")};b.Invitation.hide=function(){var a=document.getElementById("mibewinvitationpopup");a&&a.parentNode.removeChild(a)};b.Invitation.accept=function(){document.getElementById("mibewAgentButton")&&(document.getElementById("mibewAgentButton").onclick(),b.Invitation.hide())};b.Invitation.reject=function(){b.Objects.widget.sendToServer({invitation_rejected:1});b.Invitation.hide()};b.APIFunctions={};b.APIFunctions.updateUserId=function(a){b.Utils.createCookie(b.Objects.widget.visitorCookieName, | ||||
| a.user.id)};b.APIFunctions.invitationCreate=function(a){b.Invitation.create(a.invitation)};b.APIFunctions.invitationClose=function(){b.Invitation.hide()}})(Mibew); | ||||
|  | ||||
| @ -374,11 +374,13 @@ var Mibew = {}; | ||||
|      *  - 'avatarUrl' String, URL of operator's avatar; | ||||
|      *  - 'threadUrl': String, URL of the invitation thread which must be | ||||
|      *    dispaly in invitation iframe. | ||||
|      *  - 'acceptCaption': String, caption for accept button. | ||||
|      */ | ||||
|     Mibew.Invitation.create = function (options) { | ||||
|         var operatorName = options.operatorName; | ||||
|         var avatarUrl = options.avatarUrl; | ||||
|         var threadUrl = options.threadUrl; | ||||
|         var acceptCaption = options.acceptCaption; | ||||
| 
 | ||||
|         var popuptext = '<div id="mibewinvitationpopup" style="display: none;">'; | ||||
|         popuptext += '<div id="mibewinvitationclose">' | ||||
| @ -406,6 +408,14 @@ var Mibew = {}; | ||||
|                 + '" onload="Mibew.Invitation.show();"></iframe>'; | ||||
|         } | ||||
| 
 | ||||
|         // Add accept button if acceptCaption set
 | ||||
|         if (acceptCaption) { | ||||
|             popuptext += '<div id="mibewinvitationaccept"' | ||||
|                 + ' onclick="Mibew.Invitation.accept();">' | ||||
|                 + acceptCaption | ||||
|                 + '</div>'; | ||||
|         } | ||||
| 
 | ||||
|         popuptext += '<div style="clear: both;"></div></div>'; | ||||
| 
 | ||||
|         var invitationdiv = document.getElementById("mibewinvitation"); | ||||
|  | ||||
| @ -225,6 +225,7 @@ installed.login_link=Proceed to the login page | ||||
| installed.message=<b>Application installed successfully.</b> | ||||
| installed.notice=You can logon as <b>admin</b> with empty password.<br/><br/><font color="#c13030"><b>!!! For security reasons please change your password immediately and remove the {0} folder from your server.</b></font> | ||||
| invitation.message=Hello, how can I help you? | ||||
| invitation.accept.caption=Answer | ||||
| lang.choose=Choose your language | ||||
| leavemail.body=Your have a message from {0}:\n\n{2}\n\nHis email: {1}\n{3}\n--- \nRegards,\nMibew | ||||
| leavemail.subject=Question from {0} | ||||
|  | ||||
| @ -226,6 +226,7 @@ installed.login_link= | ||||
| installed.message=<b>Установка успешно завершена. </b> | ||||
| installed.notice=Вы можете войти в систему как <b>admin</b> с пустым паролем.<br/><br/><font color="#c13030"><b>!!! В целях безопасности, удалите, пожалуйста, каталог {0} с вашего сервера и поменяйте пароль.</b></font> | ||||
| invitation.message=Здравствуйте! Могу ли я Вам помочь? | ||||
| invitation.accept.caption=Îòâåòèòü | ||||
| lang.choose=Выберите ваш язык | ||||
| leavemail.body=Ваш посетитель '{0}' оставил сообщение:\n\n{2}\n\nЕmail: {1}\n{3}\n--- \nС уважением,\nВаш Веб Мессенджер | ||||
| leavemail.subject=Вопрос от {0} | ||||
|  | ||||
| @ -87,3 +87,8 @@ | ||||
|     border: 1px solid #000; | ||||
|     background-color: #FFFFFF; | ||||
| } | ||||
| #mibewinvitationaccept { | ||||
|     font-weight: bold; | ||||
|     text-align: center; | ||||
|     cursor: pointer; | ||||
| } | ||||
|  | ||||
| @ -59,6 +59,7 @@ function tpl_content() { global $page, $webimroot; | ||||
| 		</div> | ||||
| 		<h1 onclick="void(0);"><?php echo $page['operatorName'] ?></h1>
 | ||||
| 		<div id="mibewinvitationframe"><?php echo getlocal("invitation.message"); ?></div>
 | ||||
| 		<div id="mibewinvitationaccept" onclick="void(0);"><?php echo getlocal("invitation.accept.caption"); ?></div>
 | ||||
| 		<div style="clear: both;"></div> | ||||
| 	</div> | ||||
| </div> | ||||
|  | ||||
| @ -95,7 +95,8 @@ if (Settings::get('enabletracking') == '1') { | ||||
| 			'operatorName' => htmlspecialchars($operator_name), | ||||
| 			'avatarUrl' => htmlspecialchars($operator['vcavatar']), | ||||
| 			'threadUrl' => get_app_location(true, is_secure_request()) | ||||
| 				. '/client.php?act=invitation' | ||||
| 				. '/client.php?act=invitation', | ||||
| 			'acceptCaption' => getlocal('invitation.accept.caption') | ||||
| 		); | ||||
| 
 | ||||
| 		$_SESSION['invitation_threadid'] = $thread->id; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user