Вы можете столкнуться с ситуацией, когда он ожидает завершения клипа, прежде чем отвечать на любые новые щелчки.
Если это так, вставьте этот код в начале вашей функции, чтобы сбросить клип каждый раз, когда по нему щелкают:
audio.currentTime = 0; // On each click, rewind clip to start
Это будет выглядеть примерно так:
if (playPromise !== undefined) {
playPromise.then(function() {
audio.currentTime = 0; // On each click, rewind clip to start
// Automatic playback started!
}).catch(function(error) {
console.error("Sound was not played: " + error);
});
Возможно, вы захотите изменить свой код, чтобы он стал чище. Я не проверял это, но все должно работать нормально:
const soundObject = document.querySelector("#newMessageSoundObjectId");
soundObject.addEventListener("mousedown", playClip);
function playClip() {
audio.currentTime = 0; // On each click, rewind clip to start
audio.play();
} else {
console.error("Something went wrong");
What you shall do is up to your own discretion, but what you should do is implement something like Drupal.
Drupal is a CMS which is intended to be used for community sites. It's not the easiest system to understand and use, but it's very customizable.
Here's some references that you could use to get started learning about Drupal: http://www.packtpub.com/drupal/book http://drupal.org/node/367131
Whenever you have to choose between writing something for yourself and using existing software there are four key pieces of information you need to account for.
If it's not very complex, nothing else really matches your needs well, it would be cheap to create (in time and money) and you don't need it immediately then go ahead and do your own thing.
Otherwise, jump on board one of the existing open source CMS's and start contributing there. Not only will you get great feedback from experienced programmers, but you'll be part of some really awesome software.
It seems to me that these days successful community web sites are purpose-built. They don't have a lot of extraneous junk, are easy to navigate and are fun to use. StackOverflow is a good example here. For your web site to be successful your user interface will be very important.
If you want ultimate control over your user interface, then your best bet is to build it on your own. You can start with the code base of something that you like, or at least use it as a working example.
Fortunately, as long as you have reasonable programming skills to begin with the web tools that are available these days can make you very productive after a reasonable learning curve is surmounted.
At the end of the day, if you build it yourself, you'll have a web site that is very flexible, and looks exactly how you want it. If you use someone else's code, the you'll get the web site up faster and with more features, but it won't be as flexible and you'll probably have to make some concessions on look and feel.
To create something of the same quality as wordpress+mediawiki+some forum software would take many thousands of hours.
But if you're just building it for yourself to use, there are a lot of "good enoughs" you'll come across that'll save you time. So I would say... under 1,000 hours. That sounds kind of vague doesn't it? I've been programming 14 years and I'm still horrible at estimating time for projects, lol. Of course the definition of the project is pretty vague too.
To answer the question if it's worth it is really a question for yourself. If it's something you're excited about doing then it could be a great learning opportunity. About 7 years ago (before the days of Google Analytics) I wrote a fairly powerful web traffic tracking & statistics engine. It was a great learning experience for me and I don't regret doing it. Of course on the other hand, just like myself, you will be pouring a whole lot of work into something you'll have little chance of making any money from.
The how much time factor is impossible to answer, as we frankly, do not know how good you are or what resources you have. I will say though, every example you cited probably has atleast a thousand man hours behind it, and that is being very very conservative.
As to if you should develop your own? Well, that really depends what you want to accomplish. Want to be efficient in your usage of time? By all means, NO! Use a pre-existing solution. Want a case study to learn better programming? Thats a completely different scenario.
I think you'll find similar answers to Good resources for developing a Bug tracking tool?
As I said there, it really depends on your ultimate goal.
While I agree with what many have said already - why reinvent the wheel? - an answer that is going to be useful to you is going to depend on what you are trying to do.
Point #1:
If [you|your company] just need a CMS, there are numerous tools out there, free and otherwise, high quality and otherwise, why program your own?
Point #2:
If you are looking for a learning experience, looking for some something to learn [ChoiceLanguage] with, and/or just looking to learn more about wheels, there are a number of articles and there are a number of open source projects you can peek at the code to see how they work (or not as the case may be).
I've found that sometimes starting with an open source project helps me at least get a large chunk of code out of the way. I have taken a Classic ASP forum package and morphed it into a CMS - but it took a year or so and I was getting paid to do it. YMMV
In the end:
If the latter is your ultimate goal, then by all means, read the articles, do the research, and code away.
If its the former, you might want to look at something thats already been done - unless its going to be your businesses core competency.
Ultimately, the answer you get is going to depend on the question you ask. Being clear from the get-go will go a long way. ;)
If you want to go at it for the learning experience then I think you should. Phil Haack wrote a good blog post called Rolling Your Own Blog Engine with a good list of issues you'll run in to.
It's not as easy as many try to make it sound. The truth is that you can write a very minimal blog engine in a few hours (some will say minutes, but following along with the Rails video doesn't really count as your own development time), but it wouldn't be much use to anyone but yourself. Other users are going to demand more features.
Just make sure you leave yourself enough time to bail out and go with Plan B (wordpress+mediawiki+some forum software) if you need to.
Its possible in that time frame depending on how good you are with ruby on rails and php.
However, I would just use what's out there. Is it really worth all that time to make your own?
No.
"Don't Reinvent The Wheel, Unless You Plan on Learning More About Wheels".
I'd focus on learning about each of the tools and how you can integrate them together, instead of writing a CMS.
I'm in a somewhat similar situation, albeit at a smaller scale. I need a blog software in ,net, but the existing ones aren't really that good, so I've started my own. Here are my thoughts:
If you are willing to cut some corners at the beginning, I think that building a CMS in 300 hours is certainly feasible. But then don't start thinking about stuff like a Plugin Architecture, great User Experience for the Admin and Documentation - these points are really important if you want to release your CMS to other people, but not that much for internal use.
Judging from your goals it seems like it'd be easily accomplished in Drupal with minimal work.
www.drupal.org
Forums and user blogs are built in and I'm pretty sure I saw a wiki module somewhere.
However, if you're going for a learning experience - doing it yourself will be quite the learning experience. Whether you actually accomplish it or not you will understand RoR and/or PHP better by the time you're done.
roll out your own :)
you will gain experience (which is priceless), and on top of that you will end up with something thats not bloated...
I would say consider why you are doing it, if it's to further your knowledge of programming and learn something new then go for it and build it your self, otherwise I would just use available tools to put it together.
As for time frame? I am crap at estimation for my own skills, so have no chance of estimating yours :)
Вам не нужно заново изобретать колесо, чтобы получить опыт.
Я бы выбрал Wordpress. Я использую его на своем веб-сайте (www.norwegianfashion.no) и считаю, что у меня довольно продвинутый веб-сайт. Я, безусловно, улучшил свои навыки программирования на PHP.
Я тоже пытался разобраться в Drupal. Это очень хорошая CMS, но учить ее - заноза в заднице.
Даже после 5 лет разработки на других системах CMS (.NET) я не смог освоить Drupal после 1 месяца попыток.
Я Я не заядлый программист, но считаю, что CMS должна быть довольно простой в использовании.
Итак, я выбрал Wordpress. У него есть ограничения, но вы можете создать свои собственные плагины, чтобы компенсировать это.
Я бы сам выбрал WordPress в рамках проекта, который вы определили. Simple Press Forum - это надежный полнофункциональный плагин форума для WordPress, в который довольно легко интегрировать MediaWiki. Также существует проект плагина для вики-сайтов WordPress, который может использовать часы, которые, как кажется, вы готовы совершить. WordPress может делать все, что вы описали, за выходные.
Я должен подчеркнуть замечание barfoon, чтобы не изобретать велосипед. Есть много полезного опыта, который можно получить, взяв чужую CMS и научившись использовать и развиваться против нее.
Кроме того, вы многому научитесь, если возьмете проект с открытым исходным кодом и просмотрите, как они решили разработать свой продукт. Затем , поняв, как они работают, вы можете внести свой вклад в проект или даже расширить его самостоятельно, но у этого способа есть несколько преимуществ:
Тем не менее, я лично рекомендую вам взглянуть на Magnolia . Он пользуется поддержкой сообщества, это открытый исходный код и система качества.
G'luck
Как истинный разработчик, вы будете иметь желание большого количества настроек. Многие предварительно упакованные CMS / блоги имеют системы плагинов, но мне все они кажутся немного странными, когда мне приходится регистрировать свой код в системе через запись в базе данных.
Если честно, у меня был свой блог. в wordpress, переписал свой собственный на PHP, и с тех пор я дважды переписал его в Django.
Каждый раз становится быстрее, каждый раз, когда вы хотите сделать что-то еще, и каждый раз, когда вы изучаете все удобство использования и безопасность проблемы, которые должны пройти люди, создавшие очень большие проекты.
Переписывание было ценным опытом, и я никогда не стал бы использовать аргумент «Не изобретайте велосипед». Я чувствую, что могу посмотреть на колесо и сказать, что с ним не так,