mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-21 16:55:01 -05:00
Extension: Paster Update
This commit is contained in:
parent
75ef62302d
commit
b09880a116
@ -95,8 +95,6 @@ end;
|
|||||||
|
|
||||||
function PasteIt(out Data: string; HOST: string): boolean;
|
function PasteIt(out Data: string; HOST: string): boolean;
|
||||||
begin
|
begin
|
||||||
if (HOST = '') then
|
|
||||||
HOST := HOSTDef;
|
|
||||||
if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Upload this script to ' + HOST + '?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Upload this script to ' + HOST + '?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
||||||
begin
|
begin
|
||||||
Data := '{"language": "delphi", "code": "' + EncodeString(ScriptText) + '", "private": ' + Lowercase(BoolToStr(Private_MenuItem.Checked)) + '}';
|
Data := '{"language": "delphi", "code": "' + EncodeString(ScriptText) + '", "private": ' + Lowercase(BoolToStr(Private_MenuItem.Checked)) + '}';
|
||||||
@ -114,6 +112,8 @@ procedure Paste(Host: string);
|
|||||||
var
|
var
|
||||||
Data: string;
|
Data: string;
|
||||||
begin
|
begin
|
||||||
|
if (HOST = '') then
|
||||||
|
HOST := HOSTDef;
|
||||||
if PasteIt(Data, Host) then
|
if PasteIt(Data, Host) then
|
||||||
begin
|
begin
|
||||||
if (Browser_MenuItem.Checked) then
|
if (Browser_MenuItem.Checked) then
|
||||||
@ -157,31 +157,33 @@ procedure OnClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
I, K: integer;
|
I, K: integer;
|
||||||
begin;
|
begin;
|
||||||
|
{$IFDEF DEV}
|
||||||
|
if (Sender is TMenuItem) then
|
||||||
|
WriteLn('Sender is '#39 + TMenuItem(Sender).Name + #39'.'); //(Sender as TMenuItem).Name
|
||||||
|
{$ENDIF}
|
||||||
case Sender of
|
case Sender of
|
||||||
Paster_MenuItem: Paste('');
|
Paster_MenuItem: Paste('');
|
||||||
GetPaste_MenuItem: GetPaste('');
|
GetPaste_MenuItem: GetPaste('');
|
||||||
Private_MenuItem: begin
|
Private_MenuItem: begin
|
||||||
Private_MenuItem.Checked := (not (Private_MenuItem.Checked));
|
Private_MenuItem.Checked := (not (Private_MenuItem.Checked));
|
||||||
Settings.setKeyValue('Private', Lowercase(BoolToStr(Private_MenuItem.Checked)));
|
Settings.setKeyValue('Private', Lowercase(BoolToStr(Private_MenuItem.Checked)));
|
||||||
{$IFDEF DEV}WriteLn('Private = ' + Lowercase(BoolToStr(Private_MenuItem.Checked)));{$ENDIF}
|
{$IFDEF DEV}WriteLn('Private = ' + Lowercase(BoolToStr(Private_MenuItem.Checked)));{$ENDIF}
|
||||||
end;
|
end;
|
||||||
Browser_MenuItem: begin
|
Browser_MenuItem: begin
|
||||||
Browser_MenuItem.Checked := (not (Browser_MenuItem.Checked));
|
Browser_MenuItem.Checked := (not (Browser_MenuItem.Checked));
|
||||||
Settings.setKeyValue('OpenBrowser', Lowercase(BoolToStr(Browser_MenuItem.Checked)));
|
Settings.setKeyValue('OpenBrowser', Lowercase(BoolToStr(Browser_MenuItem.Checked)));
|
||||||
{$IFDEF DEV}WriteLn('OpenBrowser = ' + Lowercase(BoolToStr(Browser_MenuItem.Checked)));{$ENDIF}
|
{$IFDEF DEV}WriteLn('OpenBrowser = ' + Lowercase(BoolToStr(Browser_MenuItem.Checked)));{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
for I := 1 to 5 do
|
for I := 1 to 5 do
|
||||||
for K := 1 to 4 do
|
for K := 1 to 4 do
|
||||||
if (Sender = AltHost_MenuItems[I][K]) then
|
if (Sender = AltHost_MenuItems[I][K]) then
|
||||||
begin
|
begin
|
||||||
{$IFDEF DEV}WriteLn('Sender = ' + IntToStr(I) + ', ' + IntToStr(K));{$ENDIF}
|
case K of
|
||||||
if (K = 4) then
|
4: UpdateHost(I);
|
||||||
UpdateHost(I);
|
2: GetPaste(Settings.getKeyValue('Host' + IntToStr(I)));
|
||||||
if (K = 2) then
|
1: Paste(Settings.getKeyValue('Host' + IntToStr(I)));
|
||||||
GetPaste(Settings.getKeyValue('Host' + IntToStr(I)));
|
end;
|
||||||
if (K = 1) then
|
|
||||||
Paste(Settings.getKeyValue('Host' + IntToStr(I)));
|
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -226,6 +228,7 @@ begin;
|
|||||||
Paster_MenuItem := TMenuItem.Create(Paster_Menu);
|
Paster_MenuItem := TMenuItem.Create(Paster_Menu);
|
||||||
with Paster_MenuItem do
|
with Paster_MenuItem do
|
||||||
begin
|
begin
|
||||||
|
Name := 'Default_Paste';
|
||||||
Caption := 'Paste It!';
|
Caption := 'Paste It!';
|
||||||
OnClick := @OnClick;
|
OnClick := @OnClick;
|
||||||
end;
|
end;
|
||||||
@ -234,6 +237,7 @@ begin;
|
|||||||
GetPaste_MenuItem := TMenuItem.Create(Paster_Menu);
|
GetPaste_MenuItem := TMenuItem.Create(Paster_Menu);
|
||||||
with GetPaste_MenuItem do
|
with GetPaste_MenuItem do
|
||||||
begin
|
begin
|
||||||
|
Name := 'Default_GetPaste';
|
||||||
Caption := 'Get Paste!';
|
Caption := 'Get Paste!';
|
||||||
OnClick := @OnClick;
|
OnClick := @OnClick;
|
||||||
end;
|
end;
|
||||||
@ -250,6 +254,7 @@ begin;
|
|||||||
Private_MenuItem := TMenuItem.Create(Paster_Menu);
|
Private_MenuItem := TMenuItem.Create(Paster_Menu);
|
||||||
with Private_MenuItem do
|
with Private_MenuItem do
|
||||||
begin
|
begin
|
||||||
|
Name := 'Private_Setting';
|
||||||
Caption := 'Private';
|
Caption := 'Private';
|
||||||
OnClick := @OnClick;
|
OnClick := @OnClick;
|
||||||
Checked := (Lowercase(Settings.getKeyValueDef('Private', 'true')) = 'true');
|
Checked := (Lowercase(Settings.getKeyValueDef('Private', 'true')) = 'true');
|
||||||
@ -259,6 +264,7 @@ begin;
|
|||||||
Browser_MenuItem := TMenuItem.Create(Paster_Menu);
|
Browser_MenuItem := TMenuItem.Create(Paster_Menu);
|
||||||
with Browser_MenuItem do
|
with Browser_MenuItem do
|
||||||
begin
|
begin
|
||||||
|
Name := 'Browser_Setting';
|
||||||
Caption := 'Open in Browser';
|
Caption := 'Open in Browser';
|
||||||
OnClick := @OnClick;
|
OnClick := @OnClick;
|
||||||
Checked := (Lowercase(Settings.getKeyValueDef('OpenBrowser', 'true')) = 'true');
|
Checked := (Lowercase(Settings.getKeyValueDef('OpenBrowser', 'true')) = 'true');
|
||||||
@ -281,10 +287,19 @@ begin;
|
|||||||
begin
|
begin
|
||||||
AltHost_MenuItems[I][K] := TMenuItem.Create(AltHost_Menus[I]);
|
AltHost_MenuItems[I][K] := TMenuItem.Create(AltHost_Menus[I]);
|
||||||
case K of
|
case K of
|
||||||
1: AltHost_MenuItems[I][1].Caption := 'Paste It!';
|
1: begin
|
||||||
2: AltHost_MenuItems[I][2].Caption := 'Get Paste!';
|
AltHost_MenuItems[I][1].Name := 'Host' + IntToStr(I) + '_Paste';
|
||||||
|
AltHost_MenuItems[I][1].Caption := 'Paste It!';
|
||||||
|
end;
|
||||||
|
2: begin
|
||||||
|
AltHost_MenuItems[I][2].Name := 'Host' + IntToStr(I) + '_GetPaste';
|
||||||
|
AltHost_MenuItems[I][2].Caption := 'Get Paste!';
|
||||||
|
end;
|
||||||
3: AltHost_MenuItems[I][3].Caption := '-';
|
3: AltHost_MenuItems[I][3].Caption := '-';
|
||||||
4: AltHost_MenuItems[I][4].Caption := 'Update Host';
|
4: begin
|
||||||
|
AltHost_MenuItems[I][4].Name := 'Host' + IntToStr(I) + '_Update';
|
||||||
|
AltHost_MenuItems[I][4].Caption := 'Update Host';
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
AltHost_MenuItems[I][K].OnClick := @OnClick;
|
AltHost_MenuItems[I][K].OnClick := @OnClick;
|
||||||
if ((not ((K = 3) or (K = 4))) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then
|
if ((not ((K = 3) or (K = 4))) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then
|
||||||
|
Loading…
Reference in New Issue
Block a user