Skip to content

Instantly share code, notes, and snippets.

@ritacse
Last active March 8, 2022 10:16
Show Gist options
  • Save ritacse/20052febf01e10b90505a132e4637319 to your computer and use it in GitHub Desktop.
Save ritacse/20052febf01e10b90505a132e4637319 to your computer and use it in GitHub Desktop.
/// Report open from approval system without external Login
/// Example from : \DMS\DMS.Planning.Web\Scripts\Planning\YarnAllocation.js
function RefFBLink(fbCode, fbVersion) {
var ReportName = 'rptFabricBooking.aspx';
var DocBaseID = 63;
if (fbCode == 'N/A' || fbCode == null || fbCode =='')
toastr.warning("Fabric booknig does not found against this job.",'Invalid');
else {
//var urlLink = 'http://localhost:59780/ApprovalSystem/htmlReport/' + ReportName + '?clientAgent=Web&userId=' + 0 + '&docBaseId=' + DocBaseID + '&docCode=' + fbCode + '&docVersion=' + fbVersion;
var urlLink = 'http://172.16.1.8/ApprovalSystem/htmlReport/' + ReportName + '?clientAgent=Web&userId=' + 0 + '&docBaseId=' + DocBaseID + '&docCode=' + fbCode + '&docVersion=' + fbVersion;
window.open(urlLink);
}
}
// send parameter
var url = '../ApprovalReportViewer.aspx?docBaseId=' + aData.Doc_Type + "&docCode=" + aData.Code + "&docVersion=" + aData.Version;
window.open(url, '_blank'); // <- This is what makes it open in a new window.
//Get parameter
var docBaseId = $.url().param('docBaseId');
var docCode = $.url().param('docCode');
var docVersion = $.url().param('docVersion');
//Or
var docBaseId = GetParameterValues('docBaseId');
var docCode = GetParameterValues('docCode');
var docVersion = GetParameterValues('docVersion');
function GetParameterValues(param) {
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < url.length; i++) {
var urlparam = url[i].split('=');
if (urlparam[0] == param) {
return urlparam[1];
}
}
}
if (window.location.hostname.indexOf("192") > -1) /// Not provid ethe full link
var redirect = 'http://192.168.200.35:5693/ApprovalHRMS/API/ExternalCommunicationHandler.ashx';
else
var redirect = 'http://localhost:8222/API/ExternalCommunicationHandler.ashx';
//Tips
window.location.host : you'll get sub.domain.com:8080 or sub.domain.com:80
window.location.hostname : you'll get sub.domain.com
window.location.protocol : you'll get http:
window.location.port : you'll get 8080 or 80
window.location.pathname : you'll get /virtualPath
window.location.origin : you'll get http://sub.domain.com *****
//ditect page name
var pageName = document.location.pathname.match(/[^\/]+$/)[0];
var pageName2 = location.pathname.split('/').slice(-1)[0];
var href = document.location.href;
var lastPathSegment = href.substr(href.lastIndexOf('/') + 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment