-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add new JSMinify Instant Answer #3352
Add new JSMinify Instant Answer #3352
Conversation
Js MinifyDescription: An Interactive JavaScript Minifier Tool Example Query: [js minify](https://beta.duckduckgo.com/?q=js minify), [js minifier](https://beta.duckduckgo.com/?q=js minifier) Tab Name: Answer Source: These are the important fields from the IA page. Please check these for errors or missing information and update the IA page This is an automated message which will be updated as changes are made to the IA page |
zci answer_type => 'jsminify'; | ||
zci is_cached => 1; | ||
|
||
triggers any => 'js minify', 'js minifier'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sahildua2305 I think we'd also want this to trigger for queries like "javascript minify, javascript minifier, minify js, minify javascript"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely! This is just the beginning. I have added these trigger words for testing. I'll add more. Thanks for suggesting these words. 😄
@sahildua2305 Thanks for working on this! Please let me know if you need any help 😄 |
@MariagraziaAlastra Actually I need help in getting started with this. With this initial setup, I am not able to show anything on search page. The IA gets triggered but doesn't show anything. Not even an IA tab. Can you please look into this? I may be missing something naive. |
@sahildua2305 It actually triggers for me: |
Weird! I'll check again. Thanks a lot. |
@MariagraziaAlastra I have pushed a working interactive js minifier (with very basic UI) and it looks like this - Please deploy this on Beta. 😄 |
return; | ||
|
||
// set the flag to true so it doesn't get run again | ||
shown = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shown
logic seems like it is indicative of a different, underlying problem... does onShow
get called multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onShow
gets called every time the Answer
tab is shown.
For example, if user searches for js minify
by default Answer
tab will be opened. If user clicks on Web
tab and then comes back to Answer
tab, onShow
will be called again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is done in other javascript, but it just seems like something that should be built-in at a lower level. Carry on!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! 👍
@sahildua2305 Hey, nice job here, thanks! I tested it on DuckPAN in the meantime and it works really well. As discussed on Slack, why don't you make the tab name be "Minifier" instead? Maybe "JavaScript Minifier", even. |
@MariagraziaAlastra Thanks 😇 I have changed the tab name to "Minifier" so that even CSS minifier can come under the same name. However it's not showing up as Also, @moollaza the CSS minifier doesn't need to be different. I can change this IA's name to |
Yeah, disabling the button until the library is loaded sounds like a good idea. Thanks @sahildua2305! |
@MariagraziaAlastra please deploy this on beta so that we can test it. I have made the library load on change in textarea contents. I have also disabled the button till the time library is loaded. |
$minifyButton.css('cursor', 'default'); | ||
|
||
// Add event handler for change in input of textarea | ||
$input.on('input', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sahildua2305 maybe try on keyup instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid keyup
won't be triggered if user pastes the code using context menu. input
will be triggered whenever the input changes, in any way. @MariagraziaAlastra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cool, I was worried about IE9, but turns out this has basic support there, except for deleting, pressing backspace and cutting, and I think we don't care about either of those 😄
Hey @sahildua2305 it's deployed again! It works, but for some reason the minified code shows underneath the original code, instead of showing on the right: I'm using Firefox 47, 1920 × 1080 screen resolution |
@MariagraziaAlastra this is weird! It works for me. at a lower resolution. Can you please check the dimensions of Edit: I just tested on 1920 x 1080 resolution using the emulator. It shows well on the side for me. 😕 Edit 2: I figured out what's causing problem. I'll fix this one right now. Edit 3: Fixed! Please test it. 😄 |
@sahildua2305 Thanks, deployed again! Looks good on my laptop, let me just test it on my desktop in a few hours, before the IAs release. |
@MariagraziaAlastra let me know how it goes 😄 |
@sahildua2305 It's ready! Merging now... |
@sahildua2305 this is now merged! It should be live on DuckDuckGo within one week (or during the next release) and we'll be sure to notify you when it happens. After your Instant Answer goes live for the World to use, you will be able to see traffic information about your IA as well as receive feedback directly from users. Please refer to the maintenance guide and docs to keep up with potential changes to your Instant Answer. Thank you again for your help! |
@@ -0,0 +1,8 @@ | |||
<h5>Minify JavaScript Code on the go!</h5> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a title
property from data
-- don't need the content
template to render this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the text to "JavaScript Minifier"
What does your Pull Request do (check all that apply)?
Choose the most relevant items and use the following title template to name
your Pull Request.
New {Cheat Sheet Name} Cheat Sheet
New JS Minify Instant Answer
{IA Name}: Fix {Issue number or one-line description}
{IA Name}: {Description of Improvements}
{GoodieRole/Templates/Tests/Docs}: {Short Description}
Description of changes
Developing an interactive JS Minifier using this library. Work in progress
People to notify (@mention interested parties)
@moollaza @MariagraziaAlastra
Instant Answer Page: https://duck.co/ia/view/js_minify