我在javascript函数中有一行,它根据另一个字符串数组的顺序对一个对象数组进行排序.这是在Firefox中工作但不在IE中,我不知道为什么.这是我的数据在IE7中进入排序调用的样子.(我正在使用三个项目的数组来说明这一点).
//cherry first then the rest in alphabetical order
originalData = ['cherry','apple','banana','clementine','nectarine','plum']
//data before sorting - note how clementine is second item - we wan to to to be after apple and banana
csub = [
{"value":"cherry","data":["cherry"],"result":"cherry"},
{"value":"clementine","data":["clementine"],"result":"clementine"},
{"value":"apple","data":["apple"],"result":"apple"},
{"value":"banana","data":["banana"],"result":"banana"},
{"value":"nectarine","data":["nectarine"],"result":"nectarine"},
{"value":"plum","data":["plum"],"result":"plum"}
]
//after sorting, csub has been rearranged but still isn't right: clementine is before banana. in FF it's in the right place.
csubSorted = [
{"value":"cherry","data":["cherry"],"result":"cherry"},
{"value":"apple","data":["apple"],"result":"apple"},
{"value":"clementine","data":["clementine"],"result":"clementine"},
{"value":"banana","data":["banana"],"result":"banana"},
{"value":"nectarine","data":["nectarine"],"result":"nectarine"},
{"value":"plum","data":["plum"],"result":"plum"}
]
Run Code Online (Sandbox Code Playgroud)
这是实际的排序代码:
csubSorted = csub.sort(function(a,b){ return (originalData.indexOf(a.value) …Run Code Online (Sandbox Code Playgroud) 此代码适用于具有本机android系统的普通google设备.但是在htc感应设备的列表中没有MMS应用程序,我不知道摩托罗拉模糊等:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("image/png");
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
context.startActivity(Intent.createChooser(emailIntent, context.getString(R.string.send_intent_name)));
Run Code Online (Sandbox Code Playgroud)
这段代码适用于htc意义,但不适用于Chooser,我真正需要的是:
Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("image/png");
context.startActivity(sendIntent);
Run Code Online (Sandbox Code Playgroud)
但我不知道如何将这些代码示例组合在一起,我不知道如何以编程方式确定Htc Sense ui.是支持不同类型设备的正确方法吗?
谢谢你的回答.
我有一个存储关系的mysql表.项目可以在一个方向上与另一个项目相关,或者两个项目可以彼此相关.
我想返回与我的主要项目相关的所有项目 - 但我还想检查相关项目是否与当前项目具有"反向关系"并将其显示为布尔值
|--------------|---------------|
| SKU | related_SKU |
|--------------|---------------|
| 0001 | 0099 |
| 0002 | 0099 |
| 0099 | 0001 |
|--------------|---------------|
Run Code Online (Sandbox Code Playgroud)
如果我想获得SKU = 0001的所有关系
SELECT related_SKU from relationships where SKU='0001'
Run Code Online (Sandbox Code Playgroud)
回报
|--------------|
| related_SKU |
|--------------|
| 0099 |
|--------------|
Run Code Online (Sandbox Code Playgroud)
但我想要的是
|--------------|---------------|
| related_SKU | reciprocal |
|--------------|---------------|
| 0099 | 1 |
|--------------|---------------|
Run Code Online (Sandbox Code Playgroud)
要么
SELECT related_SKU from relationships where SKU='0002'
|--------------|---------------|
| related_SKU | reciprocal |
|--------------|---------------|
| 0099 | 0 |
|--------------|---------------| …Run Code Online (Sandbox Code Playgroud) 想象一下,我在变量中有一些文件数据$data.我需要确定它是否是图像.不需要像腐败图像等细节.
首先想到的是通过查看幻数来获取文件mime类型,然后查看"image"是否属于mime类型.
没有这样的运气,即使我有一个"mime类型的文件扩展名"脚本,我没有一个可靠的方法从魔法数字获取mime.
我的下一个选择是拥有一个合理的图像文件幻数列表并查阅它们.然而,找到这样的魔术数字是相对困难的(例如,gif有不同的幻数,其中一些可能非常罕见 - 如果记忆对我有用).
一个更好的想法是一些Linux程序可以做这种事情.
有任何想法吗?我正在运行RHEL和PHP 5.3.我有root权限 - 即可以根据需要安装东西.
- 克里斯.
我有一个TextArea输入分隔值:
例如:
Value1 Value2 Value3 Value4 Value5
有没有一种快速的方法将它们放在一个String数组中
String[] newStringArray = ???
Run Code Online (Sandbox Code Playgroud) 当我试图在Facebook Graph API上获得我所有的"喜欢"(以前的粉丝页面)时,有时它会返回一个空集:
{
"data": [
]
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用https://graph.facebook.com/me/likes?access_token=MY_ACCESS_TOKEN和graph.facebook.com/vinch/likes?access_token=MY_ACCESS_TOKEN,但结果完全相同(空).
知道它可能是什么吗?我需要知道用户是否喜欢(是粉丝)特定页面.
关于Html diff引擎有一些关于SO的问题,但我找不到正确的答案.我需要的是用于比较两个渲染的 html字符串和显示差异的.NET库(如SO渲染问题/答案编辑修订版(示例)).