KD2 Framework  Check-in [ed89cb87a3]

Overview
Comment:XHR micro-lib
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ed89cb87a3dfdda71244e13d027a471d0ed44baf
User & Date: bohwaz on 2015-02-04 05:24:07
Other Links: manifest | tags
Context
2015-02-06
02:36
Variable assignation mistake check-in: f8499cfec7 user: bohwaz tags: trunk
2015-02-04
05:24
XHR micro-lib check-in: ed89cb87a3 user: bohwaz tags: trunk
02:05
JPEG files may be weird depending on the JPEG writer, the fourth byte is unreliable. check-in: 3bb7956e46 user: bohwaz tags: trunk
Changes

Added src/js/xhr.js version [d5f956445e].





































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var xhr = function (url, callback, format, errorCallback) {
	var http = new XMLHttpRequest();
	if (!http || !url) return false;
	if (http.overrideMimeType) http.overrideMimeType('text/xml');
	
	// avoid cache issues, append datetime at the end of URL
	url += (url.indexOf('?')+1 ? '&' : '?') + (+(new Date));
	
	http.onreadystatechange = function ()
	{
		if (http.readyState != 4) return;

		if ((s = http.status) == 200)
		{
			if (!callback) return true;

			var result = http.responseText;
			
			if (format == 'json')
			{
				return ((j = window.JSON) && j.parse) ? j.parse(result) : eval('(' + result.replace(/[\n\r]/g, '') + ')');
			}

			callback(result);
		}
		else if (errorCallback)
		{
			errorCallback(s);
		}
	};

	http.open('GET', url, true);
	http.send(null);
};

Added src/js/xhr.min.js version [47563cc6cf].



>
1
var xhr=function(b,d,f,e){var a=new XMLHttpRequest();if(!a||!b)return false;if(a.overrideMimeType)a.overrideMimeType('text/xml');b+=(b.indexOf('?')+1?'&':'?')+(+(new Date));a.onreadystatechange=function(){if(a.readyState!=4)return;if((s=a.status)==200){if(!d)return true;var c=a.responseText;if(f=='json'){return((j=window.JSON)&&j.parse)?j.parse(c):eval('('+c.replace(/[\n\r]/g,'')+')')}d(c)}else if(e){e(s)}};a.open('GET',b,true);a.send(null)};

Modified src/lib/kd2/XML_RPC_Server.php from [2d40afc8c5] to [edbeeab0a0].

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
	}

	/**
	 * Encodes a string in a base64 XML-RPC data type
	 * @param  string $binary Input binary string
	 * @return object         XML-RPC object
	 */
	public function base64($binary)
	{
		if (xmlrpc_set_type($binary, 'base64'))
		{
			return $binary;
		}

		return false;
	}

	/**
	 * Encodes a string in a datetime XML-RPC data type
	 * @param  string $timestamp 	Input UNIX timestamp
	 * @return object         		XML-RPC object
	 */
	public function datetime($timestamp)
	{
		$timestamp = date('c', $timestamp);

		if (xmlrpc_set_type($timestamp, 'datetime'))
		{
			return $timestamp;
		}

		return false;
	}
}







|














|











72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
	}

	/**
	 * Encodes a string in a base64 XML-RPC data type
	 * @param  string $binary Input binary string
	 * @return object         XML-RPC object
	 */
	static public function base64($binary)
	{
		if (xmlrpc_set_type($binary, 'base64'))
		{
			return $binary;
		}

		return false;
	}

	/**
	 * Encodes a string in a datetime XML-RPC data type
	 * @param  string $timestamp 	Input UNIX timestamp
	 * @return object         		XML-RPC object
	 */
	static public function datetime($timestamp)
	{
		$timestamp = date('c', $timestamp);

		if (xmlrpc_set_type($timestamp, 'datetime'))
		{
			return $timestamp;
		}

		return false;
	}
}