audio won't work on safari browser - html

could someone please help me to find out why this won't work on safari browser? It seems to work really well in all other browsers apart from Safari. I really could not work it out.
Any help will be most appreciated.
function loadPlayer()
{
var audioPlayer = new Audio();
audioPlayer.controls="";
audioPlayer.setAttribute("data-index", -1); //set default index to -1.
audioPlayer.addEventListener('ended',nextSong,false);
audioPlayer.addEventListener('error',errorFallback,true);
document.getElementById("player").appendChild(audioPlayer);
}
function nextSong(index, e)
{
var next;
var audioPlayer = document.getElementsByTagName('audio')[0];
//check for index. If so load from index. If not, index is defined auto iterate to next value.
if (index >= 0)
{
next = index;
}
else
{
next = parseInt(audioPlayer.getAttribute("data-index"))+1;
next >= urls.length ? next = 0 : null;
}
audioPlayer.src=urls[next][0]; //load the url.
audioPlayer.setAttribute("data-index", next);
//disable the player.
var audioPlayerControls = document.getElementById("playerControls");
audioPlayer.removeEventListener('canplay',enablePlayerControls,false);
audioPlayerControls.setAttribute("disabled", true);
audioPlayer.addEventListener('canplay',enablePlayerControls,false);
audioPlayer.load();
//show the image:
var image = document.getElementById("playerList").querySelectorAll("a")[next].querySelector("img").cloneNode();
image.style.width = "30px";
if(audioPlayerControls.querySelector("img"))
{
audioPlayerControls.replaceChild(image, audioPlayerControls.querySelector("img"));
}
else
{
audioPlayerControls.insertBefore(image, audioPlayerControls.querySelector("a"));
}
}
function enablePlayerControls()
{
//File has loaded, so we can start playing the audio.
//Enable the player options.
var audioPlayer = document.getElementsByTagName('audio')[0];
audioPlayer.removeEventListener('canplay',enablePlayerControls,false);
document.getElementById("playerControls").removeAttribute("disabled");
audioPlayer.play();
}
function errorFallback() {
nextSong();
}
function playPause()
{
var audioPlayer = document.getElementsByTagName('audio')[0];
if (audioPlayer.paused)
{
audioPlayer.play();
} else
{
audioPlayer.pause();
}
}
function pickSong(e)
{
//we want the correct target. Select it via the event (e).
var target;
//pickSong does the selecting:
if (e && e.target && e.target.tagName && e.target.tagName.toLowerCase() == "img")
{
//The event target = the img element.
target = e.target.parentElement;
}
else
{
//the event target is the a element
target = e.target;
}
var index = target.getAttribute("data-index"); //get the song index stored in the data-index attribute.
nextSong(index);
}
var urls = new Array();
urls[0] = ['http://mp3lg4.tdf-cdn.com/9079/jet_143844.mp3', 'http://radio-maghreb.net/radio/radio almazighia.png'];
urls[1] = ['http://mp3lg4.tdf-cdn.com/9077/jet_143651.mp3', "http://radio-maghreb.net/radio/alwatania.png"];
urls[2] = ['http://mp3lg4.tdf-cdn.com/9080/jet_144136.mp3', "http://radio-maghreb.net/radio/inter.jpg"];
function startAudioPlayer()
{
loadPlayer();
for (var i = 0; i < urls.length; ++i)
{
//this for loop runs through all urls and appends them to the player list. This smooths the adding off new items. You only have
//to declare them in the array, the script does the rest.
var link = document.createElement("a");
link.href = "javascript: void(0)";
link.addEventListener("click", pickSong, false);
link.setAttribute("data-index", i);
link.img = document.createElement("img");
link.img.src = urls[i][1];
link.appendChild(link.img);
document.getElementById("playerList").appendChild(link);
}
}
//Event that starts the audio player.
window.addEventListener("load", startAudioPlayer, false);
#playerControls[disabled=true] > a{
color: #c3c3c3;
}
<span id="playerControls" disabled="true">
Play
Stop
</span>
Next Track
<!-- player ends -->
<br>
<br>
<!-- img links start -->
<div id="playerList">
</div>

Related

Get the first hyperlink and its text value

I hope everyone is in good health health and condition.
Recently, I have been working on Google Docs hyperlinks using app scripts and learning along the way. I was trying to get all hyperlink and edit them and for that I found an amazing code from this post. I have read the code multiple times and now I have a good understanding of how it works.
My confusion
My confusion is the recursive process happening in this code, although I am familiar with the concept of Recursive functions but when I try to modify to code to get only the first hyperlink from the document, I could not understand it how could I achieve that without breaking the recursive function.
Here is the code that I am trying ;
/**
* Get an array of all LinkUrls in the document. The function is
* recursive, and if no element is provided, it will default to
* the active document's Body element.
*
* #param {Element} element The document element to operate on.
* .
* #returns {Array} Array of objects, vis
* {element,
* startOffset,
* endOffsetInclusive,
* url}
*/
function getAllLinks(element) {
var links = [];
element = element || DocumentApp.getActiveDocument().getBody();
if (element.getType() === DocumentApp.ElementType.TEXT) {
var textObj = element.editAsText();
var text = element.getText();
var inUrl = false;
for (var ch=0; ch < text.length; ch++) {
var url = textObj.getLinkUrl(ch);
if (url != null) {
if (!inUrl) {
// We are now!
inUrl = true;
var curUrl = {};
curUrl.element = element;
curUrl.url = String( url ); // grab a copy
curUrl.startOffset = ch;
}
else {
curUrl.endOffsetInclusive = ch;
}
}
else {
if (inUrl) {
// Not any more, we're not.
inUrl = false;
links.push(curUrl); // add to links
curUrl = {};
}
}
}
if (inUrl) {
// in case the link ends on the same char that the element does
links.push(curUrl);
}
}
else {
var numChildren = element.getNumChildren();
for (var i=0; i<numChildren; i++) {
links = links.concat(getAllLinks(element.getChild(i)));
}
}
return links;
}
I tried adding
if (links.length > 0){
return links;
}
but it does not stop the function as it is recursive and it return back to its previous calls and continue running.
Here is the test document along with its script that I am working on.
https://docs.google.com/document/d/1eRvnR2NCdsO94C5nqly4nRXCttNziGhwgR99jElcJ_I/edit?usp=sharing
I hope you will understand what I am trying to convey, Thanks for giving a look at my post. Stay happy :D
I believe your goal as follows.
You want to retrieve the 1st link and the text of link from the shared Document using Google Apps Script.
You want to stop the recursive loop when the 1st element is retrieved.
Modification points:
I tried adding
if (links.length > 0){
return links;
}
but it does not stop the function as it is recursive and it return back to its previous calls and continue running.
About this, unfortunately, I couldn't understand where you put the script in your script. In this case, I think that it is required to stop the loop when links has the value. And also, it is required to also retrieve the text. So, how about modifying as follows? I modified 3 parts in your script.
Modified script:
function getAllLinks(element) {
var links = [];
element = element || DocumentApp.getActiveDocument().getBody();
if (element.getType() === DocumentApp.ElementType.TEXT) {
var textObj = element.editAsText();
var text = element.getText();
var inUrl = false;
for (var ch=0; ch < text.length; ch++) {
if (links.length > 0) break; // <--- Added
var url = textObj.getLinkUrl(ch);
if (url != null) {
if (!inUrl) {
// We are now!
inUrl = true;
var curUrl = {};
curUrl.element = element;
curUrl.url = String( url ); // grab a copy
curUrl.startOffset = ch;
}
else {
curUrl.endOffsetInclusive = ch;
}
}
else {
if (inUrl) {
// Not any more, we're not.
inUrl = false;
curUrl.text = text.slice(curUrl.startOffset, curUrl.endOffsetInclusive + 1); // <--- Added
links.push(curUrl); // add to links
curUrl = {};
}
}
}
if (inUrl) {
// in case the link ends on the same char that the element does
links.push(curUrl);
}
}
else {
var numChildren = element.getNumChildren();
for (var i=0; i<numChildren; i++) {
if (links.length > 0) { // <--- Added or if (links.length > 0) break;
return links;
}
links = links.concat(getAllLinks(element.getChild(i)));
}
}
return links;
}
In this case, I think that if (links.length > 0) {return links;} can be modified to if (links.length > 0) break;.
Note:
By the way, when Google Docs API is used, both the links and the text can be also retrieved by a simple script as follows. When you use this, please enable Google Docs API at Advanced Google services.
function myFunction() {
const doc = DocumentApp.getActiveDocument();
const res = Docs.Documents.get(doc.getId()).body.content.reduce((ar, {paragraph}) => {
if (paragraph && paragraph.elements) {
paragraph.elements.forEach(({textRun}) => {
if (textRun && textRun.textStyle && textRun.textStyle.link) {
ar.push({text: textRun.content, url: textRun.textStyle.link.url});
}
});
}
return ar;
}, []);
console.log(res) // You can retrieve 1st link and test by console.log(res[0]).
}

Google Apps Script. Get all links from document

Hi all) I need to get all links from google document. I found that general approach:
function getAllLinks(element) {
var links = [];
element = element || DocumentApp.getActiveDocument().getBody();
if (element.getType() === DocumentApp.ElementType.TEXT) {
var textObj = element.editAsText();
var text = element.getText();
Logger.log("text " + text);
var inUrl = false;
for (var ch=0; ch < text.length; ch++) {
var url = textObj.getLinkUrl(ch);
if (url != null) {
if (!inUrl) {
// We are now!
inUrl = true;
var curUrl = {};
curUrl.element = element;
curUrl.url = String( url ); // grab a copy
curUrl.startOffset = ch;
}
else {
curUrl.endOffsetInclusive = ch;
}
}
else {
if (inUrl) {
// Not any more, we're not.
inUrl = false;
links.push(curUrl); // add to links
curUrl = {};
}
}
}
}
else {
var numChildren = element.getNumChildren();
for (var i=0; i<numChildren; i++) {
links = links.concat(getAllLinks(element.getChild(i)));
}
}
Logger.log(links);
}
It works perfectly fine if i, for example, type url in text, but if add link via menu ("Insert" -> "Link") it doesn't work, function getLinkUrl() returns null. Documentation contains info about Link class, i thought all links represented by it, but don't understand why i can't get link inserted via menu.
I thought maybe i can use some regular expression on text of document element, but if i add link via menu item i can specify custom label for link, which may not contain url in it.
Have anyone faced this scenario? What i missed?

Google maps not working IE11 (sharepoint 2010)

I have a code to show Google Maps in my list on Sharepoint 2010. Code plot list items in the map. Work great with Edge and Chrome, but on IE not.
In IE console error on this line (object doesn't support this action (error 445))
var latlng = new google.maps.LatLng(defaultLatitude,defaultLongitude);
//build map
$('#'+idOfMapDiv).css({"width":mapWidth, "height":mapHeight});
var latlng = new google.maps.LatLng(defaultLatitude,defaultLongitude);
var myOptions = {
zoom: 6,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var gmMap = new google.maps.Map(document.getElementById(idOfMapDiv), myOptions);
var gmBounds = new google.maps.LatLngBounds();
var gmGeocoder = new google.maps.Geocoder();
var jQuerySelect_GetListRowByAttributeCTXName;
if(isSharePoint2010)
{
jQuerySelect_GetListRowByAttributeCTXName = jQuerySelect_2010_GetListRowByAttributeCTXName;
}
else
{
jQuerySelect_GetListRowByAttributeCTXName = jQuerySelect_2007_GetListRowByAttributeCTXName;
}
Full code on Sharepoint:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" type="text/javascript"></script><script src="http://maps.google.com/maps/api/js?key=MY KEY" type="text/javascript"></script><script type="text/javascript">
/* *****************************************************
AND NOW SOME VARIABLES YOU MAY WANT TO CHANGE.
***************************************************** */
var mapWidth = "1725px"; //the width of the map
var mapHeight = "400px"; //the height of the map
//if true the coordinates (latitude, longitude) will be used
//if false the addresses (street, zip, city, country) will be used
var useCoordinates = true;
//if true the map will not be shown by default
//if false the map will be shown by default
var hideMapUntilClick = false;
//if 0 absolutely no warning- and error-alerts will be written to a log-div
//if 1 the warning- and error-alerts will be written to a log-div
//if 2 the warning- and error-alerts will be alerted via javascript-alert
var showWarningAndErrorAlerts = 1;
//the internal-names of list-columns (not the display-name!)
var colLinkTitleInternalName = "ows_Nome_x0020_Instala_x00e7__x00e3_"; //will be used as the title of the geo-markers
var colLongitudeInternalName = "ows_Longitude"; //useCoordinates == true
var colLatitudeInternalName = "ows_Latitude"; //useCoordinates == true
var colStreetInternalName = "WorkAddress"; //useCoordinates == false
var colStreetDisplayName = "Endereço"; //useCoordinates == false
var colZipInternalName = "WorkZip"; //useCoordinates == false
var colCityInternalName = "WorkCity"; //useCoordinates == false
var colCountryInternalName = "WorkCountry"; //useCoordinates == false
var defaultCountryValue = "Brazil"; //the default country which will be used if no country-name will be found in the list-column
//default position (Germany: 51.165691,10.451526) > used if no markers will be set to the map
var defaultLatitude = -15.77972;
var defaultLongitude = -47.92972;
//some language-specific messages
var resxGoogleMapsLink = "Google-Map"; //the name of new menu-point in the menu-toolbar of the sharepoint-list
var resxGoogleMapsLinkTitle = "Menu: Show or hide Google-Map"; //the title which will be visible while hovering
var resxAlertsMessageText = resxGoogleMapsLink+": There are # hints!"; //the hint which will be visible if configuration warnings or errors occured.
var resxAlertsMessageTextTitle = "Click here to show or hide the hints!"; //the title which will be visible while hovering
/* *******************************************************************
NOW DO NOT CHANGE ANYTHING IF YOU ARE NOT FAMILIAR WITH JAVASCRIPT!
******************************************************************* */
var isSharePoint2010 = true;
var hasMapBeenLoadedInitially = false;
var idOfMapDiv = "divGoogleMapForSharePointList";
var idOfCustomLogDiv = "divCustomLog";
var idOfCustomLogOverview = "divCustomLogOverview";
var noOfCustomLogEntries = 0;
var noOfMaxGeocodingRequest = 10;
//the attribute-name of the column "id" > will be used for a) finding the id of a certain row and b) for building the ajax-request-url
var colID = "ID";
//now some templates for jquery-selects
var jQuerySelect_2007_GetListRowByAttributeCTXName = "table[CTXName]";
var jQuerySelect_2010_GetListRowByAttributeCTXName = "div[CTXName]";
function InitializeGoogleMapForSharePointList()
{
BuildGoogleMapCustomLogForSharePointList();
if(!DoPreCheckForInitializationOfGooglemapsForSharePointList())
{
//pre-check not successfully done > abort now!
customAlert("The Pre-Check has not been successfully! > Abort now.");
return;
}
DoSchemaCheckAndBuildGoogleMapIconForSharePointList();
}
function DoSchemaCheckAndBuildGoogleMapIconForSharePointList()
{
//get the schema-data for the list
$.get(BuildAjaxRequestUrlForSharePointListSchemaOnly(), {}, function (xml)
{
//find all necessary internal-field-names
var arrNeccessaryFields = new Array();
arrNeccessaryFields.push(colLinkTitleInternalName);
if(useCoordinates)
{
arrNeccessaryFields.push(colLatitudeInternalName);
arrNeccessaryFields.push(colLongitudeInternalName);
}
else
{
arrNeccessaryFields.push(colStreetInternalName);
arrNeccessaryFields.push(colZipInternalName);
arrNeccessaryFields.push(colCityInternalName);
arrNeccessaryFields.push(colCountryInternalName);
}
//check all neccessary internal-field-names
var foundAllNeccessaryFields = true;
for(i=0;i<arrNeccessaryFields.length;i++)
{
//getting <xml><s:Schema><s:ElementType><s:AttributeType name="[internal-field-name]">
var xmlQuery = 'xml > *:first > *:first > *[name='+arrNeccessaryFields[i]+']';
if($(xmlQuery, xml).length<1)
{
foundAllNeccessaryFields = false;
customAlert("Schema-Check failed for internal-field-name '"+arrNeccessaryFields[i]+"'. The field is not available in this list.");
}
}
//check if the neccessary fields have been found
if(foundAllNeccessaryFields)
{
BuildGoogleMapIconForSharePointList();
}
else
{
var ajaxRequestLinkTag = 'ajax-request for list-schema';
customAlert("Hint: You can get the internal names of the columns by calling the "+ajaxRequestLinkTag+" for the current sharepoint-list manually.");
customAlert("Schema-Check failed. Abort now!");
}
});
}
function DoPreCheckForInitializationOfGooglemapsForSharePointList()
{
//check if this is SharePoint2010 or not
//if it is not 2010 it is assumed that it is 2007
if(typeof(_fV4UI)!='undefined')
{
//the checked javascript-variable exists only in 2010
isSharePoint2010 = true;
}
else
{
isSharePoint2010 = false;
}
//for the first shot: support only one table
//for further version we could support more tables (table[class=ms-listviewtable].length>1)
var noOfListViews = $("table[class=ms-listviewtable]").length;
if(noOfListViews==0)
{
//no list-view exists > there is no need to show google-maps
customAlert("There is no list-view available on this site. > No need to show google-maps. > Abort now.");
return false;
}
else if(noOfListViews>1)
{
//there are more than one list-view > this is not supported at the moment
customAlert("There are more than one list-views on the site. This is not supported at the moment. > Abort now!");
return false;
}
//check if multi-lookup exists
if($("table[FieldType=LookupMulti]").length>0)
{
//If there are columns in the list-view which are of type multi-lookup the ajax-call (via owssrv.dll) will return zero results.
var multiMsg = "Multi-lookup exists! Please remove the mulit-lookup-column or use another view (otherwise the ajax-request will receive an empty result). > Abort now!";
multiMsg += "\n\nColumns which are of type multi-lookup are (the display-name will be shown):";
$("table[FieldType=LookupMulti]").each(function(){
var displayName = $(this).attr("displayName");
multiMsg += "\n- "+displayName;
});
customAlert(multiMsg);
return false;
}
//check if javascript-variable exists > we need ctx to get the id of the sharepoint-list
if(ctx==null)
{
//this javascript-variable is essential for getting the list-id and the list-view-id.
customAlert("The javascript-variable 'ctx' does not exist within the html-dom. > Abort now!");
return false;
}
//all checks passed - return true
return true;
}
function BuildGoogleMapCustomLogForSharePointList()
{
if(showWarningAndErrorAlerts!=1)
{
return;
}
var divCustomLogOverview = '<div title="'+resxAlertsMessageTextTitle+'" onclick="ToggleCustomLog();" id="'+idOfCustomLogOverview+'" style="margin: 10px; cursor: pointer; color: red; display: none;"></div>';
$("table.ms-menutoolbar").parent().append(divCustomLogOverview);
var divCustomLog = '<div id="'+idOfCustomLogDiv+'" style="margin: 10px; display: none;"></div>';
$("table.ms-menutoolbar").parent().append(divCustomLog);
}
function ToggleCustomLog()
{
//show or hide
$("#"+idOfCustomLogDiv).toggle();
}
function ToggleGoogleMapDiv()
{
//check if the map will be called for the first time
if(!hasMapBeenLoadedInitially)
{
ShowGoogleMapForSharePointList();
}
//show or hide
$("#"+idOfMapDiv).toggle();
}
function BuildGoogleMapIconForSharePointList()
{
//searching for the correct position in the menu-toolbar (ms-menutoolbar)
$("td.ms-toolbar").each(function(j){
if($(this).attr("width")=="99%")
{
//insert a new menu-item before the found placeholder
//var newMenuItem = '</internal-name-of-column><td class="ms-separator">';
var newMenuItem = '<td class="ms-separator">';
newMenuItem += '<img src="/_layouts/images/blank.gif" alt=""/>';
newMenuItem += '</td>';
newMenuItem += '<td nowrap="true" class="ms-toolbar">';
newMenuItem += '<span title="'+resxGoogleMapsLinkTitle+'">';
newMenuItem += '<div nowrap="nowrap" hoverinactive="ms-menubuttoninactivehover" hoveractive="ms-menubuttonactivehover" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" class="ms-menubuttoninactivehover">';
newMenuItem += '<a onclick="javascript:ToggleGoogleMapDiv();return false;" href="#" style="cursor: pointer; white-space: nowrap;">'+resxGoogleMapsLink+'</a>';
newMenuItem += '</div>';
newMenuItem += '</span>';
newMenuItem += '</td>';
$(this).before(newMenuItem);
}
});
//adding map-canvas as div-tag to the dom
var divMapCanvas = '<div id="'+idOfMapDiv+'" style="margin: 10px; display: none;"></div>';
$("table.ms-menutoolbar").parent().before(divMapCanvas);
//check if the map should be shown as soon as possible or if it should be hidden until the user clicked the new menu-point
if(!hideMapUntilClick)
{
ToggleGoogleMapDiv();
}
}
//gets the complete list-schema and one row with all its values (not filtered by the current used view)
function BuildAjaxRequestUrlForSharePointListByID_Template()
{
if(ctx!=null)
{
//build the url of the ajax-request
return ctx.HttpRoot+'/_vti_bin/owssvr.dll?XMLDATA=1&List=' + ctx.listName + '&Query=*&FilterField1='+colID+'&FilterValue1=';
}
}
//gets the list-schema and no rows
function BuildAjaxRequestUrlForSharePointListSchemaOnly()
{
//build the url of the ajax-request
return BuildAjaxRequestUrlForSharePointListByID_Template()+'-1';
}
function ShowGoogleMapForSharePointList()
{
//build the url of the ajax-request
var urlTemplate = BuildAjaxRequestUrlForSharePointListByID_Template();
//build map
$('#'+idOfMapDiv).css({"width":mapWidth, "height":mapHeight});
var latlng = new google.maps.LatLng(defaultLatitude,defaultLongitude);
var myOptions = {
zoom: 6,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var gmMap = new google.maps.Map(document.getElementById(idOfMapDiv), myOptions);
var gmBounds = new google.maps.LatLngBounds();
var gmGeocoder = new google.maps.Geocoder();
var jQuerySelect_GetListRowByAttributeCTXName;
if(isSharePoint2010)
{
jQuerySelect_GetListRowByAttributeCTXName = jQuerySelect_2010_GetListRowByAttributeCTXName;
}
else
{
jQuerySelect_GetListRowByAttributeCTXName = jQuerySelect_2007_GetListRowByAttributeCTXName;
}
//check if the number of geocodings will exceed the max-number
if(!useCoordinates && $(jQuerySelect_GetListRowByAttributeCTXName).length > noOfMaxGeocodingRequest)
{
var linkToStatusCodes = '<a title="Statuscodes of geocoding-responses from Google-Maps" target="_blank" href="http://code.google.com/intl/de-DE/apis/maps/documentation/javascript/services.html#GeocodingStatusCodes">OVER_QUERY_LIMIT-Status</a>';
var tooManyMsg = "Hint: In the current view of the SharePoint-List there are more than "+noOfMaxGeocodingRequest+" list-entries. ";
tooManyMsg += "This will result in an "+linkToStatusCodes+" by Google-Maps (and not all markers will be shown on the map). > You have 2 options: ";
tooManyMsg += "a) Change your view to get no more than "+noOfMaxGeocodingRequest+" list-entries or ";
tooManyMsg += "b) use the coordinates (longitude, latitude) of the addresses (they will be shown on the map).";
customAlert(tooManyMsg);
}
//get each row from list-view which is shown at the moment
$(jQuerySelect_GetListRowByAttributeCTXName).each(function(j)
{
var lat, lng, gmLatLng, gmMarker, title, customUrl, street, city, country;
var idOfListItem = $(this).attr(colID);
if(isSharePoint2010)
{
var linkToListItem = '<table height="auto" width="calcWidthpx"><tr class="ms-alternating ms-itmhover"><td height="100%" class="ms-vb-title" onmouseover="OnChildItem(this)">';
linkToListItem += $(this).parent().html();
linkToListItem += '</td></tr></table><span style="font-size:72pt;"></br></span>';
}
else
{
linkToListItem = $(this).parent().html();
linkToListItem = linkToListItem.replace(/100%/g, "auto"); //exchange tag-attributes for width and height
}
//build url for the ajax-request which reads all data for a certain row (for the current list-view)
customUrl = urlTemplate+idOfListItem;
//get the data for the row
$.get(customUrl, {}, function (xml)
{
$('xml > *:last > *', xml).each(function (i)
{
//get some data from the xml-response
title = $(this).attr(colLinkTitleInternalName);
if(isSharePoint2010)
{
var titleLength= title.length+185;
linkToListItem = linkToListItem.replace('calcWidth', titleLength);
}
if(useCoordinates)
{
//getting coordinates
lat = $(this).attr(colLatitudeInternalName);
lng = $(this).attr(colLongitudeInternalName);
if(typeof(lat)!='undefined' && typeof(lng)!='undefined')
{
gmLatLng = new google.maps.LatLng(lat, lng);
msgForInfoWindow = linkToListItem; //you may add more information-text here
SetMarkerForGoogleMapForSharePointList(gmLatLng, gmMap, gmBounds, title, msgForInfoWindow);
}
else
{
customAlert(title +" has undefined lat+lng. > Do not add marker on map.");
}
}
else
{
//getting address
street = $(this).attr(colStreetInternalName);
zip = $(this).attr(colZipInternalName);
city = $(this).attr(colCityInternalName);
country = $(this).attr(colCountryInternalName);
//checking received values
if(typeof(street)=='undefined') street = ""; //optional
if(typeof(zip)=='undefined') zip = ""; //optional
if(typeof(city)=='undefined')
{
customAlert("The ajax-response got no city for '"+title+"'. > Do not add marker on map.");
return;
}
if(typeof(country)=='undefined') country = defaultCountryValue;
address = street+","+zip+","+city+","+country;
//getting coordinates
gmGeocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
if(results.length==0)
{
customAlert("Geocoding: There are no results for address '"+results[0].formatted_address+"'! Expected exactly one result. > Do not show any marker on map for this address.");
}
else if(results.length>1)
{
var msg = "Geocoding: There are too many ("+results.length+") results for given address! Expected exactly one result. > Do not show any marker on map for this address.\n\nFound addresses:\n";
for(i=0;i<results.length;i++)
{
var c = i+1;
msg += "\n"+c+": "+results[i].formatted_address;
}
customAlert(msg);
}
else
{
gmLatLng = results[0].geometry.location;
var msgForInfoWindow = linkToListItem+"<br>";
msgForInfoWindow += "<span style='font-size:0.8em;'>Koordinaten (Lat, Lon): "+gmLatLng+"<br>Adresse: "+results[0].formatted_address+"</span>";
SetMarkerForGoogleMapForSharePointList(gmLatLng, gmMap, gmBounds, title, msgForInfoWindow);
}
}
else
{
customAlert("Geocode for address '"+address+"' was not successful for the following reason: " + status);
}
});
}
});
});
});
hasMapBeenLoadedInitially = true;
}
function SetMarkerForGoogleMapForSharePointList(gmLatLng, gmMap, gmBounds, title, contentForInfoWindow)
{
var gmMarker = new google.maps.Marker({
position: gmLatLng,
map: gmMap,
title: title,
zIndex: 0
});
gmBounds.extend(gmLatLng);
gmMap.setCenter(gmBounds.getCenter());
gmMap.fitBounds(gmBounds);
if(contentForInfoWindow!=null && contentForInfoWindow!="")
{
var gmInfowindow = new google.maps.InfoWindow({
content: contentForInfoWindow
});
google.maps.event.addListener(gmMarker, 'click', function() {
gmInfowindow.open(gmMap,gmMarker);
});
}
}
function customAlert(msg)
{
if(msg==null || msg=="")
{
return;
}
else
{
var now = new Date();
msg = now.getHours()+":"+now.getMinutes()+":"+now.getSeconds()+": "+msg;
}
if(showWarningAndErrorAlerts==0)
{
//do nothing
}
else if(showWarningAndErrorAlerts==1)
{
//do log in log-div
msg = msg.replace(/\n/g, "<br/>");
msg += "<br/><br/>";
$("#"+idOfCustomLogDiv).append(msg);
noOfCustomLogEntries++;
$("#"+idOfCustomLogOverview).show();
var overviewText = resxAlertsMessageText.replace(/#/g, noOfCustomLogEntries);
$("#"+idOfCustomLogOverview).text(overviewText);
}
else if(showWarningAndErrorAlerts==2)
{
//do alert via javascript-alert
alert(msg);
}
else
{
//unsupported
}
}
//call initialization after the dom has been loaded completely > so it does not matter where this piece of javascript will be inserted in the dom
$(document).ready(InitializeGoogleMapForSharePointList);</script>
Result in Chrome e Edge:
Screenshot
Just to put an answer to this question, adding the meta tag of <meta http-equiv="X-UA-Compatible" content="IE=8"> would solve the issue.

How to syncronize iframes (html5-banner)?

I would like to synchronize two advertising banners (html5) on a website. The banners are displayed in iframes. I have unfortunately only access to the code of the two banner. I'm trying to use localconnection.js
The html5 banner I create with adobe animate. My two test banners contain a very simple animation. The one banner is a little shorter, in order to demonstrate the temporal "diverge" with different banners. The animation of the right banner I stopped in the first picture (directly behind the Connect) - which should then be "pushed" from the left banner. Is that right? And if so, how do I do that?
HTML - Banner 1:
<!DOCTYPE html>
<!--
NOTES:
1. All tokens are represented by '$' sign in the template.
2. You can write your code only wherever mentioned.
3. All occurrences of existing tokens will be replaced by their appropriate values.
4. Blank lines will be removed automatically.
5. Remove unnecessary comments before creating your template.
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="authoring-tool" content="Adobe_Animate_CC">
<title>sky1</title>
<!-- write your code here -->
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
<script src="sky1.js"></script>
<script src="localconnection.js"></script>
<script>
var canvas, stage, exportRoot;
function init() {
canvas = document.getElementById("canvas");
handleComplete();
}
function handleComplete() {
//This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
exportRoot = new lib.sky1();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
//Registers the "tick" event listener.
createjs.Ticker.setFPS(lib.properties.fps);
createjs.Ticker.addEventListener("tick", stage);
//Code to support hidpi screens and responsive scaling.
(function(isResp, respDim, isScale, scaleType) {
var lastW, lastH, lastS=1;
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
function resizeCanvas() {
var w = lib.properties.width, h = lib.properties.height;
var iw = window.innerWidth, ih=window.innerHeight;
var pRatio = window.devicePixelRatio || 1, xRatio=iw/w, yRatio=ih/h, sRatio=1;
if(isResp) {
if((respDim=='width'&&lastW==iw) || (respDim=='height'&&lastH==ih)) {
sRatio = lastS;
}
else if(!isScale) {
if(iw<w || ih<h)
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==1) {
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==2) {
sRatio = Math.max(xRatio, yRatio);
}
}
canvas.width = w*pRatio*sRatio;
canvas.height = h*pRatio*sRatio;
canvas.style.width = w*sRatio+'px';
canvas.style.height = h*sRatio+'px';
stage.scaleX = pRatio*sRatio;
stage.scaleY = pRatio*sRatio;
lastW = iw; lastH = ih; lastS = sRatio;
}
})(false,'both',false,1);
}
</script>
<!-- write your code here -->
</head>
<body onload="init();" style="margin:0px;">
<canvas id="canvas" width="200" height="668" style="display: block; background-color:rgba(255, 255, 255, 1.00)"></canvas>
</body>
</html>
js - Banner 1:
(function (lib, img, cjs, ss) {
var p; // shortcut to reference prototypes
lib.webFontTxtInst = {};
var loadedTypekitCount = 0;
var loadedGoogleCount = 0;
var gFontsUpdateCacheList = [];
var tFontsUpdateCacheList = [];
// library properties:
lib.properties = {
width: 200,
height: 668,
fps: 24,
color: "#FFFFFF",
opacity: 1.00,
webfonts: {},
manifest: []
};
lib.ssMetadata = [];
lib.updateListCache = function (cacheList) {
for(var i = 0; i < cacheList.length; i++) {
if(cacheList[i].cacheCanvas)
cacheList[i].updateCache();
}
};
lib.addElementsToCache = function (textInst, cacheList) {
var cur = textInst;
while(cur != exportRoot) {
if(cacheList.indexOf(cur) != -1)
break;
cur = cur.parent;
}
if(cur != exportRoot) { //we have found an element in the list
var cur2 = textInst;
var index = cacheList.indexOf(cur);
while(cur2 != cur) { //insert all it's children just before it
cacheList.splice(index, 0, cur2);
cur2 = cur2.parent;
index++;
}
}
else { //append element and it's parents in the array
cur = textInst;
while(cur != exportRoot) {
cacheList.push(cur);
cur = cur.parent;
}
}
};
lib.gfontAvailable = function(family, totalGoogleCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], gFontsUpdateCacheList);
loadedGoogleCount++;
if(loadedGoogleCount == totalGoogleCount) {
lib.updateListCache(gFontsUpdateCacheList);
}
};
lib.tfontAvailable = function(family, totalTypekitCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], tFontsUpdateCacheList);
loadedTypekitCount++;
if(loadedTypekitCount == totalTypekitCount) {
lib.updateListCache(tFontsUpdateCacheList);
}
};
// symbols:
(lib.Symbol1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// Ebene 1
this.shape = new cjs.Shape();
this.shape.graphics.f("#990033").s().p("AvyMwIAA5fIflAAIAAZfg");
this.shape.setTransform(101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.shape).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(0,0,202.3,163.4);
// stage content:
(lib.sky1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// timeline functions:
this.frame_0 = function() {
LC.key = '123';
LC.name = 'links';
LC.frames = 'rechts';
LC.onConnect = function () {
console.log('Do this as soon as connection established!');
LC.rechts.document.getElementsByTagName('body')[0].style.backgroundColor = 'red';
};
LC.connect();
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(203));
// animation
this.instance = new lib.Symbol1();
this.instance.parent = this;
this.instance.setTransform(100,80.6,1,1,0,0,0,101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1).to({x:100.1,y:85.7},0).wait(1).to({y:90.8},0).wait(1).to({y:95.9},0).wait(1).to({y:101},0).wait(1).to({y:106.1},0).wait(1).to({y:111.3},0).wait(1).to({y:116.4},0).wait(1).to({y:121.5},0).wait(1).to({y:126.6},0).wait(1).to({x:100.2,y:131.7},0).wait(1).to({y:136.8},0).wait(1).to({y:141.9},0).wait(1).to({y:147},0).wait(1).to({y:152.1},0).wait(1).to({y:157.2},0).wait(1).to({y:162.3},0).wait(1).to({y:167.4},0).wait(1).to({y:172.6},0).wait(1).to({x:100.3,y:177.7},0).wait(1).to({y:182.8},0).wait(1).to({y:187.9},0).wait(1).to({y:193},0).wait(1).to({y:198.1},0).wait(1).to({y:203.2},0).wait(1).to({y:208.3},0).wait(1).to({y:213.4},0).wait(1).to({y:218.5},0).wait(1).to({x:100.4,y:223.6},0).wait(1).to({y:228.7},0).wait(1).to({y:233.9},0).wait(1).to({y:239},0).wait(1).to({y:244.1},0).wait(1).to({y:249.2},0).wait(1).to({y:254.3},0).wait(1).to({y:259.4},0).wait(1).to({y:264.5},0).wait(1).to({x:100.5,y:269.6},0).wait(1).to({y:274.7},0).wait(1).to({y:279.8},0).wait(1).to({y:284.9},0).wait(1).to({y:290.1},0).wait(1).to({y:295.2},0).wait(1).to({y:300.3},0).wait(1).to({y:305.4},0).wait(1).to({y:310.5},0).wait(1).to({x:100.6,y:315.6},0).wait(1).to({y:320.7},0).wait(1).to({y:325.8},0).wait(1).to({y:330.9},0).wait(1).to({y:336},0).wait(1).to({y:341.1},0).wait(1).to({y:346.2},0).wait(1).to({y:351.4},0).wait(1).to({y:356.5},0).wait(1).to({x:100.7,y:361.6},0).wait(1).to({y:366.7},0).wait(1).to({y:371.8},0).wait(1).to({y:376.9},0).wait(1).to({y:382},0).wait(1).to({y:387.1},0).wait(1).to({y:392.2},0).wait(1).to({y:397.3},0).wait(1).to({y:402.4},0).wait(1).to({x:100.8,y:407.5},0).wait(1).to({y:412.7},0).wait(1).to({y:417.8},0).wait(1).to({y:422.9},0).wait(1).to({y:428},0).wait(1).to({y:433.1},0).wait(1).to({y:438.2},0).wait(1).to({y:443.3},0).wait(1).to({y:448.4},0).wait(1).to({x:100.9,y:453.5},0).wait(1).to({y:458.6},0).wait(1).to({y:463.7},0).wait(1).to({y:468.9},0).wait(1).to({y:474},0).wait(1).to({y:479.1},0).wait(1).to({y:484.2},0).wait(1).to({y:489.3},0).wait(1).to({y:494.4},0).wait(1).to({x:101,y:499.5},0).wait(1).to({y:504.6},0).wait(1).to({y:509.7},0).wait(1).to({y:514.8},0).wait(1).to({y:519.9},0).wait(1).to({y:525},0).wait(1).to({y:530.2},0).wait(1).to({y:535.3},0).wait(1).to({y:540.4},0).wait(1).to({x:101.1,y:545.5},0).wait(1).to({y:550.6},0).wait(1).to({y:555.7},0).wait(1).to({y:560.8},0).wait(1).to({y:565.9},0).wait(1).to({y:571},0).wait(1).to({y:576.1},0).wait(1).to({y:581.2},0).wait(1).to({y:586.4},0).wait(1).to({y:581.5},0).wait(1).to({y:576.6},0).wait(1).to({y:571.7},0).wait(1).to({y:566.8},0).wait(1).to({y:561.9},0).wait(1).to({y:557},0).wait(1).to({y:552.1},0).wait(1).to({y:547.2},0).wait(1).to({y:542.3},0).wait(1).to({y:537.4},0).wait(1).to({y:532.5},0).wait(1).to({y:527.6},0).wait(1).to({y:522.7},0).wait(1).to({y:517.8},0).wait(1).to({y:512.9},0).wait(1).to({y:508},0).wait(1).to({y:503.1},0).wait(1).to({y:498.2},0).wait(1).to({y:493.3},0).wait(1).to({y:488.4},0).wait(1).to({y:483.5},0).wait(1).to({y:478.6},0).wait(1).to({y:473.7},0).wait(1).to({y:468.8},0).wait(1).to({y:463.9},0).wait(1).to({y:459},0).wait(1).to({y:454.1},0).wait(1).to({y:449.2},0).wait(1).to({y:444.3},0).wait(1).to({y:439.4},0).wait(1).to({y:434.5},0).wait(1).to({y:429.6},0).wait(1).to({y:424.7},0).wait(1).to({y:419.8},0).wait(1).to({y:414.9},0).wait(1).to({y:410},0).wait(1).to({y:405.1},0).wait(1).to({y:400.2},0).wait(1).to({y:395.3},0).wait(1).to({y:390.4},0).wait(1).to({y:385.5},0).wait(1).to({y:380.6},0).wait(1).to({y:375.7},0).wait(1).to({y:370.8},0).wait(1).to({y:365.9},0).wait(1).to({y:361},0).wait(1).to({y:356.1},0).wait(1).to({y:351.2},0).wait(1).to({y:346.3},0).wait(1).to({y:341.4},0).wait(1).to({y:336.5},0).wait(1).to({y:331.6},0).wait(1).to({y:326.7},0).wait(1).to({y:321.8},0).wait(1).to({y:316.9},0).wait(1).to({y:312},0).wait(1).to({y:307.1},0).wait(1).to({y:302.2},0).wait(1).to({y:297.3},0).wait(1).to({y:292.4},0).wait(1).to({y:287.5},0).wait(1).to({y:282.6},0).wait(1).to({y:277.7},0).wait(1).to({y:272.8},0).wait(1).to({y:267.9},0).wait(1).to({y:263},0).wait(1).to({y:258.1},0).wait(1).to({y:253.2},0).wait(1).to({y:248.3},0).wait(1).to({y:243.4},0).wait(1).to({y:238.5},0).wait(1).to({y:233.6},0).wait(1).to({y:228.7},0).wait(1).to({y:223.8},0).wait(1).to({y:218.9},0).wait(1).to({y:214},0).wait(1).to({y:209.1},0).wait(1).to({y:204.2},0).wait(1).to({y:199.3},0).wait(1).to({y:194.4},0).wait(1).to({y:189.5},0).wait(1).to({y:184.6},0).wait(1).to({y:179.7},0).wait(1).to({y:174.8},0).wait(1).to({y:169.9},0).wait(1).to({y:165},0).wait(1).to({y:160.1},0).wait(1).to({y:155.2},0).wait(1).to({y:150.3},0).wait(1).to({y:145.4},0).wait(1).to({y:140.5},0).wait(1).to({y:135.6},0).wait(1).to({y:130.7},0).wait(1).to({y:125.8},0).wait(1).to({y:120.9},0).wait(1).to({y:116},0).wait(1).to({y:111.1},0).wait(1).to({y:106.2},0).wait(1).to({y:101.3},0).wait(1).to({y:96.4},0).wait(1).to({y:91.5},0).wait(1).to({y:86.6},0).wait(1).to({y:81.7},0).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(98.9,332.9,202.3,163.4);
})(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
var lib, images, createjs, ss;
HTML - Banner 2:
<!DOCTYPE html>
<!--
NOTES:
1. All tokens are represented by '$' sign in the template.
2. You can write your code only wherever mentioned.
3. All occurrences of existing tokens will be replaced by their appropriate values.
4. Blank lines will be removed automatically.
5. Remove unnecessary comments before creating your template.
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="authoring-tool" content="Adobe_Animate_CC">
<title>sky2</title>
<!-- write your code here -->
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
<script src="sky2.js"></script>
<script src="localconnection.js"></script>
<script>
var canvas, stage, exportRoot;
function init() {
canvas = document.getElementById("canvas");
handleComplete();
}
function handleComplete() {
//This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
exportRoot = new lib.sky2();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
//Registers the "tick" event listener.
createjs.Ticker.setFPS(lib.properties.fps);
createjs.Ticker.addEventListener("tick", stage);
//Code to support hidpi screens and responsive scaling.
(function(isResp, respDim, isScale, scaleType) {
var lastW, lastH, lastS=1;
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
function resizeCanvas() {
var w = lib.properties.width, h = lib.properties.height;
var iw = window.innerWidth, ih=window.innerHeight;
var pRatio = window.devicePixelRatio || 1, xRatio=iw/w, yRatio=ih/h, sRatio=1;
if(isResp) {
if((respDim=='width'&&lastW==iw) || (respDim=='height'&&lastH==ih)) {
sRatio = lastS;
}
else if(!isScale) {
if(iw<w || ih<h)
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==1) {
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==2) {
sRatio = Math.max(xRatio, yRatio);
}
}
canvas.width = w*pRatio*sRatio;
canvas.height = h*pRatio*sRatio;
canvas.style.width = w*sRatio+'px';
canvas.style.height = h*sRatio+'px';
stage.scaleX = pRatio*sRatio;
stage.scaleY = pRatio*sRatio;
lastW = iw; lastH = ih; lastS = sRatio;
}
})(false,'both',false,1);
}
</script>
<!-- write your code here -->
</head>
<body onload="init();" style="margin:0px;">
<canvas id="canvas" width="200" height="668" style="display: block; background-color:rgba(255, 255, 255, 1.00)"></canvas>
</body>
</html>
js - Banner 2:
(function (lib, img, cjs, ss) {
var p; // shortcut to reference prototypes
lib.webFontTxtInst = {};
var loadedTypekitCount = 0;
var loadedGoogleCount = 0;
var gFontsUpdateCacheList = [];
var tFontsUpdateCacheList = [];
// library properties:
lib.properties = {
width: 200,
height: 668,
fps: 24,
color: "#FFFFFF",
opacity: 1.00,
webfonts: {},
manifest: []
};
lib.ssMetadata = [];
lib.updateListCache = function (cacheList) {
for(var i = 0; i < cacheList.length; i++) {
if(cacheList[i].cacheCanvas)
cacheList[i].updateCache();
}
};
lib.addElementsToCache = function (textInst, cacheList) {
var cur = textInst;
while(cur != exportRoot) {
if(cacheList.indexOf(cur) != -1)
break;
cur = cur.parent;
}
if(cur != exportRoot) { //we have found an element in the list
var cur2 = textInst;
var index = cacheList.indexOf(cur);
while(cur2 != cur) { //insert all it's children just before it
cacheList.splice(index, 0, cur2);
cur2 = cur2.parent;
index++;
}
}
else { //append element and it's parents in the array
cur = textInst;
while(cur != exportRoot) {
cacheList.push(cur);
cur = cur.parent;
}
}
};
lib.gfontAvailable = function(family, totalGoogleCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], gFontsUpdateCacheList);
loadedGoogleCount++;
if(loadedGoogleCount == totalGoogleCount) {
lib.updateListCache(gFontsUpdateCacheList);
}
};
lib.tfontAvailable = function(family, totalTypekitCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], tFontsUpdateCacheList);
loadedTypekitCount++;
if(loadedTypekitCount == totalTypekitCount) {
lib.updateListCache(tFontsUpdateCacheList);
}
};
// symbols:
(lib.Symbol1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// Ebene 1
this.shape = new cjs.Shape();
this.shape.graphics.f("#990033").s().p("AvyMwIAA5fIflAAIAAZfg");
this.shape.setTransform(101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.shape).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(0,0,202.3,163.4);
// stage content:
(lib.sky2 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// timeline functions:
this.frame_0 = function() {
LC.key = '123';
LC.name = 'rechts';
LC.frames = 'links';
LC.onConnect = function () {
console.log('Do this as soon as connection established!');
LC.links.document.getElementsByTagName('body')[0].style.backgroundColor = 'blue';
};
LC.connect();
this.stop();
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(202));
// animation
this.instance = new lib.Symbol1();
this.instance.parent = this;
this.instance.setTransform(100,80.6,1,1,0,0,0,101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1).to({x:100.1,y:85.7},0).wait(1).to({y:90.8},0).wait(1).to({y:95.9},0).wait(1).to({y:101},0).wait(1).to({y:106.1},0).wait(1).to({y:111.3},0).wait(1).to({y:116.4},0).wait(1).to({y:121.5},0).wait(1).to({y:126.6},0).wait(1).to({x:100.2,y:131.7},0).wait(1).to({y:136.8},0).wait(1).to({y:141.9},0).wait(1).to({y:147},0).wait(1).to({y:152.1},0).wait(1).to({y:157.2},0).wait(1).to({y:162.3},0).wait(1).to({y:167.4},0).wait(1).to({y:172.6},0).wait(1).to({x:100.3,y:177.7},0).wait(1).to({y:182.8},0).wait(1).to({y:187.9},0).wait(1).to({y:193},0).wait(1).to({y:198.1},0).wait(1).to({y:203.2},0).wait(1).to({y:208.3},0).wait(1).to({y:213.4},0).wait(1).to({y:218.5},0).wait(1).to({x:100.4,y:223.6},0).wait(1).to({y:228.7},0).wait(1).to({y:233.9},0).wait(1).to({y:239},0).wait(1).to({y:244.1},0).wait(1).to({y:249.2},0).wait(1).to({y:254.3},0).wait(1).to({y:259.4},0).wait(1).to({y:264.5},0).wait(1).to({x:100.5,y:269.6},0).wait(1).to({y:274.7},0).wait(1).to({y:279.8},0).wait(1).to({y:284.9},0).wait(1).to({y:290.1},0).wait(1).to({y:295.2},0).wait(1).to({y:300.3},0).wait(1).to({y:305.4},0).wait(1).to({y:310.5},0).wait(1).to({x:100.6,y:315.6},0).wait(1).to({y:320.7},0).wait(1).to({y:325.8},0).wait(1).to({y:330.9},0).wait(1).to({y:336},0).wait(1).to({y:341.1},0).wait(1).to({y:346.2},0).wait(1).to({y:351.4},0).wait(1).to({y:356.5},0).wait(1).to({x:100.7,y:361.6},0).wait(1).to({y:366.7},0).wait(1).to({y:371.8},0).wait(1).to({y:376.9},0).wait(1).to({y:382},0).wait(1).to({y:387.1},0).wait(1).to({y:392.2},0).wait(1).to({y:397.3},0).wait(1).to({y:402.4},0).wait(1).to({x:100.8,y:407.5},0).wait(1).to({y:412.7},0).wait(1).to({y:417.8},0).wait(1).to({y:422.9},0).wait(1).to({y:428},0).wait(1).to({y:433.1},0).wait(1).to({y:438.2},0).wait(1).to({y:443.3},0).wait(1).to({y:448.4},0).wait(1).to({x:100.9,y:453.5},0).wait(1).to({y:458.6},0).wait(1).to({y:463.7},0).wait(1).to({y:468.9},0).wait(1).to({y:474},0).wait(1).to({y:479.1},0).wait(1).to({y:484.2},0).wait(1).to({y:489.3},0).wait(1).to({y:494.4},0).wait(1).to({x:101,y:499.5},0).wait(1).to({y:504.6},0).wait(1).to({y:509.7},0).wait(1).to({y:514.8},0).wait(1).to({y:519.9},0).wait(1).to({y:525},0).wait(1).to({y:530.2},0).wait(1).to({y:535.3},0).wait(1).to({y:540.4},0).wait(1).to({x:101.1,y:545.5},0).wait(1).to({y:550.6},0).wait(1).to({y:555.7},0).wait(1).to({y:560.8},0).wait(1).to({y:565.9},0).wait(1).to({y:571},0).wait(1).to({y:576.1},0).wait(1).to({y:581.2},0).wait(1).to({y:586.4},0).wait(1).to({y:581.4},0).wait(1).to({y:576.4},0).wait(1).to({y:571.4},0).wait(1).to({y:566.4},0).wait(1).to({y:561.4},0).wait(1).to({y:556.4},0).wait(1).to({y:551.4},0).wait(1).to({y:546.4},0).wait(1).to({y:541.4},0).wait(1).to({y:536.4},0).wait(1).to({y:531.4},0).wait(1).to({y:526.4},0).wait(1).to({y:521.4},0).wait(1).to({y:516.4},0).wait(1).to({y:511.4},0).wait(1).to({y:506.4},0).wait(1).to({y:501.4},0).wait(1).to({y:496.4},0).wait(1).to({y:491.4},0).wait(1).to({y:486.4},0).wait(1).to({y:481.4},0).wait(1).to({y:476.4},0).wait(1).to({y:471.4},0).wait(1).to({y:466.4},0).wait(1).to({y:461.4},0).wait(1).to({y:456.4},0).wait(1).to({y:451.4},0).wait(1).to({y:446.4},0).wait(1).to({y:441.5},0).wait(1).to({y:436.5},0).wait(1).to({y:431.5},0).wait(1).to({y:426.5},0).wait(1).to({y:421.5},0).wait(1).to({y:416.5},0).wait(1).to({y:411.5},0).wait(1).to({y:406.5},0).wait(1).to({y:401.5},0).wait(1).to({y:396.5},0).wait(1).to({y:391.5},0).wait(1).to({y:386.5},0).wait(1).to({y:381.5},0).wait(1).to({y:376.5},0).wait(1).to({y:371.5},0).wait(1).to({y:366.5},0).wait(1).to({y:361.5},0).wait(1).to({y:356.5},0).wait(1).to({y:351.5},0).wait(1).to({y:346.5},0).wait(1).to({y:341.5},0).wait(1).to({y:336.5},0).wait(1).to({y:331.5},0).wait(1).to({y:326.5},0).wait(1).to({y:321.5},0).wait(1).to({y:316.5},0).wait(1).to({y:311.5},0).wait(1).to({y:306.5},0).wait(1).to({y:301.6},0).wait(1).to({y:296.6},0).wait(1).to({y:291.6},0).wait(1).to({y:286.6},0).wait(1).to({y:281.6},0).wait(1).to({y:276.6},0).wait(1).to({y:271.6},0).wait(1).to({y:266.6},0).wait(1).to({y:261.6},0).wait(1).to({y:256.6},0).wait(1).to({y:251.6},0).wait(1).to({y:246.6},0).wait(1).to({y:241.6},0).wait(1).to({y:236.6},0).wait(1).to({y:231.6},0).wait(1).to({y:226.6},0).wait(1).to({y:221.6},0).wait(1).to({y:216.6},0).wait(1).to({y:211.6},0).wait(1).to({y:206.6},0).wait(1).to({y:201.6},0).wait(1).to({y:196.6},0).wait(1).to({y:191.6},0).wait(1).to({y:186.6},0).wait(1).to({y:181.6},0).wait(1).to({y:176.6},0).wait(1).to({y:171.6},0).wait(1).to({y:166.6},0).wait(1).to({y:161.6},0).wait(1).to({y:156.6},0).wait(1).to({y:151.7},0).wait(1).to({y:146.7},0).wait(1).to({y:141.7},0).wait(1).to({y:136.7},0).wait(1).to({y:131.7},0).wait(1).to({y:126.7},0).wait(1).to({y:121.7},0).wait(1).to({y:116.7},0).wait(1).to({y:111.7},0).wait(1).to({y:106.7},0).wait(1).to({y:101.7},0).wait(1).to({y:96.7},0).wait(1).to({y:91.7},0).wait(1).to({y:86.7},0).wait(1).to({y:81.7},0).wait(2));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(98.9,332.9,202.3,163.4);
})(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
var lib, images, createjs, ss;
it's better to call LC.connect(); function at the end of handleComplete() event, because as soon as exportRoot defined, it's available to use it main Animation object.
For example :
.....
exportRoot = new lib.sky2();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
LC.key = '123';
LC.name = 'links';
LC.frames = 'rechts';
LC.onConnect = function () {
exportRoot.play();
LC.rechts.exportRoot.play();
};
exportRoot.stop();
LC.connect();
.....
on the other animation you only need to define & call LC.connect(); like this :
.....
exportRoot = new lib.sky2();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
LC.key = '123';
LC.name = 'rechts'; // adjust name
LC.frames = 'links'; // adjust frames
LC.onConnect = function () {
// no action needed here
};
exportRoot.stop();
LC.connect();
....

HTML5 DnD, event handlers and class indexes

Is there anyway to obtain the node list index offset, of a class element, that triggered a 'dragstart' event handler, from within that handler? I require this information so that I may set a data transfer object with that index for use later in a 'dragend' event handler.
<div id="div1">
<div draggable="true" class="thetiles">goo</div>
<div draggable="true" class="thetiles">hoo</div>
<div draggable="true" class="thetiles">zoo</div>
</div>
function registerSource() {
var matches = document.querySelectorAll('div.thetiles');
for (var i = 0; i < matches.length; i++) {
matches[i].addEventListener('dragstart', handleDragStart, false);
}
}
function handleDragStart(e) {
this.style.opacity = '0.3';
e.dataTransfer.effectAllowed = 'move';
/* need to get index of the class element that triggered this
for the following data transfer object set */
e.dataTransfer.setData('text/html', ????);
}
function registerSource() {
var matches = document.querySelectorAll('div.thetiles');
for (var i = 0; i < matches.length; i++) {
matches[i].addEventListener('dragstart', handleDragStart, false);
matches[i].addEventListener('dragstart', handleDragEnd, false);
}
}
var index
function handleDragStart(e) {
this.style.opacity = '0.3';
// Here is your index
index = Array.prototype.indexOf.call(e.target.parentNode.children, e.target)
e.dataTransfer.effectAllowed = 'move';
//e.dataTransfer.setData('text/html', ????);
}
function handleDragEnd(e) {
e.target.style.opacity = "";
console.log(index) // Quick confirmation
}
registerSource()
jsfiddle
Is this what you need?