$(document).ready(function() { var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); var themeprefix = app.data("home") + app.data("themeprefix"); var clientroot = jQuery("#showcaseclient").data("clientroot"); jQuery("body") .on("click", "#addcue", function() { var paused = cuepoint.video.paused; var departmentasset = jQuery(this) .data("dataid"); var targetfield = jQuery(this).data("targetfield"); var current = cuepoint.currentTime(); var time = Math.round(current); jQuery .ajax({ url: clientroot + "/addcue.html?save=true&field=timecode&timecode.value=" + time + "&field=assetid&assetid.value=" + departmentasset + "&planid=" + departmentasset + "&targetfield", async: false, success: function(data) { reloadCues(paused, data); //$('#editmodal').modal('hide'); if (paused) { pause(); } } }); }); jQuery("body").on('click', ".cardloader", function() { var target = $(this).data("target"); return false; }); jQuery("body").on('click', ".shiftLeft", function() { var amount = jQuery(this).data("amount"); if (amount == null) { amount = 1; } shiftLeft(amount); return false; }); jQuery("body").on('click', ".shiftRight", function() { var amount = jQuery(this).data("amount"); if (amount == null) { amount = 1; } shiftRight(amount); return false; }); jQuery("body").on("click", '.play', function() { play(); var hidepanel = jQuery(this).data("hidepanel"); if (hidepanel == true) { $("#responseform :input").prop("disabled", true); jQuery(".autohide").fadeOut("slow"); } return false; }); // TODO: Move this code to a function jQuery(".ImageLink").on('mousedown', function(e) { $(this).data('p0', { x: e.pageX, y: e.pageY }); }).on( 'mouseup', function(e) { var p0 = $(this).data('p0'), p1 = { x: e.pageX, y: e.pageY }, d = Math.sqrt(Math.pow(p1.x - p0.x, 2) + Math.pow(p1.y - p0.y, 2)); if (d < 4) { e.stopPropagation(); e.preventDefault(); // reload the page into application and full // screen it var link = $(this).attr("href"); window.location.assign(link); /* * jQuery.get(link, {}, function(data) { * $('#application').replaceWith(data); * //now somehow let it load? } ); * $('#application').fullScreen(function(e) { * $(window).resize(); }); */ } }); }); updateVideoDisplay = function() { var urls = apphome + "/test/active/actions/teststatus.json"; console.log("Updating.."); $.getJSON(urls, function(data) { var percent = data.testdata.percentcomplete; $("#completion-bar").css("width", percent + "%"); jQuery.each(data.testdata.nodes, function(index, more) { console.log(more.id + ":" + more.show); var id = more.id; var show = more.show; if (show) { console.log("showing" + id); jQuery("#node-" + id).show(); } else { console.log("hiding" + id); jQuery("#node-" + id).hide(); } }); }); } getPadding = function() { if ($("#cuepointcontainer").is(":visible")) { return 200; } return 80; } jump = function(timecode) { if (timecode == null) { timecode = getSessionValue("timecode"); } console.log("time " + timecode); cuepoint.setTime(timecode); } mark = function() { var current = cuepoint.currentTime(); setSessionValue("timecode", current); } pause = function() { cuepoint.pause(); } play = function() { cuepoint.play(); } play = function() { cuepoint.play(); } $('#productmodal').on('show', function() { pause(); }); slideToCue = function() { var page = jQuery(".videolinks a.current").parents(".item").data("page"); var cueid = jQuery(".videolinks a.current").data("cueid"); loadCueMenu(cueid); jQuery("#myCarousel").carousel(page); jQuery("#myCarousel").carousel('pause'); $(window).resize(); } shiftLeft = function(shiftamount) { var current = cuepoint.currentTime(); current = current - shiftamount; var paused = cuepoint.video.paused; cuepoint.setTime(current); if (paused) { pause(); } // cuepoint.play(); } shiftRight = function(shiftamount) { var current = cuepoint.currentTime(); current = current + shiftamount; var paused = cuepoint.video.paused; cuepoint.setTime(current); if (paused) { pause(); } } loadCueMenu = function(cueid) { var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); var dataid = jQuery("#showcaseclient").data("dataid"); var clientroot = jQuery("#showcaseclient").data("clientroot"); jQuery("#cuepointactions").load(clientroot + "/details/cuepointactions.html?oemaxlevel=1&cueid=" + cueid + "&dataid=" + dataid); } reloadCues = function(paused, startingcue) { var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); var videoid = jQuery("#video-cuepoints").data("dataid"); if (paused) { var pstatus = "true" } else { pstatus = "false"; } var clientroot = jQuery("#showcaseclient").data("clientroot"); jQuery("#video-cuepoints").load(clientroot + "/details/cuepoints.html?oemaxlevel=1&id=" + videoid + "&paused=" + pstatus + "&planid=" + videoid, function() { if (startingcue != null) { var slide = jQuery("#aslide-" + startingcue); loadCueMenu(startingcue); slide.addClass("current"); slideToCue(); if (paused) { pause(); } } } ); } reloadProducts = function() { var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); var videoid = jQuery("#cuepoint-products").data("cueid"); var clientroot = app.data("home") + jQuery("#showcaseclient").data("clientroot"); jQuery("#cuepoint-products").load(clientroot + "/details/cuepointproducts.html?oemaxlevel=1&cueid=" + videoid); } setSessionValue = function(key, value) { var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); jQuery.ajax({ url: apphome + "/components/session/setvalue.html?key=" + key + "&value=" + value }); } getSessionValue = function(key) { var returnval = ""; var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); jQuery.ajax({ url: apphome + "/components/session/getvalue.html?key=" + key, async: false, success: function(data) { returnval = data; } }); return returnval; } showModal = function(inUrl) { $('#edit-modal-body').load(inUrl, function(result) { var textareas = jQuery(".htmleditor"); if (textareas.size() > 0) { loadEditors(); } $('#editmodal').modal({ show: true }); }); }