from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.core.js.fncs import JsFncsRecords jsObj = Js.JsBase() jsObj.registerFunction("row-buckets") jsObj.addKeyEvent(jsObj.window.alert("test alert"), 13) f = JsUtils.JsFile("RowBucket", path=r"../outs") f.writeReport(jsObj) f.close()
import pytest from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.core.js.primitives import JsNumber jsObj = Js.JsBase() print(jsObj.objects.number.new(349.673, "MyNumber").toStr()) jsObj = Js.JsBase() f = JsUtils.JsFile(os.path.basename(__file__).split(".")[0], path=r"C:\Users\olivier\Documents\youpi\jsFiles") f.writeJs([ jsObj.objects.array.new([2, 5, 12, -3], "MyArray"), jsObj.objects.array.new([3, -9, 2, -6], "MyArray2"), jsObj.objects.array.new([], "MyArray3"), jsObj.console.log(jsObj.objects.array.get("MyArray3").concat(jsObj.objects.array.get("MyArray"), jsObj.objects.array.get("MyArray2"))), jsObj.console.log(jsObj.objects.array.get("MyArray").findIndex([ jsObj.if_(jsObj.data.loop.val <= 0, [ jsObj.return_(jsObj.objects.true)]).else_(jsObj.return_(jsObj.objects.false)), ])), jsObj.console.log(jsObj.objects.array.get("MyArray").map([ jsObj.data.loop.val * jsObj.math.max(jsObj.data.loop.arr.toArgs()), jsObj.return_(jsObj.data.loop.val) ])), jsObj.console.log("########"), # jsObj.console.log(jsObj.objects.array.get("MyArray")),
""" Create a HTML page only from JavaScript functions """ from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.core.js.packages import JsDatatable from epyk.tests import test_statics # Create a blank Javascript Python object jsObj = Js.JsBase() # Write the results to a Javascript file with a Launcher f = JsUtils.JsFile("TestDatatable", path=test_statics.OUTPUT_PATHS) tab = JsDatatable.DatatableAPI(selector="table", setVar=False) cell = JsDatatable.CellAPI() f.writeJs([ tab.order().draw().destroy(), tab.data().length, cell.select().deselect(), tab.jquery_node().text("") ]) # Close the file and print the location of the launcher print(f.close(jsObj))
from epyk.core.js.html import JsHtml from epyk.core.js import JsUtils class HtmlComp(object): htmlCode = "test" # ------------------------------------------------------------------------------------------------------------------ # dom = JsHtml.JsHtml(HtmlComp()) f = JsUtils.JsFile("Dom", path=r"../outs") f.writeJs([ dom.hide(), dom.toggle() ]) f.close()
""" Create a HTML page only from JavaScript functions """ from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.core.js.packages import JsTabulator from epyk.tests import test_statics # Create a blank Javascript Python object jsObj = Js.JsBase() # Write the results to a Javascript file with a Launcher f = JsUtils.JsFile("TestTabulator", path=test_statics.OUTPUT_PATHS) tab = JsTabulator.Tabulator(selector="table", setVar=False) tab.setData([]) col = JsTabulator.ColumnComponent() col.delete() f.writeJs([ tab.getColumns.forEach(jsObj.console.log("column")).table.addRow({"test": "ok"}), col ]) # Close the file and print the location of the launcher print(f.close(jsObj))
""" Create a HTML page only from JavaScript functions """ from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.tests import test_statics # Create a blank Javascript Python object jsObj = Js.JsBase() dom = jsObj.createElement("div", "testDom") # Write the results to a Javascript file with a Launcher f = JsUtils.JsFile("TestJquery", path=test_statics.OUTPUT_PATHS) # Write the Javascript fragments to the file f.writeJs([ dom.attr("id", "jq"), jsObj.body.appendChild(dom), # Use Jquery from the new dom object dom.jquery.text("test").css("color", "red").html("<b>test</b>test"), dom.jquery.click(jsObj.console.log(jsObj.objects.jqThis.html())) ]) # Close the file and print the location of the launcher print(f.close(jsObj))
""" """ from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.tests import test_statics # Create a blank Javascript Python object jsObj = Js.JsBase() # Write the results to a Javascript file with a Launcher f = JsUtils.JsFile("DataExamplesNvd3", path=test_statics.OUTPUT_PATHS) # Load the data from the static sample file data = test_statics.get_data("flights.txt", n=10) # Create the data object record = jsObj.data.records(data) #record.f.count("B").o.nvd3_bar("count", "column") #.top("count_distinct", n=2, order="asc") #record.f.count("B").o.nvd3.pie("count", "column") #.top("count_distinct", n=2, order="asc") #record.f.count("B").o.billboard.line("count", "column") #.top("count_distinct", n=2, order="asc") data_fnc = record.fnc.count_with_kpi(["origin", "destination"], ["distance", "delay"]) # Write the Javascript fragments to the file f.writeJs([ jsObj.console.log(data_fnc), #.a.eq("B", "RR5")), #jsObj.console.log(data_fnc.filter.in_("origin", ["MCI", "STL"])), #.a.eq("B", "RR5")),
from epyk.core.js import JsUtils from epyk.core.js import Js f = JsUtils.JsFile(path=r"../outs") js_obj = Js.JsBase() breadcrumb = js_obj.breadcrumb js_obj.addOnLoad(breadcrumb.add("test1", "value1")) js_obj.addOnLoad(breadcrumb.add("test2", "value2")) js_obj.addOnLoad(breadcrumb.hash("test3")) js_obj.addOnLoad(js_obj.clipboard(breadcrumb.url)) js_obj.addOnLoad(js_obj.info("icon")) f.codepen(js_obj)
from epyk.core.js.packages import JsDatatable from epyk.core.js.packages import JsDc from epyk.core.js.packages import JsRequire from epyk.core.js.packages import JsTabulator data = [ {"name": "banana", "category": "fruit", "country": "Martinique", "outOfDateQuantity": 3, "quantity": 12}, {"name": "apple", "category": "fruit", "country": "Spain", "outOfDateQuantity": 7, "quantity": 9}, {"name": "tomato", "category": "vegetable", "country": "Spain", "outOfDateQuantity": 2, "quantity": 25} ] # ------------------------------------------------------------------------------------------------------------------ # f = JsUtils.JsFile("CrossFilter", path=r"../outs") f.writeJs([ JsCrossFilter.CrossFilter(data, 'cross1').dimension("quantity").filter([9, 13]), JsCrossFilter.CrossFilter(data, 'cross1').dimension("quantity").top(10), # JsCrossFilter.CrossFilter(data, 'cross1').dimension("category").group().reduceCount() ]) f.close() # ------------------------------------------------------------------------------------------------------------------ # f = JsUtils.JsFile("Datatable", path=r"../outs") f.writeJs([ JsDatatable.DatatableAPI().draw('page').clear().cell().data(), JsDatatable.DatatableAPI().draw('page').state(), JsDatatable.DatatableAPI().columns([1, 2]).search("%test").draw().jquery_nodes(),
from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.tests import test_statics # Create a blank Javascript Python object jsObj = Js.JsBase() # Define a dataSet using CrossFilter library crossFilter = jsObj.data.crossfilter(data=[{"column": 200}], var_name="test") # Write the results to a Javascript file with a Launcher f = JsUtils.JsFile("CrossFilter", path=test_statics.OUTPUT_PATHS) # Write the Javascript fragments to the file f.writeJs([ crossFilter.toStr(), crossFilter.dimension("column").filterAll().filterRange( 100, 400).top(10).toStr(), jsObj.console.log(crossFilter.var) ]) # Close the file and print the location of the launcher print(f.close(jsObj))
from epyk.core.js import Js from epyk.core.js import JsUtils # ------------------------------------------------------------------------------------------------------------------ # f = JsUtils.JsFile("jsWindows", path=r"../outs") jsObj = Js.JsBase() f.writeJs([ jsObj.window.btoa("Test").setVar("bin"), jsObj.createElement("div", "MyDiv").text(jsObj.objects.get("bin")).css( {"color": 'red'}), jsObj.body.appendChild(jsObj.objects.get("MyDiv")), jsObj.console.log(jsObj.objects.get("bin")), jsObj.console.log(jsObj.window.atob(jsObj.objects.get("bin"))), jsObj.window.setInterval([jsObj.console.log(jsObj.math.random())], 500).setVar("interva1"), jsObj.window.clearInterval(jsObj.objects.get("interva1")), jsObj.sessionStorage.setItem("lastname", jsObj.objects.get("bin")), jsObj.sessionStorage.removeItem("lastname"), jsObj.console.log(jsObj.sessionStorage["lastname"]) ]) f.close() # ------------------------------------------------------------------------------------------------------------------ # jsObj = Js.JsBase() f = JsUtils.JsFile("Maths", path=r"../outs") f.writeJs([ jsObj.objects.number.new(23.6, varName="MyNumber"), jsObj.console.log(jsObj.math.log(2)), jsObj.console.log(jsObj.math.E),
from epyk.core.js import Js from epyk.core.js import JsUtils from epyk.core.js.primitives import JsDate from epyk.core.js.primitives import JsString # ------------------------------------------------------------------------------------------------------------------ # jsObj = Js.JsBase() f = JsUtils.JsFile("Array", path=r"../outs") f.writeJs([ jsObj.objects.array.new([2, 5, 12, -3], "MyArray"), jsObj.objects.array.new([3, -9, 2, -6], "MyArray2"), jsObj.objects.array.new([], "MyArray3"), jsObj.console.log( jsObj.objects.array.get("MyArray3").concat( jsObj.objects.array.get("MyArray"), jsObj.objects.array.get("MyArray2"))), jsObj.console.log( jsObj.objects.array.get("MyArray").findIndex([ jsObj.if_(jsObj.data.loop.val <= 0, [jsObj.return_(jsObj.objects.true)]).else_( jsObj.return_(jsObj.objects.false)), ])), jsObj.console.log( jsObj.objects.array.get("MyArray").map([ jsObj.data.loop.val * jsObj.math.max(jsObj.data.loop.arr.toArgs()), jsObj.return_(jsObj.data.loop.val) ])), jsObj.console.log("########"), # jsObj.console.log(jsObj.objects.array.get("MyArray")),