我写了一个脚本,通过拖放使用jQuery上传文件,jQuery在drop上读取文件并将其添加到文件数组中,如下所示:
var files = [];
$(document).ready(function() {
jQuery.fn.dropbox = function(config) {
var dragging = 0;
var dragEnter = function(e) {
e.stopPropagation();
e.preventDefault();
dragging++;
$(".external-drop-indicator").fadeIn();
$(".toast.toast-success").fadeIn().css("display", "inline-block");;
return false;
};
var dragOver = function(e) {
e.stopPropagation();
e.preventDefault();
return false;
};
var dragLeave = function(e) {
e.stopPropagation();
e.preventDefault();
dragging--;
if(dragging === 0) {
$(".external-drop-indicator").fadeOut();
$(".toast.toast-success").fadeOut();
}
return false;
};
var drop = function(e) {
var dt = e.dataTransfer;
var files_upload = dt.files;
e.stopPropagation();
e.preventDefault();
if(files_upload && files_upload.length > 0 && config.onDrop !== …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行的查询的代码是
$query = $this->db->select("*")->from('items')->like("replace(name, '=', ' ')", "foo bar", 'both')->get();
$items = $query->num_rows();
Run Code Online (Sandbox Code Playgroud)
Mysql查询字符串是
SELECT replace(name, ' = ', ' ') FROM `items`
Run Code Online (Sandbox Code Playgroud)
代码正在做的是在编译查询时在"="之前和之后添加一个空格,导致"="返回没有结果,因为名称中没有带"="的项,只有"=".
foo=bar, replace(name, '=', ' ') returns 1 result.
foo = bar, replace(name, ' = ', ' ') returns 0 results.
Run Code Online (Sandbox Code Playgroud)
我正在使用的CodeIgniter版本是:3.0.6
我使用CefSharp的SchemeHandler来从我的C#项目中获取资源.css,.js或者.png使用自定义URL的文件,例如custom://cefsharp/assets/css/style.css
我有2个自定义类来存档.
第一类,MyCustomSchemeHandlerFactory将是处理自定义Scheme的那个,它看起来像这样,其中"custom"将是自定义方案:
internal class MyCustomSchemeHandlerFactory : ISchemeHandlerFactory
{
public const string SchemeName = "custom";
public IResourceHandler Create(IBrowser browser, IFrame frame, string schemeName, IRequest request)
{
return new MyCustomSchemeHandler();
}
}
Run Code Online (Sandbox Code Playgroud)
我实现的下一个类是MyCustomSchemeHandler接收调用并输出响应,它看起来像这样:
internal class MyCustomSchemeHandler : IResourceHandler
{
private static readonly IDictionary<string, string> ResourceDictionary;
private string mimeType;
private MemoryStream stream;
static MyCustomSchemeHandler()
{
ResourceDictionary = new Dictionary<string, string>
{
{ "/home.html", Properties.Resources.index},
{ "/assets/css/style.css", Properties.Resources.style}
};
}
public Stream …Run Code Online (Sandbox Code Playgroud) I have a RecyclerView that displays an Button which extends outside its parent ViewHolder. To the button I added a clickListener to display a toast. If you click on the Button and the click is on the area of the Button parent ViewHolder, the toast shows, but if you click on the button but outside its parent ViewHolder the toast doesn't show anymore.
Here's what I currently have
RecyclerView:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:focusedByDefault="false"
android:scrollbars="horizontal" …Run Code Online (Sandbox Code Playgroud) 我想从这个字符串中删除最后一个数字,包括破折号:
hello-world-093
结果应该是:
你好,世界
嘿,我有这段代码:
private void Window_KeyUp(object sender, KeyEventArgs e)
{
if (playing == false)
{
return;
}
if (e.KeyCode == Keys.D1)
{
pictureBox6.Image = Form.Properties.Resources.black_square_button;
player.Stop();
player.Close();
playing = false;
}
}
Run Code Online (Sandbox Code Playgroud)
我没有工作,但Window_KeyDown()工作.
我的代码出了什么问题?
谢谢.
我有一个需要调整大小的无边界 winForm,我设法这样做:
protected override void WndProc(ref Message m)
{
const int wmNcHitTest = 0x84;
const int htLeft = 10;
const int htRight = 11;
const int htTop = 12;
const int htTopLeft = 13;
const int htTopRight = 14;
const int htBottom = 15;
const int htBottomLeft = 16;
const int htBottomRight = 17;
if (m.Msg == wmNcHitTest)
{
Console.Write(true + "\n");
int x = (int)(m.LParam.ToInt64() & 0xFFFF);
int y = (int)((m.LParam.ToInt64() & 0xFFFF0000) >> 16);
Point pt = PointToClient(new …Run Code Online (Sandbox Code Playgroud) 我需要使用Volley从API检索各种JSONObject。该API需要使用Basic进行标头验证。如果我不添加标题,它将起作用,但是当我继续获取时,就可以了org.jetbrains.kotlin.codegen.CompilationException。这是我编写的函数:
private suspend fun readData(url: String): JSONObject = suspendCancellableCoroutine { continuation ->
val request: JsonObjectRequest = object: JsonObjectRequest(Request.Method.POST, url, null, Response.Listener<JSONObject> {
continuation.resume(it)
}, Response.ErrorListener {
continuation.resumeWithException(Exception(it.cause))
}) {
override fun getHeaders(): Map<String, String> = mapOf("Content-Type" to "application/json", "charset" to "utf-8", "Authorization" to "Basic ".plus(android.util.Base64.encode(String.format("%s:%s", getString(R.string.api_login_username), getString(R.string.api_login_password)).toByteArray(), android.util.Base64.DEFAULT)))
}
request.setShouldCache(false)
this.queue?.add(request)
}
fun data(url: String) = async(CommonPool) { readData(url) }
Run Code Online (Sandbox Code Playgroud)
他们像这样实现它们:
val brands = data(getString(R.string.api_url).plus("/api/brand"))
val models = data(getString(R.string.api_url).plus("/api/model"))
launch(UI) {
val brandsJsonArray = brands.await().getJSONArray("recordset")
val modelsJsonArray = …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,当按下或单击一个键或按钮时我需要播放一个wav文件,我使用SoundPlayer类,但当我尝试播放另一个wav文件同时正在播放的那个文件停止.
有没有办法同时播放多个wav文件?如果它可以请你给我举例或教程?
这是我到目前为止所得到的:
private void pictureBox20_Click(object sender, EventArgs e)
{
if (label30.Text == "Waiting 15.wav")
{
MessageBox.Show("No beat loaded");
return;
}
using (SoundPlayer player = new SoundPlayer(label51.Text))
{
try
{
player.Play();
}
catch (FileNotFoundException)
{
MessageBox.Show("File has been moved." + "\n" + "Please relocate it now!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我有一个表单,一旦提交结果不应该通过重新加载页面再次复制,我已经尝试分配一个随机密钥,以便当你重新加载页面时,密钥将不匹配,你将无法复制它但它不起作用:
$bypass = rand(1,999);
if ($_SERVER['REQUEST_METHOD'] === 'POST'){
if ($_POST['key'] == $bypass) {
echo'Hello';
} else {
echo "invalid key";
}
} else {
echo '<form action="test.php" method="post">';
echo '<input type="hidden" name="key" value="'.$bypass.'" /><input name="submit" type="submit" value="submit" /></form>';
}
Run Code Online (Sandbox Code Playgroud)
上面代码的预期功能是生成一个随机密钥,该密钥仅在您提交表单时才起作用,但是如果您通过重新加载页面重新发送表单现在可以工作但是它不起作用,因为当您提交表单时密钥将改变了.我怎样才能解决这个问题?