Skip to content

Commit f41c30e

Browse files
Wrong Caché JSON encoding fixes #20
1 parent 76a65de commit f41c30e

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

import.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
:: This batch script makes the Caché application deployment much faster by building and importing
2+
:: the project. Replace the path below to your Caché installation and build & import application to
3+
:: Caché using only one command.
4+
5+
:: CHANGE THIS PATH TO YOUR CACHÉ INSTALLATION PATH ON WINDOWS
6+
set CACHE_DIR=C:\Program Files\InterSystems\Ensemble
7+
:: NAMESPACE IMPORTING TO
8+
set NAMESPACE=USER
9+
10+
npm run gulp & echo w "OK:"_$system.OBJ.ImportDir("%~dp0build\Cache",,"ck") halt | "%CACHE_DIR%\bin\cache.exe" -s "%CACHE_DIR%\mgr" -U %NAMESPACE%

package.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
{
22
"name": "CacheClassExplorer",
3-
"version": "1.20.0",
3+
"version": "1.20.1",
44
"description": "Class Explorer for InterSystems Caché",
55
"directories": { "test": "test" },
66
"dependencies": {},
7-
"devDependencies": { "autoprefixer-core": "^5.1.11", "express": "^5.0.0-alpha.1",
8-
"gulp": "^3.9.0", "gulp-add-src": "^0.2.0", "gulp-clean": "^0.3.1", "gulp-concat": "^2.4.1",
9-
"gulp-header": "^1.2.2", "gulp-html-replace": "^1.4.1", "gulp-minify-css": "^0.3.11",
10-
"gulp-postcss": "^5.1.3", "gulp-rename": "^1.2.0", "gulp-replace": "^0.5.3",
11-
"gulp-strip-comments": "^1.0.1", "gulp-uglify": "^1.2.0", "gulp-wrap": "^0.5.0",
12-
"gulp-zip": "^2.0.2" },
7+
"devDependencies": {
8+
"autoprefixer-core": "^6.0.1",
9+
"gulp": "^3.9.0",
10+
"gulp-add-src": "^0.2.0",
11+
"gulp-clean": "^0.3.1",
12+
"gulp-concat": "^2.6.1",
13+
"gulp-header": "^1.8.8",
14+
"gulp-html-replace": "^1.6.2",
15+
"gulp-minify-css": "^1.2.4",
16+
"gulp-postcss": "^6.4.0",
17+
"gulp-rename": "^1.2.0",
18+
"gulp-replace": "^0.5.3",
19+
"gulp-strip-comments": "^2.4.5",
20+
"gulp-uglify": "^2.1.2",
21+
"gulp-wrap": "^0.13.0",
22+
"gulp-zip": "^4.0.0"
23+
},
1324
"scripts": { "gulp": "gulp" },
1425
"repository": { "type": "git", "url": "https://github.com/ZitRos/CacheUMLExplorer" },
1526
"keywords": [ "UMLExplorer", "Caché", "UML", "diagram" ],

web/js/Lib.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@ Lib.prototype.load = function (url, data, callback) {
1616

1717
xhr.onreadystatechange = function () {
1818
if (xhr.readyState === 4 && xhr.status === 200) {
19+
var res = {};
1920
try {
20-
return callback(null, JSON.parse(xhr.responseText) || {});
21+
res = JSON.parse(xhr.responseText);
22+
} catch (e) {
23+
var text = xhr.responseText.replace(/\\x([0-9a-fA-F]{2})/g, "\\u00$1");
24+
try {
25+
res = JSON.parse(text);
26+
} catch (e) {
27+
try {
28+
res = eval(text);
29+
} catch (e) {
30+
console.error("Unable to parse server response:", text);
31+
}
32+
}
33+
}
34+
try {
35+
return callback(null, res);
2136
} catch (e) {
2237
console.error(e, url, "Unable to parse:", { data: xhr.responseText });
2338
return {};
@@ -275,7 +290,7 @@ Lib.prototype.highlightXML = function (code) {
275290

276291
Lib.prototype.getSelection = function () {
277292
var html = "";
278-
if (typeof window.getSelection != "undefined") {
293+
if (typeof window.getSelection !== "undefined") {
279294
var sel = window.getSelection();
280295
if (sel.rangeCount) {
281296
var container = document.createElement("div");
@@ -284,8 +299,8 @@ Lib.prototype.getSelection = function () {
284299
}
285300
html = container.innerHTML;
286301
}
287-
} else if (typeof document.selection != "undefined") {
288-
if (document.selection.type == "Text") {
302+
} else if (typeof document.selection !== "undefined") {
303+
if (document.selection.type === "Text") {
289304
html = document.selection.createRange().htmlText;
290305
}
291306
}

0 commit comments

Comments
 (0)