diff --git a/assets/js/legacy/annotation.js b/assets/js/legacy/annotation.js index bf0f8901432..3a546eb80c5 100644 --- a/assets/js/legacy/annotation.js +++ b/assets/js/legacy/annotation.js @@ -1,327 +1,325 @@ /* For licensing terms, see /license.txt */ -(function (window, $) { - "use strict"; +;(function (window, $) { + "use strict" function getPointOnImage(referenceElement, x, y) { var pointerPosition = { left: x + window.scrollX, - top: y + window.scrollY + top: y + window.scrollY, }, canvasOffset = { x: referenceElement.getBoundingClientRect().left + window.scrollX, - y: referenceElement.getBoundingClientRect().top + window.scrollY - }; + y: referenceElement.getBoundingClientRect().top + window.scrollY, + } return { x: Math.round(pointerPosition.left - canvasOffset.x), - y: Math.round(pointerPosition.top - canvasOffset.y) - }; + y: Math.round(pointerPosition.top - canvasOffset.y), + } } var SvgElementModel = function (attributes) { - this.attributes = attributes; - this.id = 0; - this.name = ""; + this.attributes = attributes + this.id = 0 + this.name = "" - this.changeEvent = null; - }; + this.changeEvent = null + } SvgElementModel.prototype.set = function (key, value) { - this.attributes[key] = value; + this.attributes[key] = value if (this.changeEvent) { - this.changeEvent(this); + this.changeEvent(this) } - }; + } SvgElementModel.prototype.get = function (key) { - return this.attributes[key]; - }; + return this.attributes[key] + } SvgElementModel.prototype.onChange = function (callback) { - this.changeEvent = callback; - }; + this.changeEvent = callback + } SvgElementModel.decode = function () { - return new this(); - }; + return new this() + } SvgElementModel.prototype.encode = function () { - return ""; - }; + return "" + } var SvgPathModel = function (attributes) { - SvgElementModel.call(this, attributes); - }; - SvgPathModel.prototype = Object.create(SvgElementModel.prototype); + SvgElementModel.call(this, attributes) + } + SvgPathModel.prototype = Object.create(SvgElementModel.prototype) SvgPathModel.prototype.addPoint = function (x, y) { - x = parseInt(x); - y = parseInt(y); + x = parseInt(x) + y = parseInt(y) - var points = this.get("points"); - points.push([x, y]); + var points = this.get("points") + points.push([x, y]) - this.set("points", points); - }; + this.set("points", points) + } SvgPathModel.prototype.encode = function () { - var pairedPoints = []; + var pairedPoints = [] this.get("points").forEach(function (point) { - pairedPoints.push( - point.join(";") - ); - }); + pairedPoints.push(point.join(";")) + }) - return "P)(" + pairedPoints.join(")("); - }; + return "P)(" + pairedPoints.join(")(") + } SvgPathModel.decode = function (pathInfo) { - var points = []; + var points = [] $(pathInfo).each(function (i, point) { - points.push([point.x, point.y]); - }); + points.push([point.x, point.y]) + }) - return new SvgPathModel({points: points}); - }; + return new SvgPathModel({ points: points }) + } var TextModel = function (userAttributes) { - var attributes = $.extend({ - text: "", - x: 0, - y: 0, - color: "red", - fontSize: 20 - }, userAttributes); - - SvgElementModel.call(this, attributes); - }; - TextModel.prototype = Object.create(SvgElementModel.prototype); + var attributes = $.extend( + { + text: "", + x: 0, + y: 0, + color: "red", + fontSize: 20, + }, + userAttributes, + ) + + SvgElementModel.call(this, attributes) + } + TextModel.prototype = Object.create(SvgElementModel.prototype) TextModel.prototype.encode = function () { - return "T)(" + this.get("text") + ")(" + this.get("x") + ";" + this.get("y"); - }; + return "T)(" + this.get("text") + ")(" + this.get("x") + ";" + this.get("y") + } TextModel.decode = function (textInfo) { return new TextModel({ text: textInfo.text, x: textInfo.x, - y: textInfo.y - }); - }; + y: textInfo.y, + }) + } var SvgPathView = function (model) { - var self = this; + var self = this - this.model = model; + this.model = model this.model.onChange(function () { - self.render(); - }); - - this.el = document.createElementNS("http://www.w3.org/2000/svg", "path"); - this.el.setAttribute("fill", "transparent"); - this.el.setAttribute("stroke", "red"); - this.el.setAttribute("stroke-width", "3"); - }; + self.render() + }) + + this.el = document.createElementNS("http://www.w3.org/2000/svg", "path") + this.el.setAttribute("fill", "transparent") + this.el.setAttribute("stroke", "red") + this.el.setAttribute("stroke-width", "3") + } SvgPathView.prototype.render = function () { - var d = ""; + var d = "" - $.each( - this.model.get("points"), - function (i, point) { - d += (i === 0) ? "M" : " L "; - d += point[0] + " " + point[1]; - } - ); + $.each(this.model.get("points"), function (i, point) { + d += i === 0 ? "M" : " L " + d += point[0] + " " + point[1] + }) - this.el.setAttribute("d", d); + this.el.setAttribute("d", d) - return this; - }; + return this + } var TextView = function (model) { - var self = this; + var self = this - this.model = model; + this.model = model this.model.onChange(function () { - self.render(); - }); - - this.el = document.createElementNS('http://www.w3.org/2000/svg', 'text'); - this.el.setAttribute('fill', this.model.get('color')); - this.el.setAttribute('font-size', this.model.get('fontSize')); - this.el.setAttribute('stroke', 'none'); - }; + self.render() + }) + + this.el = document.createElementNS("http://www.w3.org/2000/svg", "text") + this.el.setAttribute("fill", this.model.get("color")) + this.el.setAttribute("font-size", this.model.get("fontSize")) + this.el.setAttribute("stroke", "none") + } TextView.prototype.render = function () { - this.el.setAttribute('x', this.model.get('x')); - this.el.setAttribute('y', this.model.get('y')); - this.el.textContent = this.model.get('text'); + this.el.setAttribute("x", this.model.get("x")) + this.el.setAttribute("y", this.model.get("y")) + this.el.textContent = this.model.get("text") - return this; - }; + return this + } var ElementsCollection = function () { - this.models = []; - this.length = 0; - this.addEvent = null; - }; + this.models = [] + this.length = 0 + this.addEvent = null + } ElementsCollection.prototype.add = function (pathModel) { - pathModel.id = ++this.length; + pathModel.id = ++this.length - this.models.push(pathModel); + this.models.push(pathModel) if (this.addEvent) { - this.addEvent(pathModel); + this.addEvent(pathModel) } - }; + } ElementsCollection.prototype.get = function (index) { - return this.models[index]; - }; + return this.models[index] + } ElementsCollection.prototype.onAdd = function (callback) { - this.addEvent = callback; - }; + this.addEvent = callback + } var AnnotationCanvasView = function (elementsCollection, image, questionId) { - var self = this; + var self = this - this.questionId = parseInt(questionId); - this.image = image; + this.questionId = parseInt(questionId) + this.image = image - this.el = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - this.el.setAttribute('version', '1.1'); - this.el.setAttribute('viewBox', '0 0 ' + this.image.width + ' ' + this.image.height); - this.el.setAttribute('width', this.image.width); - this.el.setAttribute('height', this.image.height); + this.el = document.createElementNS("http://www.w3.org/2000/svg", "svg") + this.el.setAttribute("version", "1.1") + this.el.setAttribute("viewBox", "0 0 " + this.image.width + " " + this.image.height) + this.el.setAttribute("width", this.image.width) + this.el.setAttribute("height", this.image.height) - var svgImage = document.createElementNS('http://www.w3.org/2000/svg', 'image'); - svgImage.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.image.src); - svgImage.setAttribute('width', this.image.width); - svgImage.setAttribute('height', this.image.height); + var svgImage = document.createElementNS("http://www.w3.org/2000/svg", "image") + svgImage.setAttributeNS("http://www.w3.org/1999/xlink", "href", this.image.src) + svgImage.setAttribute("width", this.image.width) + svgImage.setAttribute("height", this.image.height) - this.el.appendChild(svgImage); + this.el.appendChild(svgImage) - this.$el = $(this.el); + this.$el = $(this.el) - this.elementsCollection = elementsCollection; + this.elementsCollection = elementsCollection this.elementsCollection.onAdd(function (pathModel) { - self.renderElement(pathModel); - }); + self.renderElement(pathModel) + }) - this.$rdbOptions = null; - }; + this.$rdbOptions = null + } AnnotationCanvasView.prototype.render = function () { - this.setEvents(); + this.setEvents() - this.$rdbOptions = $('[name="' + this.questionId + '-options"]'); + this.$rdbOptions = $('[name="' + this.questionId + '-options"]') - return this; - }; + return this + } AnnotationCanvasView.prototype.setEvents = function () { - var self = this; + var self = this var isMoving = false, - elementModel = null; + elementModel = null self.$el - .on('dragstart', function (e) { - e.preventDefault(); + .on("dragstart", function (e) { + e.preventDefault() }) - .on('click', function (e) { - e.preventDefault(); + .on("click", function (e) { + e.preventDefault() - if ("1" !== self.$rdbOptions.filter(':checked').val()) { - return; + if ("1" !== self.$rdbOptions.filter(":checked").val()) { + return } - var point = getPointOnImage(self.el, e.clientX, e.clientY); - elementModel = new TextModel({x: point.x, y: point.y, text: ''}); - self.elementsCollection.add(elementModel); - elementModel = null; - isMoving = false; + var point = getPointOnImage(self.el, e.clientX, e.clientY) + elementModel = new TextModel({ x: point.x, y: point.y, text: "" }) + self.elementsCollection.add(elementModel) + elementModel = null + isMoving = false }) - .on('mousedown', function (e) { - e.preventDefault(); + .on("mousedown", function (e) { + e.preventDefault() - var point = getPointOnImage(self.el, e.clientX, e.clientY); - if (isMoving || "0" !== self.$rdbOptions.filter(':checked').val() || elementModel) { - return; + var point = getPointOnImage(self.el, e.clientX, e.clientY) + if (isMoving || "0" !== self.$rdbOptions.filter(":checked").val() || elementModel) { + return } - elementModel = new SvgPathModel({points: [[point.x, point.y]]}); - self.elementsCollection.add(elementModel); - isMoving = true; + elementModel = new SvgPathModel({ points: [[point.x, point.y]] }) + self.elementsCollection.add(elementModel) + isMoving = true }) - .on('mousemove', function (e) { - e.preventDefault(); + .on("mousemove", function (e) { + e.preventDefault() - if (!isMoving || "0" !== self.$rdbOptions.filter(':checked').val() || !elementModel) { - return; + if (!isMoving || "0" !== self.$rdbOptions.filter(":checked").val() || !elementModel) { + return } - var point = getPointOnImage(self.el, e.clientX, e.clientY); - elementModel.addPoint(point.x, point.y); + var point = getPointOnImage(self.el, e.clientX, e.clientY) + elementModel.addPoint(point.x, point.y) }) - .on('mouseup', function (e) { - e.preventDefault(); + .on("mouseup", function (e) { + e.preventDefault() - if (!isMoving || "0" !== self.$rdbOptions.filter(':checked').val() || !elementModel) { - return; + if (!isMoving || "0" !== self.$rdbOptions.filter(":checked").val() || !elementModel) { + return } - elementModel = null; - isMoving = false; - }); - }; + elementModel = null + isMoving = false + }) + } AnnotationCanvasView.prototype.renderElement = function (elementModel) { var elementView = null, - self = this; + self = this if (elementModel instanceof SvgPathModel) { - elementView = new SvgPathView(elementModel); + elementView = new SvgPathView(elementModel) } else if (elementModel instanceof TextModel) { - elementView = new TextView(elementModel); + elementView = new TextView(elementModel) } if (!elementView) { - return; + return } - $('') + $("") .attr({ - type: 'hidden', - name: 'choice[' + this.questionId + '][' + elementModel.id + ']' + type: "hidden", + name: "choice[" + this.questionId + "][" + elementModel.id + "]", }) .val(elementModel.encode()) - .appendTo(this.el.parentNode); + .appendTo(this.el.parentNode) - $('') + $("") .attr({ - type: 'hidden', - name: 'hotspot[' + this.questionId + '][' + elementModel.id + ']' + type: "hidden", + name: "hotspot[" + this.questionId + "][" + elementModel.id + "]", }) .val(elementModel.encode()) - .appendTo(this.el.parentNode); + .appendTo(this.el.parentNode) - this.el.appendChild(elementView.render().el); + this.el.appendChild(elementView.render().el) elementModel.onChange(function () { - elementView.render(); + elementView.render() - $('input[name="choice[' + self.questionId + '][' + elementModel.id + ']"]').val(elementModel.encode()); - $('input[name="hotspot[' + self.questionId + '][' + elementModel.id + ']"]').val(elementModel.encode()); - }); + $('input[name="choice[' + self.questionId + "][" + elementModel.id + ']"]').val(elementModel.encode()) + $('input[name="hotspot[' + self.questionId + "][" + elementModel.id + ']"]').val(elementModel.encode()) + }) if (elementModel instanceof TextModel) { - $('') + $("") .attr({ - type: 'text', - name: 'text[' + this.questionId + '][' + elementModel.id + ']' + type: "text", + name: "text[" + this.questionId + "][" + elementModel.id + "]", }) - .addClass('form-control input-sm') - .on('change', function (e) { - elementModel.set('text', this.value); + .addClass("form-control input-sm") + .on("change", function (e) { + elementModel.set("text", this.value) - e.preventDefault(); + e.preventDefault() }) - .val(elementModel.get('text')) - .appendTo('#annotation-toolbar-' + this.questionId + ' ul') + .val(elementModel.get("text")) + .appendTo("#annotation-toolbar-" + this.questionId + " ul") .wrap('
') - .focus(); + .focus() } - }; + } window.AnnotationQuestion = function (userSettings) { $(function () { @@ -329,39 +327,38 @@ { questionId: 0, exerciseId: 0, - relPath: '/' + relPath: "/", }, - userSettings + userSettings, ), - xhrUrl = 'exercise/annotation_user.php?', - $container = $('#annotation-canvas-' + settings.questionId); + xhrUrl = "exercise/annotation_user.php?", + $container = $("#annotation-canvas-" + settings.questionId) $.getJSON(settings.relPath + xhrUrl, { question_id: parseInt(settings.questionId), exe_id: parseInt(settings.exerciseId), - course_id: parseInt(settings.courseId) + course_id: parseInt(settings.courseId), + }).done(function (questionInfo) { + var image = new Image() + image.onload = function () { + var elementsCollection = new ElementsCollection(), + canvas = new AnnotationCanvasView(elementsCollection, this, settings.questionId) + + $container.html(canvas.render().el) + + /** @namespace questionInfo.answers.paths */ + $.each(questionInfo.answers.paths, function (i, pathInfo) { + var pathModel = SvgPathModel.decode(pathInfo) + elementsCollection.add(pathModel) + }) + + /** @namespace questionInfo.answers.texts */ + $(questionInfo.answers.texts).each(function (i, textInfo) { + var textModel = TextModel.decode(textInfo) + elementsCollection.add(textModel) + }) + } + image.src = questionInfo.image.path }) - .done(function (questionInfo) { - var image = new Image(); - image.onload = function () { - var elementsCollection = new ElementsCollection(), - canvas = new AnnotationCanvasView(elementsCollection, this, settings.questionId); - - $container.html(canvas.render().el); - - /** @namespace questionInfo.answers.paths */ - $.each(questionInfo.answers.paths, function (i, pathInfo) { - var pathModel = SvgPathModel.decode(pathInfo); - elementsCollection.add(pathModel); - }); - - /** @namespace questionInfo.answers.texts */ - $(questionInfo.answers.texts).each(function (i, textInfo) { - var textModel = TextModel.decode(textInfo); - elementsCollection.add(textModel); - }); - }; - image.src = questionInfo.image.path; - }); - }); - }; -})(window, window.jQuery); + }) + } +})(window, window.jQuery) diff --git a/assets/js/legacy/app.js b/assets/js/legacy/app.js index 2e8cca623a1..f8763d5bdb6 100644 --- a/assets/js/legacy/app.js +++ b/assets/js/legacy/app.js @@ -24,6 +24,7 @@ import "./main" import moment from "moment" import Sortable from "sortablejs" import Swal from "sweetalert2" +import "./vendor" // Gets HTML content from tinymce window.getContentFromEditor = function (id) { @@ -53,8 +54,6 @@ window.setContentFromEditor = function (id, content) { // global.frameReady = frameReady; // window.frameReady = frameReady; -import "./vendor" - global.moment = moment moment.locale(locale) //$.datepicker.setDefaults($.datepicker.regional[locale]); @@ -544,7 +543,7 @@ function addMainEvent(elm, evType, fn, useCapture) { } } -window.copyTextToClipBoard = function(elementId) { +window.copyTextToClipBoard = function (elementId) { var copyText = document.getElementById(elementId) if (copyText) { diff --git a/assets/js/legacy/document.js b/assets/js/legacy/document.js index 58955fb44f4..230231dcd90 100755 --- a/assets/js/legacy/document.js +++ b/assets/js/legacy/document.js @@ -1,9 +1,9 @@ -import { createPinia, setActivePinia } from 'pinia' +import { createPinia, setActivePinia } from "pinia" +import translateHtml from "./../translatehtml.js" const pinia = createPinia() setActivePinia(pinia) -import translateHtml from './../translatehtml.js' -document.addEventListener('DOMContentLoaded', function () { +document.addEventListener("DOMContentLoaded", function () { translateHtml() -}); +}) diff --git a/assets/js/legacy/exercise.js b/assets/js/legacy/exercise.js index d8a7cc604c7..f4089d484f4 100644 --- a/assets/js/legacy/exercise.js +++ b/assets/js/legacy/exercise.js @@ -1,38 +1,38 @@ // Script to be added in the exercises tool. -import 'jsplumb'; -import 'jquery-ui-touch-punch'; -import 'signature_pad'; -import '../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.dateformat.min.js'; -import '../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.epiclock.js'; -import '../../../public/main/inc/lib/javascript/epiclock/renderers/minute/epiclock.minute.js'; -import './annotation' -import '../../../public/main/inc/lib/javascript/hotspot/js/hotspot.js'; -import '../../../public/main/inc/lib/javascript/d3/jquery.xcolor.js'; +import "jsplumb" +import "jquery-ui-touch-punch" +import "signature_pad" +import "../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.dateformat.min.js" +import "../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.epiclock.js" +import "../../../public/main/inc/lib/javascript/epiclock/renderers/minute/epiclock.minute.js" +import "./annotation" +import "../../../public/main/inc/lib/javascript/hotspot/js/hotspot.js" +import "../../../public/main/inc/lib/javascript/d3/jquery.xcolor.js" -document.addEventListener("DOMContentLoaded", function() { +document.addEventListener("DOMContentLoaded", function () { // Mapping French paths to their English equivalents var routeMapping = { - "enregistrement-audio": "audio-recording-help" - }; + "enregistrement-audio": "audio-recording-help", + } - var currentUrlParams = new URLSearchParams(window.location.search); - var cid = currentUrlParams.get('cid') || '0'; - var sid = currentUrlParams.get('sid') || '0'; - var gid = currentUrlParams.get('gid') || '0'; + var currentUrlParams = new URLSearchParams(window.location.search) + var cid = currentUrlParams.get("cid") || "0" + var sid = currentUrlParams.get("sid") || "0" + var gid = currentUrlParams.get("gid") || "0" - var links = document.querySelectorAll('a[href*="web"]'); - links.forEach(function(link) { - var href = link.getAttribute("href"); - var pathSegments = href.split("/"); - var lastSegmentIndex = pathSegments.length - (pathSegments[pathSegments.length - 1] === '' ? 2 : 1); - var lastPathSegment = pathSegments[lastSegmentIndex]; + var links = document.querySelectorAll('a[href*="web"]') + links.forEach(function (link) { + var href = link.getAttribute("href") + var pathSegments = href.split("/") + var lastSegmentIndex = pathSegments.length - (pathSegments[pathSegments.length - 1] === "" ? 2 : 1) + var lastPathSegment = pathSegments[lastSegmentIndex] if (lastPathSegment && routeMapping[lastPathSegment]) { - var englishEquivalent = routeMapping[lastPathSegment]; - var newHref = `/main/inc/ajax/exercise.ajax.php?a=${englishEquivalent}&cid=${cid}&sid=${sid}&gid=${gid}`; - link.setAttribute("href", newHref); - link.setAttribute("data-title", link.textContent.trim()); - link.classList.add("ajax"); + var englishEquivalent = routeMapping[lastPathSegment] + var newHref = `/main/inc/ajax/exercise.ajax.php?a=${englishEquivalent}&cid=${cid}&sid=${sid}&gid=${gid}` + link.setAttribute("href", newHref) + link.setAttribute("data-title", link.textContent.trim()) + link.classList.add("ajax") } - }); -}); + }) +}) diff --git a/assets/js/legacy/lp.js b/assets/js/legacy/lp.js index fbcc5835cf7..359e590cc82 100644 --- a/assets/js/legacy/lp.js +++ b/assets/js/legacy/lp.js @@ -1,44 +1,42 @@ - /* For licensing terms, see /license.txt */ -import $ from 'jquery'; - -window.jQuery = $; -window.$ = $; -global.jQuery = $; +import $ from "jquery" +import "jquery-ui-dist/jquery-ui.js" -import 'jquery-ui-dist/jquery-ui.js'; +window.jQuery = $ +window.$ = $ +global.jQuery = $ -const frameReady = require('/public/main/inc/lib/javascript/jquery.frameready.js'); +const frameReady = require("/public/main/inc/lib/javascript/jquery.frameready.js") -global.frameReady = frameReady; -window.frameReady = frameReady; +global.frameReady = frameReady +window.frameReady = frameReady -var hljs = require('highlight.js'); -global.hljs = hljs; +var hljs = require("highlight.js") +global.hljs = hljs -document.addEventListener('DOMContentLoaded', (event) => { - var tabLinks = document.querySelectorAll('.nav-item.nav-link'); +document.addEventListener("DOMContentLoaded", (event) => { + var tabLinks = document.querySelectorAll(".nav-item.nav-link") function removeActiveClasses() { - tabLinks.forEach(function(link) { - link.classList.remove('active'); - var tabPanel = document.getElementById(link.getAttribute('aria-controls')); + tabLinks.forEach(function (link) { + link.classList.remove("active") + var tabPanel = document.getElementById(link.getAttribute("aria-controls")) if (tabPanel) { - tabPanel.classList.remove('active'); + tabPanel.classList.remove("active") } - }); + }) } - tabLinks.forEach(function(link) { - link.addEventListener('click', function() { - removeActiveClasses(); - this.classList.add('active'); - var tabContentId = this.getAttribute('aria-controls'); - var tabContent = document.getElementById(tabContentId); + tabLinks.forEach(function (link) { + link.addEventListener("click", function () { + removeActiveClasses() + this.classList.add("active") + var tabContentId = this.getAttribute("aria-controls") + var tabContent = document.getElementById(tabContentId) if (tabContent) { - tabContent.classList.add('active'); + tabContent.classList.add("active") } - }); - }); -}); + }) + }) +}) diff --git a/assets/js/legacy/main.js b/assets/js/legacy/main.js index a577f091ac3..6cc10f86034 100644 --- a/assets/js/legacy/main.js +++ b/assets/js/legacy/main.js @@ -2,35 +2,40 @@ $(function () { // Elevator Scroll $(window).scroll(function () { if ($(this).scrollTop() > 50) { - $('.app-elevator').fadeIn(); + $(".app-elevator").fadeIn() } else { - $('.app-elevator').fadeOut(); + $(".app-elevator").fadeOut() } - }); + }) // scroll body to 0px on click - $('#back-to-top').click(function () { - $('#back-to-top').tooltip('hide'); - $('body,html').animate({ - scrollTop: 0 - }, 800); - return false; - }); + $("#back-to-top").click(function () { + $("#back-to-top").tooltip("hide") + $("body,html").animate( + { + scrollTop: 0, + }, + 800, + ) + return false + }) - var $inputTitle = $("#add_course_title"); - $inputTitle.keyup(function () { - var value = $(this).val(); - var titleDefault = "Course Title"; - if (value.length > 0) { - $("#title_course_card").text(value); - } else { - $("#title_course_card").text(titleDefault); - } - }).keyup(); + var $inputTitle = $("#add_course_title") + $inputTitle + .keyup(function () { + var value = $(this).val() + var titleDefault = "Course Title" + if (value.length > 0) { + $("#title_course_card").text(value) + } else { + $("#title_course_card").text(titleDefault) + } + }) + .keyup() $("select[name=category_code]").change(function () { - $(".category").show(); - var $category = $('select[name=category_code] option:selected').html(); - $(".category").text($category); - }); -}); + $(".category").show() + var $category = $("select[name=category_code] option:selected").html() + $(".category").text($category) + }) +})