我已经阅读了有关如何从后台javascript文件(main.js)发送消息到内容脚本(content.js)的文档,但我无法让onMessage打开我的警报.
的manifest.json
{
"name": "Example",
"version": "1.0.1",
"manifest_version" : 2,
"description": "Example Description",
"background" : {
"scripts" : ["main.js"]
},
"page_action" : {
"default_icon": {
"19": "icons/19.png",
"38": "icons/38.png"
},
"default_title" : "Example Title"
},
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["lib/jquery-1.8.3.min.js","scripts/content.js"],
"run_at": "document_idle",
"all_frames": false
}],
"permissions": [
"tabs",
"geolocation"
],
"icons": {
"16": "icons/16.png",
"48": "icons/48.png",
"128": "icons/48.png"
}
}
Run Code Online (Sandbox Code Playgroud)
后台javascript文件(main.js)
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "SendIt"}, function(response) {});
});
Run Code Online (Sandbox Code Playgroud)
内容javascript文件(content.js)
chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置Access-Control-Allow-Methods标题,options目前看来claudia-api-builder没有能力设置http选项响应,就像GET请求一样.请参见下面的GET示例.
获取示例
api.get('/hard-coded-headers', function () {
return 'OK';
}, {success: {headers: {'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS'}}});
Run Code Online (Sandbox Code Playgroud)
此外......
如果通过设置此标头值aws-api-gateway -> resources -> OPTIONS > Integration Response,然后如果您要执行claudia update它,它将被覆盖回其默认状态,如下所示.
该claudia-api-builder文档显示,它支持API网关自定义错误答复,但没有成功.
我希望能够像处理GET请求一样设置选项自定义标头响应.这可能吗?
我可以从作业文件夹中的静态触发器运行一个cron,它将执行,但是当我尝试从我的控制器触发一个触发器时,它只是失败...我错过了什么?
错误代码:没有方法签名:static com.example.TaskReminderJob.triggerNow()适用于参数类型:(java.util.LinkedHashMap)值:[[params:[name:Frank,email:frank@test.com] ]]
grails-app/jobs/example中的Quartz Job
package com.example
class TaskReminderJob {
def reminderMailService
static triggers = { }
def execute(context) {
def email = context.mergedJobDataMap.get('email')
def name = context.mergedJobDataMap.get('name')
reminderMailService.remindMail1(name, email) //send email via service
}
}
Run Code Online (Sandbox Code Playgroud)
控制器呼吁工作
package example
class UserController {
def quartzScheduler
...
//user is created
...
TaskReminderJob.triggerNow([name:"frank",email:"frank@test.com"] )
}
Run Code Online (Sandbox Code Playgroud) 如何遍历我的结果并格式化每个数字字符串.第一个结果是正确格式化的,但不是第二个结果或第一个结果之后的任何结果.
$('#phoneResults').each(function(){
//Only the first result is being altered! Ugh.
var string = $(this).html();
$(this).html(string.substring(0,3) + '.' + string.substring(3,6) + '.' + string.substring(6,10))
});
Run Code Online (Sandbox Code Playgroud) 我正在使用Grails的HDImageService插件来完成扩展用户上传图像的繁重工作.我创建了ImageService.groovy以保存到我的Amazon S3存储桶.一切正常,用户选择文件,点击发布和wahla图像缩放,存储和显示.我的问题是我不知道如何限制用户上传图像以外的文件.我想只允许上传jpeg,jpg,gif或png类型的文件.我用这些变量创建了一个ENUM类,但我不知道在哪里或如何实现.任何人都可以指出我正确的方向
RegistrationController.groovy:获取文件并保存到存储桶
if ( params.photo ) {
MultipartFile file = request.getFile( 'photo' )
byte[] fileBytes = file.bytes
ByteArrayInputStream bais = new ByteArrayInputStream( fileBytes )
BufferedImage image = ImageIO.read( bais )
def width = image.width
def height = image.height
def maxWidth = 500
// Calculate the ratio that we will need to resize the image
double ratio = 1.0f
if ( width > maxWidth ) {
def r = maxWidth / width
ratio = r < 1.0f ? r : …Run Code Online (Sandbox Code Playgroud) 我有一个域类(缩小)为: -
class Expense {
Date dateOfExpense
int amount
}
Run Code Online (Sandbox Code Playgroud)
我试图获得按周/月/费用日期分组的金额总和.参考grails doc http://grails.org/doc/latest/guide/GORM.html中的 'sqlGroupProjection'方法,
我尝试使用以下代码: -
def results = c {
between("dateOfExpense", fromDate, toDate)
projections {
sqlGroupProjection 'dateOfExpense,sum(amount) as summed',
'MONTH(dateOfExpense)',['date','summed'],[DATE,NUMBER]
}
}
Run Code Online (Sandbox Code Playgroud)
抛出异常:
No such property: DATE for class: grails.orm.HibernateCriteriaBuilder. Stacktrace follows:
Message: No such property: DATE for class: grails.orm.HibernateCriteriaBuilder
Run Code Online (Sandbox Code Playgroud)
请建议使用sqlGroupProjection方法的方法
grails ×3
aws-lambda ×1
claudiajs ×1
content-type ×1
file-upload ×1
grails-orm ×1
groovy ×1
http ×1
javascript ×1
jquery ×1
manifest ×1
node.js ×1