X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=xynt.git;a=blobdiff_plain;f=web%2Fxynt%2Fxynt-commons.js;h=550cc281e9b4ec8e8f3c14950d494e7c06ba0722;hp=45b5c85f4eb8f341dc59971c702f237b580db484;hb=1716e67da8e78da7de463d5224baeaaaca1cf2ff;hpb=5ba9cf2d51aeb6ca0d9687c908ccb10496e843ca diff --git a/web/xynt/xynt-commons.js b/web/xynt/xynt-commons.js index 45b5c85..550cc28 100644 --- a/web/xynt/xynt-commons.js +++ b/web/xynt/xynt-commons.js @@ -169,4 +169,45 @@ function url_append_args(url) } return (ret); -} \ No newline at end of file +} + +function url_complete(parent, url) +{ + var p, p2, rest; + var host = "", path = ""; + + // host extraction + p = parent.indexOf("://"); + if (p > -1) { + rest = parent.substring(p+3); + p2 = rest.indexOf("/"); + if (p2 > -1) { + host = parent.substring(0, p+3+p2); + rest = parent.substring(p+3+p2); + } + else { + host = rest; + rest = ""; + } + } + else { + rest = parent; + } + + // path extraction + p = rest.lastIndexOf("/"); + if (p > -1) { + path = rest.substring(0, p+1); + } + + // alert("host: ["+host+"] path: ["+path+"]"); + if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/') { + return (url); + } + else if (url.substring(0,1) == '/') { + return (host+url); + } + else { + return (host+path+url); + } +}