Hello i was trying to solve this issue on my Notion database,
What i am trying to accomplish is to have a code that shows me the latest read chapter in the database.
The difference between a read/unread chapter is the status field i put up (it is a basic boolean figure if you read it you click on the checkmark that turns the 0-1 )
I have done a similar database structure/configuration with the episodes that has been watched. It was easy to do because there are no irregularities and all of them are in integer values such as ep1,ep2 i just wrote a formula to find the total checked(watched) episode numbers . I could have also done it as to give me the latest input (episode) that has been watched.
But on manga/comic/books they are not on integer values there are always extras,editoral notes which counts as 1.1,1.2
Example:
read chapters (value checked/true)
Chapter 1 ( status:read = true)
Chapter 2 ( status:read = true)
Chapter 2,1 ( status:read = true)
Chapter 2,2 ( status:read = true)
Chapter 3 ( status:read = false)
If i try the same formula that is in notions system it doesn't give me the right answer because it cannot find/count it like an integer value list.
On this example i have 5 values in total 4 that has been checked as read if i try to do count checked values like in episodes it will give me false number like 4.(it has to give me 2,2)
I had no idea about JavaScript so after many trial and errors i have managed to combine to code to give me what i want. The only issue is it only accepts a value but not a changeable property on notion.
Because of the quotation that involves this thing -> ""(Quotation) it is not lining perfectly so i always get the error message saying i should put up a "(" in the code to solve it.Which doesn't make sense because whenever i have tried to put it did not solve my issue
The working version is as follows
replaceAll(replace(prop("all chapter numbers"), "(?:[^,]*,){2}", ""), ",.*", "");
i use prop("all chapter numbers") that shows all the chapters that has been read like (201,202,202.1,202.2,...)
I have used 2 as an example in here that works it just does what it suppose to do. But instead of 2 i need a property value so it changes based up on each book/comic/manga.
i have the total checked/read chapter value stored in a property in a int value like 2,4,5
When i put the property on notion into this code structure it gives me the error and does not accept it. Idk how can i fix this issue
replaceAll(replace(prop("all chapter numbers"), "(?:[^,]*,);{toNumber(prop("total checked chapter"))}",""), ",.*", "");
Related
I'm not sure if this question makes sense but when I'm using an IDE and for example I type:
x = 5
s = typeof(x)
if (s === ) //Cursor selection after === (before i finished the statement)
the IDE's autocomplete feature gives me a list of the possible values. And if I type value that doesn't exist in that list it's highlighted, and when I execute the program (in other examples, not this one), it throws an error.
I want to achieve a similar functionality with my own variables so that I can only assign specific values to it.
I'd recommend using TypeScript. See this question.
For example, your code will throw a TypeScript error if you try to compare the result of typeof against anything that isn't a proper JavaScript type:
x = 5
s = typeof(x)
if (s === 'foobar') {
}
results in
In a reasonable IDE with TypeScript (such as VSCode), any line of code that doesn't make sense from a type perspective will be highlighted with the error.
If you want to permit only particular values for some variable, you can use | to alternate, eg:
let someString: 'someString' | 'someOtherString' = 'someString';
will mean that only those two strings can occur when doing
someString =
later.
TypeScript makes writing large applications so much easier. It does take some time to get used to, but it's well worth it IMO. It turns many hard-to-debug runtime errors into (usually) trivially-fixable compile-time errors.
I got a column with filter type textbox and i got filterrow enabled but i need the filter conditions dropdown to also appear next to the textbox because i need to be able to apply multiple conditions like not equal and other filters.
It seems like it is possible, but only by making changes to the jqxgrid.filter module, which the licensing seems to allow. I base this answer on the code for jQWidgets v3.4.0. (Of course, it's convenient to de-minify the code first.)
There are switch statements in several functions which switch on the filtertype (such as number and textbox). You can define your own filtertype that shows a textbox with a dropdown list by choosing a new name and adding case statements to fall through to the number case in the function definitions _updatefilterrowui, clearfilterrow, and refreshfilterrow. For the function _addfilterwidget, you need to add your own case and copy the code for the number case, but replace the line saying
var A = F._getfiltersbytype("number");
with
var A = F._getfiltersbytype("string");
to populate the dropdown list with the string comparison operators – or you can define your own filtertype, but this of course requires additional adjustments. In the function _applyfilterfromfilterrow you also need to add a case based on the code for the number case, with some adjustments. Basically, what seems to do the trick is to firstly remove the part about the decimal separator and secondly to not typecast the input string by changing
y = k.createfilter(d, new Number(p), w, null, u.cellsformat, C.gridlocalization);
to
y = k.createfilter(d, p, w, null, u.cellsformat, C.gridlocalization);
Note that this answer is possibly not complete, as I haven't done extensive testing (but I am interested to know of any problems, as I am looking for the same functionality as BeyondProgramming).
I am facing a strange issue in the below javascript code. From a page, the values which are getting pushed in project_list array are project_id (value range from 1 to 150) and bid_amount (value range from 1 to 2000). Everything works fine apart from one thing, whenever value of project_id (sent from page) is greater than 127, the value getting inserted in code line project_id = project_list[i]; is 127. As I checked, var does not have such a low limit. Also this code line bid_amount = parseFloat($("#bidAmount_"+project_list[i]).val()); works fine, easily taking value greater than 127. Please help, I have not declared shortint anywhere!
function bid_project_tournament(current_round)
{
var i;
var project_list= [];
$('#B2WProjectList :checkbox:checked').each(function(i){
project_list.push($(this).val());
});
$("#bid_project").attr("disabled","disabled");
var project_id;
var bid_amount;
var bid_data="0";
for(i=0;i<project_list.length;i++)
{
project_id = project_list[i];
bid_amount = parseFloat($("#bidAmount_"+project_list[i]).val());
bid_data = bid_data+";"+project_id+","+bid_amount;
}
}
We figured out the reason for this specific problem in the comments (a column with the type TINYINT instead of INT), but I'll leave a more general answer in case people come here with similar problems.
If you find that numbers are being capped at or around some power of two when sent to the server, there's a good chance the problem lies somewhere in your back-end code or database. Here are some things to check:
Have you accidentally set a column in your database to BYTE, TINYINT, SMALLINT or similar instead of INT or larger? Check your column definitions!
Are you passing the value to a variable in your back-end code which has a type like short, word, byte or similar?
If the values are in pre-filled HTML form fields, have you checked if the values in that HTML are correct?
If everything above checks out, fire up your browser's debug tools and watch the network activity panel to confirm if the values are being capped on the client.
There's no (reasonable) limit to the value of a checkbox in HTML, or indeed to any field without any restriction like a max or maxlength attribute. The biggest number you can represent in JavaScript without losing precision is 9,007,199,254,740,992, so if your numbers are being capped or rounded above that value, the problem might be JavaScript.
I was wondering if someone could give me advice on this code. I have done it in python but I think I need to have it in javascript as it is for a website. I am new to programming so please be kind!
Aims of the site:
The user will have to answer 6 multiple choice questions. (Q1 has
7 possible answers but the others only have 2).
Depending on their inputs they will receive an outcome (I have just put the outcomes as range(1,225) for now but there will be different outcomes depending on the input
The outcomes and the possible input combinations are all fixed and will not change
I am pretty sure I have not done it the best way as I don't have much experience, but it seems to work so far.
Does the code look ok?
Do you think I will be able to translate this into javascript easily enough?
Should I have the table of outcomes/inputs fixed in some way so it doesn't need to be worked out by the computer every time or is it ok as it is?
Any advice or help is very much appreciated indeed.
#list of possible inputs
list = [[23,24,25,26,27,28,29],["male","female"],["true","false"],["true","false"],
["true","false"],["true","false"]]
#make a list of outcomes
outcome=[]
for i in range(1,225):
outcome.append(i)
#make a table of all possible list input combinations
r=[[]]
for e in list:
table = []
for item in e:
for i in r:
table.append(i+[item])
r = table
#make a dictionary where the input is the key and outcome is the value
adict = dict((str(r), outcome) for r, outcome in zip(r, outcome))
#dummy inputs as an example
input1 = 27
input2 = "male"
input3 = "true"
input4="true"
input5="true"
input6="true"
#put all the inputs into one string & look up outcome in adict
new_input = []
new_input.extend([input1,input2,input3,input4,input5,input6])
print adict.get(str(new_input))
There is no need to rewrite it in javascript; instead try using one of the Python web frameworks like Flask or Django.
I am trying to write a lucene search in an Alfresco webscript (javascript) to find 1 of 2 custom types within a custom type cm:folder
So the folder might have the following contents
1. Some text (cm:content)
2. More text (custom:content)
3. Even more text (custom:content)
4. Another folder (cm:folder)
5. Crazy, more text (custom:content2)
6. Last text (custom:content2)
The expected result of the lucene search should return the following
2. More text (custom:content)
3. Even more text (custom:content)
5. Crazy, more text (custom:content2)
6. Last text (custom:content2)
Where am I going wrong with the lucene search? I have written something along the lines of
+PATH:"/app:company_home/PATH_TO_A_CUSTOM_TYPE_FOLDER/*" TYPE:"custom:content1" TYPE:"custom:content2"
The problem is it returns all content, I think the intention is to write something like
+PATH:"/app:company_home/PATH_TO_A_CUSTOM_TYPE_FOLDER/*" +TYPE:"custom:content1" OR +PATH:"/app:company_home/PATH_TO_A_CUSTOM_TYPE_FOLDER/*"+TYPE:"custom:content2"
Worse case scenario is I can run 2 lucene searches, but it would be good to know how the query is written :-)
Thanks
Can't you just do the following:
+PATH:"/app:company_home/PATH_TO_A_CUSTOM_TYPE_FOLDER/*" AND (TYPE:"custom:content1" TYPE:"custom:content2")
Because if you write +PATH TYPE: TYPE:, it actually says PATH:(Must have) OR TYPE: OR TYPE:, hence it looks that if the PATH: is matched it will return everything beneath.