Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit 42f457e

Browse files
author
Maximilian Schmidt
authored
Merge pull request #12 from MCStreetguy/dev
FIX: jQuery Bug
2 parents 7685bf3 + a632574 commit 42f457e

File tree

9 files changed

+31
-26
lines changed

9 files changed

+31
-26
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ They are not associated with this license. This applies to imported sources,
3434
to contents that are part of the source code and to contents that are not
3535
authored by the copyright holder. External content that is part of the source
3636
code is labeled by a comment containing the source's name and uri. Contents that
37-
are not authored by the copyright holder are located within the `externals/` folder.
37+
are not authored by the copyright holder are located within the `lib/externals/` folder.

lib/externals/jquery-3.2.1.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/icon-helper.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/snippet-injector.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ export default {
9696
if(window.localStorage.getItem('snippet-injector-debug') === 'true') {
9797
if(window.localStorage.getItem('snippet-injector-debug-time') === 'true') {
9898
window.localStorage.setItem('snippet-injector-debug-time',false.toString());
99-
atom.notifications.addInfo('Disabled timings debug.', {detail: 'Reload the window (with Ctrl+Shift+F5 e.g.) to let the changes take effect.'});
99+
atom.notifications.addInfo('Disabled timings debug.', {detail: 'Reload the window (Ctrl+Shift+F5) to let the changes take effect.'});
100100
} else {
101101
window.localStorage.setItem('snippet-injector-debug-time',true.toString());
102-
atom.notifications.addInfo('Enabled timings debug.', {detail: 'Reload the window (with Ctrl+Shift+F5 e.g.) to let the changes take effect.'});
102+
atom.notifications.addInfo('Enabled timings debug.', {detail: 'Reload the window (Ctrl+Shift+F5) to let the changes take effect.'});
103103
}
104104
} else {
105105
atom.notifications.addWarning('Cannot toggle debug mode since it is disabled.', null);
@@ -110,10 +110,10 @@ export default {
110110
if(window.localStorage.getItem('snippet-injector-debug') === 'true') {
111111
if(window.localStorage.getItem('snippet-injector-debug-objl') === 'true') {
112112
window.localStorage.setItem('snippet-injector-debug-objl',false.toString());
113-
atom.notifications.addInfo('Disabled object debug.', {detail: 'Reload the window (with Ctrl+Shift+F5 e.g.) to let the changes take effect.'});
113+
atom.notifications.addInfo('Disabled object debug.', {detail: 'Reload the window (Ctrl+Shift+F5) to let the changes take effect.'});
114114
} else {
115115
window.localStorage.setItem('snippet-injector-debug-objl',true.toString());
116-
atom.notifications.addInfo('Enabled object debug.', {detail: 'Reload the window (with Ctrl+Shift+F5 e.g.) to let the changes take effect.'});
116+
atom.notifications.addInfo('Enabled object debug.', {detail: 'Reload the window (Ctrl+Shift+F5) to let the changes take effect.'});
117117
}
118118
} else {
119119
atom.notifications.addWarning('Cannot toggle debug mode since it is disabled.', null);
@@ -127,14 +127,6 @@ export default {
127127
var selection = atom.workspace.getActiveTextEditor().getSelectedText();
128128
var grammar = atom.workspace.getActiveTextEditor().getGrammar().name;
129129
var storage = this.storage;
130-
var uid = Util.generateUID({
131-
unique: true,
132-
tester: storage.testFile,
133-
timeout: 100,
134-
length: 20,
135-
prefix: 'sn',
136-
insertstring: 'SNIPPET'
137-
});
138130
const inputPrompt = Util.promptUser({
139131
placeholder: 'Enter snippet title',
140132
btnconfirm: 'Save snippet',
@@ -143,10 +135,9 @@ export default {
143135
if(Util.isset(text,'string')) {
144136
var result = storage.store(new Snippet({
145137
title: text,
146-
tags: new Array(),
147138
content: selection,
148139
lang: grammar,
149-
uid: uid
140+
version: Util.getPackageVersion()
150141
}));
151142
if(result) {
152143
atom.notifications.addSuccess('Snippet "'+text+'" was saved successfully.', null);

lib/snippet.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
'use babel';
22

33
import Util from './util.js';
4+
import Storage from './storage.js';
45
const os = require('os');
56

7+
const lastUpdate = '1.1.8';
8+
69
export default class Snippet {
710

811
content = '';
912
title = '';
1013
tags = new Array();
1114
lang = '';
12-
uid = Date.now().toString();
15+
uid = Util.generateUID({
16+
unique: true,
17+
tester: Storage.testFile,
18+
timeout: 100,
19+
length: 20,
20+
prefix: 'sn',
21+
insertstring: 'SNIPPET'
22+
});
1323
version = undefined;
1424
author = os.userInfo().username;
1525

@@ -111,4 +121,8 @@ export default class Snippet {
111121
setAuthor(newauthor) {
112122
this.author = newauthor;
113123
}
124+
125+
static getLastUpdate() {
126+
return lastUpdate;
127+
}
114128
}

lib/storage.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Snippet from './snippet.js';
55
import Util from './util.js';
66
const fs = require('fs');
77

8-
const lastSnippetUpdate = '1.1.8';
9-
108
export default class Storage {
119

1210
dir = '';
@@ -115,7 +113,7 @@ export default class Storage {
115113
}
116114
}
117115

118-
testFile(uid) {
116+
static testFile(uid) {
119117
if(this.dir === '') {
120118
throw new TypeError('Storage directory has not been initialized.');
121119
} else {
@@ -175,8 +173,8 @@ export default class Storage {
175173
_this.backup(current);
176174

177175
var snippet = new Snippet(JSON.parse(_this.retrieveFile(current)));
178-
var res = Util.compareVersions(lastSnippetUpdate,snippet.getVersion());
179-
if(res === lastSnippetUpdate || res === undefined) {
176+
var res = Util.compareVersions(Snippet.getLastUpdate(),snippet.getVersion());
177+
if(res === Snippet.getLastUpdate() || res === undefined) {
180178
snippet.setVersion(Util.getPackageVersion());
181179
snippet.setUID(Util.generateUID({
182180
unique: true,

lib/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TextEditor } from 'atom';
44
import IconHelper from './icon-helper.js';
55
const fs = require('fs');
66
const path = require('path');
7-
const $ = require('jquery');
7+
const $ = require('./externals/jquery-3.2.1.min.js');
88

99
export default class Util {
1010

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@
99
"engines": {
1010
"atom": ">=1.0.0 <2.0.0"
1111
},
12-
"dependencies": {
13-
"jquery": "^3.2.1"
14-
}
12+
"dependencies": {}
1513
}

0 commit comments

Comments
 (0)