Skip to content

Commit bffd24c

Browse files
committed
First Commit
1 parent dff747c commit bffd24c

File tree

9 files changed

+382
-0
lines changed

9 files changed

+382
-0
lines changed

ErrorCodes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Sharp Error List
2+
Code | String Code | Component | Reason | Fix
3+
------------------------------------------------------------------------------------------------------------------------------------
4+
0x558d70 | ERR_NO_INTERNET_ACCESS | Updater | No internet access on first run | Connect to internet and run once

SharpAbout.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Sharp Version Info</title>
5+
<script>const fs = require("fs"); const path = require("path");</script>
6+
</head>
7+
<body style="background-color: whitesmoke;">
8+
<h1>Sharp Version</h1><br/>
9+
Sharp Version: <script>document.write(fs.existsSync(path.join(__dirname, "version.txt")) ? fs.readFileSync(path.join(__dirname, "version.txt")) : "No installed version");</script><br/>
10+
Node: <script>document.write(process.versions.node);</script><br/>
11+
Chromium: <script>document.write(process.versions.chrome);</script><br/>
12+
Electron: <script>document.write(process.versions.electron);</script><br/>
13+
V8: <script>document.write(process.versions.v8);</script><br/>
14+
Platform: <script>document.write(process.platform);</script><br/>
15+
Arch: <script>document.write(process.arch);</script><br/>
16+
</body>
17+
</html>

SharpBrowser.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Sharp Web Browser</title>
5+
<script>
6+
document.addEventListener("DOMContentLoaded", function(){
7+
document.getElementById("url").onkeypress = function(e){
8+
if(e.which == 13){
9+
window.location.href = e.target.value;
10+
}
11+
};
12+
});
13+
</script>
14+
</head>
15+
<body style="background-color: whitesmoke;">
16+
17+
<h1>Sharp Scratch Mod</h1>
18+
<b>Enter the URL you would like to go to below. Enter to navigate to page.<b><br/><br/>
19+
<input type="text" id="url" style="border: 1px solid black;border-radius: 5px; padding: 10px; width:90%;">
20+
21+
</body>
22+
</html>

SharpErrNoInternet.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>!Error! No Internet Access!</title>
5+
</head>
6+
<body style="background-color: whitesmoke">
7+
<h1>Error: 0x558d70 (ERR_NO_INTERNET_ACCESS)</h1>
8+
<b>Reason</b>: Internet is required on first run to download Sharp!<br/>
9+
<b>Fix</b>: Connect to the internet, run Sharp and wait for Sharp to start<br/>
10+
<pre>
11+
Sharp Offline Editor Partial Crash Log
12+
Code: 0x558d70 (ERR_NO_INTERNET_ACCESS)
13+
Cause for error: Could not resolve DNS of sharpscratchmod.cf - Most likely reason is no internet access.
14+
Component: Updater
15+
Platform: <script>document.write(process.platform);</script>
16+
Arch: <script>document.write(process.arch);</script>
17+
Node: <script>document.write(process.versions.node);</script>
18+
Electron: <script>document.write(process.versions.electron);</script>
19+
Chromium: <script>document.write(process.versions.chrome);</script>
20+
V8: <script>document.write(process.versions.v8);</script>
21+
Sharp: <script>document.write(require("fs").existsSync(require("path").join(__dirname, "version.txt")) ? require("fs").readFileSync(require("path").join(__dirname, "version.txt")) : "No version installed!")</script>
22+
</pre>
23+
</body>
24+
</html>

SharpInstallGuide.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Sharp Scratch Mod Setup Guide</title>
5+
<script>
6+
document.addEventListener("DOMContentLoaded", function(){
7+
switch(process.platform){
8+
case "win32":
9+
document.getElementById("windows").style.display = "block";
10+
break;
11+
case "darwin":
12+
document.getElementById("osx").style.display = "block";
13+
break;
14+
case "linux":
15+
document.getElementById("linux").style.display = "block";
16+
break;
17+
default:
18+
document.getElementById("other").style.display = "block";
19+
break;
20+
}
21+
document.getElementById("wait").style.display = "none";
22+
});
23+
</script>
24+
</head>
25+
<body style="background-color: whitesmoke">
26+
<h1 id="wait">Please wait...</h1>
27+
<div id="windows" style="display:none">
28+
<h1>Sharp Setup Guide</h1>
29+
<b>Guide for: Windows</b><br/>
30+
* Install Google Chrome if you don't have it. (It must be the same 64-bit or 32-bit as Sharp Scratch Mod Offline Editor)<br/>
31+
* Open Chrome and visit chrome://plugins<br/>
32+
* Select Details<br/>
33+
* Locate the location part of Adobe Flash Player and move it to <i><script>document.write(__dirname);</script></i><br/>
34+
* If no location is said then visit http://sharpscratchmod.cf/Sharp.swf to get it to download it.
35+
</div>
36+
<div id="osx" style="display:none">
37+
<h1>Sharp Setup Guide</h1>
38+
<b>Guide for: OS X</b><br/>
39+
* Install Google Chrome if you don't have it. (64-bit is required as Sharp Scratch Mod Offline Editor is 64-bit)<br/>
40+
* Open Chrome and visit chrome://plugins<br/>
41+
* Select Details<br/>
42+
* Locate the location part of Adobe Flash Player and move it to <i><script>document.write(__dirname);</script></i><br/>
43+
* If no location is said then visit http://sharpscratchmod.cf/Sharp.swf to get it to download it.
44+
</div>
45+
<div id="linux" style="display:none">
46+
<h1>Sharp Setup Guide</h1>
47+
<b>Guide for: Linux</b><br/>
48+
* Install Google Chrome if you don't have it. (It must be the same 64-bit or 32-bit as Sharp Scratch Mod Offline Editor)<br/>
49+
* Open Chrome and visit chrome://plugins<br/>
50+
* Select Details<br/>
51+
* Locate the location part of Adobe Flash Player and move it to <i><script>document.write(__dirname)</script></i><br/>
52+
* If not location is said then visit http://sharpscratchmod.cf/Sharp.swf to get it to download it.
53+
</div>
54+
<div id="other" style="display:none">
55+
<h1>Sharp Setup Guide</h1>
56+
<b style="color:red">Invalid Platform: <script>document.write(process.platform);</script>; Supported are win32, darwin, linux!</b><br/>
57+
<b>It might still work! Follow the steps below to try!</b><br/>
58+
* Install Google Chrome if you don't have it. (It must be the same 64-bit or 32-bit as Sharp Scratch Mod Offline Editor)<br/>
59+
* Open Chrome and visit chrome://plugins<br/>
60+
* Select Details<br/>
61+
* Locate the location part of Adobe Flash Player and move it to <i><script>document.write(__dirname)</script></i><br/>
62+
* If not location is said then visit http://sharpscratchmod.cf/Sharp.swf to get it to download it.
63+
</div>
64+
</body>
65+
</html>

SharpOffline.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
const electron = require("electron");
2+
const app = electron.app;
3+
const BrowserWindow = electron.BrowserWindow;
4+
const path = require("path");
5+
const fs = require("fs");
6+
const Menu = require("electron").Menu;
7+
const MenuItem = require("electron").MenuItem;
8+
9+
let mainWindow;
10+
var pluginName;
11+
switch(process.platform){
12+
case "win32":
13+
pluginName = "pepflashplayer.dll";
14+
break;
15+
case "darwin":
16+
pluginName = "PepperFlashPlayer.plugin";
17+
break;
18+
case "linux":
19+
pluginName = "libpepflashplayer.so";
20+
break;
21+
}
22+
app.commandLine.appendSwitch("ppapi-flash-path", path.join(__dirname, pluginName));
23+
24+
function createWindow(){
25+
mainWindow = new BrowserWindow({width: 800, height: 600, webPreferences: {plugins: true}});
26+
mainWindow.loadURL(`file://${__dirname}/SharpUpdate.html`);
27+
mainWindow.on("closed", function(){
28+
mainWindow = null;
29+
});
30+
}
31+
32+
//Change prompt to execute in render process
33+
var template = [
34+
{
35+
label: "About",
36+
submenu: [
37+
{
38+
label: "Tool Menu",
39+
click: function(item, focusedWindow){
40+
if(focusedWindow) focusedWindow.loadURL(`file://${__dirname}/SharpToolMenu.html`);
41+
}
42+
},
43+
{
44+
label: "About Version",
45+
click: function(item, focusedWindow){
46+
if(focusedWindow) focusedWindow.loadURL(`file://${__dirname}/SharpAbout.html`);
47+
}
48+
}
49+
]
50+
},
51+
{
52+
label: "Developer Tools",
53+
submenu: [
54+
{
55+
label: "Toggle Developer Tools",
56+
click: function(item, focusedWindow){
57+
if(focusedWindow) focusedWindow.webContents.toggleDevTools();
58+
}
59+
},
60+
{
61+
label: "Refresh Page (Loses project!)",
62+
click: function(item, focusedWindow){
63+
if(focusedWindow) focusedWindow.webContents.executeJavaScript("window.location.reload();");
64+
}
65+
},
66+
{
67+
label: "Visit URL (Loses project!)",
68+
click: function(item, focusedWindow){
69+
if(focusedWindow) focusedWindow.loadURL(`file://${__dirname}/SharpBrowser.html`);
70+
}
71+
},
72+
{
73+
label: "Open Sharp Browser",
74+
click: function(item, focusedWindow){
75+
if(focusedWindow) focusedWindow.webContents.executeJavaScript("window.open('SharpBrowser.html', '')");
76+
}
77+
}
78+
]
79+
},
80+
{
81+
label: "Help",
82+
submenu: [
83+
{
84+
label: "Bugs and Support",
85+
click: function(item, focusedWindow){
86+
if(focusedWindow) focusedWindow.webContents.executeJavaScript("window.open('https://github.com/SharpScratchMod/SharpOfflineMacLinux/issues', '');");
87+
}
88+
},
89+
{
90+
label: "Troubleshoot",
91+
click: function(item, focusedWindow){
92+
if(focusedWindow) focusedWindow.webContents.executeJavaScript("window.open('https://github.com/SharpScratchMod/SharpOfflineMacLinux/wiki/Troubleshoot', '');");
93+
}
94+
}
95+
]
96+
}
97+
];
98+
var menu = Menu.buildFromTemplate(template);
99+
Menu.setApplicationMenu(menu);
100+
101+
app.on("ready", createWindow);
102+
app.on("window-all-closed", function(){
103+
if(process.platform !== "darwin"){
104+
app.quit();
105+
}
106+
});
107+
app.on("activate", function(){
108+
if(mainWindow === null){
109+
createWindow();
110+
}
111+
});

SharpToolMenu.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Sharp Tool Menu</title>
5+
<script>
6+
const fs = require("fs");
7+
const path = require("path");
8+
document.addEventListener("DOMContentLoaded", function(){
9+
document.getElementById("force-update").onclick = function(){
10+
fs.writeFileSync(path.join(__dirname, "version.txt"), "-1");
11+
};
12+
document.getElementById("reset").onclick = function(){
13+
fs.unlinkSync(path.join(__dirname, "version.txt"));
14+
fs.unlinkSync(path.join(__dirname, "Sharp.swf"));
15+
};
16+
});
17+
</script>
18+
</head>
19+
<body style="background-color: whitesmoke;">
20+
<h1>Sharp Tool Menu</h1>
21+
<button id="force-update">Force Update</button>
22+
<button id="reset">Reset</button>
23+
</body>
24+
</html>

SharpUpdate.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Sharp Scratch Mod</title>
5+
<script>
6+
document.addEventListener("DOMContentLoaded", function(){
7+
var BrowserWindow = require("electron").remote.BrowserWindow;
8+
var http = require("http");
9+
var fs = require("fs");
10+
var path = require("path");
11+
var pluginName;
12+
switch(process.platform){
13+
case "win32":
14+
pluginName = "pepflashplayer.dll";
15+
break;
16+
case "darwin":
17+
pluginName = "PepperFlashPlayer.plugin";
18+
break;
19+
case "linux":
20+
pluginName = "libpepflashplayer.so";
21+
break;
22+
}
23+
if(!fs.existsSync(path.join(__dirname, pluginName))){
24+
//alert("Please visit chrome://version in Google Chrome and enable Details and copy the path for Adobe Flash Player to " + __dirname);
25+
//window.close();
26+
window.location.href = path.join(__dirname, "SharpInstallGuide.html");
27+
}
28+
require("dns").lookup("sharpscratchmod.cf", function(err){
29+
if(err){
30+
if(fs.existsSync("Sharp.swf")){
31+
window.location.href = "Sharp.swf";
32+
}else{
33+
window.location.href = "SharpErrNoInternet.html";
34+
}
35+
}else{
36+
var cver;
37+
http.get("http://sharpscratchmod.cf/SharpVersion.txt", function(res){
38+
var body = '';
39+
res.on("data", function(chunk){
40+
body += chunk;
41+
});
42+
res.on("end", function(){
43+
cver = body;
44+
var ver = fs.existsSync(path.join(__dirname, "version.txt")) ? fs.readFileSync(path.join(__dirname, "version.txt")) : "0";
45+
if(cver != ver){
46+
document.getElementById("updates").innerHTML = "Sharp is downloading updates";
47+
var pos = 0;
48+
var str = "Sharp is downloading updates";
49+
var file = fs.createWriteStream(path.join(__dirname, "Sharp.swf"));
50+
fs.writeFileSync(path.join(__dirname, "version.txt"), cver);
51+
http.get("http://sharpscratchmod.cf/Sharp.swf", function(res){
52+
res.pipe(file);
53+
res.on("data", function(c){
54+
if(pos == 0){
55+
document.getElementById("updates").innerHTML = str;
56+
pos = 1;
57+
}else if(pos == 1){
58+
document.getElementById("updates").innerHTML = str + ".";
59+
pos = 2;
60+
}else if(pos == 2){
61+
document.getElementById("updates").innerHTML = str + "..";
62+
pos = 3;
63+
}else if(pos == 3){
64+
document.getElementById("updates").innerHTML = str + "...";
65+
pos = 0;
66+
}
67+
});
68+
res.on("end", function(){
69+
window.location.href = "Sharp.swf";
70+
});
71+
});
72+
}else{
73+
window.location.href = "Sharp.swf";
74+
}
75+
});
76+
});
77+
}
78+
});
79+
});
80+
</script>
81+
</head>
82+
<body style="background-color: whitesmoke;">
83+
<center>
84+
<h1 id="updates">Sharp is checking for updates...</h1>
85+
</center>
86+
</body>
87+
</html>

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "sharpoffline",
3+
"version": "1.0.0",
4+
"description": "Sharp Offline Editor for Mac OS X and Linux.",
5+
"main": "SharpOffline.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/SharpScratchMod/SharpOfflineMacLinux.git"
12+
},
13+
"keywords": [
14+
"Sharp",
15+
"Offline",
16+
"Mac",
17+
"Linux",
18+
"OSX",
19+
"MacOSX",
20+
"MacOS"
21+
],
22+
"author": "Sharp Scratch Mod Team",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/SharpScratchMod/SharpOfflineMacLinux/issues"
26+
},
27+
"homepage": "https://github.com/SharpScratchMod/SharpOfflineMacLinux#readme"
28+
}

0 commit comments

Comments
 (0)