Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

230
LINES

< > BotCompany Repo | #1011983 // Stefan's/Smart Bot's Chat Template (including JavaScript)

HTML

1  
<html>
2  
<head>
3  
<title>Chat Popup Test</title>
4  
 <link href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css' rel='stylesheet'>
5  
                                <style>@import url(https://fonts.googleapis.com/css?family=Oswald:400,300);
6  
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
7  
@import url(https://fonts.googleapis.com/css?family=#BOTFONT#);
8  
body
9  
{
10  
    font-family: 'Open Sans', sans-serif;
11  
}
12  
13  
.morebox {
14  
  float: left;
15  
  width: 722px;
16  
  border: 1px solid #b0b0b0;
17  
  padding: 10px;
18  
  margin-left: 30px;
19  
}
20  
21  
.popup-box {
22  
   background-color: #ffffff;
23  
    border: 1px solid #b0b0b0;
24  
    /* XXX bottom: 0;*/
25  
    top: 0;
26  
    /*display: none;*/
27  
    height: 415px;
28  
    /*position: fixed;
29  
    right: 70px;*/
30  
    width: 600px; /* actual chat width, was 300 */
31  
    float: left; /* XX */
32  
    margin: 0 auto auto auto;
33  
    font-family: 'Open Sans', sans-serif;
34  
}
35  
36  
#RELATIVESTYLES#
37  
38  
#actionMsg {
39  
    position: absolute;
40  
    z-index: 9999;
41  
    left: 0;
42  
    top: 0; // bottom 
43  
    height: 20px;
44  
    /*width: 300px;*/
45  
    width: auto;
46  
    
47  
    background-color: white;
48  
    display: none;
49  
}
50  
</style>
51  
<script type='text/javascript' src='//code.jquery.com/jquery-1.10.2.min.js'></script>
52  
                                <script type='text/javascript' src='//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js'></script>
53  
                                <script type='text/javascript'>  $(function(){
54  
$("#addClass").click(function () {
55  
          $('#qnimate').addClass('popup-box-on');
56  
            });
57  
          
58  
            $("#removeClass").click(function () {
59  
          $('#qnimate').removeClass('popup-box-on');
60  
            });
61  
  });
62  
63  
var haveFocus = true;
64  
$(window).focus(function() { haveFocus = true; });
65  
$(window).blur(function() { haveFocus = false; });
66  
  
67  
var showActions = false;
68  
  
69  
function showAction(action) {
70  
  if (showActions) {
71  
    $("#actionMsg").html(action);
72  
    $("#actionMsg").show();
73  
  }
74  
}
75  
  
76  
function appendAction(action) {
77  
  if (showActions) {
78  
    $("#actionMsg").append(" | " + action);
79  
    $("#actionMsg").show();
80  
  }
81  
}
82  
83  
function hideAction() {
84  
  $("#actionMsg").hide();
85  
  $("#actionMsg").html("");
86  
}
87  
88  
function scrollDown() {
89  
  //document.body.scrollTop = document.body.scrollHeight;
90  
  $("#scrollme").scrollTop(1E10);
91  
}
92  
93  
function htmldecode(s) {
94  
  var parser = new DOMParser;
95  
  var dom = parser.parseFromString('<!doctype html><body>' + s, 'text/html');
96  
  return dom.body.textContent;
97  
}
98  
99  
function showNotification(title, text) {
100  
  if (!window.Notification) return;
101  
  
102  
  if (Notification.permission === "granted") {
103  
    var n = new Notification(title, { body: text });
104  
  } else if (Notification.permission !== "denied")
105  
    Notification.requestPermission(function(status) {
106  
      var n = new Notification(title, { body: text });
107  
    });
108  
}
109  
110  
var n = #N#;
111  
var vis = #VISITORS#;
112  
var interval = 1000;
113  
nInitial = n;
114  
115  
function start() {
116  
  url = "#INCREMENTALURL#";
117  
  if (url != '' && url != ("#INC" + "REMENTALURL#")) {
118  
    var fullURL = url + "?v=" + vis + "&a=" + n;
119  
    showAction("Loading " + fullURL);
120  
    $.get(fullURL, function(src) {
121  
      showAction("Loaded");
122  
      
123  
      var match = src.match(/<!-- vis (\d+) --/);
124  
      if (match != null) {
125  
        var vn = $("#visnum");
126  
        if (vn != null) {
127  
          vis = match[1];
128  
          vn.html(match[1]);
129  
        }
130  
      }
131  
      
132  
      var match = src.match(/<!-- (\d+)/);
133  
      if (match != null) {
134  
        // We have new messages!
135  
        n = parseInt(match[1]);
136  
        $(".direct-chat-messages").append(src);
137  
        scrollDown();
138  
        showAction("Appended " + src.length);
139  
        match = src.match(/<!-- TEXT -->(.*?)<!-- END TEXT -->/);
140  
        if (match != null) {
141  
          //if (document.hidden)
142  
          //if (!haveFocus)
143  
          if (!document.hasFocus())
144  
            showNotification("New chat message", htmldecode(match[1]));
145  
        } else
146  
          appendAction("Not notifying");
147  
      } else
148  
        showAction("n=" + n + " (initial=" + nInitial + ")");
149  
      appendAction("Rescheduling");
150  
      setTimeout(start, interval);
151  
      appendAction("Rescheduled");
152  
    }, 'text')
153  
      .error(function(jqXHR, textStatus, errorThrown) {
154  
        showAction("Rescheduling after fail: " + errorThrown + " / " + textStatus);
155  
        setTimeout(start, interval);
156  
      })
157  
      /*.fail(function() {
158  
        showAction("Rescheduling after fail");
159  
        setTimeout(start, interval);
160  
      })*/;
161  
  }
162  
}
163  
</script>
164  
165  
<!-- COMODO -->
166  
<script type="text/javascript"> //<![CDATA[ 
167  
var tlJsHost = ((window.location.protocol == "https:") ? "https://secure.comodo.com/" : "http://www.trustlogo.com/");
168  
document.write(unescape("%3Cscript src='" + tlJsHost + "trustlogo/javascript/trustlogo.js' type='text/javascript'%3E%3C/script%3E"));
169  
//]]>
170  
</script>
171  
<!-- END COMODO -->
172  
173  
</head>
174  
<body onLoad='scrollDown(); start();'>
175  
<div id="actionMsg"></div>
176  
177  
<form>
178  
179  
<table><tr><td><!-- HEAD -->
180  
<a href="http://botcompany.de"><img style="display: block; margin-left: auto; margin-right: auto" src="http://eyeocr.sourceforge.net/filestore/filestore.php?cmd=serve&file=blob_1011942&contentType=image/png" width="128" height="128" title="Smart Bot"></a><!-- /HEAD -->
181  
<div class="popup-box popup-box-on chat-popup" id="qnimate">
182  
    		  <div class="popup-head">
183  
				<div class="popup-head-left pull-left"><img src="http://eyeocr.sourceforge.net/filestore/filestore.php?cmd=serve&file=blob_1008323&contentType=image/png" alt="Bot Image"> $HEADING | <a href="http://ai1.lol/wiki/" target="_blank">More</a></div>
184  
					  <div class="popup-head-right pull-right">
185  
					  <!--
186  
						<div class="btn-group">
187  
    								  <button class="chat-header-button" data-toggle="dropdown" type="button" aria-expanded="false">
188  
									   <i class="glyphicon glyphicon-cog"></i> </button>
189  
									  <ul role="menu" class="dropdown-menu pull-right">
190  
										<li><a href="#">Media</a></li>
191  
										<li><a href="#">Block</a></li>
192  
										<li><a href="#">Clear Chat</a></li>
193  
										<li><a href="#">Email Chat</a></li>
194  
									  </ul>
195  
						</div>
196  
						
197  
						<button data-widget="remove" id="removeClass" class="chat-header-button pull-right" type="button"><i class="glyphicon glyphicon-off"></i></button>
198  
						-->
199  
                      </div>
200  
			  </div>
201  
			  
202  
			<div id="scrollme" class="popup-messages">
203  
204  
			<div class="direct-chat-messages">
205  
			<!-- MSGS HERE -->
206  
			</div>
207  
			<div class="popup-messages-footer">
208  
			<textarea autofocus id="status_message" placeholder="Type a message..." rows="10" cols="30" name="message" onkeydown="if (event.keyCode == 13 && !event.shiftKey && !event.ctrlKey) { if (status_message.value.toUpperCase() == 'CLEAR') form.submit(); else { url = '#MSGURL#' + encodeURIComponent(status_message.value); showAction('Submitting ' + url); $.get(url); } this.select(); return false; }"></textarea>
209  
			<div class="btn-footer">
210  
			<!--
211  
			<button class="bg_none"><i class="glyphicon glyphicon-film"></i> </button>
212  
			<button class="bg_none"><i class="glyphicon glyphicon-camera"></i> </button>
213  
            <button class="bg_none"><i class="glyphicon glyphicon-paperclip"></i> </button>
214  
      -->
215  
      <!--
216  
			<button class="bg_none pull-right"><i class="glyphicon glyphicon-thumbs-up"></i> </button>
217  
		  -->
218  
			</div>
219  
			</div>
220  
	  </div>
221  
	  
222  
	  </td><td valign="top">
223  
	  
224  
	  <div class="morebox">
225  
	    <!--MORE STUFF HERE-->
226  
	  </div>
227  
	  
228  
</td></tr></table>
229  
</form>
230  
</body></html>

Author comment

Began life as a copy of #1009081

download  render html  show line numbers   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011983
Snippet name: Stefan's/Smart Bot's Chat Template (including JavaScript)
Eternal ID of this version: #1011983/28
Text MD5: c718adc2be369244842314fc2e19dd14
Author: stefan
Category: javax / web chat bots
Type: HTML
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-01 09:21:08
Source code size: 7620 bytes / 230 lines
Pitched / IR pitched: No / No
Views / Downloads: 347 / 17205
Version history: 27 change(s)
Referenced in: [show references]