needs to generate and update missing DocumentID and instanceID of the links of .indd Indesign files through extend script - adobe

I am using Mac with InDesign CC 219, and in my .indd file, some of the links are missing DocumentID and InstanceID, the below is the code I am using to get those details. If for any of the links, DocumentID and InstanceID are missing then I need to generate random DocumentID and InstanceID, and update the relevant links meta data. Is it possible through scripting, any directions please...
var doc = app.activeDocument;
for (var i = 0, len = doc.links.length; i < len; i++) {
var linkFilepath = File(doc.links[i].filePath).fsName;
var linkFileName = doc.links[i].name;
var xmpFile = new XMPFile(linkFilepath, XMPConst.FILE_INDESIGN, XMPConst.OPEN_FOR_READ);
var allXMP = xmpFile.getXMP();
// Retrieve values from external links XMP.
var documentID = allXMP.getProperty(XMPConst.NS_XMP_MM, 'DocumentID', XMPConst.STRING);
var instanceID = allXMP.getProperty(XMPConst.NS_XMP_MM, 'InstanceID', XMPConst.STRING);
}

$.level=0;
// Warn if there are no documents open.
if (!app.documents.length) {
alert('Open a document and try again.', 'Missing Document', false);
exit();
}
var doc = app.activeDocument;
// load XMP Library
function loadXMPLibrary() {
if (!ExternalObject.AdobeXMPScript) {
try {
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
} catch (e) {
alert('Failed loading AdobeXMPScript library\n' + e.message, 'Error', true);
return false;
}
}
return true;
}
// Check all link statuses are be ok.
function linksStatusCheck(doc) {
for (var i = 0, len = doc.links.length; i < len; i++) {
if (doc.links[i].status !== LinkStatus.NORMAL) {
alert('The status of all links must be OK \nPlease update link status ' +
'via the Links panel and try again', 'Link Status', true);
exit();
}
}
return true;
}
function randomString(length, chars) {
var randomGenStr = '';
for (var i = length; i > 0; --i) {
randomGenStr += chars[Math.floor(Math.random() * chars.length)];
}
return randomGenStr;
}
function randomString(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for(var k = 0; k < length; k++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
function checkLinksXMP(doc) {
for (var i = 0, len = doc.links.length; i < len; i++) {
var linkFilepath = File(doc.links[i].filePath).fsName;
var linkFileName = doc.links[i].name;
var xmpFile = new XMPFile(linkFilepath, XMPConst.FILE_INDESIGN, XMPConst.OPEN_FOR_UPDATE);
var allXMP = xmpFile.getXMP();
// Retrieve values from external links XMP.
var documentID = allXMP.getProperty(XMPConst.NS_XMP_MM, 'DocumentID', XMPConst.STRING);
var instanceID = allXMP.getProperty(XMPConst.NS_XMP_MM, 'InstanceID', XMPConst.STRING);
// Useful for testing purposes....
// Log properties for each link to the console.
// Notify user when XMP is missing...
var docMissingCnt = 0;
var insMissingCnt = 0;
if (!documentID && !instanceID) {
alert('Link missing DocumentID and InstanceID\n' +
'Name: ' + linkFileName + '\n\n' +
'Path: ' + linkFilepath, 'Missing XMP', true);
docMissingCnt++;
insMissingCnt++;
} else if (!documentID) {
alert('Link missing DocumentID\n' +
'Name: ' + linkFileName + '\n\n' +
'Path: ' + linkFilepath, 'Missing XMP', true);
docMissingCnt++;
} else if (!instanceID) {
alert('Link missing InstanceID\n' +
'Name: ' + linkFileName + '\n\n' +
'Path: ' + linkFilepath, 'Missing XMP', true);
insMissingCnt++;
}
if(docMissingCnt > 0) {
documentID = randomString(32);
allXMP.setProperty(XMPConst.NS_XMP_MM, 'DocumentID', documentID);
var documentIDNew = allXMP.getProperty(XMPConst.NS_XMP_MM, 'DocumentID', XMPConst.STRING);
$.writeln('DocumentID - New : ' + documentIDNew);
docMissingCnt = 0;
}
if(insMissingCnt > 0) {
instanceID = randomString(32);
allXMP.setProperty(XMPConst.NS_XMP_MM, 'InstanceID', instanceID);
var instanceIDNew = allXMP.getProperty(XMPConst.NS_XMP_MM, 'InstanceID', XMPConst.STRING);
$.writeln('InstanceID - New : ' + instanceIDNew);
insMissingCnt = 0;
}
}
}
if (loadXMPLibrary() && linksStatusCheck(doc)) {
checkLinksXMP(doc);
}

Related

Marker change based on text/address input using HERE map

I'm using HERE map plugin and I need to change marker position based on address/text input. I was looking for an examples in internet, but nothing was found.
Is it even possible to do such thing, using this plugin? May be someone can point out, where do I have to look, or may be someone have working example? Any help appreciated.
Something similar is used in "Google Maps"
https://developers.google.com/maps/documentation/javascript/examples/places-searchbox
You can refer to the documentation for "Search for a Location based on an Address" can be found at https://developer.here.com/documentation/examples/maps-js/services/geocode-a-location-from-address
The working example is available at https://jsfiddle.net/4Lodwfb3/ - request a location using a free-form text input and display a marker on the map.
function geocode(platform) {
var geocoder = platform.getSearchService(),
geocodingParameters = {
q: '200 S Mathilda Sunnyvale CA'
};
geocoder.geocode(
geocodingParameters,
onSuccess,
onError
);
}
function onSuccess(result) {
var locations = result.items;
addLocationsToMap(locations);
addLocationsToPanel(locations);
}
function onError(error) {
alert('Can\'t reach the remote server');
}
var platform = new H.service.Platform({
apikey: window.apikey
});
var defaultLayers = platform.createDefaultLayers();
var map = new H.Map(document.getElementById('map'),
defaultLayers.vector.normal.map,{
center: {lat:37.376, lng:-122.034},
zoom: 15,
pixelRatio: window.devicePixelRatio || 1
});
window.addEventListener('resize', () => map.getViewPort().resize());
var locationsContainer = document.getElementById('panel');
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
var ui = H.ui.UI.createDefault(map, defaultLayers);
var bubble;
function openBubble(position, text){
if(!bubble){
bubble = new H.ui.InfoBubble(
position,
{content: text});
ui.addBubble(bubble);
} else {
bubble.setPosition(position);
bubble.setContent(text);
bubble.open();
}
}
function addLocationsToPanel(locations){
var nodeOL = document.createElement('ul'),
i;
nodeOL.style.fontSize = 'small';
nodeOL.style.marginLeft ='5%';
nodeOL.style.marginRight ='5%';
for (i = 0; i < locations.length; i += 1) {
let location = locations[i];
var li = document.createElement('li'),
divLabel = document.createElement('div'),
address = location.address,
content = '<strong style="font-size: large;">' + address.label + '</strong></br>';
position = location.position;
content += '<strong>houseNumber:</strong> ' + address.houseNumber + '<br/>';
content += '<strong>street:</strong> ' + address.street + '<br/>';
content += '<strong>district:</strong> ' + address.district + '<br/>';
content += '<strong>city:</strong> ' + address.city + '<br/>';
content += '<strong>postalCode:</strong> ' + address.postalCode + '<br/>';
content += '<strong>county:</strong> ' + address.county + '<br/>';
content += '<strong>country:</strong> ' + address.countryName + '<br/>';
content += '<strong>position:</strong> ' +
Math.abs(position.lat.toFixed(4)) + ((position.lat > 0) ? 'N' : 'S') +
' ' + Math.abs(position.lng.toFixed(4)) + ((position.lng > 0) ? 'E' : 'W') + '<br/>';
divLabel.innerHTML = content;
li.appendChild(divLabel);
nodeOL.appendChild(li);
}
locationsContainer.appendChild(nodeOL);
}
for (i = 0; i < locations.length; i += 1) {
let location = locations[i];
marker = new H.map.Marker(location.position);
marker.label = location.address.label;
group.addObject(marker);
}
group.addEventListener('tap', function (evt) {
map.setCenter(evt.target.getGeometry());
openBubble(
evt.target.getGeometry(), evt.target.label);
}, false);
map.addObject(group);
map.setCenter(group.getBoundingBox().getCenter());
}
geocode(platform);

sequence of select query not right

I tried to query my database for data. However, when I query for my data, I only managed to get the data after my last alert, which is the alert("Total...") For instance, I run the code below, the alert for "result row:" only appear after the last alert appear. May I know why?
function (result) {
window.location.href = "#/app/CustHomePage";
var totalBalance = 0;
var tableRef = document.getElementById("myList").getElementsByTagName("tbody")[0];
for (var i = 0; i < tableRef.rows.length; i++) {
alert(tableRef.rows[i].cells[3].innerHTML.substr(1));
var addBalance = parseInt(tableRef.rows[i].cells[3].innerHTML.substr(1));
totalBalance = totalBalance + addBalance;
}
alert(totalBalance);
var myText = result.text;
var myTextTwo = myText.replace(/['"]+/g, '');
alert(myTextTwo);
var custBal;
var myDB = window.sqlitePlugin.openDatabase({ name: "mySQLite.db", location: 'default' });
alert("Hello");
myDB.transaction(function(transaction) {
alert("Hello");
transaction.executeSql("SELECT customerBalance FROM customer where nric = '" + myTextTwo + "'", [], function (tx, results) {
var len = results.rows.length;
for (var i = 0; i < len; i++) {
custBal = results.rows.item(i).customerBalance;
alert("result row" + results.rows.item(i).customerBalance);
alert("CustomerBal" + custBal);
}
},
function(tx, error)
{
}
);
});
alert("Total after entitled discount: ");
alert("Transaction successful, Next Customer Please");
}
Move anything you want to happen after the DB transaction has returned or failed in either the success or error handlers, I just moved them out of the arguments and gave them names to keep track of them. and then added your comment to the end of the successCallback handler. Anything you want to happen after a transaction was not successful use the error callback.
function successCallback(tx, results) {
var len = results.rows.length;
for (var i = 0; i < len; i++) {
custBal = results.rows.item(i).customerBalance;
alert("result row" + results.rows.item(i).customerBalance);
alert("CustomerBal" + custBal);
}
alert("Total after entitled discount: ");
alert("Transaction successful, Next Customer Please");
}
function errorCallback(tx, error) {
}
myDB.transaction(function (transaction) {
alert("Hello");
transaction.executeSql("SELECT customerBalance FROM customer where nric = '" + myTextTwo + "'", [], successCallback, errorCallback);
});

On Approval Of Quotation, Run Report, Generate PDF and Send an Email With PDF as attachment

I am using CRM ONLINE 2013.
How to automate below process?
On Approval Of Quotation, Run Report.
Generate PDF.
Send an Email With PDF as attachment.
As I have gone through many forums for this topic, but creating a plugin code for generating Report PDF is not possible in CRM ONLINE.
What is the alternate way to do this..?
I have tried below code and it is working fine for me.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof (SDK) == "undefined")
{ SDK = { __namespace: true }; }
SDK.JScriptRESTDataOperations = {
_context: function () {
if (typeof GetGlobalContext != "undefined")
{ return GetGlobalContext(); }
else {
if (typeof Xrm != "undefined") {
return Xrm.Page.context;
}
else { return new Error("Context is not available."); }
}
},
_getServerUrl: function () {
var serverUrl = this._context().getServerUrl()
if (serverUrl.match(/\/$/)) {
serverUrl = serverUrl.substring(0, serverUrl.length - 1);
}
return serverUrl;
},
_ODataPath: function () {
return this._getServerUrl() + "/XRMServices/2011/OrganizationData.svc/";
},
_errorHandler: function (req) {
return new Error("Error : " +
req.status + ": " +
req.statusText + ": " +
JSON.parse(req.responseText).error.message.value);
},
_dateReviver: function (key, value) {
var a;
if (typeof value === 'string') {
a = /Date\(([-+]?\d+)\)/.exec(value);
if (a) {
return new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
}
}
return value;
},
Create: function (object, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 201) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
}
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
}
}
};
req.send(JSON.stringify(object));
},
Retrieve: function (id, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("GET", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 200) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
}
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
}
}
};
req.send();
},
Update: function (id, object, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "MERGE");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 204 || this.status == 1223) {
successCallback();
}
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
}
}
};
req.send(JSON.stringify(object));
},
Delete: function (id, type, successCallback, errorCallback) {
var req = new XMLHttpRequest();
req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "DELETE");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 204 || this.status == 1223) {
successCallback();
}
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
}
}
};
req.send();
},
RetrieveMultiple: function (type, filter, successCallback, errorCallback) {
if (filter != null) {
filter = "?" + filter;
}
else { filter = ""; }
var req = new XMLHttpRequest();
req.open("GET", this._ODataPath() + type + "Set" + filter, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 200) {
successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d.results);
}
else {
errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
}
}
};
req.send();
},
__namespace: true
};
</script>
<script type="text/javascript">
//Create Email and link it with Order as Regarding field
var Xrm;
var email = new Object();
var ownerID = "";
var CustomerId = "";
if (window.opener) { Xrm = window.opener.Xrm; }
else if (window.parent) { Xrm = window.parent.Xrm; }
//Get ownerid who send email of quotation to customer
function GetOwnerID() {
var owner = Xrm.Page.getAttribute("ownerid").getValue();
ownerID = owner[0].id;
var ownerName = owner[0].name;
var entityType = owner[0].entityType;
GetToEmailGUID();
}
//Get customerid who receive email of quotation from owner
function GetToEmailGUID() {
var Customer = Xrm.Page.getAttribute('customerid').getValue();
CustomerId = Customer[0].id;
var CustomerName = Customer[0].name;
var entityType = Customer[0].entityType;
//if CustomerId is type of "Account" then get Primary Contact id of that account
if (entityType == "account") {
var contact = Xrm.Page.getAttribute("customerid").getValue();
if (contact === null) return;
var serverUrl = Xrm.Page.context.getClientUrl();
var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + contact[0].id + "')?$select=PrimaryContactId";
var req = new XMLHttpRequest();
req.open("GET", oDataSelect, false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status === 200) {
var retrieved = JSON.parse(req.responseText).d;
CustomerId = retrieved.PrimaryContactId.Id;
}
else {
alert(this.statusText);
}
}
};
req.send();
}
}
function CreateEmail() {
GetOwnerID();
email.Subject = "Email with Report Attachment";
//Set The current order as the Regarding object
email.RegardingObjectId = {
Id: Xrm.Page.data.entity.getId(), //Get the current entity Id , here OrderId
LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be “salesOrder”
};
//Create Email Activity
SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });
}
// Email Call Back function
function EmailCallBack(result) {
email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
var activityPartyFrom = new Object();
// Set the From party of the ActivityParty to relate an entity with Email From field
activityPartyFrom.PartyId = {
Id: CustomerId, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
LogicalName: "contact"
};
// Set the "activity" of the ActivityParty
activityPartyFrom.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
};
// Now set the participation type that describes the role of the party on the activity).
activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
// Create the from ActivityParty for the email
SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
var activityPartyTo = new Object();
// Set the From party of the ActivityParty to relate an entity with Email From field
activityPartyTo.PartyId = {
Id: ownerID, //"79EBDD26-FDBE-E311-8986-D89D6765B238", // id of entity you want to associate this activity with.
LogicalName: "systemuser"
};
// Set the "activity" of the ActivityParty
activityPartyTo.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
};
// Now set the participation type that describes the role of the party on the activity).
activityPartyTo.ParticipationTypeMask = { Value: 1 }; // 1 means Sender
// Create the from ActivityParty
SDK.JScriptRESTDataOperations.Create(activityPartyTo, "ActivityParty", ActivityPartyToCallBack, function (error) { alert(error.message); });
}
//ActivityParty From Callback
function ActivityPartyFromCallBack(result) {
}
//ActivityParty To Callback
function ActivityPartyToCallBack(result) {
GetReportId('Quotation');
}
//Create attachment for the created email
function CreateEmailAttachment() {
//get reporting session and use the params to convert a report in PDF
var params = getReportingSession();
//Email attachment parameters
var activitymimeattachment = Object();
activitymimeattachment.ObjectId = Object();
activitymimeattachment.ObjectId.LogicalName = "email";
activitymimeattachment.ObjectId.Id = email.ActivityId;
activitymimeattachment.ObjectTypeCode = "email",
activitymimeattachment.Subject = "File Attachment";
activitymimeattachment.Body = encodePdf(params);
activitymimeattachment.FileName = "Report.pdf";
activitymimeattachment.MimeType = "application/pdf";
//Attachment call
SDK.JScriptRESTDataOperations.Create(activitymimeattachment, "ActivityMimeAttachment", ActivityMimeAttachmentCallBack, function (error) { alert(error.message); });
}
//ActivityMimeAttachment CallBack function
function ActivityMimeAttachmentCallBack(result) {
var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
var width = "800px";
var height = "600px";
window.open(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", features);
// To open window which works in outlook and IE both
//openStdWin(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", width, height, features);
}
//This method will get the reportId based on a report name that will be used in getReportingSession() function
function GetReportId(reportName) {
var oDataSetName = "ReportSet";
var columns = "ReportId";
var filter = "Name eq '" + reportName + "'";
retrieveMultiple(oDataSetName, columns, filter, onSuccess);
}
function retrieveMultiple(odataSetName, select, filter, successCallback) {
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "?";
if (select) {
odataUri += "$select=" + select + "&";
}
if (filter) {
odataUri += "$filter=" + filter;
}
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odataUri,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data) {
if (successCallback) {
if (data && data.d && data.d.results) {
successCallback(data.d.results);
}
else if (data && data.d) {
successCallback(data.d);
}
else {
successCallback(data);
}
}
},
error: function (XmlHttpRequest, errorThrown) {
if (XmlHttpRequest && XmlHttpRequest.responseText) {
alert("Error while retrieval ; Error – " + XmlHttpRequest.responseText);
}
}
});
}
function onSuccess(data) {
reportId = data[0].ReportId.replace('{', ").replace('}', ");
CreateEmailAttachment(); // Create Email Attachment
}
//Gets the report contents
function getReportingSession() {
var pth = Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
var retrieveEntityReq = new XMLHttpRequest();
var Id = Xrm.Page.data.entity.getId();
var quotationGUID = Id.replace('{', ""); //set this to selected quotation GUID
quotationGUID = quotationGUID.replace('}', "");
var reportName = "Quotation"; //set this to the report you are trying to download
var reportID = "7C39D18F-1DC6-E311-8986-D89D6765B238"; //set this to the guid of the report you are trying to download
var rptPathString = ""; //set this to the CRMF_Filtered parameter
var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='quote'><all-attributes /><filter type='and'><condition attribute='quoteid' operator='eq' uitype='quote' value='" + quotationGUID + "' /> </filter></entity></fetch>";
retrieveEntityReq.open("POST", pth, false);
retrieveEntityReq.setRequestHeader("Accept", "*/*");
retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
rptPathString = "id=%7B" + reportID + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName=" +
reportName + "&isScheduledReport=false&p:CRMAF_Filteredquote=" + strParameterXML;
//remove the part starting from &p:salesorderid if your report has no parameters
retrieveEntityReq.send(rptPathString);
var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
var ret = new Array();
ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
x = retrieveEntityReq.responseText.indexOf("ControlID=");
ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
return ret;
}
var bdy = new Array();
var bdyLen = 0;
function concat2Bdy(x) {
bdy[bdyLen] = x;
bdyLen++;
}
function encodePdf(params) {
bdy = new Array();
bdyLen = 0;
var retrieveEntityReq = new XMLHttpRequest();
var pth = Xrm.Page.context.getServerUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] +
"&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] +
"&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
retrieveEntityReq.open("GET", pth, false);
retrieveEntityReq.setRequestHeader("Accept", "*/*");
retrieveEntityReq.send();
BinaryToArray(retrieveEntityReq.responseBody);
return encode64(bdy);
}
var StringMaker = function () {
this.parts = [];
this.length = 0;
this.append = function (s) {
this.parts.push(s);
this.length += s.length;
}
this.prepend = function (s) {
this.parts.unshift(s);
this.length += s.length;
}
this.toString = function () {
return this.parts.join('');
}
}
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
var output = new StringMaker();
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
while (i < input.length) {
chr1 = input[i++];
chr2 = input[i++];
chr3 = input[i++];
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
}
return output.toString();
}
</script>
<script type="text/vbscript">
Function BinaryToArray(Binary)
Dim i
ReDim byteArray(LenB(Binary))
For i = 1 To LenB(Binary)
byteArray(i-1) = AscB(MidB(Binary, i, 1))
concat2Bdy(AscB(MidB(Binary, i, 1)))
Next
BinaryToArray = byteArray
End Function
</script>
</head>
<body>
<input type="button" onclick="CreateEmail();" value="Attach Report" />
</body>
</html>

Hyperlinks cannot be clicked on wordpress

i have a site i did for a friend using the theme KIN for wordpress as a base. The site is built on Wordpress and it's using AJAX to load all the pages, but the links although visible cannot be clicked! i don't really know why at all. Below is the site...
http://www.baudesigncreative.com
if you navigate to the keep in touch page, you will notice there are links to pages. Odd thing here as i can see the link on the status bar, but nothing happens when i click. Im not sure where to look to resolve this, can anyone offer any help?
thanks so much!
I found the link break to be from bau.js thanks to help from below,
$(document).ready(function() {
var url = '';
var currentOpen = '';
var mousedown = false;
var galleryMousedown = false;
var mouseX = 0;
var xdiff = 0;
var movePercentage = 0;
var toMove = 0;
function randomQuotes() {
$('body').append('<div id="bau-quotes-holder"></div>');
$('#bau-quotes-holder').hide();
var quotesUrl = 'http://baudesigncreative.com/quotes/';
var quotesLength = 0;
$('#bau-description').html('').hide();
$('#bau-quotes-holder').load(quotesUrl + ' #page_content_wrapper', function() {
$('#bau-quotes-holder').find('dt').each(function() {
$('#bau-description').append('<img src="' + $('a', this).attr('href') + '" />');
quotesLength++;
});
$('#bau-description img').hide();
var randomized = Math.floor((Math.random() * quotesLength) + 1);
$('#bau-description').show();
$('#bau-description img:nth-child(' + randomized + ')').fadeIn(500, function() {
$('#bau-quotes-holder').remove();
});
});
}
randomQuotes();
function scrollers() {
$('#bau-gallery').hover(function() {
$('#bau-gallery-left').fadeIn(200);
$('#bau-gallery-right').css('marginLeft', $('#galleryScrollbar').width() - '29').fadeIn(200);
}, function() {
$('#bau-gallery-left').fadeOut(200);
$('#bau-gallery-right').fadeOut(200);
});
var galleryLength = 0;
$('#bau-gallery-list').find('img').each(function() {
galleryLength++;
});
var scrollbarWidth = parseFloat($('#galleryScrollbar').width()) - 20;
var scrollbarToMove = 0;
var isDown = false;
var galleryLeft = parseFloat($('#bau-gallery-list').css('left'));
var galleryWidth = parseFloat($('#bau-gallery-list').width());
var lastImgWidth = parseFloat($('#bau-gallery-list img:last-child').width()) + 2;
toMove = Math.abs($('hr').width() - $('#bau-gallery-list img:last-child').width());
// var jumpWidth = ((galleryWidth - lastImgWidth - toMove) / (galleryLength - 1)) / 20;
var jumpWidth = ((galleryWidth - lastImgWidth - toMove) / (galleryLength - 1)) / 2;
// scrollbarToMove = (scrollbarWidth / (galleryLength - 1)) / 20;
scrollbarToMove = (scrollbarWidth / (galleryLength - 1)) / 2;
var timeoutLeft;
var timeoutRight;
$('#bau-gallery-left').dblclick(function(e) {
return false;
});
$('#bau-gallery-right').dblclick(function(e) {
return false;
});
$('#bau-gallery-left').click(function(e) {
galleryWidth = parseFloat($('#bau-gallery-list').width());
lastImgWidth = parseFloat($('#bau-gallery-list img:last-child').width()) + 2;
toMove = Math.abs($('hr').width() - $('#bau-gallery-list img:last-child').width());
jumpWidth = ((galleryWidth - lastImgWidth - toMove) / (galleryLength - 1)) / 2;
if ((galleryWidth - Math.abs(parseFloat($('#bau-gallery-list').css('left')))) > galleryWidth - jumpWidth) {
$('#galleryScrollbarThumb').css('left', 0);
$('#bau-gallery-list').css('left', 0);
}
else {
$('#bau-gallery-list').animate({'left': '+=' + jumpWidth + 'px'}, 100);
$('#galleryScrollbarThumb').animate({'left': '-=' + scrollbarToMove + 'px'}, 100);
}
return false;
});
$('#bau-gallery-right').click(function(e) {
galleryWidth = parseFloat($('#bau-gallery-list').width());
lastImgWidth = parseFloat($('#bau-gallery-list img:last-child').width()) + 2;
toMove = Math.abs($('hr').width() - $('#bau-gallery-list img:last-child').width());
jumpWidth = ((galleryWidth - lastImgWidth - toMove) / (galleryLength - 1)) / 2;
if ((scrollbarWidth - Math.abs(parseFloat($('#galleryScrollbarThumb').css('left')))) < scrollbarToMove) {
$('#galleryScrollbarThumb').css('left', scrollbarWidth);
$('#bau-gallery-list').css('left', -(galleryWidth - lastImgWidth - toMove));
}
else {
$('#bau-gallery-list').animate({'left': '-=' + jumpWidth + 'px'}, 100);
$('#galleryScrollbarThumb').animate({'left': '+=' + scrollbarToMove + 'px'}, 100);
}
return false;
});
//onhold
// $('#bau-gallery-left').mousedown(function(e) {
// if (!galleryMousedown) {
// galleryMousedown = true;
// timeoutLeft = setInterval(function() {
// if ((scrollbarWidth - Math.abs(parseFloat($('#galleryScrollbarThumb').css('left')))) > scrollbarWidth - scrollbarToMove) {
// $('#galleryScrollbarThumb').css('left', 0);
// $('#bau-gallery-list').css('left', 0);
// }
// else {
// $('#bau-gallery-list').animate({'left': '+=' + jumpWidth + 'px'}, 50);
// $('#galleryScrollbarThumb').animate({'left': '-=' + scrollbarToMove + 'px'}, 50);
// }
// }, 50);
// }
// return false;
// });
// $('#bau-gallery-right').mousedown(function(e) {
// if (!galleryMousedown) {
// galleryMousedown = true;
// timeoutRight = setInterval(function() {
// if ((scrollbarWidth - Math.abs(parseFloat($('#galleryScrollbarThumb').css('left')))) < scrollbarToMove) {
// $('#galleryScrollbarThumb').css('left', scrollbarWidth);
// $('#bau-gallery-list').css('left', -(galleryWidth - lastImgWidth - toMove));
// }
// else {
// $('#bau-gallery-list').animate({'left': '-=' + jumpWidth + 'px'}, 50);
// $('#galleryScrollbarThumb').animate({'left': '+=' + scrollbarToMove + 'px'}, 50);
// }
// }, 50);
// }
// return false;
// });
// $(window).mouseup(function(e) {
// galleryMousedown = false;
// clearInterval(timeoutLeft);
// clearInterval(timeoutRight);
// return false;
// });
}
function backLoop() {
$('#bau-gallery-back a').dblclick(function(e) {
return false;
});
$('#bau-gallery-back a').click(function(e) {
randomQuotes();
var backShowcaseUrl = $(this).attr('href');
$('#bau-content').fadeOut(1000, function() {
$('#bau-gallery').remove();
$('#bau-content').hide();
$('#bau-content').append('<div id="page_content_wrapper"><div class="inner"><div id="bau-showcase"></div></div></div>')
$('#bau-showcase').append($('#bau-showcase-holder').html());
$('#bau-content').height('')
.css('marginBottom', '')
.width('')
.css('overflow', '');
$('#bau-content').fadeIn(500, function() {
$('#bau-showcase-holder').remove();
showcaseEvents();
});
$('#bau-content').height($('.inner').height());
});
return false;
});
}
function showcaseEvents() {
$('#bau-showcase li').dblclick(function(e) {
return false;
});
$('#bau-showcase li').click(function(e) {
randomQuotes();
var showcaseUrl = $('a', this).attr('href');
var tempWidth = 0;
$('#bau-content').fadeOut(1000, function() {
$('#bau-showcase-holder').remove();
$('body').append('<div id="bau-showcase-holder">' + $('#bau-showcase').html() + '</div>');
$('#bau-showcase-holder').hide();
$('#page_content_wrapper').remove();
$('#bau-content').append('<div id="bau-gallery"></div>');
$('#bau-gallery-holder').load(showcaseUrl + ' #page_content_wrapper', function() {
$('#bau-gallery').append('<div id="bau-gallery-title">' + $('#bau-gallery-holder h2').text() + '</div><div id="bau-gallery-list"></div><div id="bau-gallery-left" class="scroller scroll-left"></div><div id="bau-gallery-right" class="scroller scroll-right"></div>')
$('#bau-gallery-holder').find('dt').each(function() {
var _thisImgUrl = $('a', this).attr('href');
$('#bau-gallery-list').append('<img src="' + _thisImgUrl + '"/>');
});
$('#bau-gallery').append('<div class="clear"></div><div id="galleryScrollbar"><div id="galleryScrollbarThumb"><img src="http://baudesigncreative.com/wp-content/uploads/2011/09/scrollbar_thumb.png" alt=""></div></div>')
.append('<div id="bau-gallery-back"><img src="http://baudesigncreative.com/wp-content/uploads/2011/09/back-to-showcase.png" />Back to Showcase</div>');
$('#bau-content').fadeIn(1000, function() {
tempWidth = $('#bau-gallery').width();
// $('#bau-gallery').width($('hr').width());
$('#bau-content').width($('hr').width());
// $('#bau-gallery-list').width($('#bau-gallery').width());
// $('#bau-gallery-list').width($('hr').width());
$('#galleryScrollbarThumb').mousedown(function(event) {
if (!mousedown) {
mousedown = true;
}
return false;
});
var scrollerOffset = $('hr').offset();
var scrollerOffsetLeft = scrollerOffset.left;
var realEvent = 0;
$(window).mousemove(function(event) {
if (mousedown) {
realEvent = event.pageX - (scrollerOffsetLeft + 10);
if (realEvent < 0) {
realEvent = 0;
}
else if (realEvent > ($('hr').width() - 20)) {
realEvent = $('hr').width() - 20;
}
$('#galleryScrollbarThumb').css('left', realEvent);
movePercentage = (realEvent) / ($('hr').width() - 20);
toMove = Math.abs($('hr').width() - $('#bau-gallery-list img:last-child').width());
$('#bau-gallery-list').css('left', -(movePercentage * ($('#bau-gallery-list').width() - $('#bau-gallery-list img:last-child').width() - 2 - toMove)));
}
return false;
});
$(window).mouseup(function(event) {
mousedown = false;
if (parseFloat($('#galleryScrollbarThumb').css('left')) <= 0) {
$('#galleryScrollbarThumb').css('left', 0);
$('#bau-gallery-list').css('left', 0);
}
else if (parseFloat($('#galleryScrollbarThumb').css('left')) >= $('hr').width() - 20) {
$('#galleryScrollbarThumb').css('left', $('hr').width() - 20);
toMove = Math.abs($('hr').width() - $('#bau-gallery-list img:last-child').width());
$('#bau-gallery-list').css('left', -($('#bau-gallery-list').width() - $('#bau-gallery-list img:last-child').width() - 2 - toMove));
}
return false;
});
scrollers();
backLoop();
});
$('#bau-content').height($('#bau-gallery').height())
.css('marginBottom', $('#bau-gallery').css('marginBottom'))
.width('100%')
.css('overflow', 'hidden');
$('#bau-gallery-back').width($('hr').width());
$('#galleryScrollbar').width($('hr').width());
$('#bau-gallery-holder').remove();
$('body').prepend('<div id="bau-gallery-holder"></div>');
});
});
return false;
});
}
$('#page_content_wrapper').remove();
$('#main_menu li:first').append('<div id="bau-ajax"><div id="bau-content"></div><div class="clear"></div></div>');
$('#bau-ajax').hide();
$('body').prepend('<div id="bau-gallery-holder"></div>');
$('#bau-gallery-holder').hide();
$('#main_menu > li').dblclick(function(e) {
return false;
});
$('#main_menu > li').click(function(e) {
randomQuotes();
$('#bau-showcase-holder').remove();
var _this = $(this);
var _thisA = $('a', this);
$('#main_menu li a').css('color', '#000');
$('#bau-content').slideUp(500, function() {
if (_this.attr('id') != currentOpen) {
$('#bau-ajax').remove();
_this.append('<div id="bau-ajax"><hr><div id="bau-content"></div><div class="clear"></div><hr></div>');
url = _thisA.attr('href');
$('#bau-ajax').show();
$('#bau-content').hide();
_thisA.css('color', '#909295');
$('#bau-content').load(url + ' #page_content_wrapper', function() {
$('#bau-content h1').remove();
$('#bau-content br').remove();
$('#bau-content').fadeIn(500, function() {
$('#bau-content').click(function(e) {
return false;
});
showcaseEvents();
});
$('#bau-content').height($('.inner').height());
currentOpen = _this.attr('id');
});
}
else {
$('#bau-ajax').remove();
_this.append('<div id="bau-ajax"><div id="bau-content"></div><div class="clear"></div></div>');
url = _thisA.attr('href');
currentOpen = '';
}
});
return false;
});
//styleSheets
$('#menu_wrapper').css('width', '100%');
$('#page_content_wrapper').css('width', '1000px');
});
Anyone by any chance spot anything that could be it?
when i comment out (from line 297)
$('#page_content_wrapper').remove();
it seems to remove the styling overlapping it which results it the page breaking a bit :(
am i missing something simple by any chance?
your link are working on my end if still you have problem with links then use CSS proerty.
Z-index:999;

JW Player playlist only loads randomly in IE, works fine in FF every time

The playlist loads every time in FF but only the first time in IE (6-8), after that only randomly.
If I alert the error that's thrown I get "TypeError: playerReady is undefined".
My code looks good and obviously works since FF displays the playlist perfectly. I've got no idea how to solve this. Anyone?
<script type='text/javascript'>
var so = new SWFObject('/UI/Flash/player.swf', 'ply', '<%=FlashWidth %>', '<%=FlashHeight %>', '9', '#ffffff'),
playlistURL = '<%=PlaylistURL %>',
imageURL = '<%=GetBackgroundImageUrl() %>';
so.addParam('allowfullscreen', 'true');
so.addParam('allowscriptaccess', 'always');
if (playlistURL !== '') {
so.addVariable('playlistfile', playlistURL);
so.addVariable('playlist', 'none');
so.addVariable('enablejs', 'true');
}
else {
so.addVariable('file', '<%=FlashURL %>');
}
if (imageURL.length > 0) {
so.addVariable('image', imageURL);
}
so.write('preview<%=PlayerID %>');
</script>
The playerReady function is called by the player once it's finished it's setup process. Do you happen to define that function and then set it to undefined? That might cause an error.
Also, what version of the player are you using?
so.addVariable('enablejs', 'true');
I don't belive that's been a flashvar since the 3.X player, which is no longer supported.
Best,
Zach
Developer, LongTail Video
Not sure how I solved it, but here is the final code that actually works:
HTML PAGE:
<script type='text/javascript'>
var so = new SWFObject('/UI/Flash/player.swf', 'ply', '700', '345', '9', '#ffffff'),
playlistUrl = 'XML-PLaylist',
imageURL = '/ImageVault/Images/conversionFormat_2/id_1577/scope_0/ImageVaultHandler.aspx';
so.addParam('allowfullscreen', 'true');
so.addParam('allowscriptaccess', 'always');
so.addParam('wmode', 'opaque');
if (playlistUrl !== '') {
so.addVariable('playlistfile', playlistUrl);
so.addVariable('playlist', 'none');
so.addVariable('controlbar', 'bottom');
so.addVariable('backcolor', '0xDDE5FF');
so.addVariable('frontcolor', '0x142864');
so.addVariable('screencolor', '0xffffff');
so.addVariable('enablejs', 'true');
so.addVariable('overstretch', 'true');
}
else {
so.addVariable('file', '');
}
if (imageURL.length > 0) {
so.addVariable('image', imageURL);
}
so.write('preview');
</script>
And here's the JavaScript:
try {
var playlistReady = playerReady;
} cat
ch (err) {
//alert('1' + err);
}
playerReady = function(obj) {
setTimeout(function() { checkPlaylistLoaded(obj) }, 1);
try {
playlistReady(obj);
} catch (err) {
//alert(err);
}
}
function itemHandler(obj) {
var item = obj['index'];
var playlist = $("#" + obj['id']).next();
var currentItem = 0;
playlist.children().each(function() {
if (currentItem == item) {
$(this).addClass("playing");
} else {
$(this).removeClass("playing");
}
currentItem++;
});
}
function checkPlaylistLoaded(obj) {
//debugger;
var player = document.getElementById(obj['id']),
jsPlaylist = player.getPlaylist();
if (jsPlaylist.length > 0) {
var playlist = createPlaylist(obj);
populatePlaylist(player, jsPlaylist, playlist);
player.addControllerListener("PLAYLIST", "playlistHandler");
player.addControllerListener("ITEM", "itemHandler");
player.addControllerListener("STOP", "showPlaylist");
player.addModelListener("STATE", "stateListener");
} else {
setTimeout(function() { checkPlaylistLoaded(obj) }, 150);
}
}
function stateListener(obj) {
if (obj.newstate === 'PLAYING') {
hidePlaylist();
}
if (obj.newstate === 'PAUSED') {
showPlaylist();
}
}
function createPlaylist(obj) {
var playerDiv = $("#" + obj['id']);
playerDiv.after("<div class='jw_playlist_playlist'></div>");
return playerDiv.next();
}
function hidePlaylist() {
$('.jw_playlist_playlist').animate({ left: "-320px" }, 1000);
}
function showPlaylist() {
$('.jw_playlist_playlist').animate({ left: "-10px" }, 1000);
}
function playlistHandler(obj) {
var player = document.getElementById(obj['id']),
jsPlaylist = player.getPlaylist(),
playerDiv = $("#" + obj['id']),
playlist = playerDiv.next();
populatePlaylist(player, jsPlaylist, playlist);
}
function populatePlaylist(player, jsPlaylist, playlist) {
playlist.empty();
for (var i = 0; i < jsPlaylist.length; i++) {
var jsItem = jsPlaylist[i];
var alternate = "even";
if (i % 2) {
alternate = "odd";
}
playlist.append("<div id='" + getItemId(jsItem) + "' class='jw_playlist_item " + alternate + "'>" + dump(jsItem) + "</div>");
}
var playlistItem = 0;
playlist.children().each(function() {
var currentItem = playlistItem;
$(this).click(function() {
player.sendEvent("ITEM", currentItem);
});
playlistItem++;
});
}
function getItemId(arr) {
var output = '${link}',
variables = getVars(output),
j;
for (j = 0; j < variables.length; j++) {
var variable = variables[j],
varName = variable.replace('${', '').replace('}', ''),
value = arr[varName];
if (!value) {
value = '';
}
output = output.replace(variable, value);
}
return output;
}
function dump(arr) {
var output = "<div class='jw_playlist_title'>${title}</div><div class='jw_playlist_description'>${description}</div>",
variables = getVars(output),
j;
for (j = 0; j < variables.length; j++) {
var variable = variables[j],
varName = variable.replace('${', '').replace('}', ''),
value = arr[varName];
if (!value) {
value = '';
}
output = output.replace(variable, value);
}
return output;
}
function dumpText(arr) {
var dumped_text = "";
if (typeof (arr) == 'object') {
for (var item in arr) {
var value = arr[item];
if (typeof (value) == 'object') {
dumped_text += "<div class='" + item + "'>";
dumped_text += dump(value);
dumped_text += "</div>";
} else {
dumped_text += "<div class='" + item + "'>" + value + "</div>";
}
}
} else {
dumped_text += arr + " (" + typeof (arr) + ")";
}
return dumped_text;
}
function getVars(str) {
return str.match(/\$\{(.*?)\}/g);
}

Resources