X-Git-Url: http://mop.ddnsfree.com/gitweb/?p=xynt.git;a=blobdiff_plain;f=web%2Fxynt%2Fxynt-commons.js;fp=web%2Fxynt%2Fxynt-commons.js;h=9af0555517296d8d18112bfcb464cbfaf64bd33a;hp=45b5c85f4eb8f341dc59971c702f237b580db484;hb=386fa94983dde1a403adc18267ebe1865e65def5;hpb=f204bcec7746f916c356f31dbe814a865c37dd0d diff --git a/web/xynt/xynt-commons.js b/web/xynt/xynt-commons.js index 45b5c85..9af0555 100644 --- a/web/xynt/xynt-commons.js +++ b/web/xynt/xynt-commons.js @@ -169,4 +169,45 @@ function url_append_args(url) } return (ret); +} + +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); + } } \ No newline at end of file