以下是我正在使用的原始剧本:
http://www.jqueryscript.net/demo/Creating-A-Dynamic-Speedometer-with-jQuery-TweenLite-Vroom/
' js / vroom.js' file包含以下代码:
st.push(i)
如您所见,它会查找用户输入,然后更改车速表上的指针。
我希望它能从页面中获取此值。我们将此页面称为“currentnumber.php'”。此外,在没有用户输入任何东西的情况下,针头会更新它自己作为“currentnnumber.php”中的值。变化。
这个数字必须经过“公里到公里”的转换。如代码行之间所示,51-73' on' js / vroom.js'如下所示:
// a linear time solution for stock span problem
#include <iostream>
#include <stack>
using namespace std;
void calculateSpan(int price[], int n, int S[])
{
// Create a stack and push index of first element to it
stack<int> st;
st.push(0);
// Span value of first element is always 1
S[0] = 1;
// Calculate span values for rest of the elements
for (int i = 1; i < n; i++)
{
// Pop elements from stack while stack is not empty and top of
// stack is smaller than price[i]
while (!st.empty() && price[st.top()] < price[i])
st.pop();
// If stack becomes empty, then price[i] is greater than all elements
// on left of it, i.e., price[0], price[1],..price[i-1]. Else price[i]
// is greater than elements after top of stack
S[i] = (st.empty())? (i + 1) : (i - st.top());
// Push this element to stack
st.push(i);
}
}
// A utility function to print elements of array
void printArray(int arr[], int n)
{
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
}
// Driver program to test above function
int main()
{
int price[] = {1, 4, 50, 90, 12, 80};
int n = sizeof(price)/sizeof(price[0]);
int S[n];
// Fill the span values in array S[]
calculateSpan(price, n, S);
// print the calculated span values
printArray(S, n);
return 0;
}
除此之外,速度表上的针不是直接跳到它的位置,而是希望它从0开始。这将使速度表移动的效果。例如:如果currentnumber.php在5秒内从10变为34到56,则针将按如下方式移动:
0 - 10
0 - 34
0 - 56
我相信这可以通过样本页面上可以看到的初始代码来控制。你可以轻轻地看到针头&#39;最初进入位置。这是实现这一目标的代码。
TweenLite.to(needle,2,{rotation:-31,transformOrigin:&#34; right right&#34;});
问题是:如何通过从远程页面(位于同一服务器上)调用值来自动更新车速表上的指针。请让我知道,如果你有任何问题。