Menu

[r343]: / phprpc_3.0 / ajs / flashrequest.js  Maximize  Restore  History

Download this file

139 lines (122 with data), 4.5 kB

  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
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**********************************************************\
| |
| The implementation of PHPRPC Protocol 3.0 |
| |
| flashrequest.js |
| |
| Release 3.0.0 beta |
| Copyright (c) 2005-2007 by Team-PHPRPC |
| |
| WebSite: http://www.phprpc.org/ |
| http://www.phprpc.net/ |
| http://www.phprpc.com/ |
| http://sourceforge.net/projects/php-rpc/ |
| |
| Authors: Ma Bingyao <andot@ujn.edu.cn> |
| |
| This file may be distributed and/or modified under the |
| terms of the GNU Lesser General Public License (LGPL) |
| version 3.0 as published by the Free Software Foundation |
| and appearing in the included file LICENSE. |
| |
\**********************************************************/
/* POST data to HTTP Server (using Flash)
*
* Copyright (C) 2005-2007 Ma Bingyao <andot@ujn.edu.cn>
* Version: 3.0.0 beta
* LastModified: Nov 21, 2007
* This library is free. You can redistribute it and/or modify it.
*/
/*
* Interfaces:
* FlashRequest.post(url, data, username, password, callback);
*/
/* public class FlashRequest
* static encapsulation environment for FlashRequest
*/
var FlashRequest = (function() {
// static private members
/*
* to save Flash Request
*/
var s_request = null;
/*
* to save all request callback functions
*/
var s_callbackList = [];
/*
* to save FlashRequest tasks.
*/
var s_jsTaskQueue = [];
var s_swfTaskQueue = [];
/*
* to save js & swf status.
*/
var s_jsReady = false;
var s_swfReady = false;
function post(url, data, username, password, callbackid) {
if (s_swfReady) {
s_request.post(url, data, username, password, callbackid);
}
else {
var task = function() {
s_request.post(url, data, username, password, callbackid);
};
s_swfTaskQueue.push(task);
}
}
var FlashRequest = {};
FlashRequest.post = function (url, data, username, password, callback) {
var callbackid = -1;
if (callback) {
callbackid = s_callbackList.length;
s_callbackList[callbackid] = callback;
}
if (s_jsReady) {
post(url, data, username, password, callbackid);
}
else {
var task = function() {
post(url, data, username, password, callbackid);
};
s_jsTaskQueue.push(task);
}
}
FlashRequest.__callback = function(callbackid, data) {
if (typeof(s_callbackList[callbackid]) == 'function') {
s_callbackList[callbackid](data);
}
delete s_callbackList[callbackid];
}
FlashRequest.__jsReady = function () {
return s_jsReady;
}
FlashRequest.__setJsReady = function () {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
var id = 'flashrequest_as3';
s_request = (isIE) ? window[id] : document[id];
while (s_jsTaskQueue.length > 0) {
var task = s_jsTaskQueue.shift();
if (typeof(task) == 'function') {
task();
}
}
s_jsReady = true;
}
FlashRequest.__setSwfReady = function () {
while (s_swfTaskQueue.length > 0) {
var task = s_swfTaskQueue.shift();
if (typeof(task) == 'function') {
task();
}
}
s_swfReady = true;
}
return FlashRequest;
})();
if (document.all) {
window.attachEvent('onload', function () {FlashRequest.__setJsReady();});
}
else {
window.addEventListener('load', function () {FlashRequest.__setJsReady();}, false);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.