简体   繁体   English

Javascript / JQuery:如何重新定义?

[英]Javascript/JQuery: How to redefine something?

Please pardon my "layman language", but I've been working at this for all day. 请原谅我的“外行语言”,但是我整天都在为此工作。 I almost done customizing this but I just can't seem to wrap my head around this. 我几乎完成了对此的自定义设置,但是似乎无法解决这个问题。 I'm using Soundmanager (playlist). 我正在使用Soundmanager(播放列表)。 There's this part in the script that reads: 脚本中的这一部分内容为:

thisSound._data = {
          oLink: o, // DOM reference within SM2 object event handlers
          oLI: oLI,
          oControls: self.select('controls',oLI),
          oStatus: self.select('statusbar',oLI),
          oLoading: self.select('loading',oLI),
          oPosition: self.select('position',oLI), // HERE IT IS
          .......

        };

(This is what is setup after the page has finished loading): (这是页面加载完成后的设置):

controlTemplate = document.getElementById("my_sounds");
controlTemplate.innerHTML = [

      // control markup inserted dynamically after each page player link
      // if you want to change the UI layout, this is the place to do it.

      '  <div class="controls">',
      '   <div class="statusbar">',
      '    <div class="loading"></div>',
      '    <div class="position"></div>', // HERE'S WHAT "oPosition" IS CONNECTING TOO
      '   </div>',
      '  </div>'

    ].join('\n');

Now, I'm not using what Soundmanager has setup for me ( <div class="position">... ), but instead, I have a div somewhere on the page that'd I'd like to be the "new" oPosition ( <div class="my_new_position_div">... ). 现在,我没有使用Soundmanager为我设置的设置( <div class="position">... ),而是在页面上某处有一个div,我想将其作为“新“ oPosition<div class="my_new_position_div">... )。

So, in short, I want to have use my_new_position_div as my progress bar instead of the other div. 因此,简而言之,我想使用my_new_position_div作为进度条,而不是其他div。

How do you redefine "oPosition" in this Soundmanger script? 您如何在此Soundmanger脚本中重新定义“ oPosition”?

full soundmanager script: page_player.js 完整的Soundmanager脚本: page_player.js

I've erased my previous answer. 我已经删除了以前的答案。 I realized that wouldn't work a second after I posted it. 我意识到在发布后一秒钟内将无法正常工作。 The reason why is because the _data property is only set when it is first needed in a handleClick event (this is pretty bad coding). 原因是因为_data属性仅在handleClick事件中首次需要时设置(这是非常糟糕的编码)。 I was hoping I could find a way to keep the script in tact as much as possible, so you are not stuck with a patched version of somebody elses' handy work. 我希望我能找到一种使脚本尽可能完整的方法,这样您就不会陷入别人方便工作的补丁版本中。 But now it seems there is no other way non-intrusive way then to just replace the oPosition line with: 但现在看来,除了将oPosition行替换为:

oPosition: document.getElementById('my_new_position_div');

You need to change <div class="my_new_position_div"> to <div id="my_new_position_div"> also. 您还需要将<div class="my_new_position_div">更改为<div id="my_new_position_div">

I suggest you place some big comments around this patched code. 我建议您围绕此修补代码放置一些大注释。 This will help you or somebody else working on this code to upgrade to newer versions in the future. 这将帮助您或其他使用此代码的人将来升级到新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM