main.js.tpl 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. var ajax_url = _p.web_ajax + 'chat.ajax.php';
  2. var online_button = '<img src="' + _p.web_img + 'statusonline.png">';
  3. var offline_button = '<img src="' + _p.web_img + 'statusoffline.png">';
  4. var connect_lang = '{{ "ChatConnected"|get_lang | escape('js')}}';
  5. var disconnect_lang = '{{ "ChatDisconnected"|get_lang | escape('js')}}';
  6. var chatLang = '{{ "GlobalChat"|get_lang | escape('js')}}';
  7. {% if 'hide_chat_video'|api_get_configuration_value %}
  8. var hide_chat_video = true;
  9. {% else %}
  10. var hide_chat_video = false;
  11. {% endif %}
  12. $(function() {
  13. addMainEvent(window, 'unload', courseLogout ,false);
  14. $("#open-view-list").click(function(){
  15. $("#student-list-work").fadeIn(300);
  16. });
  17. $("#closed-view-list").click(function(){
  18. $("#student-list-work").fadeOut(300);
  19. });
  20. checkBrand();
  21. var id;
  22. $(window).resize(function() {
  23. clearTimeout(id);
  24. id = setTimeout(doneResizing, 200);
  25. });
  26. // Removes the yellow input in Chrome
  27. if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
  28. $(window).on("load", function () {
  29. $('input:-webkit-autofill').each(function(){
  30. var text = $(this).val();
  31. var name = $(this).attr('name');
  32. $(this).after(this.outerHTML).remove();
  33. $('input[name=' + name + ']').val(text);
  34. });
  35. });
  36. }
  37. $(".accordion_jquery").accordion({
  38. autoHeight: false,
  39. active: false, // all items closed by default
  40. collapsible: true,
  41. header: ".accordion-heading"
  42. });
  43. // Start modals
  44. // class='ajax' loads a page in a modal
  45. $('body').on('click', 'a.ajax', function(e) {
  46. e.preventDefault();
  47. var globalModal = $('#global-modal');
  48. if ($(this).hasClass('no-close-button')) {
  49. globalModal.find('.close').hide();
  50. }
  51. var contentUrl = this.href;
  52. var loadModalContent = $.get(contentUrl);
  53. var self = $(this);
  54. var blockDiv = $(this).attr('data-block-closing');
  55. if (blockDiv != '') {
  56. /*globalModal.on('hidden.bs.modal', function () {
  57. $('#' + blockDiv + ' :input').attr('disabled', 'true');
  58. });*/
  59. globalModal.attr('data-backdrop', 'static');
  60. globalModal.attr('data-keyboard', 'false');
  61. }
  62. $.when(loadModalContent).done(function(modalContent) {
  63. var modalDialog = globalModal.find('.modal-dialog'),
  64. modalSize = self.data('size') || get_url_params(contentUrl, 'modal_size'),
  65. modalWidth = self.data('width') || get_url_params(contentUrl, 'width'),
  66. modalTitle = self.data('title') || ' ';
  67. modalDialog.removeClass('modal-lg modal-sm').css('width', '');
  68. if (modalSize && modalSize.length != 0) {
  69. switch (modalSize) {
  70. case 'lg':
  71. modalDialog.addClass('modal-lg');
  72. break;
  73. case 'sm':
  74. modalDialog.addClass('modal-sm');
  75. break;
  76. }
  77. } else if (modalWidth) {
  78. modalDialog.css('width', modalWidth + 'px');
  79. }
  80. globalModal.find('.modal-title').text(modalTitle);
  81. globalModal.find('.modal-body').html(modalContent);
  82. globalModal.modal('show');
  83. });
  84. });
  85. // Expands an image modal
  86. $('a.expand-image').on('click', function(e) {
  87. e.preventDefault();
  88. var title = $(this).attr('title');
  89. var image = new Image();
  90. image.onload = function() {
  91. if (title) {
  92. $('#expand-image-modal').find('.modal-title').text(title);
  93. } else {
  94. $('#expand-image-modal').find('.modal-title').html('&nbsp;');
  95. }
  96. $('#expand-image-modal').find('.modal-body').html(image);
  97. $('#expand-image-modal').modal({
  98. show: true
  99. });
  100. };
  101. image.src = this.href;
  102. });
  103. // Delete modal
  104. $('#confirm-delete').on('show.bs.modal', function(e) {
  105. $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
  106. var message = '{{ 'AreYouSureToDeleteJS' | get_lang | escape('js')}}: <strong>' + $(e.relatedTarget).data('item-title') + '</strong>';
  107. if ($(e.relatedTarget).data('item-question')) {
  108. message = $(e.relatedTarget).data('item-question');
  109. }
  110. $('.debug-url').html(message);
  111. });
  112. // End modals
  113. // old jquery.menu.js
  114. $('#navigation a').stop().animate({
  115. 'marginLeft':'50px'
  116. },1000);
  117. $('#navigation div').hover(
  118. function () {
  119. $('a',$(this)).stop().animate({
  120. 'marginLeft':'1px'
  121. },200);
  122. },
  123. function () {
  124. $('a',$(this)).stop().animate({
  125. 'marginLeft':'50px'
  126. },200);
  127. }
  128. );
  129. /* Make responsive image maps */
  130. $('map').imageMapResize();
  131. jQuery.fn.filterByText = function(textbox) {
  132. return this.each(function() {
  133. var select = this;
  134. var options = [];
  135. $(select).find('option').each(function() {
  136. options.push({value: $(this).val(), text: $(this).text()});
  137. });
  138. $(select).data('options', options);
  139. $(textbox).bind('change keyup', function() {
  140. var options = $(select).empty().data('options');
  141. var search = $.trim($(this).val());
  142. var regex = new RegExp(search,"gi");
  143. $.each(options, function(i) {
  144. var option = options[i];
  145. if(option.text.match(regex) !== null) {
  146. $(select).append(
  147. $('<option>').text(option.text).val(option.value)
  148. );
  149. }
  150. });
  151. });
  152. });
  153. };
  154. $(".black-shadow").mouseenter(function() {
  155. $(this).addClass('hovered-course');
  156. }).mouseleave(function() {
  157. $(this).removeClass('hovered-course');
  158. });
  159. $("[data-toggle=popover]").each(function(i, obj) {
  160. $(this).popover({
  161. html: true,
  162. content: function() {
  163. var id = $(this).attr('id')
  164. return $('#popover-content-' + id).html();
  165. }
  166. });
  167. });
  168. $('.scrollbar-inner').scrollbar();
  169. // Date time settings.
  170. moment.locale('{{ locale }}');
  171. $.datepicker.setDefaults($.datepicker.regional["{{ locale }}"]);
  172. $.datepicker.regional["local"] = $.datepicker.regional["{{ locale }}"];
  173. // Fix old calls of "inc/lib/mediaplayer/player.swf" and convert to <audio> tag, then rendered by media element js
  174. // see BT#13405
  175. $('embed').each( function () {
  176. var flashVars = $(this).attr('flashvars');
  177. if (flashVars && flashVars.indexOf("file") == -1) {
  178. var audioId = Math.floor( Math.random()*99999 );
  179. flashVars = flashVars.replace('&autostart=false', '');
  180. flashVars = flashVars.replace('&autostart=true', '');
  181. var audioDiv = '<audio id="'+audioId+'" controls="controls" style="width:400px;" width:"400px;" src="'+flashVars+'" ><source src="'+flashVars+'" type="audio/mp3" ></source></audio>';
  182. $(this).hide();
  183. $(this).after(audioDiv);
  184. }
  185. });
  186. // Chosen select
  187. $(".chzn-select").chosen({
  188. disable_search_threshold: 10,
  189. no_results_text: '{{ 'SearchNoResultsFound' | get_lang | escape('js') }}',
  190. placeholder_text_multiple: '{{ 'SelectSomeOptions' | get_lang | escape('js') }}',
  191. placeholder_text_single: '{{ 'SelectAnOption' | get_lang | escape('js') }}',
  192. width: "100%"
  193. });
  194. // Bootstrap tabs.
  195. $('.tab-wrapper a').click(function (e) {
  196. e.preventDefault();
  197. $(this).tab('show');
  198. //$('#tabs a:first').tab('show') // Select first tab
  199. });
  200. // Fixes bug when loading links inside a tab.
  201. $('.tab-wrapper .tab-pane a').unbind();
  202. /**
  203. * Advanced options
  204. * Usage
  205. * <a id="link" href="url">Advanced</a>
  206. * <div id="link_options">
  207. * hidden content :)
  208. * </div>
  209. * */
  210. $(".advanced_options").on("click", function (event) {
  211. event.preventDefault();
  212. var id = $(this).attr('id') + '_options';
  213. var button = $(this);
  214. $("#" + id).toggle();
  215. });
  216. /**
  217. * <a class="advanced_options_open" href="http://" rel="div_id">Open</a>
  218. * <a class="advanced_options_close" href="http://" rel="div_id">Close</a>
  219. * <div id="div_id">Div content</div>
  220. * */
  221. $(".advanced_options_open").on("click", function (event) {
  222. event.preventDefault();
  223. var id = $(this).attr('rel');
  224. $("#" + id).show();
  225. });
  226. $(".advanced_options_close").on("click", function (event) {
  227. event.preventDefault();
  228. var id = $(this).attr('rel');
  229. $("#" + id).hide();
  230. });
  231. // Adv multi-select search input.
  232. $('.select_class_filter').each( function () {
  233. var inputId = $(this).attr('id');
  234. inputId = inputId.replace('-filter', '');
  235. $("#" + inputId).filterByText($("#" + inputId + "-filter"));
  236. });
  237. // Mediaelement
  238. if ( {{ show_media_element }} == 1) {
  239. $('video:not(.skip), audio:not(.skip)').mediaelementplayer({
  240. pluginPath: _p.web + 'web/assets/mediaelement/build/',
  241. //renderers: ['html5', 'flash_video', 'native_flv'],
  242. features: ['{{ video_features }}'],
  243. success: function(mediaElement, originalNode, instance) {
  244. {{ quiz_markers_rolls_js }}
  245. },
  246. vrPath: _p.web + 'web/assets/vrview/build/vrview.js'
  247. });
  248. }
  249. // Table highlight.
  250. $("form .data_table input:checkbox").click(function () {
  251. if ($(this).is(":checked")) {
  252. $(this).parentsUntil("tr").parent().addClass("row_selected");
  253. } else {
  254. $(this).parentsUntil("tr").parent().removeClass("row_selected");
  255. }
  256. });
  257. /* For non HTML5 browsers */
  258. if ($("#formLogin".length > 1)) {
  259. $("input[name=login]").focus();
  260. }
  261. // Tool tip (in exercises)
  262. var tip_options = {
  263. placement: 'right'
  264. };
  265. $('.boot-tooltip').tooltip(tip_options);
  266. var more = '{{ 'SeeMore' | get_lang | escape('js') }}';
  267. var close = '{{ 'Close' | get_lang | escape('js') }}';
  268. $('.list-teachers').readmore({
  269. speed: 75,
  270. moreLink: '<a href="#">' + more + '</a>',
  271. lessLink: '<a href="#">' + close + '</a>',
  272. collapsedHeight: 35,
  273. blockCSS: 'display: block; width: 100%;'
  274. });
  275. $('.star-rating li a').on('click', function(event) {
  276. var id = $(this).parents('ul').attr('id');
  277. $('#vote_label2_' + id).html("{{'Loading'|get_lang| escape('js')}}");
  278. $.ajax({
  279. url: $(this).attr('data-link'),
  280. success: function(data) {
  281. $("#rating_wrapper_"+id).html(data);
  282. if (data == 'added') {
  283. //$('#vote_label2_' + id).html("{{'Saved'|get_lang | escape('js')}}");
  284. }
  285. if (data == 'updated') {
  286. //$('#vote_label2_' + id).html("{{'Saved'|get_lang| escape('js')}}");
  287. }
  288. }
  289. });
  290. });
  291. $("#notifications").load(_p.web_ajax + "online.ajax.php?a=get_users_online");
  292. $('video:not(.skip)').attr('preload', 'metadata');
  293. function socialLikes() {
  294. {% if 'social_enable_messages_feedback'|api_get_configuration_value %}
  295. $('body').on('click', '.social-like', function (e) {
  296. e.preventDefault();
  297. var $self = $(this),
  298. status = $self.data('status') || '',
  299. group = $self.data('group') || 0,
  300. message = $self.data('message') || 0;
  301. $.getJSON(
  302. '{{ _p.web_ajax }}social.ajax.php',
  303. {'a': 'like_message', 'group': group, 'id': message, 'status': status}
  304. ).then(function (response) {
  305. if (!response) {
  306. return;
  307. }
  308. var $count = $self.children('span'),
  309. currentCount = parseInt($count.text()) || 0;
  310. if ('like' === status) {
  311. var $dislike = $self.next(),
  312. $dislikeCount = $dislike.children('span'),
  313. dislikeCount = parseInt($dislikeCount.text()) || 0;
  314. $count.text(++currentCount);
  315. if ($dislike.is('.btn-danger')) {
  316. $dislikeCount.text(dislikeCount <= 0 ? 0 : --dislikeCount);
  317. $dislike.removeClass('btn-danger');
  318. }
  319. $self.addClass('btn-primary');
  320. } else if ('dislike' === status) {
  321. var $like = $self.prev(),
  322. $likeCount = $like.children('span'),
  323. likeCount = parseInt($likeCount.text()) || 0;
  324. $count.text(++currentCount);
  325. if ($like.is('.btn-primary')) {
  326. $likeCount.text(likeCount <= 0 ? 0 : --likeCount);
  327. $like.removeClass('btn-primary');
  328. }
  329. $self.addClass('btn-danger');
  330. }
  331. });
  332. });
  333. {% endif %}
  334. }
  335. socialLikes();
  336. });
  337. $(window).resize(function() {
  338. checkBrand();
  339. });
  340. $(document).scroll(function() {
  341. var valor = $('body').outerHeight() - 700;
  342. if ($(this).scrollTop() > 100) {
  343. $('.bottom_actions').addClass('bottom_actions_fixed');
  344. } else {
  345. $('.bottom_actions').removeClass('bottom_actions_fixed');
  346. }
  347. if ($(this).scrollTop() > valor) {
  348. $('.bottom_actions').removeClass('bottom_actions_fixed');
  349. } else {
  350. $('.bottom_actions').addClass('bottom_actions_fixed');
  351. }
  352. // Exercise warning fixed at the top
  353. var fixed = $("#exercise_clock_warning");
  354. if (fixed.length) {
  355. if (!fixed.attr('data-top')) {
  356. // If already fixed, then do nothing
  357. if (fixed.hasClass('subnav-fixed')) return;
  358. // Remember top position
  359. var offset = fixed.offset();
  360. fixed.attr('data-top', offset.top);
  361. fixed.css('width', '100%');
  362. }
  363. if (fixed.attr('data-top') - fixed.outerHeight() <= $(this).scrollTop()) {
  364. fixed.addClass('navbar-fixed-top');
  365. fixed.css('width', '100%');
  366. } else {
  367. fixed.removeClass('navbar-fixed-top');
  368. fixed.css('width', '100%');
  369. }
  370. }
  371. // Admin -> Settings toolbar.
  372. if ($('body').width() > 959) {
  373. if ($('.new_actions').length) {
  374. if (!$('.new_actions').attr('data-top')) {
  375. // If already fixed, then do nothing
  376. if ($('.new_actions').hasClass('new_actions-fixed')) return;
  377. // Remember top position
  378. var offset = $('.new_actions').offset();
  379. var more_top = 0;
  380. if ($('.subnav').hasClass('new_actions-fixed')) {
  381. more_top = 50;
  382. }
  383. $('.new_actions').attr('data-top', offset.top + more_top);
  384. }
  385. // Check if the height is enough before fixing the icons menu (or otherwise removing it)
  386. // Added a 30px offset otherwise sometimes the menu plays ping-pong when scrolling to
  387. // the bottom of the page on short pages.
  388. if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop() + 30) {
  389. $('.new_actions').addClass('new_actions-fixed');
  390. } else {
  391. $('.new_actions').removeClass('new_actions-fixed');
  392. }
  393. }
  394. }
  395. });
  396. function get_url_params(q, attribute) {
  397. var hash;
  398. if (q != undefined) {
  399. q = q.split('&');
  400. for(var i = 0; i < q.length; i++){
  401. hash = q[i].split('=');
  402. if (hash[0] == attribute) {
  403. return hash[1];
  404. }
  405. }
  406. }
  407. }
  408. function checkBrand() {
  409. if ($('.subnav').length) {
  410. if ($(window).width() >= 969) {
  411. $('.subnav .brand').hide();
  412. } else {
  413. $('.subnav .brand').show();
  414. }
  415. }
  416. }
  417. function setCheckbox(value, table_id) {
  418. checkboxes = $("#"+table_id+" input:checkbox");
  419. $.each(checkboxes, function(index, checkbox) {
  420. checkbox.checked = value;
  421. if (value) {
  422. $(checkbox).parentsUntil("tr").parent().addClass("row_selected");
  423. } else {
  424. $(checkbox).parentsUntil("tr").parent().removeClass("row_selected");
  425. }
  426. });
  427. return false;
  428. }
  429. function action_click(element, table_id) {
  430. d = $("#"+table_id);
  431. if (!confirm('{{ "ConfirmYourChoice"|get_lang | escape('js')}}')) {
  432. return false;
  433. } else {
  434. var action =$(element).attr("data-action");
  435. $('#'+table_id+' input[name="action"] ').attr("value", action);
  436. d.submit();
  437. return false;
  438. }
  439. }
  440. /**
  441. * Generic function to replace the deprecated jQuery toggle function
  442. * @param inId : id of block to hide / unhide
  443. * @param inIdTxt : id of the button
  444. * @param inTxtHide : text one of the button
  445. * @param inTxtUnhide : text two of the button
  446. * @todo : allow to detect if text is from a button or from a <a>
  447. */
  448. function hideUnhide(inId, inIdTxt, inTxtHide, inTxtUnhide) {
  449. if ($('#'+inId).css("display") == "none") {
  450. $('#'+inId).show(400);
  451. $('#'+inIdTxt).attr("value", inTxtUnhide);
  452. } else {
  453. $('#'+inId).hide(400);
  454. $('#'+inIdTxt).attr("value", inTxtHide);
  455. }
  456. }
  457. function expandColumnToogle(buttonSelector, col1Info, col2Info) {
  458. $(buttonSelector).on('click', function (e) {
  459. e.preventDefault();
  460. col1Info = $.extend({
  461. selector: '',
  462. width: 4
  463. }, col1Info);
  464. col2Info = $.extend({
  465. selector: '',
  466. width: 8
  467. }, col2Info);
  468. if (!col1Info.selector || !col2Info.selector) {
  469. return;
  470. }
  471. var col1 = $(col1Info.selector),
  472. col2 = $(col2Info.selector);
  473. $('#expand').toggleClass('hide');
  474. $('#contract').toggleClass('hide');
  475. if (col2.is('.col-md-' + col2Info.width)) {
  476. col2.removeClass('col-md-' + col2Info.width).addClass('col-md-12');
  477. col1.removeClass('col-md-' + col1Info.width).addClass('hide');
  478. return;
  479. }
  480. col2.removeClass('col-md-12').addClass('col-md-' + col2Info.width);
  481. col1.removeClass('hide').addClass('col-md-' + col1Info.width);
  482. });
  483. }
  484. // Load ckeditor plugins
  485. if (typeof CKEDITOR !== 'undefined') {
  486. // External plugins not part of the default Ckeditor package.
  487. var plugins = [
  488. 'asciimath',
  489. 'asciisvg',
  490. 'audio',
  491. 'ckeditor_wiris',
  492. 'dialogui',
  493. 'glossary',
  494. 'leaflet',
  495. 'mapping',
  496. 'maximize',
  497. 'mathjax',
  498. 'oembed',
  499. 'toolbar',
  500. 'toolbarswitch',
  501. 'video',
  502. 'wikilink',
  503. 'wordcount',
  504. 'youtube',
  505. 'flash',
  506. 'inserthtml',
  507. 'qmarkersrolls',
  508. 'image2_chamilo'
  509. ];
  510. plugins.forEach(function (plugin) {
  511. CKEDITOR.plugins.addExternal(
  512. plugin,
  513. _p.web_lib + '{{ 'javascript/ckeditor/plugins/' }}' + plugin + '/'
  514. );
  515. });
  516. /**
  517. * Function use to load templates in a div
  518. **/
  519. var showTemplates = function (ckeditorName) {
  520. var editorName = 'content';
  521. if (ckeditorName && ckeditorName.length > 0) {
  522. editorName = ckeditorName;
  523. }
  524. CKEDITOR.editorConfig(CKEDITOR.config);
  525. CKEDITOR.loadTemplates(CKEDITOR.config.templates_files, function (a) {
  526. var templatesConfig = CKEDITOR.getTemplates("default");
  527. var $templatesUL = $("<ul>");
  528. if (templatesConfig) {
  529. $.each(templatesConfig.templates, function () {
  530. var template = this;
  531. var $templateLi = $("<li>");
  532. var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>";
  533. templateHTML += "<b>" + template.title + "</b>";
  534. if (template.description) {
  535. templateHTML += "<div class=description>" + template.description + "</div>";
  536. }
  537. templateHTML += "</div>";
  538. $("<a>", {
  539. href: "#",
  540. html: templateHTML,
  541. click: function (e) {
  542. e.preventDefault();
  543. if (CKEDITOR.instances[editorName]) {
  544. CKEDITOR.instances[editorName].setData(template.html, function () {
  545. this.checkDirty();
  546. });
  547. }
  548. }
  549. }).appendTo($templateLi);
  550. $templatesUL.append($templateLi);
  551. });
  552. }
  553. $templatesUL.appendTo("#frmModel");
  554. });
  555. };
  556. }
  557. function doneResizing() {
  558. var widthWindow = $(window).width();
  559. if ((widthWindow>=1024) && (widthWindow>=768)) {
  560. $("#profileCollapse").addClass("in");
  561. $("#courseCollapse").addClass("in");
  562. $("#skillsCollapse").addClass("in");
  563. $("#sn-sidebar-collapse").addClass("in");
  564. $("#user_image_block").removeClass("text-muted");
  565. } else {
  566. $("#profileCollapse").removeClass("in");
  567. $("#courseCollapse").removeClass("in");
  568. $("#skillsCollapse").removeClass("in");
  569. $("#sn-avatar-one").removeClass("in");
  570. $("#user_image_block").addClass("text-muted");
  571. }
  572. }
  573. function addMainEvent(elm, evType, fn, useCapture) {
  574. if (elm.addEventListener) {
  575. elm.addEventListener(evType, fn, useCapture);
  576. return true;
  577. } else if (elm.attachEvent) {
  578. elm.attachEvent('on' + evType, fn);
  579. } else {
  580. elm['on'+evType] = fn;
  581. }
  582. }
  583. function copyTextToClipBoard(elementId)
  584. {
  585. /* Get the text field */
  586. var copyText = document.getElementById(elementId);
  587. /* Select the text field */
  588. copyText.select();
  589. /* Copy the text inside the text field */
  590. document.execCommand("copy");
  591. }