| 1 | script_include("/SAPO/"); |
|---|
| 2 | script_include("/SAPO/Exception/"); |
|---|
| 3 | script_include("/SAPO/Communication/Syndication/0.1/"); |
|---|
| 4 | script_include("/SAPO/Utility/Url/0.1/"); |
|---|
| 5 | script_include("/SAPO/Utility/String/0.1/"); |
|---|
| 6 | script_include("/SAPO/Utility/Dumper/0.1/"); |
|---|
| 7 | script_include("/SAPO/Utility/CSS/0.1/"); |
|---|
| 8 | script_include("/SAPO/Widget/Meteo/0.1/"); |
|---|
| 9 | #CODE-START# |
|---|
| 10 | function runSnippet() { |
|---|
| 11 | var params = SAPO.Utility.Url.getQueryString(SAPO.Utility.Url.currentScriptElement().src); |
|---|
| 12 | params = Object.extend({c: "LPAV", w: 230, f: "left", sa: true, fd: 3, bg: "#F1F1F1" }, params || {}); |
|---|
| 13 | var css={ |
|---|
| 14 | '': { |
|---|
| 15 | 'background-color': params["bg"], |
|---|
| 16 | 'color':'#000000', |
|---|
| 17 | 'font-size':'70%', |
|---|
| 18 | 'font-family':'Arial, Helvetica, sans-serif' |
|---|
| 19 | }, |
|---|
| 20 | 'h1': { |
|---|
| 21 | 'margin':'0', |
|---|
| 22 | 'font-weight':'normal', |
|---|
| 23 | 'cursor':'normal' |
|---|
| 24 | }, |
|---|
| 25 | 'h2': { |
|---|
| 26 | 'margin':'0', |
|---|
| 27 | 'font-weight':'normal', |
|---|
| 28 | 'text-align':'center', |
|---|
| 29 | 'font-size':'13px', |
|---|
| 30 | 'cursor':'normal' |
|---|
| 31 | }, |
|---|
| 32 | 'p': { |
|---|
| 33 | 'margin':'0', |
|---|
| 34 | 'font-weight':'normal', |
|---|
| 35 | 'cursor':'normal' |
|---|
| 36 | }, |
|---|
| 37 | '.weatherNow': { |
|---|
| 38 | 'background-color': params["bg"], |
|---|
| 39 | 'margin':'3px auto -10px auto' |
|---|
| 40 | }, |
|---|
| 41 | '.weatherNow .image': { |
|---|
| 42 | 'float':'left', |
|---|
| 43 | 'margin':'0' |
|---|
| 44 | }, |
|---|
| 45 | '.weatherNow .image img': { |
|---|
| 46 | 'background-color': params["bg"], |
|---|
| 47 | 'color':'#000000', |
|---|
| 48 | 'width':'100px', |
|---|
| 49 | 'height':'80px', |
|---|
| 50 | 'border':'0', |
|---|
| 51 | 'margin':'0 auto', |
|---|
| 52 | 'float':'none' |
|---|
| 53 | }, |
|---|
| 54 | '.weatherNow .temp': { |
|---|
| 55 | 'background':'url(http://js.sapo.pt/Assets/Images/Meteo/tempIcon.gif) no-repeat left 2px', |
|---|
| 56 | 'width':'42px', |
|---|
| 57 | 'height':'30px', |
|---|
| 58 | 'float':'left', |
|---|
| 59 | 'margin':'0 0 0 9px' |
|---|
| 60 | }, |
|---|
| 61 | '.weatherNow .temp p': { |
|---|
| 62 | 'text-align':'left', |
|---|
| 63 | 'clear':'right', |
|---|
| 64 | 'margin':'0 0 2px 22px' |
|---|
| 65 | }, |
|---|
| 66 | '.weatherNow .temp p.max': { |
|---|
| 67 | 'font-size':'12px' |
|---|
| 68 | }, |
|---|
| 69 | '.weatherNow .temp p.min': { |
|---|
| 70 | 'font-size':'10px' |
|---|
| 71 | }, |
|---|
| 72 | '.weatherNow .actualtemp': { |
|---|
| 73 | 'margin-top':'-2px' |
|---|
| 74 | }, |
|---|
| 75 | '.weatherNow .actualtemp p': { |
|---|
| 76 | 'font-size':'16px', |
|---|
| 77 | 'margin':'0' |
|---|
| 78 | }, |
|---|
| 79 | '.weatherNow h1': { |
|---|
| 80 | 'float':'right', |
|---|
| 81 | 'font-size':'16px', |
|---|
| 82 | 'margin':'14px 0 0 0', |
|---|
| 83 | 'text-align':'left', |
|---|
| 84 | 'width':'70px' |
|---|
| 85 | }, |
|---|
| 86 | '.weatherItem': { |
|---|
| 87 | 'background-color':params["bg"], |
|---|
| 88 | 'color':'#000000', |
|---|
| 89 | 'margin':'0 auto', |
|---|
| 90 | 'padding':'0', |
|---|
| 91 | 'width':'60px', |
|---|
| 92 | 'float':'left', |
|---|
| 93 | 'color':'#333' |
|---|
| 94 | }, |
|---|
| 95 | '.weatherItem h1': { |
|---|
| 96 | 'padding-left':'8px', |
|---|
| 97 | 'text-align':'left', |
|---|
| 98 | 'font-size':'10px', |
|---|
| 99 | 'height':'14px', |
|---|
| 100 | 'overflow':'hidden' |
|---|
| 101 | }, |
|---|
| 102 | '.weatherItem .image': { |
|---|
| 103 | 'background-color':params["bg"], |
|---|
| 104 | 'color':'#000000', |
|---|
| 105 | 'width':'100%', |
|---|
| 106 | 'margin':'auto', |
|---|
| 107 | 'float':'none' |
|---|
| 108 | }, |
|---|
| 109 | '.weatherItem .image img': { |
|---|
| 110 | 'background-color':params["bg"], |
|---|
| 111 | 'color':'#000000', |
|---|
| 112 | 'border':'0', |
|---|
| 113 | 'width':'54px', |
|---|
| 114 | 'height':'48px', |
|---|
| 115 | 'margin':'0 auto', |
|---|
| 116 | 'float':'none' |
|---|
| 117 | }, |
|---|
| 118 | '.weatherItem .temp': { |
|---|
| 119 | 'margin':'-5px auto 0 auto', |
|---|
| 120 | 'text-align':'center', |
|---|
| 121 | 'clear':'both' |
|---|
| 122 | }, |
|---|
| 123 | '.weatherItem .temp p': { |
|---|
| 124 | 'font-size':'12px', |
|---|
| 125 | 'cursor':'default', |
|---|
| 126 | 'display':'inline', |
|---|
| 127 | 'padding':'0 0 0 2px', |
|---|
| 128 | 'margin':'0' |
|---|
| 129 | }, |
|---|
| 130 | '.weatherItem .temp p.min': { |
|---|
| 131 | 'margin-right':'2px', |
|---|
| 132 | 'font-size':'10px' |
|---|
| 133 | }, |
|---|
| 134 | '.weatherItem .temp p.max': { |
|---|
| 135 | 'font-size':'12px' |
|---|
| 136 | } |
|---|
| 137 | }; |
|---|
| 138 | var i=Math.round(10000*Math.random()); |
|---|
| 139 | document.write('<div style="text-align:center;float:'+params["f"]+';width:'+params["w"]+'px;">'); |
|---|
| 140 | document.write('<div id="spot'+i+'" style="float:'+params["f"]+';width:'+params["w"]+'px;"></div>'); |
|---|
| 141 | if(params["f"]==='none') { document.write('<br clear="all"/>'); } |
|---|
| 142 | document.write('<br/>'); |
|---|
| 143 | document.write('<a style="font-weight:normal;font-style:normal;font-family:Arial, Helvetica, sans-serif;font-size:12px;color:#000000;" href="http://tempo.sapo.pt">Mais tempo no SAPO</a>'); |
|---|
| 144 | document.write('</div>'); |
|---|
| 145 | var feed="http://services.sl.pt/WeatherJSON/GetWeatherForecast?cityCode="+params["c"]; |
|---|
| 146 | var p = new SAPO.Communication.Syndication(); |
|---|
| 147 | var ppid=p.push(feed,{onComplete: function(obj){var meteo=new SAPO.Widget.Meteo();meteo.printForecast(obj,{showactual: params["sa"], forecastdays: parseInt(params["fd"]), divid: "spot"+i, css: css});}}); |
|---|
| 148 | p.run(ppid); |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | SAPO.logReferer('http://js.sapo.pt/Snippets/Meteo.js'); |
|---|
| 152 | |
|---|
| 153 | runSnippet(); // this helps avoiding concurrency problems |
|---|
| 154 | |
|---|