This commit is contained in:
季圣华
2016-10-30 16:45:33 +08:00
parent c9e03495f4
commit b796dce5cc
146 changed files with 4589 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,272 @@
/*
* jDigiClock plugin 2.1
*
* http://www.radoslavdimov.com/jquery-plugins/jquery-plugin-digiclock/
*
* Copyright (c) 2009 Radoslav Dimov
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function($) {
$.fn.extend({
jdigiclock: function(options) {
var defaults = {
clockImagesPath: 'images/clock/',
weatherImagesPath: 'images/weather/',
lang: 'en',
am_pm: false,
weatherLocationCode: 'EUR|BG|BU002|BOURGAS',
weatherMetric: 'C',
weatherUpdate: 0,
proxyType: 'php'
};
var regional = [];
regional['en'] = {
monthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
}
var options = $.extend(defaults, options);
return this.each(function() {
var $this = $(this);
var o = options;
$this.clockImagesPath = o.clockImagesPath;
$this.weatherImagesPath = o.weatherImagesPath;
$this.lang = regional[o.lang] == undefined ? regional['en'] : regional[o.lang];
$this.am_pm = o.am_pm;
$this.weatherLocationCode = o.weatherLocationCode;
$this.weatherMetric = o.weatherMetric == 'C' ? 1 : 0;
$this.weatherUpdate = o.weatherUpdate;
$this.proxyType = o.proxyType;
$this.currDate = '';
$this.timeUpdate = '';
var html = '<div id="plugin_container">';
html += '<div id="digital_container">';
html += '<div id="clock"></div>';
html += '</div>';
html += '<div id="forecast_container"></div>';
html += '</div>';
$this.html(html);
$this.displayClock($this);
$this.displayWeather($this);
var panel_pos = ($('#plugin_container > div').length - 1) * 500;
var next = function() {
$('#right_arrow').unbind('click', next);
$('#plugin_container > div').filter(function(i) {
$(this).animate({'left': (i * 500) - 500 + 'px'}, 400, function() {
if (i == 0) {
$(this).appendTo('#plugin_container').css({'left':panel_pos + 'px'});
}
$('#right_arrow').bind('click', next);
});
});
};
$('#right_arrow').bind('click', next);
var prev = function() {
$('#left_arrow').unbind('click', prev);
$('#plugin_container > div:last').prependTo('#plugin_container').css({'left':'-500px'});
$('#plugin_container > div').filter(function(i) {
$(this).animate({'left': i * 500 + 'px'}, 400, function() {
$('#left_arrow').bind('click', prev);
});
});
};
$('#left_arrow').bind('click', prev);
});
}
});
$.fn.displayClock = function(el) {
$.fn.getTime(el);
setTimeout(function() {$.fn.displayClock(el)}, $.fn.delay());
}
$.fn.displayWeather = function(el) {
$.fn.getWeather(el);
if (el.weatherUpdate > 0) {
setTimeout(function() {$.fn.displayWeather(el)}, (el.weatherUpdate * 60 * 1000));
}
}
$.fn.delay = function() {
var now = new Date();
var delay = (60 - now.getSeconds()) * 1000;
return delay;
}
$.fn.getTime = function(el) {
var now = new Date();
var old = new Date();
old.setTime(now.getTime() - 60000);
var now_hours, now_minutes, old_hours, old_minutes, timeOld = '';
now_hours = now.getHours();
now_minutes = now.getMinutes();
old_hours = old.getHours();
old_minutes = old.getMinutes();
if (el.am_pm) {
var am_pm = now_hours > 11 ? 'pm' : 'am';
now_hours = ((now_hours > 12) ? now_hours - 12 : now_hours);
old_hours = ((old_hours > 12) ? old_hours - 12 : old_hours);
}
now_hours = ((now_hours < 10) ? "0" : "") + now_hours;
now_minutes = ((now_minutes < 10) ? "0" : "") + now_minutes;
old_hours = ((old_hours < 10) ? "0" : "") + old_hours;
old_minutes = ((old_minutes < 10) ? "0" : "") + old_minutes;
// date
el.currDate = el.lang.dayNames[now.getDay()] + ',&nbsp;' + now.getDate() + '&nbsp;' + el.lang.monthNames[now.getMonth()];
// time update
el.timeUpdate = el.currDate + ',&nbsp;' + now_hours + ':' + now_minutes;
var firstHourDigit = old_hours.substr(0,1);
var secondHourDigit = old_hours.substr(1,1);
var firstMinuteDigit = old_minutes.substr(0,1);
var secondMinuteDigit = old_minutes.substr(1,1);
timeOld += '<div id="hours"><div class="line"></div>';
timeOld += '<div id="hours_bg"><img src="' + el.clockImagesPath + 'clockbg1.png" /></div>';
timeOld += '<img src="' + el.clockImagesPath + firstHourDigit + '.png" id="fhd" class="first_digit" />';
timeOld += '<img src="' + el.clockImagesPath + secondHourDigit + '.png" id="shd" class="second_digit" />';
timeOld += '</div>';
timeOld += '<div id="minutes"><div class="line"></div>';
if (el.am_pm) {
timeOld += '<div id="am_pm"><img src="' + el.clockImagesPath + am_pm + '.png" /></div>';
}
timeOld += '<div id="minutes_bg"><img src="' + el.clockImagesPath + 'clockbg1.png" /></div>';
timeOld += '<img src="' + el.clockImagesPath + firstMinuteDigit + '.png" id="fmd" class="first_digit" />';
timeOld += '<img src="' + el.clockImagesPath + secondMinuteDigit + '.png" id="smd" class="second_digit" />';
timeOld += '</div>';
el.find('#clock').html(timeOld);
// set minutes
if (secondMinuteDigit != '9') {
firstMinuteDigit = firstMinuteDigit + '1';
}
if (old_minutes == '59') {
firstMinuteDigit = '511';
}
setTimeout(function() {
$('#fmd').attr('src', el.clockImagesPath + firstMinuteDigit + '-1.png');
$('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg2.png');
},200);
setTimeout(function() { $('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg3.png')},250);
setTimeout(function() {
$('#fmd').attr('src', el.clockImagesPath + firstMinuteDigit + '-2.png');
$('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg4.png');
},400);
setTimeout(function() { $('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg5.png')},450);
setTimeout(function() {
$('#fmd').attr('src', el.clockImagesPath + firstMinuteDigit + '-3.png');
$('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg6.png');
},600);
setTimeout(function() {
$('#smd').attr('src', el.clockImagesPath + secondMinuteDigit + '-1.png');
$('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg2.png');
},200);
setTimeout(function() { $('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg3.png')},250);
setTimeout(function() {
$('#smd').attr('src', el.clockImagesPath + secondMinuteDigit + '-2.png');
$('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg4.png');
},400);
setTimeout(function() { $('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg5.png')},450);
setTimeout(function() {
$('#smd').attr('src', el.clockImagesPath + secondMinuteDigit + '-3.png');
$('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg6.png');
},600);
setTimeout(function() {$('#fmd').attr('src', el.clockImagesPath + now_minutes.substr(0,1) + '.png')},800);
setTimeout(function() {$('#smd').attr('src', el.clockImagesPath + now_minutes.substr(1,1) + '.png')},800);
setTimeout(function() { $('#minutes_bg img').attr('src', el.clockImagesPath + 'clockbg1.png')},850);
// set hours
if (now_minutes == '00') {
if (el.am_pm) {
if (now_hours == '00') {
firstHourDigit = firstHourDigit + '1';
now_hours = '12';
} else if (now_hours == '01') {
firstHourDigit = '001';
secondHourDigit = '111';
} else {
firstHourDigit = firstHourDigit + '1';
}
} else {
if (now_hours != '10') {
firstHourDigit = firstHourDigit + '1';
}
if (now_hours == '20') {
firstHourDigit = '1';
}
if (now_hours == '00') {
firstHourDigit = firstHourDigit + '1';
secondHourDigit = secondHourDigit + '11';
}
}
setTimeout(function() {
$('#fhd').attr('src', el.clockImagesPath + firstHourDigit + '-1.png');
$('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg2.png');
},200);
setTimeout(function() { $('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg3.png')},250);
setTimeout(function() {
$('#fhd').attr('src', el.clockImagesPath + firstHourDigit + '-2.png');
$('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg4.png');
},400);
setTimeout(function() { $('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg5.png')},450);
setTimeout(function() {
$('#fhd').attr('src', el.clockImagesPath + firstHourDigit + '-3.png');
$('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg6.png');
},600);
setTimeout(function() {
$('#shd').attr('src', el.clockImagesPath + secondHourDigit + '-1.png');
$('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg2.png');
},200);
setTimeout(function() { $('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg3.png')},250);
setTimeout(function() {
$('#shd').attr('src', el.clockImagesPath + secondHourDigit + '-2.png');
$('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg4.png');
},400);
setTimeout(function() { $('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg5.png')},450);
setTimeout(function() {
$('#shd').attr('src', el.clockImagesPath + secondHourDigit + '-3.png');
$('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg6.png');
},600);
setTimeout(function() {$('#fhd').attr('src', el.clockImagesPath + now_hours.substr(0,1) + '.png')},800);
setTimeout(function() {$('#shd').attr('src', el.clockImagesPath + now_hours.substr(1,1) + '.png')},800);
setTimeout(function() { $('#hours_bg img').attr('src', el.clockImagesPath + 'clockbg1.png')},850);
}
}
})(jQuery);

View File

@@ -0,0 +1,4 @@
.NET proxy version
written by Alessandro Benedetti
You need the open source Newtonsoft.Json to compile.

View File

@@ -0,0 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WeatherProxy.aspx.cs" Inherits="MultiConsultCRM.Web.Resources.WeatherProxy" %>

View File

@@ -0,0 +1,127 @@
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Collections.Generic;
using System.Net;
using System.IO;
namespace MultiConsultCRM.Web.Resources
{
public partial class WeatherProxy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string _location = Request.QueryString["location"];
string _metric = Request.QueryString["metric"];
//string _url = string.Format("http://rainmeter.accu-weather.com/widget/rainmeter/weather-data.asp?location={0}&metric={1}", _location, _metric);
string _url = string.Format("http://wwwa.accuweather.com/adcbin/forecastfox/weather_data.asp?location={0}&metric={1}", _location, _metric);
string _xml = DownloadWebPage(_url);
XmlDocument _xmlDocument = new XmlDocument();
_xmlDocument.LoadXml(_xml);
XmlNamespaceManager _mgr = new XmlNamespaceManager(_xmlDocument.NameTable);
_mgr.AddNamespace("pf", _xmlDocument.DocumentElement.NamespaceURI);
Weather _weather = new Weather();
_weather.city =
_xmlDocument.SelectSingleNode("/pf:adc_database/pf:local/pf:city", _mgr).InnerText;
_weather.curr_temp = Convert.ToInt32(
_xmlDocument.SelectSingleNode("/pf:adc_database/pf:currentconditions/pf:temperature", _mgr).InnerText);
_weather.curr_text =
_xmlDocument.SelectSingleNode("/pf:adc_database/pf:currentconditions/pf:weathertext", _mgr).InnerText;
_weather.curr_icon = Convert.ToInt32(
_xmlDocument.SelectSingleNode("/pf:adc_database/pf:currentconditions/pf:weathericon", _mgr).InnerText);
XmlNodeList _xmlNodeList = _xmlDocument.SelectNodes("/pf:adc_database/pf:forecast/pf:day", _mgr);
int _day = _xmlNodeList.Count;
int i = 0;
foreach (XmlNode _dayItem in _xmlNodeList)
{
Forecast _forecast = new Forecast();
_forecast.day_date = _dayItem["obsdate"].InnerXml;
_forecast.day_text = _dayItem.SelectSingleNode("pf:daytime", _mgr)["txtshort"].InnerXml;
_forecast.day_icon =
Convert.ToInt32(_dayItem.SelectSingleNode("pf:daytime", _mgr)["weathericon"].InnerXml);
_forecast.day_htemp =
Convert.ToInt32(_dayItem.SelectSingleNode("pf:daytime", _mgr)["hightemperature"].InnerXml);
_forecast.day_ltemp =
Convert.ToInt32(_dayItem.SelectSingleNode("pf:daytime", _mgr)["lowtemperature"].InnerXml);
_weather.forecast.Add(_forecast);
i++;
// 5 day forecast
if (i == 5) break;
}
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(_weather));
}
/// <summary>
/// Returns the content of a given web adress as string.
/// </summary>
/// <param name="Url">URL of the webpage</param>
/// <returns>Website content</returns>
public string DownloadWebPage(string Url)
{
// Open a connection
HttpWebRequest WebRequestObject = (HttpWebRequest)HttpWebRequest.Create(Url);
// You can also specify additional header values like
// the user agent or the referer:
WebRequestObject.UserAgent = ".NET Framework/2.0";
WebRequestObject.Referer = "http://www.example.com/";
// Request response:
WebResponse Response = WebRequestObject.GetResponse();
// Open data stream:
Stream WebStream = Response.GetResponseStream();
// Create reader object:
StreamReader Reader = new StreamReader(WebStream);
// Read the entire stream content:
string PageContent = Reader.ReadToEnd();
// Cleanup
Reader.Close();
WebStream.Close();
Response.Close();
return PageContent;
}
}
public class Weather
{
public string city;
public int curr_temp;
public string curr_text;
public int curr_icon;
public List<Forecast> forecast = new List<Forecast>();
}
public class Forecast
{
public string day_date;
public string day_text;
public int day_icon;
public int day_htemp;
public int day_ltemp;
}
}

View File

@@ -0,0 +1,16 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MultiConsultCRM.Web.Resources {
public partial class WeatherProxy {
}
}

View File

@@ -0,0 +1,3 @@
# Ignore everything in this directory
*
# Except this file !.gitkeep

View File

@@ -0,0 +1,40 @@
<?php
$location = $_GET['location'];
$metric = (int)$_GET['metric'];
$url = 'http://wwwa.accuweather.com/adcbin/forecastfox/weather_data.asp?location=' . $location . '&metric=' . $metric;
//$url = 'http://rainmeter.accu-weather.com/widget/rainmeter/weather-data.asp?location=' . $location . '&metric=' . $metric;
$ch = curl_init();
$timeout = 0;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($file_contents);
$weather['city'] = (string)$xml->local->city;
$weather['curr_temp'] = (int)$xml->currentconditions->temperature;
$weather['curr_text'] = (string)$xml->currentconditions->weathertext;
$weather['curr_icon'] = (int)$xml->currentconditions->weathericon;
// forecast
//$day = count($xml->forecast->day);
$day = 5;
for ($i = 0; $i < $day; $i++) {
$weather['forecast'][$i]['day_date'] = (string)$xml->forecast->day[$i]->obsdate;
$weather['forecast'][$i]['day_text'] = (string)$xml->forecast->day[$i]->daytime->txtshort;
$weather['forecast'][$i]['day_icon'] = (int)$xml->forecast->day[$i]->daytime->weathericon;
$weather['forecast'][$i]['day_htemp'] = (int)$xml->forecast->day[$i]->daytime->hightemperature;
$weather['forecast'][$i]['day_ltemp'] = (int)$xml->forecast->day[$i]->daytime->lowtemperature;
}
echo json_encode($weather);
?>