1j01 / 98

💿 Web-based Windows 98 desktop recreation █████▓█▓▓▒▓▒▒░▒░░░🗕︎🗗︎🗙︎
https://98.js.org
1.17k stars 187 forks source link

Structure for new program with params? #1

Closed kirkins closed 6 years ago

kirkins commented 7 years ago

I have a question about your recommendation for coding style if I want to create a new application for your windows 98 program.

I want to create a notepad function like this:

new $DesktopIcon("Notepad", ("notepad"), NotepadFile, "shortcut");

Lets say the third param NotepadFile is a function like this:

function NotepadFile(file, title){
  var $win = new $IframeWindow("notepad/index.html?file="+file, "Notepad");
  $win.title(title);
  return new Task($win);
}

How can I re-write the $DesktopIcon structure to keep your coding style but allow programs to have params passed in like this:

new $DesktopIcon("Notepad", ("notepad"), NotepadFile("fileName", "title"), "shortcut");
1j01 commented 7 years ago

Yeah, so I've pretty much just made it handle the current usage and fleshed it out as needed. I'd accept a PR with params as you've done, preferably along with usage, but Windows shortcuts don't specify the executable explicitly when it's a shortcut to a file, so I'd probably replace the exe parameter with a file_name parameter and add some basic file extension handling, with a hard-coded map of extensions to functions that take a file_name. I'd also do a whole bunch of other refactoring. This is some old code.

kirkins commented 7 years ago

Thanks I'll try to make the change to use file type as you suggest!

kirkins commented 6 years ago

I will close this. The website is down for me https://98.js.org/

1j01 commented 6 years ago

The website hasn't actually been up yet at https://98.js.org/, but hopefully it will be soon 🙂