omnomirc.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. /*
  2. OmnomIRC COPYRIGHT 2010,2011 Netham45
  3. OmnomIRC3 rewrite COPYRIGHT 2013 Nathaniel 'Eeems' van Diepen
  4. This file is part of OmnomIRC.
  5. OmnomIRC is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. OmnomIRC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with OmnomIRC. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. (function(window,$,io,undefined){
  17. var $o = window.OmnomIRC = window.$o = function(){
  18. return 'Version: '+$o.version
  19. },
  20. event = function(msg,type){
  21. type=typeof type == 'undefined'?'event':type;
  22. switch(type){
  23. case 'ready':type='document_ready';break;
  24. }
  25. log('['+type.toUpperCase()+'] '+msg);
  26. },
  27. log = function(){
  28. console.log.apply(console,arguments);
  29. },
  30. exists = function(object){
  31. return typeof object != 'undefined';
  32. },
  33. prevent = function(e){
  34. e.stopImmediatePropagation();
  35. e.stopPropagation();
  36. e.preventDefault();
  37. return false;
  38. },
  39. selectedTab=0,
  40. settings = {
  41. colour: false,
  42. timestamp: 'exact',
  43. server: location.origin,
  44. autojoin: [
  45. '#omnimaga',
  46. '#omnimaga-fr',
  47. '#irp'
  48. ],
  49. scrollspeed: 100,
  50. theme: 'default'
  51. },
  52. tabs = [],
  53. properties = {
  54. nick: 'User',
  55. sig: '',
  56. tabs: tabs,
  57. themes: [
  58. 'default'
  59. ]
  60. },
  61. commands = [
  62. {
  63. cmd: 'names',
  64. fn: function(args){
  65. socket.emit('names',{
  66. name: tabs[selectedTab].name
  67. });
  68. }
  69. },
  70. {
  71. cmd: 'me',
  72. help: 'Say something in third person',
  73. fn: function(args){
  74. var i,ret='';
  75. for(i=1;i<args.length;i++){
  76. ret += args[i];
  77. }
  78. socket.emit('message',{
  79. from: 0,
  80. message: properties.nick+' '+ret,
  81. room: tabs[selectedTab].name
  82. });
  83. }
  84. },
  85. {
  86. cmd: 'nick',
  87. fn: function(args){
  88. properties.nick = args[1];
  89. $o.auth();
  90. }
  91. },
  92. {
  93. cmd: 'help',
  94. fn: function(args){
  95. if(typeof args[1] == 'undefined'){
  96. var m = 'Commands:',i;
  97. for(i in commands){
  98. m += ' '+commands[i].cmd;
  99. }
  100. $o.msg(m);
  101. }else{
  102. var i,cmd;
  103. for(i in commands){
  104. cmd = commands[i];
  105. if(cmd.cmd == args[1] && typeof cmd.help != 'undefined'){
  106. $o.msg('Command /'+cmd.cmd+': '+cmd.help);
  107. return;
  108. }
  109. }
  110. $o.send('/help');
  111. }
  112. }
  113. },
  114. {
  115. cmd: 'open',
  116. fn: function(args){
  117. tabs.push({
  118. name: args[1],
  119. title: args[2],
  120. topic: 'Topic for '+args[2]
  121. });
  122. $o.refreshTabs();
  123. }
  124. },
  125. { // clear
  126. cmd: 'clear',
  127. fn: function(args){
  128. $cl.html('');
  129. tabs[selectedTab].body = document.createDocumentFragment();
  130. socket.emit('echo',{
  131. room: tabs[selectedTab].name,
  132. message: 'messages cleared',
  133. name: 0
  134. });
  135. }
  136. },
  137. { // close
  138. cmd: 'close',
  139. fn: function(args){
  140. if(args.length > 1){
  141. $o.removeTab(args[1]);
  142. }else{
  143. $o.removeTab(selectedTab);
  144. }
  145. }
  146. },
  147. { // tabs
  148. cmd: 'tabs',
  149. fn: function(args){
  150. $o.msg('tabs:');
  151. for(var i in tabs){
  152. $o.msg(' ['+i+'] '+tabs[i].name);
  153. }
  154. }
  155. }
  156. ],
  157. handles = [
  158. {
  159. on: 'names',
  160. fn: function(data){
  161. tabs[$o.tabIdForName(data.room)].names = data.names;
  162. if($o.tabIdForName(data.room) == selectedTab){
  163. $o.renderUsers();
  164. }
  165. }
  166. },
  167. {
  168. on: 'authorized',
  169. fn: function(data){
  170. properties.nick = data.nick;
  171. for(var i in settings.autojoin){
  172. socket.emit('join',{
  173. name: settings.autojoin[i]
  174. });
  175. }
  176. }
  177. },
  178. {
  179. on: 'join',
  180. fn: function(data){
  181. event('joined '+data.name);
  182. var flag = tabs.length == 0;
  183. $o.addTab(data.name,data.title);
  184. if(flag){
  185. $o.selectTab(0);
  186. }
  187. }
  188. },
  189. {
  190. on: 'reconnect',
  191. fn: function(data){
  192. event('reconnected');
  193. $o.auth();
  194. }
  195. },
  196. {
  197. on: 'message',
  198. fn: function(data){
  199. event('recieved message');
  200. var date = new Date(),
  201. string,
  202. time = date.getTime(),
  203. child,
  204. i,
  205. msg = function(msg){
  206. string = '<span class="cell date_cell">[<abbr class="date date_'+time+'" title="'+date.toISOString()+'"></abbr>]</span>';
  207. child = $('<li>').html(string+'<span class="cell">'+msg.htmlentities().replace(
  208. /(https?:\/\/(([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?))/g,
  209. "<a href=\"$1\" title=\"\">$1</a>"
  210. )+'</span>');
  211. $o.msg({html:child},data.room);
  212. };
  213. if(data.from != 0){
  214. msg(' <'+data.from+'> '+data.message);
  215. }else{
  216. msg(' * '+data.message);
  217. }
  218. abbrDate('abbr.date_'+time);
  219. if(settings.timestamp == ''){
  220. $('.date_cell').css('visibility','hidden');
  221. }else{
  222. $('.date_cell').css('visibility','visible');
  223. }
  224. }
  225. }
  226. ],
  227. hooks = [
  228. {
  229. type: 'style',
  230. hook: 'load',
  231. fn: function(){
  232. }
  233. }
  234. ],
  235. abbrDate = function(selector){
  236. if(settings.timestamp == 'fuzzy'){
  237. $(selector).timeago();
  238. }else{
  239. $(selector).each(function(){
  240. var timestamp = settings.timestamp,
  241. i,
  242. text='',
  243. date = new Date($(this).attr('title'));
  244. if(timestamp == 'exact'){
  245. timestamp = 'H:m:s t';
  246. }
  247. for(i=0;i<timestamp.length;i++){
  248. switch(timestamp[i]){
  249. case 'H':text+=((date.getHours()+11)%12)+1;break;
  250. case 'h':text+=date.getHours();break;
  251. case 'm':text+=(date.getMinutes()>9?'':'0')+date.getMinutes();break;
  252. case 's':text+=(date.getSeconds()>9?'':'0')+date.getSeconds();break;
  253. case 't':text+=(date.getHours()>11)?'pm':'am';break;
  254. default:text+=timestamp[i];
  255. }
  256. }
  257. $(this).text(text);
  258. }).timeago('dispose');
  259. }
  260. },
  261. socket,$i,$s,$h,$cl,$tl,hht;
  262. $.extend($o,{
  263. version: '3.0',
  264. register: {
  265. theme: function(name){
  266. if(-1==$.inArray(properties.themes,name)){
  267. properties.themes.push(name);
  268. return true;
  269. }
  270. return false;
  271. },
  272. command: function(name,fn,help){
  273. if(-1==$.inArray(commands,name)){
  274. var o = {
  275. cmd: name,
  276. fn: fn
  277. };
  278. if(typeof help != 'undefined'){
  279. o.help = help;
  280. }
  281. commands.push(o);
  282. return true;
  283. }
  284. return false;
  285. },
  286. plugin: function(){
  287. }
  288. },
  289. connect: function(server){
  290. if($o.connected()){
  291. socket.disconnect();
  292. socket = undefined;
  293. }
  294. if(typeof server == 'undefined'){
  295. server = settings.server;
  296. }
  297. socket = io.connect(server);
  298. for(var i in handles){
  299. socket.on(handles[i].on,handles[i].fn);
  300. }
  301. $o.auth();
  302. },
  303. auth: function(){
  304. socket.emit('auth',{
  305. nick: properties.nick
  306. // TODO - send authorization info
  307. });
  308. },
  309. connected: function(){
  310. return typeof socket != 'undefined';
  311. },
  312. get: function(name,formatted){
  313. if(typeof formatted == 'undefined'){
  314. return exists(settings[name])?settings[name]:false;
  315. }else{
  316. var val = $o.get(name),
  317. type,
  318. values = false;
  319. switch(name){
  320. case 'theme':
  321. type = 'select';
  322. values = properties.themes;
  323. break;
  324. case 'autojoin':type = 'array';break;
  325. case 'timestamp':type = 'string';break;
  326. default:
  327. type = typeof val;
  328. }
  329. return {
  330. type: type,
  331. val: val,
  332. values: values,
  333. name: name
  334. };
  335. }
  336. },
  337. set: function(name,value,render){
  338. if(exists(settings[name])){
  339. settings[name] = value;
  340. $.localStorage('settings',JSON.stringify(settings));
  341. switch(name){
  342. case 'timestamp':
  343. abbrDate('abbr.date');
  344. if(settings.timestamp == ''){
  345. $('.date_cell').css('visibility','hidden');
  346. }else{
  347. $('.date_cell').css('visibility','visible');
  348. }
  349. break;
  350. }
  351. if(typeof render == 'undefined'){
  352. $o.renderSettings();
  353. }
  354. return true;
  355. }else{
  356. return false;
  357. }
  358. },
  359. renderSettings: function(){
  360. var name,setting,frag = document.createDocumentFragment(),item;
  361. for(name in settings){
  362. setting = $o.get(name,true);
  363. switch(setting.type){
  364. case 'array':
  365. item = $('<input>')
  366. .attr({
  367. type: 'text',
  368. id: 'setting_'+name
  369. })
  370. .val(setting.val)
  371. .change(function(){
  372. $o.set(this.id.substr(8),$(this).val().split(','),false);
  373. });
  374. break;
  375. case 'boolean':
  376. item = $('<input>')
  377. .attr({
  378. type: 'checkbox',
  379. id: 'setting_'+name
  380. })
  381. .change(function(){
  382. $o.set(this.id.substr(8),$(this).is(':checked'),false);
  383. });
  384. if(setting.val){
  385. item.attr('checked','checked');
  386. }
  387. break;
  388. case 'number':
  389. case 'string':default:
  390. item = $('<input>')
  391. .attr({
  392. type: 'text',
  393. id: 'setting_'+name
  394. })
  395. .val(setting.val)
  396. .change(function(){
  397. $o.set(this.id.substr(8),$(this).val(),false);
  398. });
  399. }
  400. $(frag).append(
  401. $('<li>')
  402. .addClass('row')
  403. .append(
  404. $('<span>')
  405. .text(name)
  406. .addClass('cell')
  407. )
  408. .append(
  409. $('<span>')
  410. .append(item)
  411. .addClass('cell')
  412. )
  413. );
  414. }
  415. $('#settings-list').html(frag);
  416. },
  417. renderUsers: function(){
  418. event('Rendering userlist');
  419. var $ul = $('#user-list').html(''),
  420. i,
  421. names = tabs[selectedTab].names;
  422. for(i in names){
  423. $ul.append(
  424. $('<li>').text(names[i])
  425. );
  426. }
  427. },
  428. selectedTab: function(){
  429. return selectedTab;
  430. },
  431. prop: function(name){
  432. return exists(properties[name])?properties[name]:null;
  433. },
  434. send: function(msg){
  435. if(msg !== ''){
  436. if(msg[0] == '/' && msg[1] != '/'){
  437. var args = msg.split(' '),
  438. cmd = args[0].substr(1),
  439. i;
  440. event(msg,'command');
  441. for(i in commands){
  442. if(commands[i].cmd == cmd){
  443. commands[i].fn(args);
  444. return;
  445. }
  446. }
  447. $o.msg(cmd+' is not a valid command.');
  448. }else{
  449. event(msg,'send');
  450. socket.emit('message',{
  451. message: msg,
  452. room: tabs[selectedTab].name,
  453. from: properties.nick
  454. });
  455. }
  456. }
  457. },
  458. msg: function(msg,tabName){
  459. var frag;
  460. if(typeof tabName == 'undefined' || tabName == tabs[selectedTab].name){
  461. frag = document.createDocumentFragment();
  462. }else{
  463. frag = tabs[$o.tabIdForName(tabName)].body;
  464. }
  465. switch(typeof msg){
  466. case 'string':
  467. $(frag).append($('<li>').html(msg.htmlentities()));
  468. break;
  469. case 'object':
  470. if(typeof msg.html == 'undefined'){
  471. $(frag).append($('<li>').html('&lt;'+msg.user+'&gt;&nbsp;'+msg.text.htmlentities()));
  472. }else{
  473. $(frag).append(msg.html);
  474. }
  475. break;
  476. }
  477. $(tabs[$o.tabIdForName(tabName) || selectedTab].body).append(frag);
  478. var scroll = [],i,html;
  479. for(i in tabs){
  480. html = '';
  481. $(tabs[i].body).children().each(function(){
  482. html += this.outerHTML;
  483. });
  484. scroll.push({
  485. name: tabs[i].name,
  486. body: html,
  487. date: new Date().toString()
  488. });
  489. }
  490. $.localStorage('tabs',scroll);
  491. if(typeof tabName == 'undefined' || tabName == tabs[selectedTab].name){
  492. $o.selectTab(selectedTab);
  493. }
  494. },
  495. event: function(event_name,message){
  496. event(message,event_name);
  497. },
  498. selectTab: function(id){
  499. event(id+' '+tabs[id].name,'tab_select');
  500. if(id<tabs.length&&id>=0){
  501. selectedTab=id;
  502. }
  503. $tl.children('.clicked').removeClass('clicked');
  504. $($tl.children().get(id)).addClass('clicked');
  505. $('#title').text(tabs[id].title);
  506. $('#topic').text(tabs[id].topic);
  507. $cl.html($(tabs[id].body).clone());
  508. abbrDate('abbr.date');
  509. $o.renderUsers();
  510. setTimeout(function scrollContent(){
  511. if($c.scrollTop() < $c[0].scrollHeight){
  512. $c.scrollTop($c.scrollTop()+1);
  513. setTimeout(scrollContent,settings.scrollspeed);
  514. }else{
  515. event('scrolling stopped');
  516. }
  517. },settings.scrollspeed);
  518. },
  519. tabIdForName: function(name){
  520. for(var i in tabs){
  521. if(tabs[i].name == name){
  522. return i;
  523. }
  524. }
  525. return false;
  526. },
  527. tabDOM: function(id){
  528. return tabs[id].body;
  529. },
  530. addTab: function(name,title){
  531. event('Tab added: '+name+' with title '+title);
  532. if(!(function(){
  533. for(var i in tabs){
  534. if(name==tabs[i].name){
  535. return true;
  536. }
  537. }
  538. return false;
  539. })()){
  540. var scroll = $.localStorage('tabs'),
  541. i,
  542. frag = document.createDocumentFragment();
  543. for(i in scroll){
  544. if(scroll[i].name == name){
  545. scroll[i].body = $(scroll[i].body).slice(-10);
  546. $(frag)
  547. .append(scroll[i].body)
  548. .append(
  549. $('<li>').html('<span class="to_remove">-- loaded old scrollback for '+scroll[i].date+' --</span>')
  550. )
  551. .children()
  552. .children('.remove')
  553. .remove();
  554. $(frag)
  555. .children()
  556. .children('.to_remove')
  557. .removeClass('to_remove')
  558. .addClass('remove');
  559. event('loading old tab scrollback for '+name+' last saved +'+scroll[i].date);
  560. }
  561. }
  562. tabs.push({
  563. name: name,
  564. title: title,
  565. body: frag,
  566. names: []
  567. });
  568. $tl.append($o.tabObj(tabs.length-1));
  569. $o.refreshTabs();
  570. $o.renderUsers();
  571. }else{
  572. event('Attempted to add an existing tab');
  573. }
  574. },
  575. removeTab: function(id){
  576. if(typeof tabs[id] != 'undefined'){
  577. event('Tab removed: '+tabs[id].name);
  578. socket.emit('part',{
  579. name: tabs[id].name
  580. });
  581. tabs.splice(id,1);
  582. if(selectedTab==id&&selectedTab>0){
  583. selectedTab--;
  584. }
  585. }
  586. $o.refreshTabs();
  587. $cl.html(tabs[selectedTab].body);
  588. $o.renderUsers();
  589. },
  590. tabObj: function(id){
  591. if(typeof id !== 'undefined'){
  592. return $('<div>')
  593. .addClass('tab')
  594. .text(tabs[id].title)
  595. .mouseup(function(e){
  596. switch(e.which){
  597. case 1: // RMB
  598. if($(this).data('id')!=selectedTab){
  599. $o.selectTab($(this).data('id'));
  600. return prevent(e);
  601. }
  602. break;
  603. case 2: // MMB
  604. $(this).children('span.close-button').click();
  605. return prevent(e);
  606. break;
  607. case 3: // LMB
  608. return prevent(e);
  609. break;
  610. default:
  611. return prevent(e);
  612. }
  613. })
  614. .append(
  615. $('<span>')
  616. .addClass('close-button')
  617. .click(function(){
  618. $o.removeTab(id);
  619. return false;
  620. })
  621. .css({
  622. 'position': 'absolute',
  623. 'background-color': 'inherit',
  624. 'top': 0,
  625. 'right': 0
  626. })
  627. .html('&times;')
  628. )
  629. .data('id',id);
  630. }
  631. },
  632. refreshTabs: function(){
  633. $tl.html('');
  634. var i,tab;
  635. for(i in tabs){
  636. tab = $o.tabObj(i);
  637. if(i==selectedTab){
  638. tab.addClass('clicked');
  639. $('#title').text(tabs[i].title);
  640. $('#topic').text(tabs[i].topic);
  641. }
  642. $tl.append(tab);
  643. }
  644. if($tl.get(0).scrollHeight-20 != $tl.scrollTop()){
  645. $('#tabs-scroll-right').removeClass('disabled');
  646. }
  647. if($tl.scrollTop() != 0){
  648. $('#tabs-scroll-left').removeClass('disabled');
  649. }
  650. }
  651. });
  652. String.prototype.htmlentities = function(){
  653. return this.replace(/&/g, '&amp;').replace(/\s/g, '&nbsp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  654. };
  655. $(document).ready(function(){
  656. $.extend(settings,$.parseJSON($.localStorage('settings')));
  657. $.localStorage('settings',JSON.stringify(settings));
  658. $i = $('#input');
  659. $s = $('#send');
  660. $cl = $('#content-list');
  661. $c = $('#content');
  662. $tl = $('#tabs-list');
  663. $h = $('#head');
  664. $s.click(function(){
  665. if(!$s.hasClass('clicked')){
  666. $s.addClass('clicked');
  667. setTimeout(function(){
  668. $s.removeClass('clicked');
  669. },500);
  670. }
  671. $o.send($i.val());
  672. $i.val('');
  673. });
  674. $i.keypress(function(e){
  675. if(e.keyCode == 13){
  676. if(!$s.hasClass('clicked')){
  677. $s.addClass('clicked');
  678. setTimeout(function(){
  679. $s.removeClass('clicked');
  680. },500);
  681. }
  682. $o.send($i.val());
  683. $i.val('');
  684. }
  685. });
  686. $('#settings, #users').click(function(){
  687. $(this).addClass('open');
  688. $(this).children('.close-button').show();
  689. }).hover(function(){
  690. $(this).addClass('hovered');
  691. },function(){
  692. $(this).removeClass('hovered');
  693. }).children('.close-button').click(function(){
  694. $(this).parent().removeClass('open');
  695. $(this).hide();
  696. return false;
  697. }).hide();
  698. $('#users').hoverIntent({
  699. out: function(){
  700. $(this).removeClass('open');
  701. $(this).children('.close-button').hide();
  702. },
  703. timeout: 1000
  704. });
  705. $('#content').click(function(){
  706. $('#settings, #users, #head').removeClass('hovered').removeClass('open');
  707. $('#settings, #users').children('.close-button').hide()
  708. });
  709. $('.unselectable').attr('unselectable','on');
  710. $.contextMenu({
  711. selector: 'div.tab',
  712. items: {
  713. add: {
  714. name: 'New Tab',
  715. icon: 'add',
  716. callback: function(){
  717. $(this).contextMenu('hide');
  718. var title = prompt('Title');
  719. tabs.push({
  720. name: prompt('channel'),
  721. title: title,
  722. topic: 'Topic for '+title
  723. });
  724. $o.refreshTabs();
  725. }
  726. },
  727. s1: '',
  728. close: {
  729. name: 'Close',
  730. icon: 'delete',
  731. callback: function(){
  732. $(this).contextMenu('hide');
  733. $o.removeTab($(this).data('id'));
  734. }
  735. }
  736. },
  737. zIndex: 99999,
  738. trigger: 'right'
  739. });
  740. $.contextMenu({
  741. selector: '#tabs-list',
  742. items: {
  743. add: {
  744. name: 'New Tab',
  745. icon: 'add',
  746. callback: function(){
  747. $(this).contextMenu('hide');
  748. var title = prompt('Title');
  749. tabs.push({
  750. name: prompt('channel'),
  751. title: title,
  752. topic: 'Topic for '+title
  753. });
  754. $o.refreshTabs();
  755. }
  756. }
  757. },
  758. zIndex: 99999,
  759. trigger: 'right'
  760. });
  761. $('#tabs-scroll-right').click(function(){
  762. event('scroll right');
  763. $tl.scrollTop(($tl.scrollTop()||0)+20);
  764. if($tl.get(0).scrollHeight-20 == $tl.scrollTop()){
  765. $('#tabs-scroll-right').addClass('disabled');
  766. }
  767. $('#tabs-scroll-left').removeClass('disabled');
  768. });
  769. $('#tabs-scroll-left').click(function(){
  770. event('scroll left');
  771. $tl.scrollTop(($tl.scrollTop()||0)-20);
  772. if($tl.scrollTop() == 0){
  773. $('#tabs-scroll-left').addClass('disabled');
  774. }
  775. $('#tabs-scroll-right').removeClass('disabled');
  776. });
  777. (function scrollup(){
  778. $('#tabs-scroll-left').click();
  779. if($tl.scrollTop() != 0){
  780. setTimeout(scrollup,10);
  781. }
  782. })();
  783. //DEBUG
  784. /* for(var i=0;i<20;i++){
  785. tabs.push({
  786. name: '#Tab'+i,
  787. title: 'Tab '+i,
  788. topic: 'Topic for tab '+i
  789. });
  790. } */
  791. //END DEBUG
  792. event('Date '+new Date,'ready');
  793. $h.addClass('hovered');
  794. setTimeout(function(){
  795. $h.removeClass('hovered');
  796. },1000);
  797. $o.renderSettings();
  798. $o.connect();
  799. });
  800. delete window.io;
  801. })(window,jQuery,io);
  802. if (!Date.prototype.toISOString) {
  803. Date.prototype.toISOString = function() {
  804. function pad(n) { return n < 10 ? '0' + n : n }
  805. return this.getUTCFullYear() + '-'
  806. + pad(this.getUTCMonth() + 1) + '-'
  807. + pad(this.getUTCDate()) + 'T'
  808. + pad(this.getUTCHours()) + ':'
  809. + pad(this.getUTCMinutes()) + ':'
  810. + pad(this.getUTCSeconds()) + 'Z';
  811. };
  812. }