Skip to content

Commit 6302748

Browse files
committed
remember previous URL
1 parent c5b8b31 commit 6302748

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Contents/Sketch/script.cocoascript

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var onRun = function(context) {
22
var doc = context.document;
33
var sharedStyles=doc.documentData().layerTextStyles();
4-
var queryString;
4+
var dict = NSThread.mainThread().threadDictionary();
55

66
showOptions();
77
removeAllStyles();
88

9-
var styles = getSheetsu();
9+
var styles = getSheetsu(dict['syncSource']);
1010

1111
for(var i=0; i<styles.length; i++) {
1212
createStyle(styles[i]);
@@ -21,10 +21,10 @@ var onRun = function(context) {
2121
}
2222
}
2323

24-
function getSheetsu() {
24+
function getSheetsu(queryURL) {
2525
var request = NSMutableURLRequest.new();
2626
[request setHTTPMethod:@"GET"];
27-
[request setURL:[NSURL URLWithString:queryString]];
27+
[request setURL:[NSURL URLWithString:queryURL]];
2828

2929
var error = NSError.new();
3030
var responseCode = null;
@@ -47,12 +47,12 @@ var onRun = function(context) {
4747
informativeTextWithFormat:"Enter the URL where your styles live."];
4848

4949
var input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)];
50-
input.setStringValue("https://sheetsu.com/apis/a49fa7c8");
50+
input.setStringValue(dict['syncSource'] || "https://sheetsu.com/apis/a49fa7c8");
5151
input.autorelease();
5252
alert.setAccessoryView(input);
5353
var button = alert.runModal();
5454
input.validateEditing();
55-
queryString = input.stringValue();
55+
dict['syncSource'] = input.stringValue();
5656
}
5757

5858
function createStyle(style) {

0 commit comments

Comments
 (0)