// configure curl if(typeof window.curl=="undefined"){ curl = { paths: { "jquery":"https://frameworks-scotland.scot.nhs.uk/widgets/resources/js/jquery/jquery-3.7.1.min.js", "root":"https://frameworks-scotland.scot.nhs.uk/" } } } var Spinner (function(){ var pthstr="https://frameworks-scotland.scot.nhs.uk/" var baseUrl="https://frameworks-scotland.scot.nhs.uk/" var widgetroot="widgets" var widget_container_id="image_pan" var page="" var active_page="widgets/output/index.asp" var geojson_loaded=0 var extra_scripts=[] var extra_css=[] var extra_css_last=[] var _test_id=1 var safety=0 var ie7="" var ie8="" var browser_name="unknown" var browser_info=browser_sniffer() var map_control_name="" var context="widgets/image_pan" var embedded="1" var dialog="" var embed_params={} var later_options={} while(safety<10 && null!=document.getElementById("_"+widget_container_id+_test_id)){ _test_id++ } function loading_timer(){ if($("#"+widget_container_id+"_loading_div")){ if($("#"+widget_container_id+"_loading_div").length>0){ if(null!=loading_timer){ var str=$("#"+widget_container_id+"_loading_div").html().toString() var arr=str.split(".") var txt=arr[0] var dots="" switch(arr.length){ case 4: dots="." break; case 2: dots=".." break; case 3: dots="..." break; } txt=txt+dots $("#"+widget_container_id+"_loading_div").html(txt) setTimeout(loading_timer,1000) } } } } function draw_loader(){ if(typeof window!="undefined"){ if(typeof window.jQuery=="undefined"){ setTimeout(draw_loader,20) }else{ if(typeof window.$=="undefined"){ $=jQuery.noConflict() } if(embedded=="1"){ $( document ).ready( function(){ if(typeof widget_container_id=="undefined"){ return } while($("#"+widget_container_id).length>0){ widget_container_id=widget_container_id+$("#"+widget_container_id).length } var widget_div=$("
").attr("id",widget_container_id).css("background-color","#FFF") var msg=$("").css("background","none").html("Loading...").attr("id",widget_container_id+"_loading_div") if(dialog=="1"){ var image_div=$("").attr("id",widget_container_id+"_image").css("border","1px solid #FF0000") var map_holder=$("").attr("id",widget_container_id+"_holder").css({"overflow":"hidden","position":"absolute","width":"1px","height":"1px"}) $(msg).appendTo($(image_div)) }else{ $(msg).appendTo($(widget_div)) } if(null!=loading_timer){ setTimeout(loading_timer,500) } var scripts=$("script") var attach_to=null if(scripts.length>0){ $.each(scripts,$.proxy(function(index,item){ if(null!=$(item).attr("src")){ if($(item).attr("src").toString().indexOf(context+"/embed")>-1){ embed_params.src=$(item).attr("src").toString() if($(item).attr("src").toString().indexOf("?")>-1){ embed_params.src=$(item).attr("src").toString().split("?")[0] embed_params_use=[] var params=$(item).attr("src").toString().split("?")[1] var pairs=params.split("&") var iw=100 var ih=100 $.each(pairs,function(pindex,pitem){ var vals=pitem.split("=") embed_params[vals[0]]=vals[1] if(vals[0]!="zoom" && vals[0]!="lat" && vals[0]!="lng"){ embed_params_use.push(vals[0]+"="+vals[1]) } switch(vals[0]){ case "w": $(widget_div).css("width",vals[1]+"px") if(dialog!="1"){ var w=(vals[1]/2.0)-50 $(msg).css("padding-left",w+"px") } break; case "h": $(widget_div).css("height",vals[1]+"px") if(dialog!="1"){ $(msg).css("padding-top",(vals[1]/2.0)+"px") } break; case "iw": iw=vals[1]*1 $(image_div).css("width",vals[1]+"px") break; case "ih": ih=vals[1]*1 break; default: break; } }) embed_params.src=embed_params.src+"?"+embed_params_use.join("&") if(dialog=="1"){ $(image_div).css("width",iw+"px") var w=(iw/2.0)-50 $(msg).css("padding-left",w+"px") $(image_div).css("height",ih+"px") $(msg).css("padding-top",((ih/2.0)-20)+"px") } } attach_to=$(item) } } },this)) if(null!=attach_to){ if(dialog=="1"){ $(widget_div).appendTo($(map_holder)) $(map_holder).insertAfter($(attach_to)) $(image_div).insertAfter($(attach_to)) }else{ $(widget_div).insertAfter($(attach_to)) } } } }) } } } } draw_loader() extra_css=extra_css.concat(extra_css_last) var b="unknown" var curl_loader if(typeof window.curltime=="undefined"){ window.curltime=0 }else{ window.curltime=window.curltime+20 } setTimeout(function(){ // create curl.js script tag var has_curl=0 if(typeof window!="undefined"){ if(typeof window.curl!="undefined"){ if(null!=window.curl){ if(null!=window.curl.version){ has_curl=1 } } } } if(has_curl==0){ if(typeof window.curlsrc=="undefined"){ }else{ has_curl=1 } } if(has_curl==0){ if(typeof window.curlsrc=="undefined"){ window.curlsrc="widgets/resources/js/curl/curl.0.8.1.0.js" var curlScript = document.createElement( "script" ); curlScript.setAttribute("type", "text/javascript"); curlScript.src = "https://frameworks-scotland.scot.nhs.uk/widgets/resources/js/curl/curl.0.8.1.0.js"; curl_loader=setInterval(function(){ if(null!=window.curl){ if(null!=window.curl.version){ load_resources() } } },20) curl_found=0 if(null!=window.curl){ if(null!=window.curl.version){ curl_found=1 } } if(curl_found==0){ var head = document.getElementsByTagName("head").item(0); head.appendChild(curlScript); } }else{ curl_loader=setInterval(function(){ if(null!=window.curl){ if(null!=window.curl.version){ load_resources() } } },20) } }else{ curl_loader=setInterval(function(){ if(null!=window.curl){ if(null!=window.curl.version){ load_resources() } } },20) } }, window.curltime); function load_resources(){ clearInterval(curl_loader) var timestamp="20241115073659" curl_loader=null var has_jquery=0 if(typeof window!="undefined"){ if(typeof window.jQuery!="undefined"){ if(typeof window.$=="undefined"){ $=jQuery.noConflict() has_jquery=1 } } } var has_mapbox=0 if(typeof window!="undefined"){ if(typeof window.L!="undefined"){ has_mapbox=1 } } start=[] if(has_jquery==0){ start.push("jquery") } if(has_mapbox==0){ start.push("js!https://api.tiles.mapbox.com/mapbox.js/v3.0.1/mapbox.js!order") } start.push("js!root/widgets/resources/js/modernizr/modernizr_custom.js!order") var base=[] base.push("js!root/"+widgetroot+"/resources/js/widget_setup.js?"+timestamp+"!order") var extend=[] extend.push("js!root/widgets/resources/js/widget_setup/extend.image_pan.js?20241115073659!order") //} base.push('domReady!') curl( // load base scripts start ) // when they are loaded .then( function () { curl( // load base scripts base ) // when they are loaded .then( // execute this callback, passing all dependencies as params function () { if(extend.length==0){ setup_widget() }else{ curl( extend ).then( function () { setup_widget() }, // execute this callback if there was a problem function (ex) { curl_error(ex); } ) } }, // execute this callback if there was a problem function (ex) { curl_error(ex); } ); }, // execute this callback if there was a problem function (ex) { curl_error(ex); } ) } function setup_widget(){ window[widget_container_id]=new widget_setup() var params={} var params={"pthstr":pthstr,"baseUrl":baseUrl,"active_page":active_page,"widgetroot":widgetroot,"ie_settings":{"ie8":check_css("IE 8"),"ie7":check_css("IE 7"),"browser_name":browser_name},"browser_info":browser_info} params["widget_container_id"]=widget_container_id params["dialog"]=dialog params["embed_params"]=embed_params params["timestampstr"]="20241115073659" window[widget_container_id].set_pthstr(params) if(pthstr.indexOf("../")==-1){ window[widget_container_id].set_embedded_context_path("widgets/image_pan") } window[widget_container_id].base_loaded() } function browser_sniffer(){ var user_agent=navigator.userAgent.toString() var browser_name="" switch(true){ case user_agent.indexOf("MSIE 10")>-1: browser_name="IE 10" break; case user_agent.indexOf("MSIE 9")>-1: browser_name="IE 9" break; case user_agent.indexOf("MSIE 8")>-1: browser_name="IE 8" break; case user_agent.indexOf("MSIE 7")>-1: browser_name="IE 7" break; case user_agent.indexOf("MSIE 6")>-1: browser_name="IE 6" break; } if(browser_name==""){ if(user_agent.indexOf("iPad")==-1){ switch(true){ case user_agent.indexOf("Firefox")>-1: browser_name="Firefox" break; case user_agent.indexOf("Chrome")>-1: browser_name="Chrome" break; case user_agent.indexOf("Safari")>-1: browser_name="Safari" break; case user_agent.indexOf("Opera")>-1: browser_name="Opera" break; } }else{ if(user_agent.indexOf("CriOS")>-1){ //iPad Chrome browser_name="CriOS" }else{ if(user_agent.indexOf("Safari")>-1){ //iPad Safari browser_name="Safari" } } } } if(browser_name==""){ if(user_agent.indexOf("Mozilla")>-1){ browser_name="Mozilla" }else{ browser_name="unknown" } } if(user_agent.indexOf("iPhone")>-1|| user_agent.indexOf("iPod")>-1 || user_agent.indexOf("iPad")>-1){ ipod=1 }else{ ipod=0 } return {"browser_name":browser_name,"ipod":ipod}; } function browser(browser_name){ return browser_name==browser_info.browser_name; } function check_css(css_type){ var use_css=0 if(css_type=="all" || css_type==""){ use_css=1 }else{ switch(css_type){ case "lte IE 8": if(browser("IE 7")){ use_css=1 } break; case "lte IE 9": if(browser("IE 7")){ use_css=1 } if(browser("IE 8")){ use_css=1 } break; case "not ie": use_css=1 if(browser("IE 7")){ use_css=0 } if(browser("IE 8")){ use_css=0 } break; case "not ie7": use_css=1 if(browser("IE 7")){ use_css=0 } break; case "IE 8": if(browser("IE 8")){ use_css=1 } break; case "IE 7": if(browser("IE 7")){ use_css=1 } break; case "Safari": if(browser("Safari")){ use_css=1 } break; case "Firefox": if(browser("Firefox")){ use_css=1 } break; case "Firefox": if(browser("Firefox")){ use_css=1 } break; case "Chrome": if(browser("Chrome")){ use_css=1 } break; } } return use_css==1; } })() curl_error=function(ex){ var msg = 'Error: ' + ex.message; alert(msg); }