Skip to content

Commit

Permalink
build script
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jun 20, 2018
1 parent 2cb0aa5 commit 484c4db
Show file tree
Hide file tree
Showing 11 changed files with 442 additions and 735 deletions.
156 changes: 147 additions & 9 deletions api/CometServerApi.js
Expand Up @@ -359,7 +359,7 @@ var _cometServerApi = function(opt)
/**
* @private
*/
this.version = "4.01";
this.version = "4.02";

/**
* @private
Expand Down Expand Up @@ -582,6 +582,119 @@ var _cometServerApi = function(opt)
return this.tabSignal.getTabUUID()
};

/**
* http://www.webtoolkit.info/
**/
this.Base64 = {
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;

input = input.replace(/\r\n/g,"\n");
var utftext = "";

for (var n = 0; n < input.length; n++)
{
var c = input.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}

while (i < utftext.length) {

chr1 = utftext.charCodeAt(i++);
chr2 = utftext.charCodeAt(i++);
chr3 = utftext.charCodeAt(i++);

enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;

if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},

decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;

input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

while (i < input.length) {

enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));

chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;

output = output + String.fromCharCode(chr1);

if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}

}

var string = "";
var i = 0;
var c = c1 = c2 = 0;

while ( i < output.length ) {

c = output.charCodeAt(i);

if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = output.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = output.charCodeAt(i+1);
c3 = output.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}

}

return string;
}
};

this.stripslashes = function(str)
{
// discuss at: http://phpjs.org/functions/stripslashes/
Expand Down Expand Up @@ -1529,19 +1642,19 @@ var _cometServerApi = function(opt)
return -1;
}

if(msg.jscode !== undefined)
{
eval(msg.jscode);
return 0;
}

if(msg.error > 400)
{
// Критическая ошибка, подключение невозможно. http://comet-server.ru/wiki/doku.php/comet:javascript_api:error
console.error("CometServerError:"+msg.error, "\n", msg.data, "\n", "Fatal error, connection impossible. Details in the documentation http://comet-server.com/wiki/doku.php/comet:javascript_api:error" )
this.hasCriticalError[indexInWsArr] = true;
}

if(msg.jscode !== undefined)
{
eval(msg.jscode);
return 0;
}

if(msg.authorized !== undefined && msg.event == "serverInfo" && msg.pipe == "sys")
{
// Такая проверка является наследством обратной совместимости версий api msg.authorized === "true" || msg.authorized === true
Expand Down Expand Up @@ -1600,7 +1713,32 @@ var _cometServerApi = function(opt)
msg.data = pmsg
}
}
catch (failed) { }
catch (failed) {

msg.data = this.stripslashes(msg.data);
try
{
//if(this.LogLevel) console.log(["msg", msg.data, "web_id:"+web_id]);
var pmsg = JSON.parse(msg.data);
if(pmsg !== undefined)
{
msg.data = pmsg
}
}
catch (failed)
{
try
{
//if(this.LogLevel) console.log(["msg", msg.data, "web_id:"+web_id]);
var pmsg = JSON.parse(msg.data.replace(/\\'/g, "'"));
if(pmsg !== undefined)
{
msg.data = pmsg
}
}
catch (failed) { }
}
}
}
}
}
Expand Down Expand Up @@ -2437,4 +2575,4 @@ var cometApi = new cometServerApi();
function CometServer()
{
return cometApi; //Object.assign({}, _cometServerApi);
}
}
19 changes: 19 additions & 0 deletions coverage/onlyJsTests.sh
@@ -0,0 +1,19 @@
#!/bin/bash

./jstestrun.sh > /tmp/last-tests.log

cat /tmp/last-tests.log | grep -A 4 "Coverage summary"

testIsOk=`cat /tmp/last-tests.log | grep '\[js-test-done-ok\]' | wc -l`

if [ "$testIsOk" == "1" ];
then
echo "Tests completed"
exit 0
else
cat /tmp/last-tests.log
echo "Tests failed"
exit -1
fi


0 comments on commit 484c4db

Please sign in to comment.