151 { |
151 { |
152 our_nick += "_"; |
152 our_nick += "_"; |
153 muc.join(support_config.team_rooms[question_type], our_nick); |
153 muc.join(support_config.team_rooms[question_type], our_nick); |
154 } |
154 } |
155 else |
155 else |
156 alert("unhandled error: " + error); //FIXME |
156 set_ui_state("error"); |
157 } |
157 } |
158 }); |
158 }); |
159 } |
159 } |
160 |
160 |
161 function build_ui() |
161 function build_ui() |
162 { |
162 { |
163 return $(' \ |
163 return $(" \ |
164 <div id="support-chat"> \ |
164 <div id='support-chat'> \ |
165 <div id="support-question"> \ |
165 <div id='support-question'> \ |
166 <h2>What is the nature of your question?</h2> \ |
166 <h2>What is the nature of your question?</h2> \ |
167 <select id="support-question-type"> \ |
167 <select id='support-question-type'> \ |
168 <option>Sales</option> \ |
168 <option>Sales</option> \ |
169 <option>Technical</option> \ |
169 <option>Technical</option> \ |
170 </select> \ |
170 </select> \ |
171 <h2>What is your name?</h2> \ |
171 <h2>What is your name?</h2> \ |
172 <input id="support-question-name" type="text" /> \ |
172 <input id='support-question-name' type='text' /> \ |
173 <h2>Your question:</h2> \ |
173 <h2>Your question:</h2> \ |
174 <textarea id="support-question-text"></textarea><br/> \ |
174 <textarea id='support-question-text'></textarea><br/> \ |
175 <input id="support-question-submit" type="submit" /> \ |
175 <input id='support-question-submit' type='submit' /> \ |
176 </div> \ |
176 </div> \ |
177 <div id="support-wait"> \ |
177 <div id='support-wait'> \ |
178 Please wait while we find someone to \ |
178 Please wait while we find someone to \ |
179 answer your query... \ |
179 answer your query... \ |
180 <br/><br/><br/><br/> \ |
180 <br/><br/><br/><br/> \ |
181 <center><img src="waiting.gif" alt="Waiting" /></center> \ |
181 <center><img src='waiting.gif' alt='Waiting' /></center> \ |
182 </div> \ |
182 </div> \ |
183 <div id="support-converse"> \ |
183 <div id='support-converse'> \ |
184 <div id="support-log"></div> \ |
184 <div id='support-log'></div> \ |
185 <div id="support-input-container"><textarea id="support-input" type="text" value=""></textarea></div> \ |
185 <div id='support-input-container'><textarea id='support-input' type='text' value=''></textarea></div> \ |
186 <input id="support-send-button" type="submit" value="Send" /> \ |
186 <input id='support-send-button' type='submit' value='Send' /> \ |
187 <div style="clear:right;"></div> \ |
187 <div style='clear:right;'></div> \ |
188 </div> \ |
188 </div> \ |
189 <div id="support-offline"> \ |
189 <div id='support-offline'> \ |
190 <p>Sorry, there are no assistants available \ |
190 <p>Sorry, there are no assistants available \ |
191 to answer your question at the moment. \ |
191 to answer your question at the moment. \ |
192 </p> \ |
192 </p> \ |
193 <div id="support-offline-form"> \ |
193 <div id='support-offline-form'> \ |
194 <p>To receive a reply to your question via \ |
194 <p>To receive a reply to your question via \ |
195 email, please enter your email address \ |
195 email, please enter your email address \ |
196 below: \ |
196 below: \ |
197 </p> \ |
197 </p> \ |
198 <input id="support-offline-email" type="text" /> \ |
198 <input id='support-offline-email' type='text' /> \ |
199 <input id="support-offline-submit-button" type="submit" value="Submit" /> \ |
199 <input id='support-offline-submit-button' type='submit' value='Submit' /> \ |
200 </div> \ |
200 </div> \ |
201 <div id="support-offline-thanks"> \ |
201 <div id='support-offline-thanks'> \ |
202 <p>Thank you. Your question has been submitted \ |
202 <p>Thank you. Your question has been submitted \ |
203 and will be replied to as soon as an assistant \ |
203 and will be replied to as soon as an assistant \ |
204 becomes available.</p> \ |
204 becomes available.</p> \ |
205 </div> \ |
205 </div> \ |
206 </div> \ |
206 </div> \ |
|
207 <div id='support-error'> \ |
|
208 <p>Sorry, there is a problem with the live support \ |
|
209 service at the moment. Please see our \ |
|
210 <a href='"+support_config.alternative_url+"'>alternative \ |
|
211 support channels</a> to receive assistance. \ |
|
212 </p> \ |
|
213 </div> \ |
207 </div> \ |
214 </div> \ |
208 '); |
215 "); |
209 } |
216 } |
210 |
217 |
211 function display_ui() |
218 function display_ui() |
212 { |
219 { |
213 // Display pop-up, showing question form |
220 // Display pop-up, showing question form |
214 var ui = build_ui(); |
221 var ui = build_ui(); |
215 |
222 |
216 ui.appendTo("body"); |
223 ui.appendTo("body"); |
217 |
224 |
218 if(start_connection()) |
225 $("#support-question-submit").click(on_question_submit); |
219 { |
226 $("#support-offline-submit-button").click(function () |
220 $("#support-question-submit").click(on_question_submit); |
227 { |
221 $("#support-offline-submit-button").click(function () |
228 $("#support-offline-form").hide(); |
222 { |
229 conn.send($msg({to: support_config.offline_support, type: "normal"}) |
223 $("#support-offline-form").hide(); |
230 .c("subject").t("Support query from " + question_name).up() |
224 conn.send($msg({to: support_config.offline_support, type: "normal"}) |
231 .c("body").t(question_text + "\n\nReply via email to: "+ |
225 .c("subject").t("Support query from " + question_name).up() |
232 $("#support-offline-email").val())); |
226 .c("body").t(question_text + "\n\nReply via email to: "+ |
233 $("#support-offline-thanks").show(); |
227 $("#support-offline-email").val())); |
234 }); |
228 $("#support-offline-thanks").show(); |
235 |
229 }); |
236 ui.dialog({ |
230 ui.dialog({ |
237 title:"Live Support", |
231 title:"Live Support", |
238 height: 400, |
232 height: 400, |
239 width: 285 |
233 width: 285 |
240 }); |
234 }); |
241 |
|
242 if(!start_connection()) |
|
243 { |
|
244 set_ui_state("error"); |
235 } |
245 } |
236 } |
246 } |
237 |
247 |
238 /*** Helper functions */ |
248 /*** Helper functions */ |
239 function htmlescape(s) |
249 function htmlescape(s) |