Monday, February 24, 2014

Sharepoint 2013 Visio web access webpart scripts (2. Script to find list of page names(Visio Sheets names)

<script language="javascript">

// Add a button to display or dismiss the custom message.
document.write("<input type='button' value='Show Message' onclick='onDiagramComplete()' />");

// Hook into the AJAX Sys.Application.load event.
Sys.Application.add_load(onApplicationLoad)

// Declare global variables.
var vwaControl;
var vwaPage;
var vwaShapes;

// Capture a reference to the current session of the Visio Web Access Web Part.
function onApplicationLoad() {
    try{
        vwaControl= new Vwa.VwaControl(getVWAWebPartID());
        vwaControl.addHandler("diagramcomplete", onDiagramComplete);
    }
    catch(err){
        alert(err);

    }
}

// Search SharePoint page to get WebPartID# for Visio Web Access Web Part.
function getVWAWebPartID() {
   
    // Get a NodesList of all the div tags on the page.
    var divArray = document.getElementsByTagName("div");
    var webPartElementID;
   
    // Iterate through the NodesList to get the node with the class attribute "VisioWebAccess."
    for (var i = 0; i < divArray.length; i++) {
        var node = divArray[i];
       
        // Return the first instance of the Visio Web Access Web Part.
        if (node.className == "VisioWebAccess") {
            webPartElementID = node.parentNode.parentNode.id;
            break;
        }
    }
    return webPartElementID;
}

// Capture references to global variables and display message in the Web Part after rendering is complete.
function onDiagramComplete() {
    try{

        // Get references to the current Visio page displayed in the Web Part and the shapes on the page.


 vwaPages = vwaControl.getAllPageIds();
        var pageCount = vwaPages.length;
        var vwaPage = vwaControl.getActivePage();
 for (var i = 0; i < pageCount; i++){
            // Get page ID from array of pages IDs.
            vwaPageId = vwaPages[i];
     
alert(vwaPageId);


//This code returns all the page names
// var vwaPage = vwaControl.getActivePage();
// var vwaPageName = vwaPage.getId();

// alert(vwaPageName);


}




    
    }
    catch(err){
        alert(err);
    }
}

</script>

No comments:

Post a Comment