好吧,我正在绘制一个画布对象上的描边线,这项工作正常我想要做的就是删除线条或在一段时间之后淡出它们我一直在阅读关于保存状态和刷新但我可以'似乎让它工作我还尝试将画布上下文存储到一个数组中并在它超过一定长度时拼接其中的项目但又一次没有运气......这是我的代码(这是巨大的所以我'设立了一个plunkr):
`var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.canvas = $('#spiro')[0];
$scope.canvascanvasContext = $scope.canvas.getContext("2d");
//interval
$scope.timerId = 0;
console.log($scope.canvas);
//MOUSE OVER
/*
$scope.getMousePos = function getMousePos(evt) {
var rect = $scope.canvas.getBoundingClientRect();
$scope.mouseX = evt.clientX - rect.left;
$scope.mouseY = evt.clientY - rect.top;
$scope.canvascanvasContext.fillStyle = "rgb("+$scope.red+", "+$scope.green+", "+$scope.blue+")";
$scope.canvascanvasContext.fillRect($scope.mouseX, $scope.mouseY, 4, 4);
console.log(evt.clientX);
}
*/
$scope.clearit = function clearit(){
// Store the current transformation matrix
// $scope.canvascanvasContext.save();
// Use the identity matrix while clearing the canvas
$scope.canvascanvasContext.setTransform(1, 0, 0, …Run Code Online (Sandbox Code Playgroud) 我正从API中检索一个多维php数组(我认为),现在所有的值都返回完美,当我用print_r转储数组时,我得到了这个:
Event Object
(
[title] => test
[link] => google.com
[updated] => 2013-03-06T12:08:56.521-05:00
[id] => test
[name] => Copy of Copy of Copy of Mar 05, 2013 - TEST4
[description] =>
[registered] => 2
[createdDate] => 2013-03-06T12:08:56.521-05:00
[status] => COMPLETE
[eventType] => OTHER
[eventLocation] => EventLocation Object
(
[location] => test
[addr1] => test
[addr2] =>
[addr3] =>
[city] => madrid
[state] => andalucia
[country] =>
[postalCode] => 06103
)
[registrationUrl] => https://google.com
[startDate] => 2013-03-07T13:00:00-05:00
[endDate] => 2013-03-07T13:00:00-05:00
[publishDate] …Run Code Online (Sandbox Code Playgroud) 我正在使用jquery检查div元素中的字符串,但它总是返回if if never else,即使dom不包含那么$我犯的是什么愚蠢的错误?
$('.bw-switcher').on('click', function() {
$(this).toggleClass('toggledrate', 1000);
$('.toggledrate > .bwswitch-button:before').toggle('fast');
$('.toggle_rates').toggle('fast');
if ($(".deatils.dailyPrice:contains($)")) {
$('.deatils.dailyPrice').toggle('fast');
console.log('I am the if');
} else {
console.log('I am the else');
$('.deatils.dailyPrice').toggle('fast').prepend('$');
}
$('.toggledrate > .bwswitch-button:after').toggle('fast');
});
Run Code Online (Sandbox Code Playgroud) 我试图移动到下个月点击一个div我将月份商店作为对象在months = []; 但是当我使用++它只是重复同一个月为什么?继承我的JS:
var newdate = new Date();
var getnewmonthword = newdate.getMonth();
var i = 0;
months = [];
months[0] = ('january');
months[1] = ('february');
months[2] = ('march');
months[3] = ('apri');
months[4] = ('may');
months[5] = ('june');
months[6] = ('july');
months[7] = ('august');
months[8] = ('september');
months[9] = ('october');
months[10] = ('november');
months[11] = ('december');
var countemonth = getnewmonthword;
var myMonthName = months[countemonth];
$('#test span').replaceWith('<span>' + myMonthName + '</span>')
$('#addone').on('click', function () {
alert('fred');
countemonth++;
//months[++i];
// $('#test span').replaceWith('<span>' …Run Code Online (Sandbox Code Playgroud) 好吧我有一个EC2实例并运行nodeJs并表示我正在使用生成器的vanilla安装,我的app.js文件如下:
/**
* Main application file
*/
'use strict';
// Set default node environment to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var express = require('express');
var mongoose = require('mongoose');
var config = require('./config/environment');
// Connect to database
mongoose.connect(config.mongo.uri, config.mongo.options);
// Populate DB with sample data
//require('./config/seed');
// Setup server
var app = express();
var server = require('http').createServer(app);
var socketio = require('socket.io')(server, {
serveClient: (config.env === 'production') ? false : true,
path: '/socket.io-client'
});
require('./config/socketio')(socketio);
require('./config/express')(app);
require('./routes')(app);
// Start …Run Code Online (Sandbox Code Playgroud) 有人可以解释为什么这段代码中的if语句总是返回true:
(function ($) {
//load on page load
$(".area").load("/galleries/ #projects > li a");
//load on widget title click
$('.widget-top').live("click", function () {
$(".area").load("/galleries/ #projects > li a");
});
//stop default href from working
$('.area a').unbind().live("click", function () {
event.preventDefault();
return;
});
// variables
var i = $('#widgets-right .addinput').size() + 1;
var addDiv = $('.addinput');
//dynamic forms
$('#widgets-right .addNew').live('click', function () {
$(this).parents('.addinput').append('<div class="div_' + i + '"><h4>Reference project ' + i + '</h4><div class="gallery_one_image_wrap"><img class="gallery_one" src="" /><br/></div><p><label for="title' + i …Run Code Online (Sandbox Code Playgroud) 另一个angularJS问题我有范围绑定点击,应该在第一次点击时添加一个值和第二次点击时的另一个值,但它只是保持返回并清空数组并再次填充第一个值为什么?:
scope.dbclickalert = function (scope, $watch) {
var getCheckInDate = this.cellData.date;
var formatcheckindate = new Date(getCheckInDate);
var checkingdates = [];
var curr_datecell = formatcheckindate.getDate();
var padded_day = (curr_datecell < 10) ? '0' + curr_datecell : curr_datecell;
var curr_monthcell = formatcheckindate.getMonth() + 1;
var padded_month = (curr_monthcell < 10) ? '0' + curr_monthcell : curr_monthcell;
var curr_yearcell = formatcheckindate.getFullYear();
var date_stringcell = + padded_month + "/" + padded_day + "/" + curr_yearcell;
var checkindatestrg = "checkindate";
console.log(checkingdates.length);
if (checkingdates.length < 2) …Run Code Online (Sandbox Code Playgroud) javascript ×6
angularjs ×3
jquery ×3
arrays ×1
canvas ×1
cors ×1
html5 ×1
if-statement ×1
node.js ×1
php ×1