helpers.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. Template.admin.helpers({
  2. queueCount: function () {
  3. return Queues.find().count();
  4. },
  5. genreQueue: function(type) {
  6. if (type === "none") {
  7. return Queues.find({genres: []}).count();
  8. } else {
  9. return Queues.find({genres: type}).count();
  10. }
  11. },
  12. alertsList: function() {
  13. return Alerts.find({});
  14. },
  15. queues: function () {
  16. var queues = Queues.find({}).fetch();
  17. return queues;
  18. },
  19. usersOnline: function () {
  20. Meteor.call("getUserNum", function (err, num) {
  21. if (err) {
  22. console.log(err);
  23. }
  24. Session.set("userNum", num);
  25. });
  26. return Session.get("userNum");
  27. },
  28. roomUserNum: function () {
  29. var type = this.type;
  30. var userNum = Rooms.findOne({type: type}).users;
  31. return userNum;
  32. },
  33. allUsers: function () {
  34. Meteor.call("getTotalUsers", function (err, num) {
  35. Session.set("allUsers", num);
  36. })
  37. return Session.get("allUsers");
  38. },
  39. playlists: function () {
  40. var playlists = Playlists.find({}).fetch();
  41. playlists.map(function (playlist) {
  42. if (Rooms.find({type: playlist.type}).count() !== 1) {
  43. return;
  44. } else {
  45. playlist.display = Rooms.findOne({type: playlist.type}).display;
  46. return playlist;
  47. }
  48. });
  49. return playlists;
  50. },
  51. reportsCount: function (room) {
  52. room = room.toLowerCase();
  53. var reports = Reports.findOne({room: room});
  54. return reports && "report" in reports ? reports.report.length : 0;
  55. }
  56. });
  57. Template.alerts.helpers({
  58. alerts: function () {
  59. var alerts = Alerts.find({active: true}).fetch();
  60. alerts = alerts.map(function(alert) {
  61. alert.description = replaceURLWithHTMLLinksBlank(alert.description);
  62. return alert;
  63. });
  64. return alerts;
  65. }
  66. });
  67. Template.banned.helpers({
  68. bannedAt: function () {
  69. if (Session.get("ban") !== undefined) {
  70. return Session.get("ban").bannedAt;
  71. }
  72. },
  73. bannedBy: function () {
  74. if (Session.get("ban") !== undefined) {
  75. return Session.get("ban").bannedBy;
  76. }
  77. },
  78. bannedUntil: function () {
  79. if (Session.get("ban") !== undefined) {
  80. return Session.get("ban").bannedUntil;
  81. }
  82. },
  83. bannedReason: function () {
  84. if (Session.get("ban") !== undefined) {
  85. return Session.get("ban").bannedReason;
  86. }
  87. }
  88. });
  89. Template.feedback.helpers({
  90. feedback: function () {
  91. return Feedback.find().fetch().reverse();
  92. }
  93. })
  94. Template.header.helpers({
  95. userId: function () {
  96. return Meteor.userId();
  97. }
  98. });
  99. Template.home.helpers({
  100. currentSong: function () {
  101. var type = this.type;
  102. var room = Rooms.findOne({type: type});
  103. if (room !== undefined) {
  104. return room.currentSong;
  105. } else {
  106. return false;
  107. }
  108. },
  109. userNum: function () {
  110. var type = this.type;
  111. var userNum = Rooms.findOne({type: type}).users;
  112. return userNum;
  113. },
  114. currentPrivateSong: function () {
  115. var name = this.name;
  116. var room = CommunityStations.findOne({name: name});
  117. if (room !== undefined) {
  118. return room.currentSong;
  119. } else {
  120. return false;
  121. }
  122. },
  123. userPrivateNum: function () {
  124. var name = this.name;
  125. var userNum = CommunityStations.findOne({name: name}).users;
  126. return userNum;
  127. }
  128. });
  129. Template.playlist.helpers({
  130. playlist_songs: function () {
  131. var songIDs = Playlists.find({"type": Session.get("type")}).fetch()[0].songs
  132. var data = [];
  133. songIDs.forEach(function(id){
  134. var song = Songs.findOne({"mid": id});
  135. data.push(song);
  136. })
  137. if (data !== undefined) {
  138. data.map(function (song) {
  139. if (Session.get("currentSong") !== undefined && song.mid === Session.get("currentSong").mid) {
  140. song.current = true;
  141. } else {
  142. song.current = false;
  143. }
  144. return song;
  145. });
  146. return data;
  147. } else {
  148. return [];
  149. }
  150. },
  151. nextSong: function(){
  152. var song;
  153. var data = Playlists.find({"type": Session.get("type")}).fetch()[0].songs;
  154. for(var i = 0; i < data.length; i++){
  155. if(Session.get("currentSong") !== undefined && data[i] === Session.get("currentSong").mid){
  156. if(i === data.length - 1){
  157. song = Songs.findOne({"mid": data[0]});
  158. Session.set("nextSong", [song])
  159. } else{
  160. song = Songs.findOne({"mid": data[i+1]});
  161. Session.set("nextSong", [song]);
  162. }
  163. }
  164. }
  165. return Session.get("nextSong");
  166. }
  167. });
  168. Template.profile.helpers({
  169. "real_name": function () {
  170. return Session.get("real_name");
  171. },
  172. "username": function () {
  173. return Session.get("username")
  174. },
  175. "first_joined": function () {
  176. return moment(Session.get("first_joined")).format("DD/MM/YYYY");
  177. },
  178. "rank": function () {
  179. return Session.get("rank");
  180. },
  181. "songs_requested": function () {
  182. return Session.get("songs_requested");
  183. },
  184. loaded: function () {
  185. return Session.get("loaded");
  186. },
  187. likedSongs: function () {
  188. var likedArr = [];
  189. Session.get("liked").forEach(function (mid) {
  190. Songs.find().forEach(function (data) {
  191. if (data.mid === mid) {
  192. likedArr.push({title: data.title, artist: data.artist});
  193. }
  194. });
  195. });
  196. return likedArr;
  197. },
  198. dislikedSongs: function () {
  199. var dislikedArr = [];
  200. Session.get("disliked").forEach(function (mid) {
  201. Songs.find().forEach(function (data) {
  202. if (data.mid === mid) {
  203. dislikedArr.push({title: data.title, artist: data.artist});
  204. }
  205. });
  206. });
  207. return dislikedArr;
  208. },
  209. isUser: function () {
  210. var parts = Router.current().url.split('/');
  211. var username = parts.pop();
  212. if (username === Meteor.user().profile.username) {
  213. return true;
  214. }
  215. }
  216. });
  217. Template.queues.helpers({
  218. songs: function () {
  219. return Queues.find({}).fetch();
  220. },
  221. song_image: function() {
  222. return Session.get("image_url");
  223. }
  224. });
  225. Template.news.helpers({
  226. articles: function() {
  227. var articles = News.find().fetch().reverse();
  228. articles = articles.map(function(article) {
  229. article.content = replaceURLWithHTMLLinksBlank(article.content);
  230. return article;
  231. });
  232. return articles;
  233. }
  234. });
  235. Template.manageSongs.helpers({
  236. songs: function () {
  237. var noGenres = Session.get("showNoGenres");
  238. var genres = Session.get("showGenres");
  239. if (noGenres === true && genres === true) {
  240. return Songs.find();
  241. } else if (noGenres === true && genres === false) {
  242. return Songs.find({genres: []});
  243. } else {
  244. return Songs.find({$where : "this.genres.length > 0"});
  245. }
  246. },
  247. song_image: function() {
  248. return Session.get("image_url");
  249. }
  250. });
  251. Template.manageStation.helpers({
  252. editingDesc: function() {
  253. return Session.get("editingDesc");
  254. },
  255. description: function() {
  256. var parts = location.href.split('/');
  257. parts.pop();
  258. var id = parts.pop();
  259. var type = id.toLowerCase();
  260. return Rooms.findOne({type: type}).roomDesc;
  261. },
  262. songs: function () {
  263. var parts = location.href.split('/');
  264. parts.pop();
  265. var id = parts.pop();
  266. var type = id.toLowerCase();
  267. var playlist = Playlists.findOne({type: type});
  268. var songs = [];
  269. if (playlist !== undefined && playlist.songs !== undefined) {
  270. playlist.songs.forEach(function(songMid) {
  271. songs.push(Songs.findOne({mid: songMid}));
  272. });
  273. }
  274. return songs;
  275. },
  276. song_image: function() {
  277. return Session.get("image_url");
  278. },
  279. genre: function() {
  280. var parts = location.href.split('/');
  281. parts.pop();
  282. var id = parts.pop();
  283. var type = id.toLowerCase();
  284. return type;
  285. },
  286. reports: function() {
  287. var parts = location.href.split('/');
  288. parts.pop();
  289. var id = parts.pop();
  290. var query = {room: id.toLowerCase()};
  291. var reports = Reports.find(query).fetch();
  292. return reports;
  293. }
  294. });
  295. Template.room.helpers({
  296. currentSongR: function() {
  297. return Session.get("currentSongR");
  298. },
  299. previousSongR: function() {
  300. return Session.get("previousSongR");
  301. },
  302. editingSong: function() {
  303. return Session.get("editingSong");
  304. },
  305. singleVideoResults: function () {
  306. return Session.get("songResults");
  307. },
  308. singleVideoResultsActive: function() {
  309. var songs = Session.get("songResults");
  310. if (songs !== undefined && songs.length > 0) {
  311. return true;
  312. } else {
  313. return false;
  314. }
  315. },
  316. importPlaylistVideos: function () {
  317. return Session.get("songResults");
  318. },
  319. playlistImportVideosActive: function() {
  320. var songs = Session.get("songResults");
  321. if (songs !== undefined && songs.length > 0) {
  322. return true;
  323. } else {
  324. return false;
  325. }
  326. },
  327. singleVideo: function () {
  328. return Session.get("si_or_pl") === "singleVideo";
  329. },
  330. chat: function () {
  331. Meteor.setTimeout(function () {
  332. var elem = document.getElementById('chat');
  333. if (elem !== undefined && elem !== null) {
  334. elem.scrollTop = elem.scrollHeight;
  335. }
  336. }, 100);
  337. return Chat.find({type: Session.get("type")}, {sort: {time: -1}, limit: 50}).fetch().reverse();
  338. },
  339. globalChat: function () {
  340. Meteor.setTimeout(function () {
  341. var elem = document.getElementById('global-chat');
  342. if (elem !== undefined && elem !== null) {
  343. elem.scrollTop = elem.scrollHeight;
  344. }
  345. }, 100);
  346. var messages = Chat.find({type: "global"}, {sort: {time: -1}, limit: 50}).fetch().reverse();
  347. messages = messages.map(function(message) {
  348. message.message = replaceURLWithHTMLLinks(message.message);
  349. return message;
  350. });
  351. return messages;
  352. },
  353. likes: function () {
  354. var playlist = Songs.find({"genres": Session.get("type")}).fetch();
  355. var likes = 0;
  356. playlist.forEach(function (song) {
  357. if (Session.get("currentSong") && song.mid === Session.get("currentSong").mid) {
  358. likes = song.likes;
  359. return;
  360. }
  361. });
  362. return likes;
  363. },
  364. dislikes: function () {
  365. var playlist = Songs.find({"genres": Session.get("type")}).fetch();
  366. var dislikes = 0;
  367. playlist.forEach(function (song) {
  368. if (Session.get("currentSong") && song.mid === Session.get("currentSong").mid) {
  369. dislikes = song.dislikes;
  370. return;
  371. }
  372. });
  373. return dislikes;
  374. },
  375. liked: function () {
  376. if (Meteor.userId()) {
  377. var currentSong = Session.get("currentSong");
  378. if (currentSong && Meteor.user().profile.liked.indexOf(currentSong.mid) !== -1) {
  379. return "liked";
  380. } else {
  381. return "";
  382. }
  383. } else {
  384. "";
  385. }
  386. },
  387. disliked: function () {
  388. if (Meteor.userId()) {
  389. var currentSong = Session.get("currentSong");
  390. if (currentSong && Meteor.user().profile.disliked.indexOf(currentSong.mid) !== -1) {
  391. return "disliked";
  392. } else {
  393. return "";
  394. }
  395. } else {
  396. "";
  397. }
  398. },
  399. type: function () {
  400. var parts = location.href.split('/');
  401. var id = parts.pop().toLowerCase();
  402. return Rooms.findOne({type: id}).display;
  403. },
  404. users: function () {
  405. var parts = location.href.split('/');
  406. var id = parts.pop().toLowerCase();
  407. return Rooms.findOne({type: id}).users;
  408. },
  409. title: function () {
  410. return Session.get("title");
  411. },
  412. artist: function () {
  413. return Session.get("artist");
  414. },
  415. loaded: function () {
  416. return Session.get("loaded");
  417. },
  418. paused: function () {
  419. return Session.get("state") === "paused";
  420. },
  421. private: function () {
  422. return 1;
  423. //return Rooms.findOne({type: Session.get("type")}).private === true;
  424. },
  425. currentSong: function(){
  426. return Session.get("currentSong");
  427. },
  428. reportingSong: function() {
  429. if (!Session.get("reportPrevious")) {
  430. return Session.get("currentSongR");
  431. } else {
  432. return Session.get("previousSongR");
  433. }
  434. },
  435. reportSong: function(){
  436. Meteor.setInterval(function(){
  437. if($("#report-song").is(":checked")){
  438. Session.set("reportSong", true)
  439. } else { Session.set("reportSong", false) }
  440. }, 500);
  441. return Session.get("reportSong");
  442. },
  443. reportSongOther: function(){
  444. Meteor.setInterval(function(){
  445. if($("#report-song-other").is(":checked")){
  446. Session.set("reportSongOther", true)
  447. } else { Session.set("reportSongOther", false) }
  448. }, 500);
  449. return Session.get("reportSongOther");
  450. },
  451. reportTitle: function(){
  452. Meteor.setInterval(function(){
  453. if($("#report-title").is(":checked")){
  454. Session.set("reportTitle", true)
  455. } else { Session.set("reportTitle", false) }
  456. }, 500);
  457. return Session.get("reportTitle");
  458. },
  459. reportTitleOther: function(){
  460. Meteor.setInterval(function(){
  461. if($("#report-title-other").is(":checked")){
  462. Session.set("reportTitleOther", true)
  463. } else { Session.set("reportTitleOther", false) }
  464. }, 500);
  465. return Session.get("reportTitleOther");
  466. },
  467. reportArtist: function(){
  468. Meteor.setInterval(function(){
  469. if($("#report-artist").is(":checked")){
  470. Session.set("reportArtist", true)
  471. } else { Session.set("reportArtist", false) }
  472. }, 500);
  473. return Session.get("reportArtist");
  474. },
  475. reportArtistOther: function(){
  476. Meteor.setInterval(function(){
  477. if($("#report-artist-other").is(":checked")){
  478. Session.set("reportArtistOther", true)
  479. } else { Session.set("reportArtistOther", false) }
  480. }, 500);
  481. return Session.get("reportArtistOther");
  482. },
  483. reportDuration: function(){
  484. Meteor.setInterval(function(){
  485. if($("#report-duration").is(":checked")){
  486. Session.set("reportDuration", true)
  487. } else { Session.set("reportDuration", false) }
  488. }, 500);
  489. return Session.get("reportDuration");
  490. },
  491. reportDurationOther: function(){
  492. Meteor.setInterval(function(){
  493. if($("#report-duration-other").is(":checked")){
  494. Session.set("reportDurationOther", true)
  495. } else { Session.set("reportDurationOther", false) }
  496. }, 500);
  497. return Session.get("reportDurationOther");
  498. },
  499. reportAlbumart: function(){
  500. Meteor.setInterval(function(){
  501. if($("#report-albumart").is(":checked")){
  502. Session.set("reportAlbumart", true)
  503. } else { Session.set("reportAlbumart", false) }
  504. }, 500);
  505. return Session.get("reportAlbumart");
  506. },
  507. reportAlbumartOther: function(){
  508. Meteor.setInterval(function(){
  509. if($("#report-albumart-other").is(":checked")){
  510. Session.set("reportAlbumartOther", true)
  511. } else { Session.set("reportAlbumartOther", false) }
  512. }, 500);
  513. return Session.get("reportAlbumartOther");
  514. },
  515. reportOther: function(){
  516. Meteor.setInterval(function(){
  517. if($("#report-other").is(":checked")){
  518. Session.set("reportOther", true)
  519. } else { Session.set("reportOther", false) }
  520. }, 500);
  521. return Session.get("reportOther");
  522. },
  523. votes: function () {
  524. return Rooms.findOne({type: Session.get("type")}).votes;
  525. },
  526. usersInRoom: function(){
  527. var userList = [];
  528. var roomUserList = Rooms.findOne({type: Session.get("type")}).userList;
  529. roomUserList.forEach(function(user){
  530. if(userList.indexOf(user) === -1){
  531. userList.push(user);
  532. }
  533. })
  534. return userList;
  535. }
  536. });
  537. Template.communityStation.helpers({
  538. communityStationOwnerName: function() {
  539. var room = CommunityStations.findOne({name: Session.get("CommunityStationName")});
  540. if (room !== undefined) {
  541. return Meteor.users.findOne(room.owner).profile.username;
  542. } else {
  543. return "";
  544. }
  545. },
  546. editingPlaylist: function() {
  547. return PrivatePlaylists.findOne({owner: Meteor.userId(), name: Session.get("editingPlaylistName")});
  548. },
  549. isPlaylistSelected: function(roomName, playlistName) {
  550. return CommunityStations.findOne({name: roomName}).playlist === playlistName;
  551. },
  552. globalChat: function () {
  553. Meteor.setTimeout(function () {
  554. var elem = document.getElementById('global-chat');
  555. if (elem !== undefined && elem !== null) {
  556. elem.scrollTop = elem.scrollHeight;
  557. }
  558. }, 100);
  559. var messages = Chat.find({type: "global"}, {sort: {time: -1}, limit: 50}).fetch().reverse();
  560. messages = messages.map(function(message) {
  561. message.message = replaceURLWithHTMLLinks(message.message);
  562. return message;
  563. });
  564. return messages;
  565. },
  566. communityStationDisplayName: function () {
  567. var parts = location.href.split('/');
  568. var id = parts.pop().toLowerCase();
  569. return CommunityStations.findOne({name: id}).displayName;
  570. },
  571. name: function () {
  572. var parts = location.href.split('/');
  573. var id = parts.pop().toLowerCase();
  574. return id;
  575. },
  576. users: function () {
  577. var parts = location.href.split('/');
  578. var id = parts.pop().toLowerCase();
  579. return CommunityStations.findOne({name: id}).userList.length;
  580. },
  581. allowed: function () {
  582. var parts = location.href.split('/');
  583. var id = parts.pop().toLowerCase();
  584. var arr = [];
  585. CommunityStations.findOne({name: id}).allowed.forEach(function(allowed) {
  586. arr.push({name: Meteor.users.findOne(allowed).profile.username, id: allowed});
  587. });
  588. return arr;
  589. },
  590. playlists: function () {
  591. return PrivatePlaylists.find({owner: Meteor.userId()});
  592. },
  593. title: function () {
  594. return Session.get("title");
  595. },
  596. loaded: function () {
  597. return Session.get("loaded");
  598. },
  599. paused: function () {
  600. return Session.get("state") === "paused";
  601. },
  602. private: function () {
  603. var room = CommunityStations.findOne({name: Session.get("CommunityStationName")});
  604. if (room !== undefined) {
  605. return room.private;
  606. } else {
  607. return 1;
  608. }
  609. },
  610. playing: function() {
  611. return Session.get("state") === "playing";
  612. },
  613. currentSong: function(){
  614. return Session.get("currentSong");
  615. },
  616. votes: function () {
  617. var room = CommunityStations.findOne({name: Session.get("CommunityStationName")});
  618. if (room !== undefined) {
  619. return room.votes;
  620. } else {
  621. return 0;
  622. }
  623. },
  624. usersInRoom: function() {
  625. var userList = [];
  626. var room = CommunityStations.findOne({name: Session.get("CommunityStationName")});
  627. if (room !== undefined) {
  628. var roomUserList = room.userList;
  629. roomUserList.forEach(function (user) {
  630. if (userList.indexOf(user) === -1) {
  631. userList.push(user);
  632. }
  633. })
  634. }
  635. return userList;
  636. },
  637. room: function() {
  638. var parts = location.href.split('/');
  639. var id = parts.pop().toLowerCase();
  640. setTimeout(function() {
  641. Materialize.updateTextFields();
  642. }, 100);
  643. return CommunityStations.findOne({name: id});
  644. }
  645. });
  646. Template.settings.helpers({
  647. username: function () {
  648. if (Meteor.user() !== undefined) {
  649. return Meteor.user().profile.username;
  650. } else {
  651. return "";
  652. }
  653. }
  654. });
  655. function replaceURLWithHTMLLinks(text) {
  656. var re = /(\(.*?)?\b((?:https?|ftp|file):\/\/[-a-z0-9+&@#\/%?=~_()|!:,.;]*[-a-z0-9+&@#\/%=~_()|])/ig;
  657. return text.replace(re, function(match, lParens, url) {
  658. var rParens = '';
  659. lParens = lParens || '';
  660. // Try to strip the same number of right parens from url
  661. // as there are left parens. Here, lParenCounter must be
  662. // a RegExp object. You cannot use a literal
  663. // while (/\(/g.exec(lParens)) { ... }
  664. // because an object is needed to store the lastIndex state.
  665. var lParenCounter = /\(/g;
  666. while (lParenCounter.exec(lParens)) {
  667. var m;
  668. // We want m[1] to be greedy, unless a period precedes the
  669. // right parenthesis. These tests cannot be simplified as
  670. // /(.*)(\.?\).*)/.exec(url)
  671. // because if (.*) is greedy then \.? never gets a chance.
  672. if (m = /(.*)(\.\).*)/.exec(url) ||
  673. /(.*)(\).*)/.exec(url)) {
  674. url = m[1];
  675. rParens = m[2] + rParens;
  676. }
  677. }
  678. return lParens + "<a style='font-size: 18px; padding: 0; display: inline;' target='_blank' href='" + url + "'>" + url + "</a>" + rParens;
  679. });
  680. }
  681. function replaceURLWithHTMLLinksBlank(text) {
  682. var re = /(\(.*?)?\b((?:https?|ftp|file):\/\/[-a-z0-9+&@#\/%?=~_()|!:,.;]*[-a-z0-9+&@#\/%=~_()|])/ig;
  683. return text.replace(re, function(match, lParens, url) {
  684. var rParens = '';
  685. lParens = lParens || '';
  686. // Try to strip the same number of right parens from url
  687. // as there are left parens. Here, lParenCounter must be
  688. // a RegExp object. You cannot use a literal
  689. // while (/\(/g.exec(lParens)) { ... }
  690. // because an object is needed to store the lastIndex state.
  691. var lParenCounter = /\(/g;
  692. while (lParenCounter.exec(lParens)) {
  693. var m;
  694. // We want m[1] to be greedy, unless a period precedes the
  695. // right parenthesis. These tests cannot be simplified as
  696. // /(.*)(\.?\).*)/.exec(url)
  697. // because if (.*) is greedy then \.? never gets a chance.
  698. if (m = /(.*)(\.\).*)/.exec(url) ||
  699. /(.*)(\).*)/.exec(url)) {
  700. url = m[1];
  701. rParens = m[2] + rParens;
  702. }
  703. }
  704. return lParens + "<a href='" + url + "'>" + url + "</a>" + rParens;
  705. });
  706. }