Skip to content

Commit

Permalink
Wrong Caché JSON encoding fixes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Apr 27, 2017
1 parent 76a65de commit f41c30e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
10 changes: 10 additions & 0 deletions import.bat
@@ -0,0 +1,10 @@
:: This batch script makes the Caché application deployment much faster by building and importing
:: the project. Replace the path below to your Caché installation and build & import application to
:: Caché using only one command.

:: CHANGE THIS PATH TO YOUR CACHÉ INSTALLATION PATH ON WINDOWS
set CACHE_DIR=C:\Program Files\InterSystems\Ensemble
:: NAMESPACE IMPORTING TO
set NAMESPACE=USER

npm run gulp & echo w "OK:"_$system.OBJ.ImportDir("%~dp0build\Cache",,"ck") halt | "%CACHE_DIR%\bin\cache.exe" -s "%CACHE_DIR%\mgr" -U %NAMESPACE%
25 changes: 18 additions & 7 deletions package.json
@@ -1,15 +1,26 @@
{
"name": "CacheClassExplorer",
"version": "1.20.0",
"version": "1.20.1",
"description": "Class Explorer for InterSystems Caché",
"directories": { "test": "test" },
"dependencies": {},
"devDependencies": { "autoprefixer-core": "^5.1.11", "express": "^5.0.0-alpha.1",
"gulp": "^3.9.0", "gulp-add-src": "^0.2.0", "gulp-clean": "^0.3.1", "gulp-concat": "^2.4.1",
"gulp-header": "^1.2.2", "gulp-html-replace": "^1.4.1", "gulp-minify-css": "^0.3.11",
"gulp-postcss": "^5.1.3", "gulp-rename": "^1.2.0", "gulp-replace": "^0.5.3",
"gulp-strip-comments": "^1.0.1", "gulp-uglify": "^1.2.0", "gulp-wrap": "^0.5.0",
"gulp-zip": "^2.0.2" },
"devDependencies": {
"autoprefixer-core": "^6.0.1",
"gulp": "^3.9.0",
"gulp-add-src": "^0.2.0",
"gulp-clean": "^0.3.1",
"gulp-concat": "^2.6.1",
"gulp-header": "^1.8.8",
"gulp-html-replace": "^1.6.2",
"gulp-minify-css": "^1.2.4",
"gulp-postcss": "^6.4.0",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.5.3",
"gulp-strip-comments": "^2.4.5",
"gulp-uglify": "^2.1.2",
"gulp-wrap": "^0.13.0",
"gulp-zip": "^4.0.0"
},
"scripts": { "gulp": "gulp" },
"repository": { "type": "git", "url": "https://github.com/ZitRos/CacheUMLExplorer" },
"keywords": [ "UMLExplorer", "Caché", "UML", "diagram" ],
Expand Down
23 changes: 19 additions & 4 deletions web/js/Lib.js
Expand Up @@ -16,8 +16,23 @@ Lib.prototype.load = function (url, data, callback) {

xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var res = {};
try {
return callback(null, JSON.parse(xhr.responseText) || {});
res = JSON.parse(xhr.responseText);
} catch (e) {
var text = xhr.responseText.replace(/\\x([0-9a-fA-F]{2})/g, "\\u00$1");
try {
res = JSON.parse(text);
} catch (e) {
try {
res = eval(text);
} catch (e) {
console.error("Unable to parse server response:", text);
}
}
}
try {
return callback(null, res);
} catch (e) {
console.error(e, url, "Unable to parse:", { data: xhr.responseText });
return {};
Expand Down Expand Up @@ -275,7 +290,7 @@ Lib.prototype.highlightXML = function (code) {

Lib.prototype.getSelection = function () {
var html = "";
if (typeof window.getSelection != "undefined") {
if (typeof window.getSelection !== "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
Expand All @@ -284,8 +299,8 @@ Lib.prototype.getSelection = function () {
}
html = container.innerHTML;
}
} else if (typeof document.selection != "undefined") {
if (document.selection.type == "Text") {
} else if (typeof document.selection !== "undefined") {
if (document.selection.type === "Text") {
html = document.selection.createRange().htmlText;
}
}
Expand Down

0 comments on commit f41c30e

Please sign in to comment.